ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/alert',
|
||||
], function ($, alert) {
|
||||
'use strict';
|
||||
|
||||
$.widget('mage.connectionchecker', {
|
||||
options: {
|
||||
successText: '',
|
||||
failedText: '',
|
||||
url: '',
|
||||
elementId: '',
|
||||
fieldMapping: ''
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
this._on({
|
||||
'click': $.proxy(this._ping, this)
|
||||
});
|
||||
},
|
||||
|
||||
_ping: function () {
|
||||
var buttonTitle = this.options.failedText,
|
||||
element = $('#' + this.options.elementId),
|
||||
self = this;
|
||||
element.removeClass('success').addClass('fail');
|
||||
|
||||
$.ajax({
|
||||
url: self.options.url,
|
||||
showLoader: true,
|
||||
data: self._collectParams()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
element.removeClass('fail').addClass('success');
|
||||
buttonTitle = self.options.successText;
|
||||
} else {
|
||||
var error = response.errorMessage;
|
||||
if (error) {
|
||||
alert({
|
||||
content: error
|
||||
});
|
||||
}
|
||||
}
|
||||
}).always(function () {
|
||||
if (buttonTitle) {
|
||||
$('#' + self.options.elementId + '_result').text(buttonTitle);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_collectParams: function () {
|
||||
var params = {};
|
||||
$.each(this.options.fieldMapping, function (key, el) {
|
||||
params[key] = $('#amasty_elastic_connection_' + el).val();
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
});
|
||||
|
||||
return $.mage.connectionchecker;
|
||||
});
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/grid/provider',
|
||||
'ko'
|
||||
], function ($, provider, ko) {
|
||||
'use strict';
|
||||
|
||||
return provider.extend({
|
||||
defaults: {
|
||||
externalLinks: {
|
||||
relevanceRuleWebsite: null
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
initObservable: function () {
|
||||
this.externalLinks.relevanceRuleWebsite = ko.observable(this.externalLinks.relevanceRuleWebsite);
|
||||
|
||||
return this._super();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} options
|
||||
*/
|
||||
reload: function (options) {
|
||||
var relevanceRuleCondition = $('[data-form-part="amasty_elastic_relevancerule_form"]').serialize(),
|
||||
selectedWebsite = +this.externalLinks.relevanceRuleWebsite();
|
||||
|
||||
if (typeof this.params.filters === 'undefined') {
|
||||
this.params.filters = {};
|
||||
}
|
||||
|
||||
if (selectedWebsite) {
|
||||
relevanceRuleCondition += '&websites[]=' + selectedWebsite;
|
||||
}
|
||||
|
||||
this.params.filters.elastic_rule_condition = relevanceRuleCondition;
|
||||
return this._super({'refresh': true});
|
||||
}
|
||||
});
|
||||
});
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/form/components/html',
|
||||
'ko',
|
||||
'uiRegistry'
|
||||
], function ($, html, ko, uiRegistry) {
|
||||
'use strict';
|
||||
|
||||
return html.extend({
|
||||
afterRenderCallback: function () {
|
||||
var ns = this.ns,
|
||||
gridName = ns + '.' + ns + '.conditions_fieldset.products_grid';
|
||||
|
||||
uiRegistry.get(gridName, this.initChangeListener.bind(this));
|
||||
},
|
||||
|
||||
initChangeListener: function (productsGrid) {
|
||||
var observer = new MutationObserver(subscriber);
|
||||
|
||||
function subscriber(mutations) {
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.type === 'childList') {
|
||||
productsGrid.visible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
observer.observe($('.rule-tree')[0], {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Elasticsearch char mapping rule validation
|
||||
*/
|
||||
require([
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'jquery/validate',
|
||||
'mage/validation'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.validator.addMethod(
|
||||
'amasty-validate-char-mapping',
|
||||
function (value) {
|
||||
return $.mage.isEmptyNoTrim(value) || /^\S+ ?=> ?\S+$/gm.test(value);
|
||||
},
|
||||
$.mage.__('Please enter a valid character mapping (E.g."& => and").')
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user