Browse Source

[Backoffice] Bug suppresion villes et zip dans zone

develop
Fab 3 years ago
parent
commit
0f8aded174
2 changed files with 41 additions and 2 deletions
  1. +38
    -0
      ShopBundle/Resources/public/js/backend/script/default/init-common.js
  2. +3
    -2
      ShopBundle/Resources/public/js/backend/script/user/init-edit.js

+ 38
- 0
ShopBundle/Resources/public/js/backend/script/default/init-common.js View File

initNotice(); initNotice();
initBtnEditReminder(); initBtnEditReminder();
initBtnWriteToUser(); initBtnWriteToUser();
initCollectionWidget()
$('form').on('focus', 'input[type=number]', function (e) { $('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) { $(this).on('wheel.disableScroll', function (e) {
e.preventDefault() e.preventDefault()
} }
}) })
} }


function initCollectionWidget(){
$('.form-widget-compound>div[data-prototype]').each(function (i,collectionWidget){
resetNumItemsCollectionField($(collectionWidget));
$(collectionWidget).on('easyadmin.collection.item-added', function (){
resetNumItemsCollectionField($(this));
})
});

}

function resetNumItemsCollectionField($collectionWidget){
numItems = $collectionWidget.children('div.form-group').length;
$collectionWidget.children('div.form-group').each(function (i,item){
$field = $(item).find('input[type="text"]');

//Chanegment ID
posId = $field.prop('id').lastIndexOf('_') + 1;
idPrefix = $field.prop('id').substr(0, posId);
$field.prop('id', idPrefix+i);

//Chanegment Name
posName = $field.prop('name').lastIndexOf('[') + 1;
namePrefix = $field.prop('name').substr(0, posName);
$field.prop('name', namePrefix+i+']');

$(item).find('.field-collection-item-action').remove();
$(item).find('.field-collection-item-row').append('<button style="border:0px; background: none; " class="field-collection-item-action field-collection-item-remove" type="button">&times;</button>');
});

$collectionWidget.find('.field-collection-item-remove').off('click');
$collectionWidget.find('.field-collection-item-remove').on('click', function (){
$(this).parents('.form-group:first').remove();
resetNumItemsCollectionField($collectionWidget);
});
}

+ 3
- 2
ShopBundle/Resources/public/js/backend/script/user/init-edit.js View File

dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
setFlashMessages(response.flashMessages); setFlashMessages(response.flashMessages);
$('body').append(response.data);
$('body').append(response.data).ready(function () {
initCollectionWidget();
});
$('#modal-user-address').modal('show'); $('#modal-user-address').modal('show');
$('#modal-user-address').on('hidden.bs.modal', function (e) { $('#modal-user-address').on('hidden.bs.modal', function (e) {
$('#modal-user-address').remove(); $('#modal-user-address').remove();
appUserAddress = null; appUserAddress = null;
function initUserAddressForm(form, btn) { function initUserAddressForm(form, btn) {
appUserAddress = null; appUserAddress = null;

$(form).find('button').off('click'); $(form).find('button').off('click');
$(form).find('button').on('click', function () { $(form).find('button').on('click', function () {
if(checkFormValidity('#'+$(form).prop('id'))) { if(checkFormValidity('#'+$(form).prop('id'))) {

Loading…
Cancel
Save