20 'Magento_Ui/js/modal/modal' 22 $form = $(
'[data-role=affected-attribute-set-selector]');
23 var resetValidation =
function() {
24 $form.find(
'.messages .message.error').hide();
25 $form.find(
'form').validation().data(
'validator').resetForm();
27 setAttributeSetId =
function (id) {
28 $(
'[data-role=new-variations-attribute-set-id]').val(
id);
30 closeDialogAndProcessForm =
function (
form) {
31 form.modal(
'closeModal').data(
'target').click();
33 newAttributeSetContainer = $(
'[data-role=affected-attribute-set-new-name-container]'),
34 existingAttributeSetContainer = $(
'[data-role=affected-attribute-set-existing-name-container]');
36 $form.find(
'input[type=text]').on(
'keypress',
function(e){
39 $form.closest(
'[data-role=modal]').find(
'button[data-action=confirm]').click();
43 $(
'[data-form=edit-product]').append($(
'<input>', {
45 name:
'new-variations-attribute-set-id',
46 'data-role':
'new-variations-attribute-set-id' 51 title:
'<?= /* @escapeNotVerified */ __('Choose Affected Attribute Set
') ?>',
56 text:
'<?= /* @escapeNotVerified */ __('Confirm
') ?>',
58 'data-action':
'confirm' 60 'class':
'action-primary',
62 var affectedAttributeSetId = $form.find(
'input[name=affected-attribute-set]:checked').val();
63 if (affectedAttributeSetId ==
'current') {
64 setAttributeSetId($(
'#attribute_set_id').val());
65 closeDialogAndProcessForm($form);
67 }
else if (affectedAttributeSetId ==
'existing') {
68 setAttributeSetId($(
'select', existingAttributeSetContainer).val());
69 closeDialogAndProcessForm($form);
72 $form.find(
'.messages .message.error').hide();
73 if (!$form.find(
'form').validation().valid()) {
74 $form.find(
'input[name=new-attribute-set-name]').focus();
80 url:
'<?= /* @escapeNotVerified */ $block->getAttributeSetCreationUrl() ?>',
83 attribute_set_name: $form.find(
'input[name=new-attribute-set-name]').val(),
84 skeleton_set: $(
'#attribute_set_id').val(),
85 form_key:
'<?= /* @escapeNotVerified */ $block->getFormKey() ?>',
86 return_session_messages_only: 1
92 .done(
function (data) {
94 setAttributeSetId(data.id);
95 closeDialogAndProcessForm($form);
97 $form.find(
'.messages .message.error').replaceWith($(data.messages).find(
'.message.error'));
104 text:
'<?= /* @escapeNotVerified */ __('Cancel
') ?>',
105 id:
'<?= /* @escapeNotVerified */ $block->getJsId('close-button
') ?>',
106 'class':
'action-close',
108 $form.modal(
'closeModal');
112 .
find(
'input[name=affected-attribute-set]').on(
'change',
function() {
113 var affectedAttributeSet = $(
this).val();
114 newAttributeSetContainer[affectedAttributeSet ==
'new' ?
'show' :
'hide']();
115 existingAttributeSetContainer[affectedAttributeSet ==
'existing' ?
'show' :
'hide']();
117 if (affectedAttributeSet ==
'new') {
118 newAttributeSetContainer.find(
'input[name=new-attribute-set-name]').focus();
132 var getAttributes =
function ($node) {
134 $node.find(
'[data-role=configurable-attributes-container] [data-role=attribute-info]') || [],
135 function (attribute) {
139 id:
$attribute.find(
'[name$="[attribute_id]"]').val(),
140 code:
$attribute.find(
'[name$="[code]"]').val(),
141 label:
$attribute.find(
'[name$="[label]"]').val(),
142 position:
$attribute.find(
'[name$="[position]"]').val()
151 $(
'#save-split-button .item').
on(
'click',
function(event) {
152 if ($(
'[data-role=new-variations-attribute-set-id]').val() !=
'') {
156 var extendingAttributes = [];
158 $.each(getAttributes($(
'[data-role=product-variations-matrix]')),
function () {
159 if (!$(
'#attribute-' + this.code +
'-container').length) {
160 extendingAttributes.push(this.
id);
163 if (!extendingAttributes.length) {
164 $(
'[data-role=new-variations-attribute-set-id]').val($(
'#attribute_set_id').val());
167 if (!$(
'[data-role=product-variations-matrix] [data-column=entity_id]')
168 .closest(
'tr').has(
'input[name$="[name]"]').length
173 event.stopImmediatePropagation();
175 $form.data(
'target', event.target).modal(
'openModal');
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
jquery extjs ext tree mage adminhtml form
mage('suggest', options) .on('suggestselect'(event, ui) on('suggestresponse', function(e, data, renderer) { var items=[];$.each(data, function(index, item) { if(!$('#configurable_attribute_'+item.id).length) { items.push(item);} });renderer(items);return false;}) })