first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
/**
* 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 TranslationSettingsMap from './TranslationSettingsMap';
const {$} = window;
const $coreType = $(TranslationSettingsMap.exportCoreType);
const $themesType = $(TranslationSettingsMap.exportThemesType);
const $modulesType = $(TranslationSettingsMap.exportModulesType);
const $coreValues = $(TranslationSettingsMap.exportCoreValues).closest('.form-group');
const $themesValues = $(TranslationSettingsMap.exportThemesValues).closest('.form-group');
const $modulesValues = $(TranslationSettingsMap.exportModulesValues).closest('.form-group');
const $coreCheckboxes = $(TranslationSettingsMap.exportCoreValues);
const $themesSelect = $(TranslationSettingsMap.exportThemesValues);
const $modulesSelect = $(TranslationSettingsMap.exportModulesValues);
const $exportButton = $(TranslationSettingsMap.exportLanguageButton);
/**
* Toggles show/hide for the selectors of subtypes (in case of Core type), theme or module when a Type is selected
*
* Example : If Core type is selected, the subtypes checkboxes are shown,
* Theme and Module types are unselected and their value selector are hidden
*/
export default class ExportFormFieldToggle {
constructor() {
$coreType.on('change', this.coreTypeChanged.bind(this));
$themesType.on('change', this.themesTypeChanged.bind(this));
$modulesType.on('change', this.modulesTypeChanged.bind(this));
$coreCheckboxes.on('change', this.subChoicesChanged.bind(this));
$themesSelect.on('change', this.subChoicesChanged.bind(this));
$modulesSelect.on('change', this.subChoicesChanged.bind(this));
this.check($coreType);
}
coreTypeChanged() {
if (!$coreType.is(':checked')) {
return;
}
$coreType.prop('disabled', false);
this.uncheck($themesType, $modulesType);
this.show($coreValues);
this.hide($themesValues, $modulesValues);
this.subChoicesChanged();
}
themesTypeChanged() {
if (!$themesType.is(':checked')) {
return;
}
$themesType.prop('disabled', false);
this.uncheck($coreType, $modulesType);
this.show($themesValues);
this.hide($coreValues, $modulesValues);
this.subChoicesChanged();
}
modulesTypeChanged() {
if (!$modulesType.is(':checked')) {
return;
}
$modulesValues.prop('disabled', false);
this.uncheck($themesType, $coreType);
this.show($modulesValues);
this.hide($themesValues, $coreValues);
this.subChoicesChanged();
}
subChoicesChanged() {
if (
($coreType.prop('checked') && $coreCheckboxes.find(':checked').size() > 0)
|| ($themesType.prop('checked') && $themesSelect.val() !== null)
|| ($modulesType.prop('checked') && $modulesSelect.val() !== null)
) {
$exportButton.prop('disabled', false);
return;
}
$exportButton.prop('disabled', true);
}
/**
* Make all given selectors hidden
*
* @param $selectors
* @private
*/
hide(...$selectors) {
Object.values($selectors).forEach((el) => {
el.addClass('d-none');
el.find('select, input').prop('disabled', 'disabled');
});
}
/**
* Make all given selectors visible
*
* @param $selectors
* @private
*/
show(...$selectors) {
Object.values($selectors).forEach((el) => {
el.removeClass('d-none');
el.find('select, input').prop('disabled', false);
});
}
/**
* Make all given selectors unchecked
*
* @param $selectors
* @private
*/
uncheck(...$selectors) {
Object.values($selectors).forEach((el) => {
el.prop('checked', false);
});
}
/**
* Make all given selectors checked
*
* @param $selectors
* @private
*/
check(...$selectors) {
Object.values($selectors).forEach((el) => {
el.prop('checked', true);
});
}
}

View File

@@ -0,0 +1,160 @@
/**
* 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 TranslationSettingsMap from './TranslationSettingsMap';
const {$} = window;
/**
* Back office translations type
*
* @type {string}
*/
const back = 'back';
/**
* Modules translations type
* @type {string}
*/
const themes = 'themes';
/**
* Modules translations type
* @type {string}
*/
const modules = 'modules';
/**
* Mails translations type
* @type {string}
*/
const mails = 'mails';
/**
* Other translations type
* @type {string}
*/
const others = 'others';
/**
* Email body translations type
* @type {string}
*/
const emailContentBody = 'body';
export default class FormFieldToggle {
constructor() {
$(TranslationSettingsMap.translationType).on('change', this.toggleFields.bind(this));
$(TranslationSettingsMap.emailContentType).on('change', this.toggleEmailFields.bind(this));
this.toggleFields();
}
/**
* Toggle dependant translations fields, based on selected translation type
*/
toggleFields() {
const selectedOption = $(TranslationSettingsMap.translationType).val();
const $modulesFormGroup = $(TranslationSettingsMap.modulesFormGroup);
const $emailFormGroup = $(TranslationSettingsMap.emailFormGroup);
const $themesFormGroup = $(TranslationSettingsMap.themesFormGroup);
const $defaultThemeOption = $themesFormGroup.find(TranslationSettingsMap.defaultThemeOption);
switch (selectedOption) {
case back:
case others:
this.hide($modulesFormGroup, $emailFormGroup, $themesFormGroup);
break;
case themes:
this.show($themesFormGroup);
this.hide($modulesFormGroup, $emailFormGroup, $defaultThemeOption);
break;
case modules:
this.hide($emailFormGroup, $themesFormGroup);
this.show($modulesFormGroup);
break;
case mails:
this.hide($modulesFormGroup, $themesFormGroup);
this.show($emailFormGroup);
break;
default:
break;
}
this.toggleEmailFields();
}
/**
* Toggles fields, which are related to email translations
*/
toggleEmailFields() {
if ($(TranslationSettingsMap.translationType).val() !== mails) {
return;
}
const selectedEmailContentType = $(TranslationSettingsMap.emailFormGroup).find('select').val();
const $themesFormGroup = $(TranslationSettingsMap.themesFormGroup);
const $noThemeOption = $themesFormGroup.find(TranslationSettingsMap.noThemeOption);
const $defaultThemeOption = $themesFormGroup.find(TranslationSettingsMap.defaultThemeOption);
if (selectedEmailContentType === emailContentBody) {
$noThemeOption.prop('selected', true);
this.show($noThemeOption, $themesFormGroup, $defaultThemeOption);
} else {
this.hide($noThemeOption, $themesFormGroup, $defaultThemeOption);
}
}
/**
* Make all given selectors hidden
*
* @param $selectors
* @private
*/
hide(...$selectors) {
Object.values($selectors).forEach((el) => {
el.addClass('d-none');
el.find('select').prop('disabled', 'disabled');
});
}
/**
* Make all given selectors visible
*
* @param $selectors
* @private
*/
show(...$selectors) {
Object.values($selectors).forEach((el) => {
el.removeClass('d-none');
el.find('select').prop('disabled', false);
});
}
}

View File

@@ -0,0 +1,41 @@
/**
* 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 default {
translationType: '.js-translation-type',
emailContentType: '.js-email-content-type',
emailFormGroup: '.js-email-form-group',
modulesFormGroup: '.js-module-form-group',
themesFormGroup: '.js-theme-form-group',
defaultThemeOption: '.js-default-theme',
noThemeOption: '.js-no-theme',
exportCoreType: '#form_core_selectors_core_type',
exportCoreValues: '#form_core_selectors_selected_value',
exportThemesType: '#form_themes_selectors_themes_type',
exportThemesValues: '#form_themes_selectors_selected_value',
exportModulesType: '#form_modules_selectors_modules_type',
exportModulesValues: '#form_modules_selectors_selected_value',
exportLanguageButton: '#form-export-language-button',
};

View File

@@ -0,0 +1,34 @@
/**
* 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 FormFieldToggle from './FormFieldToggle';
import ExportFormFieldToggle from './ExportFormFieldToggle';
export default class TranslationSettingsPage {
constructor() {
new FormFieldToggle();
new ExportFormFieldToggle();
}
}

View File

@@ -0,0 +1,32 @@
/**
* 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 TranslationSettingsPage from './TranslationSettingsPage';
const {$} = window;
$(() => {
new TranslationSettingsPage();
});