|
|
@@ -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">×</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); |
|
|
|
}); |
|
|
|
} |