1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'Magento_Backend/js/validate-store'
], function ($, validateStore) {
'use strict';
$.widget('mage.saveWithConfirm', validateStore, {
/**
* Check is it need to show confirmation popup
*
* @returns {Boolean}
*/
_needConfirm: function () {
var storeData = this.settings.storeData,
/* edit store view*/
storeViewEdit = $('[name="store[store_id]"]').length,
groupId = $('[name="store[group_id]"]').val(),
isNewStoreView = !$('[name="store[store_id]"]').val(),
/* edit store */
storeEdit = $('[name="group[group_id]"]').length,
storeId = $('[name="group[group_id]"]').val(),
rootCategoryId = $('[name="group[root_category_id]"]').val(),
defaultStoreView = $('[name="group[default_store_id]"]').val(),
/* edit website */
websiteEdit = $('[name="website[website_id]"]').length,
defaultStore = $('[name="website[default_group_id]"]').val(),
/* conditions */
storeViewUpdated = storeViewEdit && (isNewStoreView || storeData['group_id'] !== groupId),
storeUpdated = storeEdit && storeId &&
(rootCategoryId !== null && storeData['root_category_id'] !== rootCategoryId ||
defaultStoreView !== null && storeData['default_store_id'] !== defaultStoreView),
websiteUpdated = websiteEdit && defaultStore !== null && storeData['default_group_id'] !== defaultStore;
return storeViewUpdated || storeUpdated || websiteUpdated;
}
});
return $.mage.saveWithConfirm;
});