first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* 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.txt.
* 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://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import ChoiceTree from "../../components/form/choice-tree";
import AddonsConnector from "../../components/addons-connector";
import ChangePasswordControl from "../../components/form/change-password-control";
import employeeFormMap from "./employee-form-map";
/**
* Class responsible for javascript actions in employee add/edit page.
*/
export default class EmployeeForm {
constructor() {
this.shopChoiceTreeSelector = employeeFormMap.shopChoiceTree;
this.shopChoiceTree = new ChoiceTree(this.shopChoiceTreeSelector);
this.employeeProfileSelector = employeeFormMap.profileSelect;
this.tabsDropdownSelector = employeeFormMap.defaultPageSelect;
this.shopChoiceTree.enableAutoCheckChildren();
new AddonsConnector(
employeeFormMap.addonsConnectForm,
employeeFormMap.addonsLoginButton
);
new ChangePasswordControl(
employeeFormMap.changePasswordInputsBlock,
employeeFormMap.showChangePasswordBlockButton,
employeeFormMap.hideChangePasswordBlockButton,
employeeFormMap.generatePasswordButton,
employeeFormMap.oldPasswordInput,
employeeFormMap.newPasswordInput,
employeeFormMap.confirmNewPasswordInput,
employeeFormMap.generatedPasswordDisplayInput,
employeeFormMap.passwordStrengthFeedbackContainer
);
this._initEvents();
this._toggleShopTree();
return {};
}
/**
* Initialize page's events.
*
* @private
*/
_initEvents() {
const $employeeProfilesDropdown = $(this.employeeProfileSelector);
const getTabsUrl = $employeeProfilesDropdown.data('get-tabs-url');
$(document).on('change', this.employeeProfileSelector, () => this._toggleShopTree());
// Reload tabs dropdown when employee profile is changed.
$(document).on('change', this.employeeProfileSelector, (event) => {
$.get(
getTabsUrl,
{
profileId: $(event.currentTarget).val()
},
(tabs) => {
this._reloadTabsDropdown(tabs);
},
'json'
);
});
}
/**
* Reload tabs dropdown with new content.
*
* @param {Object} accessibleTabs
*
* @private
*/
_reloadTabsDropdown(accessibleTabs) {
const $tabsDropdown = $(this.tabsDropdownSelector);
$tabsDropdown.empty();
for (let key in accessibleTabs) {
if (accessibleTabs[key]['children'].length > 0 && accessibleTabs[key]['name']) {
// If tab has children - create an option group and put children inside.
const $optgroup = this._createOptionGroup(accessibleTabs[key]['name']);
for (let childKey in accessibleTabs[key]['children']) {
if (accessibleTabs[key]['children'][childKey]['name']) {
$optgroup.append(
this._createOption(
accessibleTabs[key]['children'][childKey]['name'],
accessibleTabs[key]['children'][childKey]['id_tab'])
);
}
}
$tabsDropdown.append($optgroup);
} else if (accessibleTabs[key]['name']) {
// If tab doesn't have children - create an option.
$tabsDropdown.append(
this._createOption(
accessibleTabs[key]['name'],
accessibleTabs[key]['id_tab']
)
);
}
}
}
/**
* Hide shop choice tree if superadmin profile is selected, show it otherwise.
*
* @private
*/
_toggleShopTree() {
const $employeeProfileDropdown = $(this.employeeProfileSelector);
const superAdminProfileId = $employeeProfileDropdown.data('admin-profile');
$(this.shopChoiceTreeSelector)
.closest('.form-group')
.toggleClass('d-none', $employeeProfileDropdown.val() == superAdminProfileId)
;
}
/**
* Creates an <optgroup> element
*
* @param {String} name
*
* @returns {jQuery}
*
* @private
*/
_createOptionGroup(name) {
return $(`<optgroup label="${name}">`);
}
/**
* Creates an <option> element.
*
* @param {String} name
* @param {String} value
*
* @returns {jQuery}
*
* @private
*/
_createOption(name, value) {
return $(`<option value="${value}">${name}</option>`);
}
}

View File

@@ -0,0 +1,46 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* 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.txt.
* 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://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Defines all selectors that are used in employee add/edit form.
*/
export default {
shopChoiceTree: '#employee_shop_association',
profileSelect: '#employee_profile',
defaultPageSelect: '#employee_default_page',
addonsConnectForm: '#addons-connect-form',
addonsLoginButton: '#addons_login_btn',
// selectors related to "change password" form control
changePasswordInputsBlock: '.js-change-password-block',
showChangePasswordBlockButton: '.js-change-password',
hideChangePasswordBlockButton: '.js-change-password-cancel',
generatePasswordButton: '#employee_change_password_generate_password_button',
oldPasswordInput: '#employee_change_password_old_password',
newPasswordInput: '#employee_change_password_new_password_first',
confirmNewPasswordInput: '#employee_change_password_new_password_second',
generatedPasswordDisplayInput: '#employee_change_password_generated_password',
passwordStrengthFeedbackContainer: '.js-password-strength-feedback',
}

View File

@@ -0,0 +1,30 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* 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.txt.
* 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://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import EmployeeForm from "./EmployeeForm";
$(() => {
new EmployeeForm();
});

View File

@@ -0,0 +1,56 @@
/**
* 2007-2019 PrestaShop and Contributors
*
* 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.txt.
* 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://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2019 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import Grid from '../../components/grid/grid';
import ReloadListActionExtension from '../../components/grid/extension/reload-list-extension';
import ExportToSqlManagerExtension from '../../components/grid/extension/export-to-sql-manager-extension';
import FiltersResetExtension from '../../components/grid/extension/filters-reset-extension';
import SortingExtension from '../../components/grid/extension/sorting-extension';
import BulkActionCheckboxExtension from '../../components/grid/extension/bulk-action-checkbox-extension';
import SubmitBulkActionExtension from '../../components/grid/extension/submit-bulk-action-extension';
import SubmitRowActionExtension from '../../components/grid/extension/action/row/submit-row-action-extension';
import ColumnTogglingExtension from '../../components/grid/extension/column-toggling-extension';
import ShowcaseCard from '../../components/showcase-card/showcase-card';
import ShowcaseCardCloseExtension from '../../components/showcase-card/extension/showcase-card-close-extension';
import LinkRowActionExtension from '../../components/grid/extension/link-row-action-extension';
const $ = window.$;
$(() => {
const employeeGrid = new Grid('employee');
employeeGrid.addExtension(new ReloadListActionExtension());
employeeGrid.addExtension(new ExportToSqlManagerExtension());
employeeGrid.addExtension(new FiltersResetExtension());
employeeGrid.addExtension(new SortingExtension());
employeeGrid.addExtension(new BulkActionCheckboxExtension());
employeeGrid.addExtension(new SubmitBulkActionExtension());
employeeGrid.addExtension(new SubmitRowActionExtension());
employeeGrid.addExtension(new ColumnTogglingExtension());
employeeGrid.addExtension(new LinkRowActionExtension());
const showcaseCard = new ShowcaseCard('employeesShowcaseCard');
showcaseCard.addExtension(new ShowcaseCardCloseExtension());
});