Files

1 line
1.8 KiB
JavaScript
Raw Permalink Normal View History

(()=>{"use strict";const{$:n}=window;class e{constructor(){this.initEvents()}initEvents(){n(document).on("change",".js-live-exchange-rate",(n=>this.initLiveExchangeRate(n)))}initLiveExchangeRate(e){const t=n(e.currentTarget),o=t.closest("form").serialize();n.ajax({type:"POST",url:t.attr("data-url"),data:o}).then((n=>{if(!n.status)return window.showErrorMessage(n.message),void this.changeTextByCurrentSwitchValue(t.val());window.showSuccessMessage(n.message),this.changeTextByCurrentSwitchValue(t.val())})).fail((n=>{void 0!==n.responseJSON&&(window.showErrorMessage(n.responseJSON.message),this.changeTextByCurrentSwitchValue(t.val()))}))}changeTextByCurrentSwitchValue(e){const t=parseInt(e,10);n(".js-exchange-rate-text-when-disabled").toggleClass("d-none",0!==t),n(".js-exchange-rate-text-when-enabled").toggleClass("d-none",1!==t)}}const{$:t}=window;t((()=>{const n=new window.prestashop.component.Grid("currency");n.addExtension(new window.prestashop.component.GridExtensions.BulkActionCheckboxExtension),n.addExtension(new window.prestashop.component.GridExtensions.SubmitBulkActionExtension),n.addExtension(new window.prestashop.component.GridExtensions.ExportToSqlManagerExtension),n.addExtension(new window.prestashop.component.GridExtensions.SortingExtension),n.addExtension(new window.prestashop.component.GridExtensions.FiltersResetExtension),n.addExtension(new window.prestashop.component.GridExtensions.ReloadListExtension),n.addExtension(new window.prestashop.component.GridExtensions.ColumnTogglingExtension),n.addExtension(new window.prestashop.component.GridExtensions.SubmitRowActionExtension),n.addExtension(new window.prestashop.component.GridExtensions.FiltersSubmitButtonEnablerExtension),n.addExtension(new window.prestashop.component.GridExtensions.LinkRowActionExtension),new e})),window.currency={}})();