Skip to content

Commit

Permalink
fixed duplicate video forms in administration product (#3422)
Browse files Browse the repository at this point in the history
  • Loading branch information
sspooky13 authored Sep 20, 2024
1 parent 79cd98f commit 7cf5aa6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 51 deletions.
11 changes: 4 additions & 7 deletions assets/js/admin/components/HreflangSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import {
} from '../validation/customization/customizeCollectionBundle';

export default class HreflangSetting {
static init () {
const $collectionItemAddButton = $('.js-hreflang-setting-item-add');
const $collection = $('.js-hreflang-setting');

$collectionItemAddButton.off('click');
$collection.off('click', '.js-hreflang-setting-item-remove');
static init ($container) {
const $collectionItemAddButton = $container.filterAllNodes('.js-hreflang-setting-item-add');
const $collection = $container.filterAllNodes('.js-hreflang-setting');

$collection.on('click', '.js-hreflang-setting-item-remove', function (event) {
const $collection = $(this).closest('.js-hreflang-setting');
Expand All @@ -25,7 +22,7 @@ export default class HreflangSetting {
});

$collectionItemAddButton.on('click', function () {
const $collection = $('.js-hreflang-setting');
const $collection = $(this).closest('.js-form-group').find('.js-hreflang-setting');
const index = $collection.data('index');

const prototype = $collection.data('prototype');
Expand Down
11 changes: 4 additions & 7 deletions assets/js/admin/components/MailWhitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import Register from '../../common/utils/Register';
import { addNewItemToCollection, removeItemFromCollection } from '../validation/customization/customizeCollectionBundle';

export default class MailWhitelist {
static init () {
const $mailWhitelistItemAdd = $('.js-mail-whitelist-item-add');
const $mailWhitelist = $('.js-mail-whitelist');

$mailWhitelistItemAdd.off('click');
$mailWhitelist.off('click', '.js-mail-whitelist-item-remove');
static init ($container) {
const $mailWhitelistItemAdd = $container.filterAllNodes('.js-mail-whitelist-item-add');
const $mailWhitelist = $container.filterAllNodes('.js-mail-whitelist');

$mailWhitelist.on('click', '.js-mail-whitelist-item-remove', function (event) {
const $collection = $(this).closest('.js-mail-whitelist');
Expand All @@ -22,7 +19,7 @@ export default class MailWhitelist {
});

$mailWhitelistItemAdd.on('click', function () {
const $collection = $('.js-mail-whitelist');
const $collection = $(this).closest('.js-form-group').find('.js-mail-whitelist');
const index = $collection.data('index');

const prototype = $collection.data('prototype');
Expand Down
9 changes: 3 additions & 6 deletions assets/js/admin/components/OpeningHoursCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import Register from '../../common/utils/Register';
import { addNewItemToCollection, removeItemFromCollection } from '../validation/customization/customizeCollectionBundle';

export default class OpeningHoursCollection {
static init () {
const $openingHoursItemAdd = $('.js-opening-hours-item-add');
const $openingHoursCollection = $('.js-opening-hours');

$openingHoursItemAdd.off('click');
$openingHoursCollection.off('click', '.js-opening-hours-item-remove');
static init ($container) {
const $openingHoursItemAdd = $container.filterAllNodes('.js-opening-hours-item-add');
const $openingHoursCollection = $container.filterAllNodes('.js-opening-hours');

$openingHoursCollection.on('click', '.js-opening-hours-item-remove', function (event) {
const $item = $(this).closest('.js-opening-hours-item');
Expand Down
16 changes: 7 additions & 9 deletions assets/js/admin/components/OrderItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import Window from '../utils/Window';

export default class OrderItems {

constructor () {
$('#js-order-items').off('click', '.js-order-item-remove');
$('#js-order-item-add').off('click');
constructor ($container) {
const $collection = $container.filterAllNodes('#js-order-items');
$collection.on('click', '.js-order-item-remove', (event) => this.onRemoveItemClick(event));
$container.filterAllNodes('#js-order-item-add').on('click', (event) => this.onAddItemClick(event));

$('#js-order-items').on('click', '.js-order-item-remove', (event) => this.onRemoveItemClick(event));
$('#js-order-item-add').on('click', (event) => this.onAddItemClick(event));

this.refreshCount($('#js-order-items'));
this.refreshCount($collection);

const _this = this;
// eslint-disable-next-line no-new
new ProductPicker($('#js-order-item-add-product'), (productId, productName) => {
new ProductPicker($container.filterAllNodes('#js-order-item-add-product'), (productId, productName) => {
_this.addProduct(productId, productName);
});
}
Expand Down Expand Up @@ -157,7 +155,7 @@ export default class OrderItems {

static init ($container) {
// eslint-disable-next-line no-new
new OrderItems();
new OrderItems($container);

$container.filterAllNodes('.js-order-item-any').each(function () {
const $orderItem = $(this);
Expand Down
14 changes: 6 additions & 8 deletions assets/js/admin/components/Parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { addNewItemToCollection, removeItemFromCollection } from '../validation/

export default class Parameters {

static init () {
static init ($container) {
const $collection = $container.filterAllNodes('.js-parameters');

$('.js-parameters-item-add').off('click');
$('.js-parameters').off('click', '.js-parameters-item-remove');

$('.js-parameters').on('click', '.js-parameters-item-remove', function (event) {
$collection.on('click', '.js-parameters-item-remove', function (event) {
const $collection = $(this).closest('.js-parameters');

const $item = $(this).closest('.js-parameters-item');
Expand All @@ -20,8 +18,8 @@ export default class Parameters {
event.preventDefault();
});

$('.js-parameters-item-add').on('click', function () {
const $collection = $('.js-parameters');
$container.filterAllNodes('.js-parameters-item-add').on('click', function () {
const $collection = $(this).closest('.js-form-group').find('.js-parameters');
const index = $collection.data('index');

const prototype = $collection.data('prototype');
Expand All @@ -42,7 +40,7 @@ export default class Parameters {
return false;
});

Parameters.refreshCount($('.js-parameters'));
Parameters.refreshCount($collection);
}

static refreshCount ($collection) {
Expand Down
11 changes: 4 additions & 7 deletions assets/js/admin/components/PromoCodeFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import Register from '../../common/utils/Register';
import { addNewItemToCollection, removeItemFromCollection } from '../validation/customization/customizeCollectionBundle';

export default class PromoCodeFlags {
static init () {
const $flagsItemAdd = $('.js-flags-item-add');
const $flags = $('.js-flags');

$flagsItemAdd.off('click');
$flags.off('click', '.js-flags-item-remove');
static init ($container) {
const $flagsItemAdd = $container.filterAllNodes('.js-flags-item-add');
const $flags = $container.filterAllNodes('.js-flags');

$flags.on('click', '.js-flags-item-remove', function (event) {
const $collection = $(this).closest('.js-flags');
Expand All @@ -22,7 +19,7 @@ export default class PromoCodeFlags {
});

$flagsItemAdd.on('click', function () {
const $collection = $('.js-flags');
const $collection = $(this).closest('.js-form-group').find('.js-flags');
const index = $collection.data('index');

const prototype = $collection.data('prototype');
Expand Down
13 changes: 6 additions & 7 deletions assets/js/admin/components/PromoCodeLimits.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { addNewItemToCollection, removeItemFromCollection } from '../validation/

export default class PromoCodeLimits {

static init () {
$('.js-limits-item-add').off('click');
$('.js-limits').off('click', '.js-limits-item-remove');
static init ($container) {
const $collection = $container.filterAllNodes('.js-limits');

$('.js-limits').on('click', '.js-limits-item-remove', function (event) {
$collection.on('click', '.js-limits-item-remove', function (event) {
const $collection = $(this).closest('.js-limits');

const $item = $(this).closest('.js-limits-item');
Expand All @@ -19,8 +18,8 @@ export default class PromoCodeLimits {
event.preventDefault();
});

$('.js-limits-item-add').on('click', function () {
const $collection = $('.js-limits');
$container.filterAllNodes('.js-limits-item-add').on('click', function () {
const $collection = $(this).closest('.js-form-group').find('.js-limits');
const index = $collection.data('index');

const prototype = $collection.data('prototype');
Expand All @@ -41,7 +40,7 @@ export default class PromoCodeLimits {
return false;
});

PromoCodeLimits.refreshCount($('.js-limits'));
PromoCodeLimits.refreshCount($collection);
}

static refreshCount ($collection) {
Expand Down

0 comments on commit 7cf5aa6

Please sign in to comment.