first commit
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
/**
|
||||
* 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 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();
|
||||
|
||||
Object.values(accessibleTabs).forEach((accessibleTab) => {
|
||||
if (accessibleTab.children.length > 0 && accessibleTab.name) {
|
||||
// If tab has children - create an option group and put children inside.
|
||||
const $optgroup = this.createOptionGroup(accessibleTab.name);
|
||||
|
||||
Object.keys(accessibleTab.children).forEach((childKey) => {
|
||||
if (accessibleTab.children[childKey].name) {
|
||||
$optgroup.append(
|
||||
this.createOption(
|
||||
accessibleTab.children[childKey].name,
|
||||
accessibleTab.children[childKey].id_tab),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$tabsDropdown.append($optgroup);
|
||||
} else if (accessibleTab.name) {
|
||||
// If tab doesn't have children - create an option.
|
||||
$tabsDropdown.append(
|
||||
this.createOption(
|
||||
accessibleTab.name,
|
||||
accessibleTab.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>`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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',
|
||||
};
|
||||
30
admin-kalsport/themes/new-theme/js/pages/employee/form.js
Normal file
30
admin-kalsport/themes/new-theme/js/pages/employee/form.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 EmployeeForm from './EmployeeForm';
|
||||
|
||||
$(() => {
|
||||
new EmployeeForm();
|
||||
});
|
||||
59
admin-kalsport/themes/new-theme/js/pages/employee/index.js
Normal file
59
admin-kalsport/themes/new-theme/js/pages/employee/index.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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 FiltersSubmitButtonEnablerExtension
|
||||
from '@components/grid/extension/filters-submit-button-enabler-extension';
|
||||
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 FiltersSubmitButtonEnablerExtension());
|
||||
employeeGrid.addExtension(new LinkRowActionExtension());
|
||||
|
||||
const showcaseCard = new ShowcaseCard('employeesShowcaseCard');
|
||||
showcaseCard.addExtension(new ShowcaseCardCloseExtension());
|
||||
});
|
||||
Reference in New Issue
Block a user