Skip to content

Commit e9587c5

Browse files
remove constant.js
1 parent 75dbeeb commit e9587c5

16 files changed

+50
-90
lines changed

assets/js/admin/components/AdvancedSearch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'select2/dist/js/select2.full';
22
import Ajax from '../../common/utils/Ajax';
33
import Register from '../../common/utils/Register';
4-
import constant from '../utils/constant';
54

65
export default class AdvancedSearch {
76

@@ -71,7 +70,7 @@ export default class AdvancedSearch {
7170
}
7271

7372
static updateValueByOperator ($rulesContainer, $rule, operator) {
74-
$rule.find('.js-advanced-search-rule-value').toggle(operator !== constant('\\Shopsys\\FrameworkBundle\\Model\\AdvancedSearch\\AdvancedSearchFilterInterface::OPERATOR_NOT_SET'));
73+
$rule.find('.js-advanced-search-rule-value').toggle(operator !== 'notSet');
7574
}
7675

7776
static init ($container) {

assets/js/admin/components/MassActionConfirm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import constant from '../utils/constant';
21
import Window from '../utils/Window';
32
import Register from '../../common/utils/Register';
43
import Translator from 'bazinga-translator';
@@ -16,10 +15,10 @@ export default class MassActionConfirm {
1615
const selectType = $('.js-mass-action-select-type').val();
1716
let count;
1817
switch (selectType) {
19-
case constant('\\Shopsys\\FrameworkBundle\\Model\\Product\\MassAction\\ProductMassActionData::SELECT_TYPE_CHECKED'):
18+
case 'selectTypeChecked':
2019
count = $('.js-grid-mass-action-select-row:checked').length;
2120
break;
22-
case constant('\\Shopsys\\FrameworkBundle\\Model\\Product\\MassAction\\ProductMassActionData::SELECT_TYPE_ALL_RESULTS'):
21+
case 'selectTypeAllResults':
2322
count = $('.js-grid').data('total-count');
2423
break;
2524
}

assets/js/admin/components/OrderItems.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Register from '../../common/utils/Register';
33
import { addNewItemToCollection, removeItemFromCollection } from '../validation/customization/customizeCollectionBundle';
44
import ProductPicker from './ProductPicker';
55
import { escapeHtml } from '../../common/utils/escapeHtml';
6-
import constant from '../utils/constant';
76
import '../../common/bootstrap/tooltip';
87
import Translator from 'bazinga-translator';
98
import Window from '../utils/Window';
@@ -134,18 +133,19 @@ export default class OrderItems {
134133

135134
getNewIndex ($collection) {
136135
let maxIndex = 0;
136+
const newItemIndex = 'new_';
137137

138138
$collection.find('.js-order-item').each(function () {
139139
const indexStr = $(this).data('index').toString();
140-
if (indexStr.indexOf(constant('\\Shopsys\\FrameworkBundle\\Model\\Order\\OrderData::NEW_ITEM_PREFIX')) === 0) {
140+
if (indexStr.indexOf(newItemIndex) === 0) {
141141
const index = parseInt(indexStr.slice(4));
142142
if (index > maxIndex) {
143143
maxIndex = index;
144144
}
145145
}
146146
});
147147

148-
return constant('\\Shopsys\\FrameworkBundle\\Model\\Order\\OrderData::NEW_ITEM_PREFIX') + (maxIndex + 1);
148+
return newItemIndex + (maxIndex + 1);
149149
}
150150

151151
static onPriceCalculationChange ($orderItem) {

assets/js/admin/components/Product.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import constant from '../utils/constant';
21
import Register from '../../common/utils/Register';
32

43
export default class Product {
@@ -10,12 +9,13 @@ export default class Product {
109
Product.toggleIsUsingStock($(this).val() === '1');
1110
});
1211

12+
const alternateAvailability = 'setAlternateAvailability';
1313
$outOfStockActionSelection.change(function () {
14-
Product.toggleIsUsingAlternateAvailability($(this).val() === constant('\\Shopsys\\FrameworkBundle\\Model\\Product\\Product::OUT_OF_STOCK_ACTION_SET_ALTERNATE_AVAILABILITY'));
14+
Product.toggleIsUsingAlternateAvailability($(this).val() === alternateAvailability);
1515
});
1616

1717
Product.toggleIsUsingStock(usingStockSelection.filter(':checked').val() === '1');
18-
Product.toggleIsUsingAlternateAvailability($outOfStockActionSelection.val() === constant('\\Shopsys\\FrameworkBundle\\Model\\Product\\Product::OUT_OF_STOCK_ACTION_SET_ALTERNATE_AVAILABILITY'));
18+
Product.toggleIsUsingAlternateAvailability($outOfStockActionSelection.val() === alternateAvailability);
1919

2020
Product.initializeSideNavigation($container);
2121
}

assets/js/admin/utils/constant.js

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const VALIDATION_GROUP_DEFAULT = 'Default';

assets/js/admin/validation/form/validationAdvert.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Script is named "noticer.js" because scripts named "advert.js" are often blocked by browser (e.g. by AdBlock plugin)
22

3-
import constant from '../../utils/constant';
43
import Register from '../../../common/utils/Register';
4+
import { VALIDATION_GROUP_DEFAULT } from './validation';
55

66
export default function validationAdvert () {
77
const $advertForm = $('form[name="advert_form"]');
@@ -36,13 +36,13 @@ export default function validationAdvert () {
3636

3737
$advertForm.jsFormValidator({
3838
'groups': function () {
39-
const groups = [constant('\\Shopsys\\FrameworkBundle\\Form\\ValidationGroup::VALIDATION_GROUP_DEFAULT')];
39+
const groups = [VALIDATION_GROUP_DEFAULT];
4040

4141
const checkedType = getCheckedType();
42-
if (checkedType === constant('\\Shopsys\\FrameworkBundle\\Model\\Advert\\Advert::TYPE_CODE')) {
43-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\Advert\\AdvertFormType::VALIDATION_GROUP_TYPE_CODE'));
44-
} else if (checkedType === constant('\\Shopsys\\FrameworkBundle\\Model\\Advert\\Advert::TYPE_IMAGE')) {
45-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\Advert\\AdvertFormType::VALIDATION_GROUP_TYPE_IMAGE'));
42+
if (checkedType === 'code') {
43+
groups.push('typeCode');
44+
} else if (checkedType === 'image') {
45+
groups.push('typeImage');
4646
}
4747

4848
return groups;

assets/js/admin/validation/form/validationCustomer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import constant from '../../utils/constant';
21
import Register from '../../../common/utils/Register';
2+
import { VALIDATION_GROUP_DEFAULT } from './validation';
33

44
export default function validationCustomer () {
55
const $customerDeliveryAddressForm = $('#customer_form_deliveryAddressData');
66
$customerDeliveryAddressForm.jsFormValidator({
77
'groups': function () {
8-
const groups = [constant('\\Shopsys\\FrameworkBundle\\Form\\ValidationGroup::VALIDATION_GROUP_DEFAULT')];
8+
const groups = [VALIDATION_GROUP_DEFAULT];
99
if ($customerDeliveryAddressForm.find('#customer_form_deliveryAddressData_deliveryAddress_addressFilled').is(':checked')) {
10-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\Customer\\DeliveryAddressFormType::VALIDATION_GROUP_DIFFERENT_DELIVERY_ADDRESS'));
10+
groups.push('differentDeliveryAddress');
1111
}
1212

1313
return groups;
@@ -17,9 +17,9 @@ export default function validationCustomer () {
1717
$customerBillingAddressForm.jsFormValidator({
1818
'groups': function () {
1919

20-
var groups = [constant('\\Shopsys\\FrameworkBundle\\Form\\ValidationGroup::VALIDATION_GROUP_DEFAULT')];
20+
var groups = [VALIDATION_GROUP_DEFAULT];
2121
if ($customerBillingAddressForm.find('#customer_form_billingAddressData_companyData_companyCustomer').is(':checked')) {
22-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\Customer\\BillingAddressFormType::VALIDATION_GROUP_COMPANY_CUSTOMER'));
22+
groups.push('companyCustomer');
2323
}
2424

2525
return groups;

assets/js/admin/validation/form/validationFreTransportAndPayment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import constant from '../../utils/constant';
21
import Register from '../../../common/utils/Register';
2+
import { VALIDATION_GROUP_DEFAULT } from './validation';
33

44
export default function validationFreeTransportAndPayment () {
55
$('.js-free-transport-and-payment-price-limit').each(function () {
66
const $priceLimitForm = $(this);
77
$priceLimitForm.jsFormValidator({
88
'groups': function () {
99

10-
const groups = [constant('\\Shopsys\\FrameworkBundle\\Form\\ValidationGroup::VALIDATION_GROUP_DEFAULT')];
10+
const groups = [VALIDATION_GROUP_DEFAULT];
1111
if ($priceLimitForm.find('.js-free-transport-and-payment-price-limit-enabled').is(':checked')) {
12-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\TransportAndPayment\\FreeTransportAndPaymentPriceLimitsFormType::VALIDATION_GROUP_PRICE_LIMIT_ENABLED'));
12+
groups.push('priceLimitEnabled');
1313
}
1414

1515
return groups;

assets/js/admin/validation/form/validationMailTemplate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import constant from '../../utils/constant';
21
import Register from '../../../common/utils/Register';
2+
import { VALIDATION_GROUP_DEFAULT } from './validation';
33

44
export default function validationMailTemplate () {
55
$('#js-mail-templates').find('.js-mail-template').each(function () {
@@ -9,9 +9,9 @@ export default function validationMailTemplate () {
99
$(this).jsFormValidator({
1010
'groups': function () {
1111

12-
const groups = [constant('\\Shopsys\\FrameworkBundle\\Form\\ValidationGroup::VALIDATION_GROUP_DEFAULT')];
12+
const groups = [VALIDATION_GROUP_DEFAULT];
1313
if ($(self).find('#' + sendMailId).is(':checked')) {
14-
groups.push(constant('\\Shopsys\\FrameworkBundle\\Form\\Admin\\Mail\\MailTemplateFormType::VALIDATION_GROUP_SEND_MAIL'));
14+
groups.push('sendMail');
1515
}
1616

1717
return groups;

0 commit comments

Comments
 (0)