@myparcel-dev/pdk-admin 1.14.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/package.json +6 -6
- package/src/__tests__/__snapshots__/exports.spec.ts.snap +8 -1
- package/src/__tests__/doComponentTestTeardown.ts +2 -0
- package/src/__tests__/mocks/index.ts +1 -1
- package/src/__tests__/mocks/mockDefaultAccount.ts +1 -0
- package/src/__tests__/mocks/mockDefaultGlobalContext.ts +2 -2
- package/src/__tests__/mocks/{mockDefaultPlatform.ts → mockDefaultProposition.ts} +1 -3
- package/src/__tests__/mocks/mockDefaultShop.ts +1 -0
- package/src/__tests__/utils/getActionIds.ts +12 -0
- package/src/__tests__/utils/mockOrderData.ts +20 -0
- package/src/actions/composables/mutations/orders/useExportOrdersMutation.ts +1 -1
- package/src/actions/composables/queries/account/useOrderCapabilitiesQuery.ts +67 -0
- package/src/actions/composables/queries/account/useShipmentCapabilitiesQuery.ts +96 -0
- package/src/actions/definitions/orders.ts +6 -8
- package/src/actions/index.ts +1 -0
- package/src/actions/orderModeActions.spec.ts +150 -0
- package/src/actions/orderModeActions.ts +90 -0
- package/src/components/OrderBox/ShipmentOptionsBox.spec.ts +109 -0
- package/src/components/OrderBox/ShipmentOptionsBox.vue +9 -25
- package/src/components/OrderListItem/OrderModeOrderListItem.spec.ts +125 -0
- package/src/components/OrderListItem/OrderModeOrderListItem.vue +10 -6
- package/src/components/PluginSettings/PluginSettingsForms.vue +7 -4
- package/src/components/common/DeliveryOptionsExcerptCarrierName.vue +3 -3
- package/src/components/modals/ShipmentOptionsModal.spec.ts +79 -0
- package/src/components/modals/ShipmentOptionsModal.vue +4 -21
- package/src/composables/components/useToggleInputContext.ts +2 -2
- package/src/composables/components/useTriStateInputContext.ts +2 -2
- package/src/composables/context/index.ts +1 -0
- package/src/composables/context/useOrderMode.spec.ts +75 -0
- package/src/composables/context/useOrderMode.ts +26 -0
- package/src/composables/language/useLanguage.spec.ts +2 -2
- package/src/composables/shipments/useShipmentData.ts +2 -2
- package/src/data/index.ts +1 -0
- package/src/data/orderMode.spec.ts +22 -0
- package/src/data/orderMode.ts +50 -0
- package/src/forms/form-builder/builders/buildAfterUpdate.spec.ts +5 -8
- package/src/forms/form-builder/operations/executeOperations.spec.ts +4 -7
- package/src/forms/form-builder/operations/executeSetPropOperation.spec.ts +4 -7
- package/src/forms/form-builder/operations/executeSetValueOperation.spec.ts +3 -2
- package/src/forms/form-builder/utils/createValueSetter.ts +21 -8
- package/src/forms/helpers/addCapabilitiesClearNotification.ts +39 -0
- package/src/forms/helpers/getDeliveryTypes.ts +5 -10
- package/src/forms/helpers/getFieldLabel.ts +7 -2
- package/src/forms/helpers/getPackageTypes.ts +7 -12
- package/src/forms/helpers/index.ts +3 -10
- package/src/forms/helpers/useFormCapabilities.spec.ts +227 -0
- package/src/forms/helpers/useFormCapabilities.ts +176 -0
- package/src/forms/pluginSettings/createPluginSettingsForm.ts +2 -2
- package/src/forms/pluginSettings/filterPluginSettingsView.spec.ts +158 -0
- package/src/forms/pluginSettings/filterPluginSettingsView.ts +96 -0
- package/src/forms/pluginSettings/index.ts +1 -0
- package/src/forms/pluginSettings/resolveSettingsValues.spec.ts +62 -0
- package/src/forms/pluginSettings/resolveSettingsValues.ts +16 -0
- package/src/forms/shipmentOptions/createShipmentOptionsForm.spec.ts +108 -0
- package/src/forms/shipmentOptions/createShipmentOptionsForm.ts +114 -52
- package/src/forms/shipmentOptions/field.ts +6 -66
- package/src/forms/shipmentOptions/fieldFactoryRegistry.ts +26 -0
- package/src/forms/shipmentOptions/fields/createCarrierField.ts +119 -30
- package/src/forms/shipmentOptions/fields/createDigitalStampRangeField.ts +3 -3
- package/src/forms/shipmentOptions/fields/createInsuranceField.ts +43 -22
- package/src/forms/shipmentOptions/fields/createPackageTypeField.ts +1 -2
- package/src/forms/shipmentOptions/fields/createShipmentOptionField.spec.ts +177 -0
- package/src/forms/shipmentOptions/fields/createShipmentOptionField.ts +90 -8
- package/src/forms/shipmentOptions/fields/index.ts +0 -9
- package/src/forms/shipmentOptions/useCapabilitiesAutoClear.spec.ts +347 -0
- package/src/forms/shipmentOptions/useCapabilitiesAutoClear.ts +452 -0
- package/src/forms/shipmentOptions/useCapabilitiesWatcher.spec.ts +14 -0
- package/src/forms/shipmentOptions/useCapabilitiesWatcher.ts +29 -0
- package/src/forms/shipmentOptions/wireProxyCapabilities.spec.ts +160 -0
- package/src/forms/shipmentOptions/wireProxyCapabilities.ts +102 -0
- package/src/index.ts +2 -0
- package/src/pdk/instance/plugins/createRegisterComponentsPlugin.ts +2 -0
- package/src/sdk/composables/api/useFetchCarrier.ts +39 -4
- package/src/sdk/composables/usePdkAdminApi.ts +8 -3
- package/src/stores/useActionStore.spec.ts +101 -0
- package/src/stores/useActionStore.ts +4 -28
- package/src/stores/useQueryStore.ts +15 -0
- package/src/types/actions/endpoints.types.ts +2 -1
- package/src/types/sdk.types.ts +54 -1
- package/src/utils/forms/formToBody.ts +2 -1
- package/src/utils/forms/getEnabledValues.spec.ts +66 -0
- package/src/utils/forms/getEnabledValues.ts +25 -0
- package/src/utils/forms/index.ts +1 -0
- package/src/utils/translations/getDynamicTranslation.ts +1 -1
- package/src/views/OrderBox.vue +11 -5
- package/src/views/OrderListItem.spec.ts +71 -0
- package/src/views/OrderListItem.vue +6 -7
- package/src/forms/helpers/createHasShipmentOptionWatcher.ts +0 -12
- package/src/forms/helpers/getCarrier.ts +0 -11
- package/src/forms/helpers/getInsuranceOptions.ts +0 -23
- package/src/forms/helpers/hasPostNlAgeCheck.ts +0 -11
- package/src/forms/helpers/hasShipmentOption.ts +0 -8
- package/src/forms/helpers/isPackageTypeMailbox.ts +0 -7
- package/src/forms/helpers/isPackageTypePackage.ts +0 -7
- package/src/forms/helpers/isPackageTypePackageOrSmall.ts +0 -7
- package/src/forms/helpers/isPackageTypeSmallPackage.ts +0 -7
- package/src/forms/helpers/setPostNlAgeCheckSubtext.ts +0 -17
- package/src/forms/shipmentOptions/fields/createAgeCheckField.ts +0 -33
- package/src/forms/shipmentOptions/fields/createDirectReturnField.ts +0 -8
- package/src/forms/shipmentOptions/fields/createHideSenderField.ts +0 -8
- package/src/forms/shipmentOptions/fields/createLargeFormatField.ts +0 -8
- package/src/forms/shipmentOptions/fields/createOnlyRecipientField.ts +0 -21
- package/src/forms/shipmentOptions/fields/createPriorityDeliveryField.ts +0 -12
- package/src/forms/shipmentOptions/fields/createReceiptCodeField.ts +0 -21
- package/src/forms/shipmentOptions/fields/createSameDayDeliveryField.ts +0 -8
- package/src/forms/shipmentOptions/fields/createSignatureField.ts +0 -11
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import {computed, reactive, ref} from 'vue';
|
|
4
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
5
|
+
import {config, mount} from '@vue/test-utils';
|
|
6
|
+
import {OrderMode} from '../data';
|
|
7
|
+
import {useOrderMode} from '../composables/context/useOrderMode';
|
|
8
|
+
import {doComponentTestSetup, doComponentTestTeardown} from '../__tests__';
|
|
9
|
+
import OrderListItem from './OrderListItem.vue';
|
|
10
|
+
|
|
11
|
+
vi.mock('../composables/context/useOrderMode', () => ({
|
|
12
|
+
useOrderMode: vi.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock('../composables/orders/useOrderData', () => ({
|
|
16
|
+
useOrderData: vi.fn(() => ({
|
|
17
|
+
order: computed(() => ({externalIdentifier: 'TEST-1'})),
|
|
18
|
+
query: reactive({data: ref({externalIdentifier: 'TEST-1'}), isLoading: false}),
|
|
19
|
+
})),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock('../stores', async (importOriginal) => ({
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
24
|
+
...(await importOriginal<typeof import('../stores')>()),
|
|
25
|
+
useActionStore: vi.fn(() => ({
|
|
26
|
+
registerOrderActions: vi.fn(),
|
|
27
|
+
})),
|
|
28
|
+
useQueryStore: vi.fn(() => ({
|
|
29
|
+
registerContextQueries: vi.fn(),
|
|
30
|
+
registerOrderQueries: vi.fn(),
|
|
31
|
+
})),
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
const mockedUseOrderMode = vi.mocked(useOrderMode);
|
|
35
|
+
|
|
36
|
+
describe('OrderListItem component selection', () => {
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
doComponentTestSetup();
|
|
39
|
+
|
|
40
|
+
config.global.stubs.OrderModeOrderListItem = true;
|
|
41
|
+
config.global.stubs.ShipmentModeOrderListItem = true;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
doComponentTestTeardown();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it.each([
|
|
49
|
+
[OrderMode.OrderV2, 'order-mode-order-list-item-stub'],
|
|
50
|
+
[OrderMode.OrderV1, 'order-mode-order-list-item-stub'],
|
|
51
|
+
[OrderMode.Shipments, 'shipment-mode-order-list-item-stub'],
|
|
52
|
+
] as const)('renders the correct component for %s mode', (mode, expectedStubTag) => {
|
|
53
|
+
mockedUseOrderMode.mockReturnValue(computed(() => mode));
|
|
54
|
+
const wrapper = mount(OrderListItem);
|
|
55
|
+
|
|
56
|
+
expect(wrapper.find(expectedStubTag).exists()).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('has a component for every OrderMode value', () => {
|
|
60
|
+
const allModes = Object.values(OrderMode);
|
|
61
|
+
|
|
62
|
+
for (const mode of allModes) {
|
|
63
|
+
mockedUseOrderMode.mockReturnValue(computed(() => mode));
|
|
64
|
+
const wrapper = mount(OrderListItem);
|
|
65
|
+
const div = wrapper.find('div');
|
|
66
|
+
|
|
67
|
+
expect(div.exists(), `Expected a rendered component for ${mode} mode`).toBe(true);
|
|
68
|
+
expect(div.element.children.length, `Expected a child component for ${mode} mode`).toBeGreaterThan(0);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-if="!query.isLoading">
|
|
3
|
-
<OrderModeOrderListItem
|
|
3
|
+
<OrderModeOrderListItem
|
|
4
|
+
v-if="orderMode === OrderMode.OrderV1 || orderMode === OrderMode.OrderV2" />
|
|
4
5
|
|
|
5
|
-
<ShipmentModeOrderListItem v-else />
|
|
6
|
+
<ShipmentModeOrderListItem v-else-if="orderMode === OrderMode.Shipments" />
|
|
6
7
|
</div>
|
|
7
8
|
|
|
8
9
|
<NotificationContainer
|
|
@@ -17,8 +18,8 @@
|
|
|
17
18
|
import {defineAsyncComponent, toValue} from 'vue';
|
|
18
19
|
import {type NotificationFilter} from '../types';
|
|
19
20
|
import {useActionStore, useQueryStore} from '../stores';
|
|
20
|
-
import {NotificationCategory} from '../data';
|
|
21
|
-
import {useOrderData,
|
|
21
|
+
import {NotificationCategory, OrderMode} from '../data';
|
|
22
|
+
import {useOrderData, useOrderMode} from '../composables';
|
|
22
23
|
import {NotificationContainer} from '../components';
|
|
23
24
|
|
|
24
25
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
@@ -40,9 +41,7 @@ const actionStore = useActionStore();
|
|
|
40
41
|
|
|
41
42
|
actionStore.registerOrderActions();
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const {orderMode} = pluginSettings.order;
|
|
44
|
+
const orderMode = useOrderMode();
|
|
46
45
|
|
|
47
46
|
const {query} = useOrderData();
|
|
48
47
|
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Shipment } from '@myparcel-dev/pdk-common';
|
|
2
|
-
import { type InteractiveElementInstance, type FormInstance } from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import { isPackageTypePackage } from './isPackageTypePackage';
|
|
4
|
-
import { hasShipmentOption } from './hasShipmentOption';
|
|
5
|
-
|
|
6
|
-
export const createHasShipmentOptionWatcher = (
|
|
7
|
-
shipmentOption: keyof Shipment.ModelShipmentOptions,
|
|
8
|
-
invert = false,
|
|
9
|
-
validator: (form: FormInstance) => boolean = isPackageTypePackage,
|
|
10
|
-
): ((field: InteractiveElementInstance) => boolean) => {
|
|
11
|
-
return ({ form }) => (validator(form) && hasShipmentOption(form, shipmentOption)) !== invert;
|
|
12
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {AdminContextKey, type Carrier} from '@myparcel-dev/pdk-common';
|
|
2
|
-
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import {FIELD_CARRIER} from '../shipmentOptions';
|
|
4
|
-
import {useContext} from '../../composables';
|
|
5
|
-
|
|
6
|
-
export const getCarrier = (form: FormInstance): Carrier.ModelCarrier | undefined => {
|
|
7
|
-
const dynamicContext = useContext(AdminContextKey.Dynamic);
|
|
8
|
-
const chosenCarrier = form.getValue(FIELD_CARRIER);
|
|
9
|
-
|
|
10
|
-
return dynamicContext.carriers.find((carrier) => carrier.externalIdentifier === chosenCarrier);
|
|
11
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {TriState} from '@myparcel-dev/pdk-common';
|
|
2
|
-
import {type ElementInstance, type SelectOption} from '../../types';
|
|
3
|
-
import {Format, type Formatter} from '../../composables';
|
|
4
|
-
import {getCarrier} from './getCarrier';
|
|
5
|
-
|
|
6
|
-
export const getInsuranceOptions = (field: ElementInstance, formatter: Formatter): SelectOption[] => {
|
|
7
|
-
const carrier = getCarrier(field.form);
|
|
8
|
-
|
|
9
|
-
const insurancePossibilities = carrier?.capabilities.shipmentOptions.insurance ?? [];
|
|
10
|
-
|
|
11
|
-
const carrierPossibilities = insurancePossibilities.map((amount) => ({
|
|
12
|
-
plainLabel: formatter.format(Format.Currency, amount / 100),
|
|
13
|
-
value: amount.toString(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
label: 'option_default',
|
|
19
|
-
value: TriState.Inherit,
|
|
20
|
-
},
|
|
21
|
-
...carrierPossibilities,
|
|
22
|
-
];
|
|
23
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {CarrierName} from '@myparcel-dev/constants';
|
|
3
|
-
import {FIELD_AGE_CHECK} from '../shipmentOptions';
|
|
4
|
-
import {triStateFieldIsEnabled} from './triStateFieldIsEnabled';
|
|
5
|
-
import {getFormCarrierName} from './getFormCarrierName';
|
|
6
|
-
|
|
7
|
-
export const hasPostNlAgeCheck = (form: FormInstance): boolean => {
|
|
8
|
-
const carrier = getFormCarrierName(form);
|
|
9
|
-
|
|
10
|
-
return CarrierName.PostNl === carrier && triStateFieldIsEnabled(form, FIELD_AGE_CHECK);
|
|
11
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Shipment } from '@myparcel-dev/pdk-common';
|
|
2
|
-
import { type FormInstance } from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import { getCarrier } from './getCarrier';
|
|
4
|
-
|
|
5
|
-
export const hasShipmentOption = (form: FormInstance, option: keyof Shipment.ModelShipmentOptions): boolean => {
|
|
6
|
-
const carrier = getCarrier(form);
|
|
7
|
-
return Boolean(carrier?.capabilities.shipmentOptions[option]);
|
|
8
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {PackageTypeName} from '@myparcel-dev/constants';
|
|
3
|
-
import {FIELD_PACKAGE_TYPE} from '../shipmentOptions';
|
|
4
|
-
|
|
5
|
-
export const isPackageTypeMailbox = (form: FormInstance): boolean => {
|
|
6
|
-
return PackageTypeName.Mailbox === form.getValue(FIELD_PACKAGE_TYPE);
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type FormInstance } from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import { PackageTypeName } from '@myparcel-dev/constants';
|
|
3
|
-
import { FIELD_PACKAGE_TYPE } from '../shipmentOptions';
|
|
4
|
-
|
|
5
|
-
export const isPackageTypePackage = (form: FormInstance): boolean => {
|
|
6
|
-
return PackageTypeName.Package === form.getValue(FIELD_PACKAGE_TYPE);
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {isPackageTypeSmallPackage} from './isPackageTypeSmallPackage';
|
|
3
|
-
import {isPackageTypePackage} from './isPackageTypePackage';
|
|
4
|
-
|
|
5
|
-
export const isPackageTypePackageOrSmall = (form: FormInstance): boolean => {
|
|
6
|
-
return isPackageTypePackage(form) || isPackageTypeSmallPackage(form);
|
|
7
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {PackageTypeName} from '@myparcel-dev/constants';
|
|
3
|
-
import {FIELD_PACKAGE_TYPE} from '../shipmentOptions';
|
|
4
|
-
|
|
5
|
-
export const isPackageTypeSmallPackage = (form: FormInstance): boolean => {
|
|
6
|
-
return PackageTypeName.PackageSmall === form.getValue(FIELD_PACKAGE_TYPE);
|
|
7
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementInstance} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {CarrierName} from '@myparcel-dev/constants';
|
|
3
|
-
import {AGE_CHECK, FIELD_AGE_CHECK, KEY_SUBTEXT} from '../shipmentOptions';
|
|
4
|
-
import {setFieldProp} from './setFieldProp';
|
|
5
|
-
import {hasPostNlAgeCheck} from './hasPostNlAgeCheck';
|
|
6
|
-
import {getFieldLabel} from './getFieldLabel';
|
|
7
|
-
import {createLabel} from './createLabel';
|
|
8
|
-
|
|
9
|
-
export const setPostNlAgeCheckSubtext = ({form}: InteractiveElementInstance): void => {
|
|
10
|
-
const defaultKey = createLabel(getFieldLabel(AGE_CHECK), KEY_SUBTEXT);
|
|
11
|
-
|
|
12
|
-
if (hasPostNlAgeCheck(form)) {
|
|
13
|
-
setFieldProp(form, FIELD_AGE_CHECK, KEY_SUBTEXT, `${defaultKey}_${CarrierName.PostNl}`);
|
|
14
|
-
} else {
|
|
15
|
-
setFieldProp(form, FIELD_AGE_CHECK, KEY_SUBTEXT, defaultKey);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {TriState} from '@myparcel-dev/pdk-common';
|
|
2
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import {type PromiseOr} from '@myparcel-dev/ts-utils';
|
|
4
|
-
import {CarrierName} from '@myparcel-dev/constants';
|
|
5
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
6
|
-
import {FIELD_AGE_CHECK, FIELD_ONLY_RECIPIENT, FIELD_SIGNATURE} from '../field';
|
|
7
|
-
import {getFormCarrierName, setPostNlAgeCheckSubtext, triStateFieldIsEnabled} from '../../helpers';
|
|
8
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
9
|
-
|
|
10
|
-
export const createAgeCheckField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
11
|
-
return createShipmentOptionField(refs, FIELD_AGE_CHECK, {
|
|
12
|
-
afterUpdate(field): PromiseOr<void> {
|
|
13
|
-
const {form} = field;
|
|
14
|
-
|
|
15
|
-
setPostNlAgeCheckSubtext(field);
|
|
16
|
-
|
|
17
|
-
if (!triStateFieldIsEnabled(field.form, FIELD_AGE_CHECK)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
switch (getFormCarrierName(form)) {
|
|
22
|
-
case CarrierName.PostNl:
|
|
23
|
-
form.setValue(FIELD_SIGNATURE, TriState.On);
|
|
24
|
-
form.setValue(FIELD_ONLY_RECIPIENT, TriState.On);
|
|
25
|
-
break;
|
|
26
|
-
|
|
27
|
-
case CarrierName.DhlForYou:
|
|
28
|
-
form.setValue(FIELD_SIGNATURE, TriState.Off);
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_DIRECT_RETURN} from '../field';
|
|
4
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
5
|
-
|
|
6
|
-
export const createDirectReturnField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
7
|
-
return createShipmentOptionField(refs, FIELD_DIRECT_RETURN);
|
|
8
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_HIDE_SENDER} from '../field';
|
|
4
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
5
|
-
|
|
6
|
-
export const createHideSenderField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
7
|
-
return createShipmentOptionField(refs, FIELD_HIDE_SENDER);
|
|
8
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_LARGE_FORMAT} from '../field';
|
|
4
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
5
|
-
|
|
6
|
-
export const createLargeFormatField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
7
|
-
return createShipmentOptionField(refs, FIELD_LARGE_FORMAT);
|
|
8
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {TriState} from '@myparcel-dev/pdk-common';
|
|
2
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import {CarrierName} from '@myparcel-dev/constants';
|
|
4
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
5
|
-
import {FIELD_AGE_CHECK, FIELD_ONLY_RECIPIENT} from '../field';
|
|
6
|
-
import {getFormCarrierName, hasPostNlAgeCheck} from '../../helpers';
|
|
7
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
8
|
-
|
|
9
|
-
export const createOnlyRecipientField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
10
|
-
return createShipmentOptionField(refs, FIELD_ONLY_RECIPIENT, {
|
|
11
|
-
readOnlyWhen: ({form}) => hasPostNlAgeCheck(form),
|
|
12
|
-
|
|
13
|
-
afterUpdate({form}, value) {
|
|
14
|
-
if (!(CarrierName.DhlForYou === getFormCarrierName(form) && TriState.On === value)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
form.setValue(FIELD_AGE_CHECK, TriState.Off);
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_PRIORITY_DELIVERY, PRIORITY_DELIVERY} from '../field';
|
|
4
|
-
import {createHasShipmentOptionWatcher, isPackageTypeMailbox} from '../../helpers';
|
|
5
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
6
|
-
|
|
7
|
-
export const createPriorityDeliveryField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
8
|
-
return createShipmentOptionField(refs, FIELD_PRIORITY_DELIVERY, {
|
|
9
|
-
visibleWhen: createHasShipmentOptionWatcher(PRIORITY_DELIVERY, false, isPackageTypeMailbox),
|
|
10
|
-
disabledWhen: createHasShipmentOptionWatcher(PRIORITY_DELIVERY, true, isPackageTypeMailbox),
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {TriState} from '@myparcel-dev/pdk-common';
|
|
2
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
3
|
-
import {CarrierName} from '@myparcel-dev/constants';
|
|
4
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
5
|
-
import {FIELD_AGE_CHECK, FIELD_RECEIPT_CODE} from '../field';
|
|
6
|
-
import {getFormCarrierName, hasPostNlAgeCheck} from '../../helpers';
|
|
7
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
8
|
-
|
|
9
|
-
export const createReceiptCodeField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
10
|
-
return createShipmentOptionField(refs, FIELD_RECEIPT_CODE, {
|
|
11
|
-
readOnlyWhen: ({form}) => hasPostNlAgeCheck(form),
|
|
12
|
-
|
|
13
|
-
afterUpdate({form}, value) {
|
|
14
|
-
if (!(CarrierName.DhlForYou === getFormCarrierName(form) && TriState.On === value)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
form.setValue(FIELD_AGE_CHECK, TriState.Off);
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_SAME_DAY_DELIVERY} from '../field';
|
|
4
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
5
|
-
|
|
6
|
-
export const createSameDayDeliveryField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
7
|
-
return createShipmentOptionField(refs, FIELD_SAME_DAY_DELIVERY);
|
|
8
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
-
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
-
import {FIELD_SIGNATURE} from '../field';
|
|
4
|
-
import {hasPostNlAgeCheck} from '../../helpers';
|
|
5
|
-
import {createShipmentOptionField} from './createShipmentOptionField';
|
|
6
|
-
|
|
7
|
-
export const createSignatureField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => {
|
|
8
|
-
return createShipmentOptionField(refs, FIELD_SIGNATURE, {
|
|
9
|
-
readOnlyWhen: ({form}) => hasPostNlAgeCheck(form),
|
|
10
|
-
});
|
|
11
|
-
};
|