Skip to content

Commit 7555192

Browse files
committed
["Save in New Attribute Set"] : Form should be validated before prompt the popup
1 parent b169e62 commit 7555192

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/components/new-attribute-form.js

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,46 @@ define([
4141
saveAttributeInNewSet: function () {
4242

4343
var self = this;
44+
this.validate();
45+
if (!this.additionalInvalid && !this.source.get('params.invalid')) {
46+
prompt({
47+
content: this.newSetPromptMessage,
48+
actions: {
4449

45-
prompt({
46-
content: this.newSetPromptMessage,
47-
actions: {
50+
/**
51+
* @param {String} val
52+
* @this {actions}
53+
*/
54+
confirm: function (val) {
55+
var rules = ['required-entry', 'validate-no-html-tags'],
56+
editForm = self,
57+
newAttributeSetName = val,
58+
i,
59+
params = {};
4860

49-
/**
50-
* @param {String} val
51-
* @this {actions}
52-
*/
53-
confirm: function (val) {
54-
var rules = ['required-entry', 'validate-no-html-tags'],
55-
editForm = self,
56-
newAttributeSetName = val,
57-
i,
58-
params = {};
59-
60-
if (!newAttributeSetName) {
61-
return;
62-
}
61+
if (!newAttributeSetName) {
62+
return;
63+
}
6364

64-
for (i = 0; i < rules.length; i++) {
65-
if (!$.validator.methods[rules[i]](newAttributeSetName)) {
66-
alert({
67-
content: $.validator.messages[rules[i]]
68-
});
65+
for (i = 0; i < rules.length; i++) {
66+
if (!$.validator.methods[rules[i]](newAttributeSetName)) {
67+
alert({
68+
content: $.validator.messages[rules[i]]
69+
});
6970

70-
return;
71+
return;
72+
}
7173
}
72-
}
7374

74-
params['new_attribute_set_name'] = newAttributeSetName;
75-
editForm.setAdditionalData(params);
76-
editForm.save();
75+
params['new_attribute_set_name'] = newAttributeSetName;
76+
editForm.setAdditionalData(params);
77+
editForm.save();
78+
}
7779
}
78-
}
79-
});
80+
});
81+
} else {
82+
this.focusInvalid();
83+
}
8084
}
8185
});
8286
});

0 commit comments

Comments
 (0)