Просмотр исходного кода

[Backoffice] Bug suppresion villes et zip dans zone

develop
Fab 3 лет назад
Родитель
Сommit
0f8aded174
2 измененных файлов: 41 добавлений и 2 удалений
  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 Просмотреть файл

@@ -5,6 +5,7 @@ jQuery(document).ready(function () {
initNotice();
initBtnEditReminder();
initBtnWriteToUser();
initCollectionWidget()
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
@@ -320,3 +321,40 @@ function initModalNewTicket(){
}
})
}


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 Просмотреть файл

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

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

Загрузка…
Отмена
Сохранить