Parcourir la source

Correctif page produit

feature/export_comptable
Fab il y a 4 ans
Parent
révision
93c96abf76
11 fichiers modifiés avec 109 ajouts et 75 suppressions
  1. +16
    -4
      ShopBundle/Controller/Backend/ProductFamilyController.php
  2. +35
    -24
      ShopBundle/Resources/public/css/backend/custom.css
  3. +6
    -0
      ShopBundle/Resources/public/js/backend/script/default/utils.js
  4. +21
    -21
      ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js
  5. +7
    -7
      ShopBundle/Resources/public/sass/backend/custom.scss
  6. +2
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  7. +7
    -8
      ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig
  8. +2
    -0
      ShopBundle/Resources/views/backend/productfamily/form.html.twig
  9. +1
    -1
      ShopBundle/Resources/views/backend/productfamily/macros.html.twig
  10. +3
    -0
      ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig
  11. +9
    -9
      ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig

+ 16
- 4
ShopBundle/Controller/Backend/ProductFamilyController.php Voir le fichier

@@ -14,6 +14,7 @@ use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType;
use Lc\ShopBundle\Model\ProductFamily;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Response;
@@ -46,7 +47,10 @@ class ProductFamilyController extends AdminController
'data' => $reductionCatalog
));


$formBuilder->add('stayOnPage', HiddenType::class, array(
'required'=>false,
'mapped'=>false,
));
$formBuilder->add('warningMessageType', ChoiceType::class, array(
'choices' => array(
'field.default.warningMessageTypeOptions.' . ProductFamily::WARNING_MESSAGE_TYPE_SUCCESS => ProductFamily::WARNING_MESSAGE_TYPE_SUCCESS,
@@ -312,9 +316,13 @@ class ProductFamilyController extends AdminController
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);

$this->utils->addFlash('success', 'Produit sauvegardé');
return $this->redirectToReferrer();

//return $this->redirectToRoute('easyadmin', ['entity' => 'ProductFamily', 'action' => 'edit', 'id' => $id]) ;
if($editForm->get('stayOnPage')->getData() || $this->request->get('submitAndStay')){
return $this->redirectToRoute('easyadmin', ['entity' => 'ProductFamily', 'action' => 'edit', 'id' => $id]) ;
}else {
return $this->redirectToReferrer();
}

}

$this->dispatch(EasyAdminEvents::POST_EDIT);
@@ -359,7 +367,11 @@ class ProductFamilyController extends AdminController
$this->executeDynamicMethod('persist<EntityName>Entity', [$entity, $newForm]);
$this->dispatch(EasyAdminEvents::POST_PERSIST, ['entity' => $entity]);

return $this->redirectToReferrer();
if($newForm->get('stayOnPage')->getData() || $this->request->get('submitAndStay')){
return $this->redirectToRoute('easyadmin', ['entity' => 'ProductFamily', 'action' => 'edit', 'id' => $entity->getId()]) ;
}else {
return $this->redirectToReferrer();
}
}

$this->dispatch(EasyAdminEvents::POST_NEW, [

+ 35
- 24
ShopBundle/Resources/public/css/backend/custom.css Voir le fichier

@@ -391,8 +391,9 @@ table th .select2-container--default .select2-selection--single {

/* Général */
/* line 125, ../../sass/backend/custom.scss */
.btn.btn-primary.action-save {
.btn.action-save {
float: right;
margin-left: 10px;
}

/* line 126, ../../sass/backend/custom.scss */
@@ -567,12 +568,12 @@ table th .select2-container--default .select2-selection--single {
}

/* ORDER */
/* line 225, ../../sass/backend/custom.scss */
/* line 224, ../../sass/backend/custom.scss */
.table-order-summary {
width: 100%;
}

/* line 228, ../../sass/backend/custom.scss */
/* line 227, ../../sass/backend/custom.scss */
.order-product-item.redelivery {
background: rgba(18, 104, 253, 0.38) !important;
}
@@ -580,36 +581,36 @@ table th .select2-container--default .select2-selection--single {
/*.select2-container--bootstrap .select2-selection{max-width: none;}*/
/*.order-product-item{margin: 15px 0; padding: 0;}*/
/* Product */
/* line 233, ../../sass/backend/custom.scss */
/* line 232, ../../sass/backend/custom.scss */
.product-form-modal {
display: none;
}

/* line 234, ../../sass/backend/custom.scss */
/* line 233, ../../sass/backend/custom.scss */
.product-form.modal .form-check-label {
font-style: italic;
color: #666;
text-align: left;
}

/* line 235, ../../sass/backend/custom.scss */
/* line 234, ../../sass/backend/custom.scss */
.products-collection-table .inherited {
color: #888;
font-style: italic;
font-weight: initial;
}

/* line 236, ../../sass/backend/custom.scss */
/* line 235, ../../sass/backend/custom.scss */
.products-collection-table td {
position: relative;
}

/* line 237, ../../sass/backend/custom.scss */
/* line 236, ../../sass/backend/custom.scss */
.card-body.p-0 .products-collection-table tbody > tr > td:first-of-type, .card-body.p-0 .products-collection-table tbody > tr > th:first-of-type, .card-body.p-0 .products-collection-table thead > tr > td:first-of-type, .card-body.p-0 .products-collection-table thead > tr > th:first-of-type {
padding-left: 0.35rem;
}

/* line 238, ../../sass/backend/custom.scss */
/* line 237, ../../sass/backend/custom.scss */
.products-collection-table .btn-empty-field {
position: absolute;
right: 3px;
@@ -618,61 +619,65 @@ table th .select2-container--default .select2-selection--single {
padding: 0px;
}

/* line 239, ../../sass/backend/custom.scss */
/* line 238, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table {
table-layout: fixed;
/* background-clip: padding-box;*/
border-collapse: collapse;
}

/* line 240, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table tr {
border-bottom: 1px solid #dee2e6;
}

/* line 241, ../../sass/backend/custom.scss */
/* line 239, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table th {
font-size: 13px;
border-left: 1px solid #dee2e6;
border-top: 1px solid #dee2e6;
text-align: center;
border-bottom: 2px solid #dee2e6;
}

/* line 242, ../../sass/backend/custom.scss */
/* line 240, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table tfoot th {
border-top: 2px solid #dee2e6;
}

/* line 241, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table th span {
white-space: initial;
}

/* line 243, ../../sass/backend/custom.scss */
/* line 242, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table th:last-child {
border-right: 1px solid #dee2e6;
}

/* line 244, ../../sass/backend/custom.scss */
/* line 243, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table td {
border-left: 1px solid #dee2e6;
text-align: center;
font-size: 13px;
border-bottom: 1px solid #dee2e6;
}

/* line 245, ../../sass/backend/custom.scss */
/* line 244, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table td:last-child {
border-right: 1px solid #dee2e6;
white-space: nowrap;
}

/* line 246, ../../sass/backend/custom.scss */
/* line 245, ../../sass/backend/custom.scss */
#lc-product-family-edit .btn-add-product {
margin: 20px 0;
float: right;
}

/* line 247, ../../sass/backend/custom.scss */
/* line 246, ../../sass/backend/custom.scss */
#lc-product-family-edit .inherited {
color: #888;
font-style: italic;
font-weight: initial;
}

/* line 248, ../../sass/backend/custom.scss */
/* line 247, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table td .value {
min-width: 80%;
margin: auto;
@@ -680,11 +685,17 @@ table th .select2-container--default .select2-selection--single {
cursor: pointer;
}

/* line 249, ../../sass/backend/custom.scss */
/* line 248, ../../sass/backend/custom.scss */
#lc-product-family-edit .products-collection-table td .modal {
text-align: left;
}

/* line 249, ../../sass/backend/custom.scss */
table.products-collection-table th.main-info, td.buyingPrice, td.multiplyingFactor, td.priceWithTax {
background: #eeeeee;
background-clip: padding-box;
}

/* DeliveryZone */
/* line 253, ../../sass/backend/custom.scss */
#autocomplete-cities {

+ 6
- 0
ShopBundle/Resources/public/js/backend/script/default/utils.js Voir le fichier

@@ -191,3 +191,9 @@ function checkFormValidity(formId){


function arrayRemove(arr, value) { return arr.filter(function(ele){ return ele != value; });}

const scratchDiv = document.createElement('div');
function toPlainText(html) {
scratchDiv.innerHTML = html;
return scratchDiv.textContent;
}

+ 21
- 21
ShopBundle/Resources/public/js/backend/script/productfamily/vuejs-product-family.js Voir le fichier

@@ -197,12 +197,18 @@ $(window).on('load', function () {
//INIT VAR
this.init();
this.initKeyboardNav();
this.title = toPlainText(this.title)

//METHOD
//this.updateProductForm();
//this.updateProductView();
},
methods: {
decode(str){
var textArea = document.createElement('textarea');
textArea.innerText = str;
return textArea.textContent;
},
titleUpdated: function () {
},
availableQuantityUpdated: function () {
@@ -238,8 +244,9 @@ $(window).on('load', function () {
deleteProductForm: function () {
if (confirm('Êtes-vous sur de cette action ?')) {
Vue.delete(this.$parent.formProducts, this.keyForm);
this.$parent.updateSortableProducts(false);
this.$parent.reindexProductForm(null);
this.$nextTick(function () {
this.$parent.updateSortableProducts(true);
});
}

},
@@ -369,6 +376,7 @@ $(window).on('load', function () {
return Object.assign(
{
isMounted: false,
stayOnPage: false,
title: null,
isNovelty: null,
isOrganic: null,
@@ -422,6 +430,9 @@ $(window).on('load', function () {
},
mounted: function () {
this.$nextTick(function () {
this.title = toPlainText(this.title)


this.isMounted = true;
$(".vuejs-checkbox-switch input").each(function () {
setBootstrapSwitch($(this));
@@ -454,6 +465,7 @@ $(window).on('load', function () {
newForm = newForm.replace(/__name__/g, Object.keys(this.formProducts).length);
Vue.set(this.formProducts, Object.keys(this.formProducts).length, newForm);

log(Object.keys(this.formProducts).length);
this.$nextTick(function () {
this.updateSortableProducts(false);
this.updateKeyboardNav();
@@ -468,19 +480,9 @@ $(window).on('load', function () {
}
});
},
reindexProductForm: function (newArray) {
if(newArray==null) {
log('ncichhc');
var newArray = {};
var i = 0;
for (key in this.formProducts) {
newArray[i] = this.formProducts[key];
i++;
}
}
this.formProducts = newArray;
this.updateKeyboardNav();

postForm:function(){
this.stayOnPage = 1;
$("#edit-productfamily-form").submit();
},

initLcSortableProductsList: function () {
@@ -494,18 +496,16 @@ $(window).on('load', function () {
});
}
},
updateSortableProducts: function (reindex) {
updateSortableProducts: function (post) {
if ($('.lc-sortable-products').length > 0) {
var app=this;
var newArray = {};

$('.lc-sortable-products tr.lc-draggable').each(function (index, li) {
oldKey = $(li).find('.field-position').val();
//log('OLD : '+oldKey);
$(li).find('.field-position').val(index);
//log('NEW : '+index);
if(reindex)newArray[index] = app.formProducts[oldKey];
});
if(reindex)app.reindexProductForm(newArray);
if(post)this.postForm();
}
},

@@ -541,7 +541,7 @@ $(window).on('load', function () {
});

var allowLeave = false;
$('#edit-productfamily-form').on('submit', function () {
$('#edit-productfamily-form, #new-productfamily-form').on('submit', function () {
allowLeave = true;
})
$(window).bind('beforeunload', function (e) {

+ 7
- 7
ShopBundle/Resources/public/sass/backend/custom.scss Voir le fichier

@@ -122,7 +122,7 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0


/* Général */
.btn.btn-primary.action-save{float: right;}
.btn.action-save{float: right; margin-left: 10px;}
.button-action a.float-right{margin-left: 10px;}

.input-group-text {
@@ -219,8 +219,7 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0
.autoresize textarea{height: auto; min-height: 38px;}



/* ORDER */
/* ORDER */

.table-order-summary{width: 100%;}

@@ -236,17 +235,18 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0
.products-collection-table td{position: relative;}
.card-body.p-0 .products-collection-table tbody > tr > td:first-of-type, .card-body.p-0 .products-collection-table tbody > tr > th:first-of-type, .card-body.p-0 .products-collection-table thead > tr > td:first-of-type, .card-body.p-0 .products-collection-table thead > tr > th:first-of-type{padding-left: 0.35rem;}
.products-collection-table .btn-empty-field{position: absolute; right: 3px; font-size: 0.7rem; top: 5px; padding: 0px;}
#lc-product-family-edit .products-collection-table {table-layout:fixed;}
#lc-product-family-edit .products-collection-table tr{border-bottom: 1px solid #dee2e6;}
#lc-product-family-edit .products-collection-table th{font-size:13px; border-left: 1px solid #dee2e6; border-top: 1px solid #dee2e6; text-align: center;}
#lc-product-family-edit .products-collection-table {table-layout:fixed;/* background-clip: padding-box;*/ border-collapse: collapse;}
#lc-product-family-edit .products-collection-table th{font-size:13px; border-left: 1px solid #dee2e6; border-top: 1px solid #dee2e6; text-align: center; border-bottom: 2px solid #dee2e6;}
#lc-product-family-edit .products-collection-table tfoot th{border-top: 2px solid #dee2e6;}
#lc-product-family-edit .products-collection-table th span {white-space: initial;}
#lc-product-family-edit .products-collection-table th:last-child{border-right: 1px solid #dee2e6;}
#lc-product-family-edit .products-collection-table td{border-left: 1px solid #dee2e6; text-align: center; font-size: 13px;}
#lc-product-family-edit .products-collection-table td{border-left: 1px solid #dee2e6; text-align: center; font-size: 13px; border-bottom: 1px solid #dee2e6;}
#lc-product-family-edit .products-collection-table td:last-child{border-right: 1px solid #dee2e6; white-space: nowrap; }
#lc-product-family-edit .btn-add-product {margin: 20px 0; float: right;}
#lc-product-family-edit .inherited {color: #888; font-style: italic; font-weight: initial;}
#lc-product-family-edit .products-collection-table td .value {min-width: 80%; margin: auto; min-height: 35px; cursor: pointer;}
#lc-product-family-edit .products-collection-table td .modal {text-align: left;}
table.products-collection-table th.main-info, td.buyingPrice, td.multiplyingFactor, td.priceWithTax{background: #eeeeee; background-clip: padding-box}

/* DeliveryZone */


+ 2
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Voir le fichier

@@ -436,10 +436,11 @@ action:
choiceFile: Parcourir
send: Envoyer
edit: Éditer
saveAndStay: Sauvegarder (rester sur la page)
search: Rechercher
delete: Supprimer
change: Modifier
save: Sauvegarder les modifications
save: Sauvegarder (retour liste)
cancel: Annuler
continue: Continuer
list: Retour à la liste

+ 7
- 8
ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig Voir le fichier

@@ -5,14 +5,6 @@
{# TODO à corriger le theme requiert des infos easyAdmin il devrait être possible de ne pas en utiliser #}










{% block form_widget -%}
{{ parent() }}

@@ -234,6 +226,11 @@
<button type="submit" name="save_and_leave" class="btn btn-primary action-save">
<span class="btn-label">{{ 'action.save'|trans(_trans_parameters, _translation_domain) }}</span>
</button>
{% if easyadmin.entity.name =='ProductFamily' %}
<button name="submitAndStay" value="1" type="submit" class="btn btn-success action-save">
<span class="btn-label">{{ 'action.saveAndStay'|trans(_trans_parameters, _translation_domain) }}</span>
</button>
{% endif %}

{% set _entity_actions = (easyadmin.view == 'new')
? easyadmin_get_actions_for_new_item(easyadmin.entity.name)
@@ -256,6 +253,8 @@
}, with_context = false) }}
{% endblock item_actions %}



{#

{% block _user_niche_row %}

+ 2
- 0
ShopBundle/Resources/views/backend/productfamily/form.html.twig Voir le fichier

@@ -106,6 +106,8 @@
{% endif %}

</div>
{{ form_widget(form.stayOnPage, {"attr": {"v-model": "stayOnPage"}}) }}


</div>
{{ form_end(form) }}

+ 1
- 1
ShopBundle/Resources/views/backend/productfamily/macros.html.twig Voir le fichier

@@ -96,7 +96,7 @@
<button type="button" class="btn-remove-product btn-sm btn-danger" @click="deleteProductForm()">
<i class="fa fa-trash"></i>
</button>
{{ form_widget(product.position, {'attr' : {'class': "field-position"}}) }}
{{ form_widget(product.position, {'attr' : {'class': "field-position", "v-model" : 'position'}}) }}


<div class="modal fade show" :id="'modal-extends-product-'+keyForm">

+ 3
- 0
ShopBundle/Resources/views/backend/productfamily/panel_general.html.twig Voir le fichier

@@ -4,6 +4,9 @@

<div class="row">
{{ macros.startCard(8, 'ProductFamily.main','light') }}
<div class="col-12">
{{ form_row(form.status) }}
</div>
<div class="col-12">
{{ form_row(form.supplier) }}
</div>

+ 9
- 9
ShopBundle/Resources/views/backend/productfamily/panel_products.html.twig Voir le fichier

@@ -23,7 +23,7 @@
Unité
</th>
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"
colspan="3" class="buyingPriceByRefUnit">
colspan="3" class="buyingPriceByRefUnit ">
PA HT / ${ getUnitReference() }
</th>
<th v-show="getBehaviorPrice() == '{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT') }}'"
@@ -31,14 +31,14 @@
PA TTC / ${ getUnitReference() }
</th>

<th colspan="3" class="price">
<th colspan="3" class="price main-info">
PA HT
</th>
<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
PA TTC
</th>
<th colspan="3" class="">
<th colspan="3" class="main-info">
Coef
</th>

@@ -56,7 +56,7 @@
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
PV HT
</th>
<th colspan="3" class="price">
<th colspan="3" class="price main-info">
PV TTC
</th>
<th colspan="2">
@@ -88,8 +88,8 @@
<tbody class="products-collection">

<template>
<product-form v-for="(formProduct, blop) in formProducts" v-bind:key="blop"
:key-form="blop" ref="productForm" v-bind:product-family="productFamily"
<product-form v-for="(formProduct, name, index) in formProducts" v-bind:key="name"
:key-form="name" ref="productForm" v-bind:product-family="productFamily"
:template="formProduct"></product-form>
</template>
</tbody>
@@ -115,14 +115,14 @@
${productFamily.buyingPriceByRefUnitWithTax}
</th>

<th colspan="3" class="price">
<th colspan="3" class="price main-info">
${productFamily.buyingPrice}
</th>
<th colspan="3" class="price"
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
${productFamily.buyingPriceWithTax}
</th>
<th colspan="3" class="">
<th colspan="3" class="main-info">
${productFamily.multiplyingFactor}
</th>

@@ -140,7 +140,7 @@
v-show="getBehaviorPrice() =='{{ constant('Lc\\ShopBundle\\Model\\ProductFamily::BEHAVIOR_PRICE_BY_PIECE') }}'">
${productFamily.price}
</th>
<th colspan="3" class="price">
<th colspan="3" class="price main-info">
${productFamily.priceWithTax}
</th>
<th colspan="2" class="price">

Chargement…
Annuler
Enregistrer