Skip to content

Commit

Permalink
Simplify few form components and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlavtox committed Sep 14, 2024
1 parent ae2872e commit 9117378
Show file tree
Hide file tree
Showing 50 changed files with 108 additions and 163 deletions.
11 changes: 5 additions & 6 deletions admin-dev/themes/new-theme/js/pages/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import ChoiceTable from '@components/choice-table';

const {$} = window;

$(() => {
const addressGrid = new window.prestashop.component.Grid('address');

Expand All @@ -39,6 +35,9 @@ $(() => {
addressGrid.addExtension(new window.prestashop.component.GridExtensions.SubmitRowActionExtension());
addressGrid.addExtension(new window.prestashop.component.GridExtensions.LinkRowActionExtension());

// needed for address required fields form
new ChoiceTable();
window.prestashop.component.initComponents(
[
'ChoiceTable',
],
);
});
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/api-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const grid = new window.prestashop.component.Grid('api_client');

Expand Down
10 changes: 5 additions & 5 deletions admin-dev/themes/new-theme/js/pages/attachment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import TranslatableInput from '@components/translatable-input';

const {$} = window;

$(() => {
const attachmentGrid = new window.prestashop.component.Grid('attachment');

Expand All @@ -39,5 +35,9 @@ $(() => {
attachmentGrid.addExtension(new window.prestashop.component.GridExtensions.SubmitRowActionExtension());
attachmentGrid.addExtension(new window.prestashop.component.GridExtensions.LinkRowActionExtension());

new TranslatableInput();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);
});
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/attribute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const grid = new window.prestashop.component.Grid('attribute');

Expand Down
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/backup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const backupGrid = new window.prestashop.component.Grid('backup');

Expand Down
4 changes: 1 addition & 3 deletions admin-dev/themes/new-theme/js/pages/carrier/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/

import NavbarHandler from '@components/navbar-handler';
import ChoiceTable from '@js/components/choice-table';
import CarrierFormManager from '@pages/carrier/form/carrier-form-manager';
import CarrierRanges from '@pages/carrier/form/carrier-range-modal';
import CarrierFormMap from './carrier-form-map';
Expand All @@ -35,13 +34,12 @@ $(() => {
'TranslatableInput',
'EventEmitter',
'MultipleZoneChoice',
'ChoiceTable',
]);

// Initialize the ranges selection modal
new CarrierRanges(window.prestashop.instance.eventEmitter);

new ChoiceTable();

new NavbarHandler($(CarrierFormMap.navigationBar));

// Initialize the carrier form manager
Expand Down
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/cart-rule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const cartRuleGrid = new window.prestashop.component.Grid('cart_rule');

Expand Down
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/cart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
*
*/


const {$} = window;

$(() => {
const grid = new window.prestashop.component.Grid('cart');
grid.addExtension(new window.prestashop.component.GridExtensions.ExportToSqlManagerExtension());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const priceRuleGrid = new window.prestashop.component.Grid('catalog_price_rule');

Expand Down
3 changes: 1 addition & 2 deletions admin-dev/themes/new-theme/js/pages/category/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import CategoryPositionExtension from '@components/grid/extension/column/catalog
import DeleteCategoryRowActionExtension from '@components/grid/extension/action/row/category/delete-category-row-action-extension';
import DeleteCategoriesBulkActionExtension from '@components/grid/extension/action/bulk/category/delete-categories-bulk-action-extension';
/* eslint-enable */
import ChoiceTable from '@components/choice-table';
import textToLinkRewriteCopier from '@components/text-to-link-rewrite-copier';
import FormSubmitButton from '@components/form-submit-button';
import ShowcaseCard from '@components/showcase-card/showcase-card';
Expand Down Expand Up @@ -63,11 +62,11 @@ $(() => {
'TinyMCEEditor',
'TranslatableInput',
'TextWithRecommendedLengthCounter',
'ChoiceTable',
],
);

const translatorInput = window.prestashop.instance.translatableInput;
new ChoiceTable();

textToLinkRewriteCopier({
sourceElementSelector: 'input[name^="category[name]"]',
Expand Down
5 changes: 2 additions & 3 deletions admin-dev/themes/new-theme/js/pages/cms-page/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import ChoiceTree from '@components/form/choice-tree';
import textToLinkRewriteCopier from '@components/text-to-link-rewrite-copier';
import Serp from '@app/utils/serp/index';
import TextWithRecommendedLengthCounter from '@components/form/text-with-recommended-length-counter';

const {$} = window;

$(() => {
new ChoiceTree('#cms_page_page_category_id');
new window.prestashop.component.ChoiceTree('#cms_page_page_category_id');

window.prestashop.component.initComponents(
[
Expand Down Expand Up @@ -72,7 +71,7 @@ $(() => {
destinationElementSelector: `${translatorInput.localeInputSelector}:not(.d-none) input.js-copier-destination-friendly-url`,
});

new ChoiceTree('#cms_page_shop_association').enableAutoCheckChildren();
new window.prestashop.component.ChoiceTree('#cms_page_shop_association').enableAutoCheckChildren();

new TextWithRecommendedLengthCounter();
});
17 changes: 10 additions & 7 deletions admin-dev/themes/new-theme/js/pages/cms-page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import ChoiceTree from '@components/form/choice-tree';
import TranslatableInput from '@components/translatable-input';
import textToLinkRewriteCopier from '@components/text-to-link-rewrite-copier';
import TaggableField from '@components/taggable-field';
import ShowcaseCard from '@components/showcase-card/showcase-card';
import ShowcaseCardCloseExtension from '@components/showcase-card/extension/showcase-card-close-extension';

Expand All @@ -47,20 +44,26 @@ $(() => {
cmsCategory.addExtension(new window.prestashop.component.GridExtensions.PositionExtension(cmsCategory));
cmsCategory.addExtension(new window.prestashop.component.GridExtensions.FiltersSubmitButtonEnablerExtension());

const translatorInput = new TranslatableInput();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);

const translatorInput = window.prestashop.instance.translatableInput;

textToLinkRewriteCopier({
sourceElementSelector: 'input[name^="cms_page_category[name]"]',
/* eslint-disable-next-line max-len */
destinationElementSelector: `${translatorInput.localeInputSelector}:not(.d-none) input[name^="cms_page_category[friendly_url]"]`,
});

new ChoiceTree('#cms_page_category_parent_category');
new window.prestashop.component.ChoiceTree('#cms_page_category_parent_category');

const shopChoiceTree = new ChoiceTree('#cms_page_category_shop_association');
const shopChoiceTree = new window.prestashop.component.ChoiceTree('#cms_page_category_shop_association');
shopChoiceTree.enableAutoCheckChildren();

new TaggableField({
new window.prestashop.component.TaggableField({
tokenFieldSelector: 'input[name^="cms_page_category[meta_keywords]"]',
options: {
createTokensOnBlur: true,
Expand Down
11 changes: 6 additions & 5 deletions admin-dev/themes/new-theme/js/pages/contacts/ContactsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import TranslatableInput from '@components/translatable-input';
import ChoiceTree from '@components/form/choice-tree';

/**
* Responsible for actions in Contacts listing page.
*/
Expand All @@ -43,8 +40,12 @@ export default class ContactsPage {
contactGrid.addExtension(new window.prestashop.component.GridExtensions.BulkActionCheckboxExtension());
contactGrid.addExtension(new window.prestashop.component.GridExtensions.SubmitRowActionExtension());

new TranslatableInput();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);

new ChoiceTree('#contact_shop_association').enableAutoCheckChildren();
new window.prestashop.component.ChoiceTree('#contact_shop_association').enableAutoCheckChildren();
}
}
8 changes: 6 additions & 2 deletions admin-dev/themes/new-theme/js/pages/country/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@

import ZipCodeManager from '@pages/country/components/zip-code-manager';
import FormSubmitButton from '@components/form-submit-button';
import TranslatableInput from '@components/translatable-input';

const {$} = window;

$(() => {
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);

new FormSubmitButton();
new TranslatableInput();
new ZipCodeManager();
});
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/country/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const countryGrid = new window.prestashop.component.Grid('country');

Expand Down
10 changes: 5 additions & 5 deletions admin-dev/themes/new-theme/js/pages/credit-slip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import TranslatableInput from '../../components/translatable-input';

const {$} = window;

$(() => {
const creditSlipGrid = new window.prestashop.component.Grid('credit_slip');

Expand All @@ -36,5 +32,9 @@ $(() => {
creditSlipGrid.addExtension(new window.prestashop.component.GridExtensions.FiltersResetExtension());
creditSlipGrid.addExtension(new window.prestashop.component.GridExtensions.FiltersSubmitButtonEnablerExtension());

new TranslatableInput();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);
});
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/customer-groups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const customerGroups = new window.prestashop.component.Grid('customer_groups');

Expand Down
3 changes: 0 additions & 3 deletions admin-dev/themes/new-theme/js/pages/customer-thread/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const grid = new window.prestashop.component.Grid('customer_thread');

Expand Down
8 changes: 5 additions & 3 deletions admin-dev/themes/new-theme/js/pages/customer/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import ChoiceTable from '@components/choice-table';
import CustomerForm from './CustomerForm';

$(() => {
new CustomerForm();

// needed for "Group access" input in Add/Edit customer forms
new ChoiceTable();
window.prestashop.component.initComponents(
[
'ChoiceTable',
],
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class EmployeeForm {

constructor() {
this.shopChoiceTreeSelector = employeeFormMap.shopChoiceTree;
this.shopChoiceTree = new ChoiceTree(this.shopChoiceTreeSelector);
this.shopChoiceTree = new window.prestashop.component.ChoiceTree(this.shopChoiceTreeSelector);
this.employeeProfileSelector = employeeFormMap.profileSelect;
this.tabsDropdownSelector = employeeFormMap.defaultPageSelect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import TranslatableInput from '@components/translatable-input';

$(() => {
new TranslatableInput();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/


const {$} = window;

$(() => {
const grid = new window.prestashop.component.Grid('feature_value');

Expand Down
11 changes: 6 additions & 5 deletions admin-dev/themes/new-theme/js/pages/feature/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import TranslatableInput from '../../components/translatable-input';
import ChoiceTree from '../../components/form/choice-tree';

$(() => {
new TranslatableInput();
new ChoiceTree('#feature_shop_association').enableAutoCheckChildren();
window.prestashop.component.initComponents(
[
'TranslatableInput',
],
);
new window.prestashop.component.ChoiceTree('#feature_shop_association').enableAutoCheckChildren();
});
3 changes: 1 addition & 2 deletions admin-dev/themes/new-theme/js/pages/invoices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
*/

import initDatePickers from '@app/utils/datepicker';
import TranslatableInput from '@components/translatable-input';

const {$} = window;

$(() => {
initDatePickers();
new TranslatableInput();

window.prestashop.component.initComponents(
[
'MultistoreConfigField',
'TranslatableInput',
],
);
});
Loading

0 comments on commit 9117378

Please sign in to comment.