first commit
This commit is contained in:
49
admin-kalsport/themes/new-theme/js/app/utils/animations.js
Normal file
49
admin-kalsport/themes/new-theme/js/app/utils/animations.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the correct transition keyword of the browser.
|
||||
* @param {string} type - The property name (transition for example).
|
||||
* @param {string} lifecycle - Which lifecycle of the property name to catch (end, start...).
|
||||
* @return {string} The transition keywoard of the browser.
|
||||
*/
|
||||
const getAnimationEvent = (type, lifecycle) => {
|
||||
const el = document.createElement('element');
|
||||
const typeUpper = type.charAt(0).toUpperCase() + type.substring(1);
|
||||
const lifecycleUpper = lifecycle.charAt(0).toUpperCase() + lifecycle.substring(1);
|
||||
|
||||
const properties = {
|
||||
transition: `${type}${lifecycle}`,
|
||||
OTransition: `o${typeUpper}${lifecycleUpper}`,
|
||||
MozTransition: `${type}${lifecycle}`,
|
||||
WebkitTransition: `webkit${typeUpper}${lifecycleUpper}`,
|
||||
};
|
||||
|
||||
const key = Object.keys(properties).find((propKey) => el.style[propKey] !== undefined);
|
||||
|
||||
return key !== undefined ? properties[key] : false;
|
||||
};
|
||||
|
||||
export default getAnimationEvent;
|
||||
38
admin-kalsport/themes/new-theme/js/app/utils/colorpicker.js
Normal file
38
admin-kalsport/themes/new-theme/js/app/utils/colorpicker.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import 'bootstrap-colorpicker';
|
||||
|
||||
const {$} = window;
|
||||
|
||||
/**
|
||||
* Enable all colorpickers.
|
||||
*/
|
||||
const init = function initDatePickers() {
|
||||
$('.colorpicker input[type="text"]').each((i, picker) => {
|
||||
$(picker).colorpicker();
|
||||
});
|
||||
};
|
||||
|
||||
export default init;
|
||||
97
admin-kalsport/themes/new-theme/js/app/utils/datepicker.js
Normal file
97
admin-kalsport/themes/new-theme/js/app/utils/datepicker.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import 'url-polyfill';
|
||||
|
||||
const {$} = window;
|
||||
|
||||
const replaceDatePicker = () => {
|
||||
const datepickerWidget = $('body').find(
|
||||
'.bootstrap-datetimepicker-widget:last',
|
||||
);
|
||||
|
||||
if (datepickerWidget.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const position = datepickerWidget.offset();
|
||||
const originalHeight = datepickerWidget.outerHeight();
|
||||
const margin = (datepickerWidget.outerHeight(true) - originalHeight) / 2;
|
||||
|
||||
// Move datepicker to the exact same place it was but attached to body
|
||||
datepickerWidget.appendTo('body');
|
||||
|
||||
// Height changed because the css from column-filters is not applied any more
|
||||
let top = position.top + margin;
|
||||
|
||||
// Datepicker is settle to the top position
|
||||
if (datepickerWidget.hasClass('top')) {
|
||||
top += originalHeight - datepickerWidget.outerHeight(true) - margin;
|
||||
}
|
||||
|
||||
datepickerWidget.css({
|
||||
position: 'absolute',
|
||||
top,
|
||||
bottom: 'auto',
|
||||
left: position.left,
|
||||
right: 'auto',
|
||||
});
|
||||
|
||||
$(window).on('resize', replaceDatePicker);
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable all datepickers.
|
||||
*/
|
||||
const init = function initDatePickers() {
|
||||
const $datePickers = $('.datepicker input[type="text"]');
|
||||
$.each($datePickers, (i, picker) => {
|
||||
$(picker)
|
||||
.datetimepicker({
|
||||
locale: window.full_language_code,
|
||||
format: $(picker).data('format')
|
||||
? $(picker).data('format')
|
||||
: 'YYYY-MM-DD',
|
||||
sideBySide: true,
|
||||
icons: {
|
||||
time: 'time',
|
||||
date: 'date',
|
||||
up: 'up',
|
||||
down: 'down',
|
||||
},
|
||||
})
|
||||
.on('dp.show', replaceDatePicker)
|
||||
.on('dp.hide', () => {
|
||||
$(window).off('resize', replaceDatePicker);
|
||||
})
|
||||
.on('dp.change', (e) => {
|
||||
// Looks like we can't bind an event to a datepicker selected afterwhile.
|
||||
// So we emit an event on change to manipulate datas
|
||||
const event = new CustomEvent('datepickerChange', e);
|
||||
window.document.dispatchEvent(event);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default init;
|
||||
43
admin-kalsport/themes/new-theme/js/app/utils/email-idn.js
Normal file
43
admin-kalsport/themes/new-theme/js/app/utils/email-idn.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import punycode from 'punycode';
|
||||
|
||||
const {$} = window;
|
||||
|
||||
const init = function initEmailFields(selector) {
|
||||
const $emailFields = $(selector);
|
||||
$.each($emailFields, (i, field) => {
|
||||
if (!field.checkValidity()) {
|
||||
const parts = field.value.split('@');
|
||||
|
||||
// if local part is not ASCII only, chrome will not auto-convert the domain part to utf8
|
||||
if (punycode.toASCII(parts[0]) === parts[0]) {
|
||||
field.value = punycode.toASCII(field.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default init;
|
||||
29
admin-kalsport/themes/new-theme/js/app/utils/event-bus.js
Normal file
29
admin-kalsport/themes/new-theme/js/app/utils/event-bus.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import Vue from 'vue';
|
||||
|
||||
export const EventBus = new Vue();
|
||||
|
||||
export default EventBus;
|
||||
37
admin-kalsport/themes/new-theme/js/app/utils/fields.js
Normal file
37
admin-kalsport/themes/new-theme/js/app/utils/fields.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
const {$} = window;
|
||||
|
||||
/**
|
||||
* Enable all datepickers.
|
||||
*/
|
||||
const initInvalidFields = () => {
|
||||
$('input,select,textarea').on('invalid', function scroll() {
|
||||
this.scrollIntoView(false);
|
||||
});
|
||||
};
|
||||
|
||||
export default initInvalidFields;
|
||||
45
admin-kalsport/themes/new-theme/js/app/utils/growl.js
Normal file
45
admin-kalsport/themes/new-theme/js/app/utils/growl.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
export const showGrowl = (type, message, durationTime) => {
|
||||
const duration = undefined !== durationTime ? durationTime : 2000;
|
||||
|
||||
if (type === 'success') {
|
||||
window.$.growl({
|
||||
title: '',
|
||||
size: 'large',
|
||||
message,
|
||||
duration,
|
||||
});
|
||||
} else {
|
||||
window.$.growl[type]({
|
||||
title: '',
|
||||
size: 'large',
|
||||
message,
|
||||
duration,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default showGrowl;
|
||||
142
admin-kalsport/themes/new-theme/js/app/utils/init-components.js
Normal file
142
admin-kalsport/themes/new-theme/js/app/utils/init-components.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
import TranslatableField from '@js/components/translatable-field.js';
|
||||
import TranslatableInput from '@js/components/translatable-input.js';
|
||||
import TinyMCEEditor from '@js/components/tinymce-editor.js';
|
||||
import TaggableField from '@js/components/taggable-field.js';
|
||||
import ChoiceTable from '@js/components/choice-table.js';
|
||||
import ChoiceTree from '@js/components/form/choice-tree.js';
|
||||
import MultipleChoiceTable from '@js/components/multiple-choice-table.js';
|
||||
import GeneratableInput from '@js/components/generatable-input.js';
|
||||
import CountryStateSelectionToggler from '@components/country-state-selection-toggler';
|
||||
import CountryDniRequiredToggler from '@components/country-dni-required-toggler';
|
||||
import TextWithLengthCounter from '@components/form/text-with-length-counter';
|
||||
import PreviewOpener from '@components/form/preview-opener';
|
||||
import MultistoreConfigField from '@js/components/form/multistore-config-field.js';
|
||||
import {EventEmitter} from '@components/event-emitter';
|
||||
import Grid from '@components/grid/grid';
|
||||
import Router from '@components/router';
|
||||
|
||||
// Grid extensions
|
||||
import AsyncToggleColumnExtension from '@components/grid/extension/column/common/async-toggle-column-extension';
|
||||
import BulkActionCheckboxExtension from '@components/grid/extension/bulk-action-checkbox-extension';
|
||||
import BulkOpenTabsExtension from '@components/grid/extension/bulk-open-tabs-extension';
|
||||
import ChoiceExtension from '@components/grid/extension/choice-extension';
|
||||
import ColumnTogglingExtension from '@components/grid/extension/column-toggling-extension';
|
||||
import ExportToSqlManagerExtension from '@components/grid/extension/export-to-sql-manager-extension';
|
||||
import FiltersResetExtension from '@components/grid/extension/filters-reset-extension.js';
|
||||
import FiltersSubmitButtonEnablerExtension from '@components/grid/extension/filters-submit-button-enabler-extension';
|
||||
import LinkRowActionExtension from '@components/grid/extension/link-row-action-extension';
|
||||
import ModalFormSubmitExtension from '@components/grid/extension/modal-form-submit-extension';
|
||||
import PositionExtension from '@components/grid/extension/position-extension';
|
||||
import PreviewExtension from '@components/grid/extension/preview-extension';
|
||||
import ReloadListExtension from '@components/grid/extension/reload-list-extension';
|
||||
import SortingExtension from '@components/grid/extension/sorting-extension';
|
||||
import SubmitBulkActionExtension from '@components/grid/extension/submit-bulk-action-extension';
|
||||
import SubmitGridActionExtension from '@components/grid/extension/submit-grid-action-extension';
|
||||
import SubmitRowActionExtension from '@components/grid/extension/action/row/submit-row-action-extension';
|
||||
|
||||
const GridExtensions = {
|
||||
AsyncToggleColumnExtension,
|
||||
BulkActionCheckboxExtension,
|
||||
BulkOpenTabsExtension,
|
||||
ChoiceExtension,
|
||||
ColumnTogglingExtension,
|
||||
ExportToSqlManagerExtension,
|
||||
FiltersResetExtension,
|
||||
FiltersSubmitButtonEnablerExtension,
|
||||
LinkRowActionExtension,
|
||||
ModalFormSubmitExtension,
|
||||
PositionExtension,
|
||||
PreviewExtension,
|
||||
ReloadListExtension,
|
||||
SortingExtension,
|
||||
SubmitBulkActionExtension,
|
||||
SubmitGridActionExtension,
|
||||
SubmitRowActionExtension,
|
||||
};
|
||||
|
||||
const initPrestashopComponents = () => {
|
||||
window.prestashop = {...window.prestashop};
|
||||
|
||||
if (!window.prestashop.instance) {
|
||||
window.prestashop.instance = {};
|
||||
}
|
||||
|
||||
window.prestashop.component = {
|
||||
initComponents(components) {
|
||||
components.forEach((component) => {
|
||||
if (window.prestashop.component[component] === undefined) {
|
||||
console.error(`Failed to initialize PrestaShop component "${component}". This component doesn't exist.`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const componentInstanceName = component.charAt(0).toLowerCase() + component.slice(1);
|
||||
|
||||
if (window.prestashop.instance[componentInstanceName] !== undefined) {
|
||||
console.warn(
|
||||
`Failed to initialize PrestaShop component "${component}". This component is already initialized.`,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// EventEmitter is a special case it has no constructor and could be used via
|
||||
// window.prestashop.component.EventEmitter straight away
|
||||
if (component === 'EventEmitter') {
|
||||
window.prestashop.instance[componentInstanceName] = window.prestashop.component[component];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
window.prestashop.instance[componentInstanceName] = new window.prestashop.component[component]();
|
||||
});
|
||||
|
||||
// Send an event so external users can initiate their own components
|
||||
EventEmitter.emit('PSComponentsInitiated');
|
||||
},
|
||||
// @todo: add all standard components in this list
|
||||
TranslatableField,
|
||||
TinyMCEEditor,
|
||||
TranslatableInput,
|
||||
TaggableField,
|
||||
ChoiceTable,
|
||||
EventEmitter,
|
||||
ChoiceTree,
|
||||
MultipleChoiceTable,
|
||||
GeneratableInput,
|
||||
CountryStateSelectionToggler,
|
||||
CountryDniRequiredToggler,
|
||||
TextWithLengthCounter,
|
||||
MultistoreConfigField,
|
||||
PreviewOpener,
|
||||
Grid,
|
||||
GridExtensions,
|
||||
Router,
|
||||
};
|
||||
};
|
||||
export default initPrestashopComponents;
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
const findAllUnwantedCharsExceptTheLatestOne = /(?:(?!^-\d+))[^\d]+(?=.*[^\d])/g;
|
||||
const findAllUnwantedChars = /(?:(?!^-\d+))([^\d]+)/g;
|
||||
|
||||
/**
|
||||
* If there is a dot in the string
|
||||
* split the string at the first dot, and
|
||||
* replace all unwanted characters.
|
||||
* Otherwise, replace all unwanted characters expect the
|
||||
* latest one, and replace the latest character
|
||||
* by a dot.
|
||||
*/
|
||||
export const transform = (value) => {
|
||||
let val = value;
|
||||
const unwantedChars = val.match(findAllUnwantedChars);
|
||||
|
||||
if (unwantedChars === null) {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (unwantedChars.length > 1) {
|
||||
const unique = [...new Set(unwantedChars)];
|
||||
|
||||
if (unique.length === 1) {
|
||||
return val.replace(findAllUnwantedChars, '');
|
||||
}
|
||||
}
|
||||
|
||||
val = val
|
||||
.replace(findAllUnwantedCharsExceptTheLatestOne, '')
|
||||
.replace(findAllUnwantedChars, '.');
|
||||
|
||||
return val;
|
||||
};
|
||||
|
||||
const clearNumberInputValue = (event, selector) => {
|
||||
if (!event.target.matches(selector)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const {value} = event.target;
|
||||
event.target.value = transform(value);
|
||||
};
|
||||
|
||||
export default (selector) => {
|
||||
document.addEventListener(
|
||||
'change',
|
||||
(event) => {
|
||||
clearNumberInputValue(event, selector);
|
||||
},
|
||||
true,
|
||||
);
|
||||
};
|
||||
36
admin-kalsport/themes/new-theme/js/app/utils/reset_search.js
Normal file
36
admin-kalsport/themes/new-theme/js/app/utils/reset_search.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a Post Request to reset search Action.
|
||||
*/
|
||||
|
||||
const {$} = window;
|
||||
|
||||
const init = function resetSearch(url, redirectUrl) {
|
||||
$.post(url).then(() => window.location.assign(redirectUrl));
|
||||
};
|
||||
|
||||
export default init;
|
||||
182
admin-kalsport/themes/new-theme/js/app/utils/serp/index.js
Normal file
182
admin-kalsport/themes/new-theme/js/app/utils/serp/index.js
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
import Vue from 'vue';
|
||||
import {EventEmitter} from '@components/event-emitter';
|
||||
import serp from './serp.vue';
|
||||
|
||||
const {$} = window;
|
||||
|
||||
/**
|
||||
* Vue component displaying a search page result, Google style.
|
||||
* Requires a tag with the id "#serp-app" to be present in the DOM to run it.
|
||||
* The component is automatically updated by watching several inputs.
|
||||
* Set the proper class to link a input to a part of the panel.
|
||||
*/
|
||||
class SerpApp {
|
||||
constructor(selectors, url) {
|
||||
// If the selector cannot be found, we do not load the Vue app
|
||||
if ($(selectors.container).length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.originalUrl = url;
|
||||
this.useMultiLang = selectors.multiLanguageInput !== undefined || selectors.multiLanguageField !== undefined;
|
||||
|
||||
if (this.useMultiLang) {
|
||||
const possibleSelectors = [];
|
||||
|
||||
if (selectors.multiLanguageInput) {
|
||||
possibleSelectors.push(selectors.multiLanguageInput);
|
||||
}
|
||||
if (selectors.multiLanguageField) {
|
||||
possibleSelectors.push(selectors.multiLanguageField);
|
||||
}
|
||||
this.multiLangSelector = possibleSelectors.join(',');
|
||||
this.attachMultiLangEvents();
|
||||
}
|
||||
|
||||
this.data = {
|
||||
url,
|
||||
title: '',
|
||||
description: '',
|
||||
};
|
||||
|
||||
this.vm = new Vue({
|
||||
el: selectors.container,
|
||||
template: '<serp ref="serp" :url="url" :title="title" :description="description" />',
|
||||
components: {serp},
|
||||
data: this.data,
|
||||
});
|
||||
|
||||
this.initializeSelectors(selectors);
|
||||
this.attachInputEvents();
|
||||
}
|
||||
|
||||
attachMultiLangEvents(itemSelector) {
|
||||
$('body').on(
|
||||
'click',
|
||||
itemSelector,
|
||||
() => {
|
||||
this.checkTitle();
|
||||
this.checkDesc();
|
||||
this.checkUrl();
|
||||
},
|
||||
);
|
||||
|
||||
EventEmitter.on('languageSelected', () => {
|
||||
this.checkTitle();
|
||||
this.checkDesc();
|
||||
this.checkUrl();
|
||||
});
|
||||
}
|
||||
|
||||
initializeSelectors(selectors) {
|
||||
this.defaultTitle = $(selectors.defaultTitle);
|
||||
this.watchedTitle = $(selectors.watchedTitle);
|
||||
this.defaultDescription = $(selectors.defaultDescription);
|
||||
this.watchedDescription = $(selectors.watchedDescription);
|
||||
this.watchedMetaUrl = $(selectors.watchedMetaUrl);
|
||||
}
|
||||
|
||||
attachInputEvents() {
|
||||
$(this.defaultTitle).on('keyup change', () => this.checkTitle());
|
||||
$(this.watchedTitle).on('keyup change', () => this.checkTitle());
|
||||
$(this.defaultDescription).on('keyup change', () => this.checkDesc());
|
||||
$(this.watchedDescription).on('keyup change', () => this.checkDesc());
|
||||
this.watchedMetaUrl.on('keyup change', () => this.checkUrl());
|
||||
|
||||
this.checkTitle();
|
||||
this.checkDesc();
|
||||
this.checkUrl();
|
||||
}
|
||||
|
||||
setTitle(title) {
|
||||
this.data.title = title;
|
||||
}
|
||||
|
||||
setDescription(description) {
|
||||
this.data.description = description;
|
||||
}
|
||||
|
||||
setUrl(rewrite) {
|
||||
// We replace two placeholders because there was a typo in the initial one ('friendy' instead of 'friendly')
|
||||
this.data.url = this.originalUrl.replace(
|
||||
'{friendy-url}',
|
||||
rewrite,
|
||||
);
|
||||
this.data.url = this.data.url.replace(
|
||||
'{friendly-url}',
|
||||
rewrite,
|
||||
);
|
||||
}
|
||||
|
||||
checkTitle() {
|
||||
let {defaultTitle} = this;
|
||||
let {watchedTitle} = this;
|
||||
|
||||
if (this.useMultiLang) {
|
||||
watchedTitle = watchedTitle.closest(this.multiLangSelector).find('input');
|
||||
defaultTitle = defaultTitle.closest(this.multiLangSelector).find('input');
|
||||
}
|
||||
|
||||
const title1 = watchedTitle.length ? watchedTitle.val() : '';
|
||||
const title2 = defaultTitle.length ? defaultTitle.val() : '';
|
||||
|
||||
this.setTitle(title1 === '' ? title2 : title1);
|
||||
// Always check for url if title change
|
||||
this.checkUrl();
|
||||
}
|
||||
|
||||
checkDesc() {
|
||||
let {watchedDescription} = this;
|
||||
let {defaultDescription} = this;
|
||||
|
||||
if (this.useMultiLang) {
|
||||
watchedDescription = watchedDescription
|
||||
.closest(this.multiLangSelector)
|
||||
.find(this.watchedDescription.is('input') ? 'input' : 'textarea');
|
||||
defaultDescription = defaultDescription
|
||||
.closest(this.multiLangSelector)
|
||||
.find(this.defaultDescription.is('input') ? 'input' : 'textarea');
|
||||
}
|
||||
|
||||
const desc1 = watchedDescription.length ? watchedDescription.val().innerText || watchedDescription.val() : '';
|
||||
const desc2 = defaultDescription.length ? $(defaultDescription.val()).text() || defaultDescription.val() : '';
|
||||
|
||||
this.setDescription(desc1 === '' ? desc2 : desc1);
|
||||
}
|
||||
|
||||
checkUrl() {
|
||||
let {watchedMetaUrl} = this;
|
||||
|
||||
if (this.useMultiLang) {
|
||||
watchedMetaUrl = watchedMetaUrl.closest(this.multiLangSelector).find('input');
|
||||
}
|
||||
|
||||
this.setUrl(watchedMetaUrl.val());
|
||||
}
|
||||
}
|
||||
|
||||
export default SerpApp;
|
||||
151
admin-kalsport/themes/new-theme/js/app/utils/serp/serp.vue
Normal file
151
admin-kalsport/themes/new-theme/js/app/utils/serp/serp.vue
Normal file
@@ -0,0 +1,151 @@
|
||||
<!--**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*-->
|
||||
<template>
|
||||
<div id="serp">
|
||||
<div class="serp-preview">
|
||||
<div class="serp-title">
|
||||
{{ displayedTitle }}
|
||||
</div>
|
||||
<div class="serp-url">
|
||||
{{ url }}<span class="serp-arrow" />
|
||||
</div>
|
||||
<div class="serp-description">
|
||||
{{ displayedDescription }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Serp',
|
||||
props: {
|
||||
url: {
|
||||
type: String,
|
||||
default: 'https://www.example.com/',
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayedTitle() {
|
||||
if (this.title.length > 70) {
|
||||
return `${this.title.substring(0, 70)}...`;
|
||||
}
|
||||
|
||||
return this.title;
|
||||
},
|
||||
displayedDescription() {
|
||||
if (this.description.length > 150) {
|
||||
return `${this.description.substring(0, 150)}...`;
|
||||
}
|
||||
|
||||
return this.description;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" type="text/scss" scoped>
|
||||
.serp-preview {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.12);
|
||||
background-color: #ffffff;
|
||||
border: solid 1px #e7e7e7;
|
||||
padding: 30px;
|
||||
max-width: 700px;
|
||||
|
||||
.serp-arrow {
|
||||
border-bottom-color: rgb(0, 102, 33);
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 0px;
|
||||
border-left-color: rgba(0, 0, 0, 0);
|
||||
border-left-style: solid;
|
||||
border-left-width: 4px;
|
||||
border-right-color: rgba(0, 0, 0, 0);
|
||||
border-right-style: solid;
|
||||
border-right-width: 4px;
|
||||
border-top-color: rgb(0, 102, 33);
|
||||
border-top-style: solid;
|
||||
border-top-width: 5px;
|
||||
color: rgb(128, 128, 128);
|
||||
cursor: default;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
height: 0px;
|
||||
position: absolute;
|
||||
line-height: 27px;
|
||||
margin-left: 3px;
|
||||
margin-top: 6px;
|
||||
text-align: center;
|
||||
user-select: none;
|
||||
visibility: visible;
|
||||
white-space: nowrap;
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
.serp-title {
|
||||
color: #1A0DAB;
|
||||
cursor: pointer;
|
||||
font-family: arial, regular;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
visibility: visible;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.serp-url {
|
||||
color: #006621;
|
||||
font-family: arial, regular;
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
line-height: 24px;
|
||||
text-align: left;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.serp-description {
|
||||
color: #545454;
|
||||
font-family: arial, regular;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
visibility: visible;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
85
admin-kalsport/themes/new-theme/js/app/utils/sql-manager.js
Normal file
85
admin-kalsport/themes/new-theme/js/app/utils/sql-manager.js
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
const {$} = window;
|
||||
|
||||
/**
|
||||
* Allow to display the last SQL query in a modal and redirect to SQL Manager.
|
||||
*/
|
||||
class SqlManager {
|
||||
showLastSqlQuery() {
|
||||
$('#catalog_sql_query_modal_content textarea[name="sql"]').val($('tbody.sql-manager').data('query'));
|
||||
$('#catalog_sql_query_modal .btn-sql-submit').click(() => {
|
||||
$('#catalog_sql_query_modal_content').submit();
|
||||
});
|
||||
$('#catalog_sql_query_modal').modal('show');
|
||||
}
|
||||
|
||||
sendLastSqlQuery(name) {
|
||||
$('#catalog_sql_query_modal_content textarea[name="sql"]').val($('tbody.sql-manager').data('query'));
|
||||
$('#catalog_sql_query_modal_content input[name="name"]').val(name);
|
||||
$('#catalog_sql_query_modal_content').submit();
|
||||
}
|
||||
|
||||
createSqlQueryName() {
|
||||
let container = false;
|
||||
let current = false;
|
||||
|
||||
if ($('.breadcrumb')) {
|
||||
container = $('.breadcrumb li').eq(0).text().replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
current = $('.breadcrumb li').eq(-1).text().replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
let title = false;
|
||||
|
||||
if ($('h2.title')) {
|
||||
title = $('h2.title').first().text().replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
let name = false;
|
||||
|
||||
if (container && current && container !== current) {
|
||||
name = `${container} > ${current}`;
|
||||
} else if (container) {
|
||||
name = container;
|
||||
} else if (current) {
|
||||
name = current;
|
||||
}
|
||||
|
||||
if (title && title !== current && title !== container) {
|
||||
if (name) {
|
||||
name = `${name} > ${title}`;
|
||||
} else {
|
||||
name = title;
|
||||
}
|
||||
}
|
||||
|
||||
return name.trim();
|
||||
}
|
||||
}
|
||||
|
||||
export default SqlManager;
|
||||
114
admin-kalsport/themes/new-theme/js/app/utils/table-sorting.js
Normal file
114
admin-kalsport/themes/new-theme/js/app/utils/table-sorting.js
Normal file
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/OSL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to https://devdocs.prestashop.com/ for more information.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
||||
*/
|
||||
|
||||
const {$} = window;
|
||||
|
||||
/**
|
||||
* Makes a table sortable by columns.
|
||||
* This forces a page reload with more query parameters.
|
||||
*/
|
||||
class TableSorting {
|
||||
/**
|
||||
* @param {jQuery} table
|
||||
*/
|
||||
constructor(table) {
|
||||
this.selector = '.ps-sortable-column';
|
||||
this.columns = $(table).find(this.selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the listeners
|
||||
*/
|
||||
attach() {
|
||||
this.columns.on('click', (e) => {
|
||||
const $column = $(e.delegateTarget);
|
||||
this.sortByColumn($column, this.getToggledSortDirection($column));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort using a column name
|
||||
* @param {string} columnName
|
||||
* @param {string} direction "asc" or "desc"
|
||||
*/
|
||||
sortBy(columnName, direction) {
|
||||
const $column = this.columns.is(`[data-sort-col-name="${columnName}"]`);
|
||||
|
||||
if (!$column) {
|
||||
throw new Error(`Cannot sort by "${columnName}": invalid column`);
|
||||
}
|
||||
|
||||
this.sortByColumn($column, direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort using a column element
|
||||
* @param {jQuery} column
|
||||
* @param {string} direction "asc" or "desc"
|
||||
* @private
|
||||
*/
|
||||
sortByColumn(column, direction) {
|
||||
window.location = this.getUrl(
|
||||
column.data('sortColName'),
|
||||
(direction === 'desc') ? 'desc' : 'asc',
|
||||
column.data('sortPrefix'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inverted direction to sort according to the column's current one
|
||||
* @param {jQuery} column
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
getToggledSortDirection(column) {
|
||||
return column.data('sortDirection') === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url for the sorted table
|
||||
* @param {string} colName
|
||||
* @param {string} direction
|
||||
* @param {string} prefix
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
getUrl(colName, direction, prefix) {
|
||||
const url = new URL(window.location.href);
|
||||
const params = url.searchParams;
|
||||
|
||||
if (prefix) {
|
||||
params.set(`${prefix}[orderBy]`, colName);
|
||||
params.set(`${prefix}[sortOrder]`, direction);
|
||||
} else {
|
||||
params.set('orderBy', colName);
|
||||
params.set('sortOrder', direction);
|
||||
}
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
}
|
||||
|
||||
export default TableSorting;
|
||||
Reference in New Issue
Block a user