Skip to content

Commit 34a0e64

Browse files
committed
MAGETWO-37594: Implementation and fixes after review
1 parent d383857 commit 34a0e64

File tree

2 files changed

+46
-93
lines changed

2 files changed

+46
-93
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js

Lines changed: 42 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -60,97 +60,48 @@ define([
6060
text: $.mage.__('Create Category'),
6161
class: 'action-primary',
6262
click: function () {
63-
widget.somedialog4.trigger('openDialog');
64-
//if (!newCategoryForm.valid()) {
65-
// return;
66-
//}
67-
//var thisButton = $(this);
68-
//thisButton.prop('disabled', true);
69-
//$.ajax({
70-
// type: 'POST',
71-
// url: widget.options.saveCategoryUrl,
72-
// data: {
73-
// general: {
74-
// name: $('#new_category_name').val(),
75-
// is_active: 1,
76-
// include_in_menu: 1
77-
// },
78-
// parent: $('#new_category_parent').val(),
79-
// use_config: ['available_sort_by', 'default_sort_by'],
80-
// form_key: FORM_KEY,
81-
// return_session_messages_only: 1
82-
// },
83-
// dataType: 'json',
84-
// context: $('body')
85-
//})
86-
// .success(
87-
// function (data) {
88-
// if (!data.error) {
89-
// $('#category_ids-suggest').trigger('selectItem', {
90-
// id: data.category.entity_id,
91-
// label: data.category.name
92-
// });
93-
// $('#new_category_name, #new_category_parent-suggest').val('');
94-
// $('#category_ids-suggest').val('');
95-
// clearParentCategory();
96-
// widget.element.trigger('closeDialog');
97-
// } else {
98-
// $('#new_category_messages').html(data.messages);
99-
// }
100-
// }
101-
//)
102-
// .complete(
103-
// function () {
104-
// thisButton.prop('disabled', false);
105-
// }
106-
//);
107-
}
108-
}]
109-
});
110-
this.somedialog1 = $('<div></div>').dialog({
111-
type: 'slide',
112-
responsive: true,
113-
title: $.mage.__('1 Category'),
114-
buttons: [{
115-
text: $.mage.__('Create Category'),
116-
class: 'action-primary',
117-
click: function () {
118-
//widget.somedialog2.trigger('openDialog');
119-
}
120-
}]
121-
});
122-
this.somedialog2 = $('<div></div>').dialog({
123-
type: 'slide',
124-
title: $.mage.__('2 Category'),
125-
buttons: [{
126-
text: $.mage.__('Create Category'),
127-
class: 'action-primary',
128-
click: function () {
129-
widget.somedialog1.trigger('openDialog');
130-
}
131-
}]
132-
});
133-
this.somedialog3 = $('<div></div>').dialog({
134-
type: 'slide',
135-
title: $.mage.__('3 Category'),
136-
buttons: [{
137-
text: $.mage.__('Create Category'),
138-
class: 'action-primary',
139-
click: function () {
140-
widget.somedialog2.trigger('openDialog');
141-
}
142-
}]
143-
});
144-
this.somedialog4 = $('<div></div>').dialog({
145-
type: 'modal',
146-
responsive: true,
147-
innerScroll: true,
148-
title: $.mage.__('4 Category'),
149-
buttons: [{
150-
text: $.mage.__('Create Category'),
151-
class: 'action-primary',
152-
click: function () {
153-
widget.somedialog3.trigger('openDialog');
63+
if (!newCategoryForm.valid()) {
64+
return;
65+
}
66+
var thisButton = $(this);
67+
68+
thisButton.prop('disabled', true);
69+
$.ajax({
70+
type: 'POST',
71+
url: widget.options.saveCategoryUrl,
72+
data: {
73+
general: {
74+
name: $('#new_category_name').val(),
75+
is_active: 1,
76+
include_in_menu: 1
77+
},
78+
parent: $('#new_category_parent').val(),
79+
use_config: ['available_sort_by', 'default_sort_by'],
80+
form_key: FORM_KEY,
81+
return_session_messages_only: 1
82+
},
83+
dataType: 'json',
84+
context: $('body')
85+
}).success(function (data) {
86+
if (!data.error) {
87+
var $suggest = $('#category_ids-suggest');
88+
89+
$suggest.trigger('selectItem', {
90+
id: data.category.entity_id,
91+
label: data.category.name
92+
});
93+
$('#new_category_name, #new_category_parent-suggest').val('');
94+
$suggest.val('');
95+
clearParentCategory();
96+
widget.element.trigger('closeDialog');
97+
} else {
98+
$('#new_category_messages').html(data.messages);
99+
}
100+
}).complete(
101+
function () {
102+
thisButton.prop('disabled', false);
103+
}
104+
);
154105
}
155106
}]
156107
});

app/code/Magento/Ui/view/base/web/js/dialog/dialog.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ define([
7777
* * @return {Number} - visible dialog count.
7878
*/
7979
_getVisibleSlideCount: function() {
80-
var elems = this.dialogWrapper.find('[data-type="'+this.options.type+'"]');
80+
var elems = this.dialogWrapper.find('[data-type="slide"]');
8181

8282
return elems.filter('.'+this.options.dialogVisibleClass).length;
8383
},
@@ -139,7 +139,9 @@ define([
139139
*/
140140
_unsetActive: function() {
141141
this.dialog.removeAttr('style');
142-
this.overlay.zIndex(this.prevOverlayIndex);
142+
if ( this.overlay ) {
143+
this.overlay.zIndex(this.prevOverlayIndex);
144+
}
143145
},
144146
/**
145147
* Creates wrapper to hold all dialogs.

0 commit comments

Comments
 (0)