- $form
- .modal({
- title: '<?= /* @escapeNotVerified */ __('Choose Affected Attribute Set') ?>',
- closed: function () {
- resetValidation();
- },
- buttons: [{
- text: '<?= /* @escapeNotVerified */ __('Confirm') ?>',
- attr: {
- 'data-action': 'confirm'
- },
- 'class': 'action-primary',
- click: function() {
- var affectedAttributeSetId = $form.find('input[name=affected-attribute-set]:checked').val();
- if (affectedAttributeSetId == 'current') {
- setAttributeSetId($('#attribute_set_id').val());
- closeDialogAndProcessForm($form);
- return;
- } else if (affectedAttributeSetId == 'existing') {
- setAttributeSetId($('select', existingAttributeSetContainer).val());
- closeDialogAndProcessForm($form);
- }
-
- $form.find('.messages .message.error').hide();
- if (!$form.find('form').validation().valid()) {
- $form.find('input[name=new-attribute-set-name]').focus();
- return false;
- }
-
- $.ajax({
- type: 'POST',
- url: '<?= /* @escapeNotVerified */ $block->getAttributeSetCreationUrl() ?>',
- data: {
- gotoEdit: 1,
- attribute_set_name: $form.find('input[name=new-attribute-set-name]').val(),
- skeleton_set: $('#attribute_set_id').val(),
- form_key: '<?= /* @escapeNotVerified */ $block->getFormKey() ?>',
- return_session_messages_only: 1
- },
- dataType: 'json',
- showLoader: true,
- context: $form
- })
- .success(function (data) {
- if (!data.error) {
- setAttributeSetId(data.id);
- closeDialogAndProcessForm($form);
- } else {
- $form.find('.messages .message.error').replaceWith($(data.messages).find('.message.error'));
- }
- });
-
- return false;
- }
- },{
- text: '<?= /* @escapeNotVerified */ __('Cancel') ?>',
- id: '<?= /* @escapeNotVerified */ $block->getJsId('close-button') ?>',
- 'class': 'action-close',
- click: function() {
- $form.modal('closeModal');
- }
- }]
- })