@vendure/admin-ui 1.7.4 → 1.8.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.
Files changed (228) hide show
  1. package/bundles/vendure-admin-ui-catalog.umd.js +902 -74
  2. package/bundles/vendure-admin-ui-catalog.umd.js.map +1 -1
  3. package/bundles/vendure-admin-ui-core.umd.js +2392 -820
  4. package/bundles/vendure-admin-ui-core.umd.js.map +1 -1
  5. package/bundles/vendure-admin-ui-customer.umd.js +4 -3
  6. package/bundles/vendure-admin-ui-customer.umd.js.map +1 -1
  7. package/bundles/vendure-admin-ui-dashboard.umd.js +3 -1
  8. package/bundles/vendure-admin-ui-dashboard.umd.js.map +1 -1
  9. package/bundles/vendure-admin-ui-order.umd.js +781 -175
  10. package/bundles/vendure-admin-ui-order.umd.js.map +1 -1
  11. package/bundles/vendure-admin-ui-settings.umd.js +5 -4
  12. package/bundles/vendure-admin-ui-settings.umd.js.map +1 -1
  13. package/bundles/vendure-admin-ui-system.umd.js +1 -1
  14. package/catalog/catalog.module.d.ts +3 -0
  15. package/catalog/components/assign-to-channel-dialog/assign-to-channel-dialog.component.d.ts +17 -0
  16. package/catalog/components/bulk-add-facet-values-dialog/bulk-add-facet-values-dialog.component.d.ts +38 -0
  17. package/catalog/components/bulk-add-facet-values-dialog/bulk-add-facet-values-dialog.graphql.d.ts +4 -0
  18. package/catalog/components/collection-list/collection-list-bulk-actions.d.ts +6 -0
  19. package/catalog/components/collection-list/collection-list.component.d.ts +7 -5
  20. package/catalog/components/collection-tree/collection-tree-node.component.d.ts +8 -4
  21. package/catalog/components/collection-tree/collection-tree.component.d.ts +2 -1
  22. package/catalog/components/facet-list/facet-list-bulk-actions.d.ts +5 -0
  23. package/catalog/components/facet-list/facet-list.component.d.ts +2 -1
  24. package/catalog/components/product-list/product-list-bulk-actions.d.ts +6 -0
  25. package/catalog/components/product-list/product-list.component.d.ts +2 -1
  26. package/catalog/public_api.d.ts +6 -0
  27. package/catalog/vendure-admin-ui-catalog.metadata.json +1 -1
  28. package/core/common/component-registry-types.d.ts +1 -1
  29. package/core/common/generated-types.d.ts +609 -3
  30. package/core/common/utilities/bulk-action-utils.d.ts +19 -0
  31. package/core/common/utilities/selection-manager.d.ts +7 -0
  32. package/core/common/version.d.ts +1 -1
  33. package/core/data/definitions/collection-definitions.d.ts +3 -0
  34. package/core/data/definitions/facet-definitions.d.ts +3 -0
  35. package/core/data/definitions/order-definitions.d.ts +12 -0
  36. package/core/data/definitions/product-definitions.d.ts +1 -0
  37. package/core/data/providers/collection-data.service.d.ts +4 -1
  38. package/core/data/providers/facet-data.service.d.ts +4 -1
  39. package/core/data/providers/order-data.service.d.ts +18 -1
  40. package/core/data/providers/product-data.service.d.ts +1 -0
  41. package/core/providers/bulk-action-registry/bulk-action-registry.service.d.ts +6 -0
  42. package/core/providers/bulk-action-registry/bulk-action-types.d.ts +149 -0
  43. package/core/providers/bulk-action-registry/register-bulk-action.d.ts +53 -0
  44. package/core/providers/modal/modal.service.d.ts +2 -0
  45. package/core/providers/nav-builder/nav-builder-types.d.ts +1 -0
  46. package/core/public_api.d.ts +18 -1
  47. package/core/shared/components/asset-gallery/asset-gallery.component.d.ts +3 -3
  48. package/core/shared/components/bulk-action-menu/bulk-action-menu.component.d.ts +29 -0
  49. package/core/shared/components/data-table/data-table.component.d.ts +26 -7
  50. package/core/shared/components/dropdown/dropdown-menu.component.d.ts +1 -0
  51. package/core/shared/components/radio-card/radio-card-fieldset.component.d.ts +21 -0
  52. package/core/shared/components/radio-card/radio-card.component.d.ts +19 -0
  53. package/core/shared/components/rich-text-editor/prosemirror/context-menu/context-menu.component.d.ts +28 -0
  54. package/core/shared/components/rich-text-editor/prosemirror/context-menu/context-menu.service.d.ts +31 -0
  55. package/core/shared/components/rich-text-editor/prosemirror/custom-nodes.d.ts +4 -0
  56. package/core/shared/components/rich-text-editor/prosemirror/inputrules.d.ts +5 -5
  57. package/core/shared/components/rich-text-editor/prosemirror/menu/links.d.ts +1 -1
  58. package/core/shared/components/rich-text-editor/prosemirror/menu/menu-common.d.ts +12 -0
  59. package/core/shared/components/rich-text-editor/prosemirror/menu/menu-plugin.d.ts +9 -0
  60. package/core/shared/components/rich-text-editor/prosemirror/menu/sub-menu-with-icon.d.ts +14 -0
  61. package/core/shared/components/rich-text-editor/prosemirror/plugins/image-plugin.d.ts +7 -0
  62. package/core/shared/components/rich-text-editor/prosemirror/plugins/link-select-plugin.d.ts +1 -1
  63. package/core/shared/components/rich-text-editor/prosemirror/plugins/raw-editor-plugin.d.ts +7 -0
  64. package/core/shared/components/rich-text-editor/prosemirror/plugins/tables-plugin.d.ts +13 -0
  65. package/core/shared/components/rich-text-editor/prosemirror/prosemirror.service.d.ts +7 -3
  66. package/core/shared/components/rich-text-editor/prosemirror/types.d.ts +0 -2
  67. package/core/shared/components/rich-text-editor/raw-html-dialog/raw-html-dialog.component.d.ts +18 -0
  68. package/core/shared/components/rich-text-editor/rich-text-editor.component.d.ts +6 -2
  69. package/core/shared/dynamic-form-inputs/code-editor-form-input/base-code-editor-form-input.component.d.ts +27 -0
  70. package/core/shared/dynamic-form-inputs/code-editor-form-input/html-editor-form-input.component.d.ts +19 -0
  71. package/core/shared/dynamic-form-inputs/code-editor-form-input/json-editor-form-input.component.d.ts +5 -17
  72. package/core/shared/dynamic-form-inputs/register-dynamic-input-components.d.ts +2 -1
  73. package/core/vendure-admin-ui-core.metadata.json +1 -1
  74. package/customer/components/customer-group-member-list/customer-group-member-list.component.d.ts +11 -4
  75. package/customer/vendure-admin-ui-customer.metadata.json +1 -1
  76. package/esm2015/catalog/catalog.module.js +25 -2
  77. package/esm2015/catalog/components/assign-products-to-channel-dialog/assign-products-to-channel-dialog.component.js +4 -1
  78. package/esm2015/catalog/components/assign-to-channel-dialog/assign-to-channel-dialog.component.js +51 -0
  79. package/esm2015/catalog/components/bulk-add-facet-values-dialog/bulk-add-facet-values-dialog.component.js +89 -0
  80. package/esm2015/catalog/components/bulk-add-facet-values-dialog/bulk-add-facet-values-dialog.graphql.js +69 -0
  81. package/esm2015/catalog/components/collection-detail/collection-detail.component.js +3 -3
  82. package/esm2015/catalog/components/collection-list/collection-list-bulk-actions.js +147 -0
  83. package/esm2015/catalog/components/collection-list/collection-list.component.js +17 -8
  84. package/esm2015/catalog/components/collection-tree/collection-tree-node.component.js +16 -7
  85. package/esm2015/catalog/components/collection-tree/collection-tree.component.js +3 -2
  86. package/esm2015/catalog/components/facet-list/facet-list-bulk-actions.js +208 -0
  87. package/esm2015/catalog/components/facet-list/facet-list.component.js +13 -4
  88. package/esm2015/catalog/components/product-detail/product-detail.component.js +35 -23
  89. package/esm2015/catalog/components/product-list/product-list-bulk-actions.js +173 -0
  90. package/esm2015/catalog/components/product-list/product-list.component.js +10 -5
  91. package/esm2015/catalog/components/product-variants-list/product-variants-list.component.js +2 -2
  92. package/esm2015/catalog/providers/routing/collection-resolver.js +2 -1
  93. package/esm2015/catalog/public_api.js +7 -1
  94. package/esm2015/core/common/component-registry-types.js +1 -1
  95. package/esm2015/core/common/generated-types.js +5 -1
  96. package/esm2015/core/common/introspection-result.js +296 -191
  97. package/esm2015/core/common/utilities/bulk-action-utils.js +44 -0
  98. package/esm2015/core/common/utilities/selection-manager.js +33 -1
  99. package/esm2015/core/common/version.js +2 -2
  100. package/esm2015/core/components/breadcrumb/breadcrumb.component.js +1 -1
  101. package/esm2015/core/data/definitions/collection-definitions.js +30 -1
  102. package/esm2015/core/data/definitions/facet-definitions.js +31 -1
  103. package/esm2015/core/data/definitions/order-definitions.js +114 -1
  104. package/esm2015/core/data/definitions/product-definitions.js +15 -1
  105. package/esm2015/core/data/providers/collection-data.service.js +17 -2
  106. package/esm2015/core/data/providers/customer-data.service.js +8 -4
  107. package/esm2015/core/data/providers/facet-data.service.js +18 -2
  108. package/esm2015/core/data/providers/order-data.service.js +38 -2
  109. package/esm2015/core/data/providers/product-data.service.js +7 -2
  110. package/esm2015/core/data/utils/remove-readonly-custom-fields.js +5 -1
  111. package/esm2015/core/providers/bulk-action-registry/bulk-action-registry.service.js +27 -0
  112. package/esm2015/core/providers/bulk-action-registry/bulk-action-types.js +2 -0
  113. package/esm2015/core/providers/bulk-action-registry/register-bulk-action.js +63 -0
  114. package/esm2015/core/providers/dashboard-widget/dashboard-widget.service.js +1 -4
  115. package/esm2015/core/providers/modal/modal.service.js +2 -1
  116. package/esm2015/core/providers/nav-builder/nav-builder-types.js +1 -1
  117. package/esm2015/core/public_api.js +19 -2
  118. package/esm2015/core/shared/components/action-bar/action-bar.component.js +4 -8
  119. package/esm2015/core/shared/components/asset-gallery/asset-gallery.component.js +2 -2
  120. package/esm2015/core/shared/components/bulk-action-menu/bulk-action-menu.component.js +99 -0
  121. package/esm2015/core/shared/components/data-table/data-table.component.js +64 -15
  122. package/esm2015/core/shared/components/dropdown/dropdown-menu.component.js +4 -3
  123. package/esm2015/core/shared/components/facet-value-selector/facet-value-selector.component.js +2 -2
  124. package/esm2015/core/shared/components/language-selector/language-selector.component.js +2 -2
  125. package/esm2015/core/shared/components/order-state-label/order-state-label.component.js +2 -1
  126. package/esm2015/core/shared/components/product-search-input/product-search-input.component.js +1 -1
  127. package/esm2015/core/shared/components/product-selector/product-selector.component.js +1 -1
  128. package/esm2015/core/shared/components/radio-card/radio-card-fieldset.component.js +57 -0
  129. package/esm2015/core/shared/components/radio-card/radio-card.component.js +54 -0
  130. package/esm2015/core/shared/components/rich-text-editor/external-image-dialog/external-image-dialog.component.js +2 -2
  131. package/esm2015/core/shared/components/rich-text-editor/prosemirror/context-menu/context-menu.component.js +140 -0
  132. package/esm2015/core/shared/components/rich-text-editor/prosemirror/context-menu/context-menu.service.js +45 -0
  133. package/esm2015/core/shared/components/rich-text-editor/prosemirror/custom-nodes.js +60 -0
  134. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/links.js +4 -4
  135. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/menu-common.js +23 -1
  136. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/menu-plugin.js +12 -0
  137. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/menu.js +73 -18
  138. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/sub-menu-with-icon.js +16 -0
  139. package/esm2015/core/shared/components/rich-text-editor/prosemirror/plugins/image-plugin.js +100 -0
  140. package/esm2015/core/shared/components/rich-text-editor/prosemirror/plugins/raw-editor-plugin.js +97 -0
  141. package/esm2015/core/shared/components/rich-text-editor/prosemirror/plugins/tables-plugin.js +166 -0
  142. package/esm2015/core/shared/components/rich-text-editor/prosemirror/prosemirror.service.js +47 -17
  143. package/esm2015/core/shared/components/rich-text-editor/prosemirror/types.js +1 -1
  144. package/esm2015/core/shared/components/rich-text-editor/raw-html-dialog/raw-html-dialog.component.js +57 -0
  145. package/esm2015/core/shared/components/rich-text-editor/rich-text-editor.component.js +20 -9
  146. package/esm2015/core/shared/components/simple-dialog/simple-dialog.component.js +2 -2
  147. package/esm2015/core/shared/dynamic-form-inputs/code-editor-form-input/base-code-editor-form-input.component.js +59 -0
  148. package/esm2015/core/shared/dynamic-form-inputs/code-editor-form-input/html-editor-form-input.component.js +66 -0
  149. package/esm2015/core/shared/dynamic-form-inputs/code-editor-form-input/json-editor-form-input.component.js +47 -84
  150. package/esm2015/core/shared/dynamic-form-inputs/dynamic-form-input/dynamic-form-input.component.js +3 -3
  151. package/esm2015/core/shared/dynamic-form-inputs/register-dynamic-input-components.js +3 -1
  152. package/esm2015/core/shared/pipes/state-i18n-token.pipe.js +2 -1
  153. package/esm2015/core/shared/shared.module.js +13 -1
  154. package/esm2015/customer/components/customer-group-list/customer-group-list.component.js +2 -2
  155. package/esm2015/customer/components/customer-group-member-list/customer-group-member-list.component.js +6 -6
  156. package/esm2015/customer/components/customer-list/customer-list.component.js +2 -2
  157. package/esm2015/dashboard/dashboard.module.js +6 -2
  158. package/esm2015/order/components/coupon-code-selector/coupon-code-selector.component.js +42 -0
  159. package/esm2015/order/components/draft-order-detail/draft-order-detail.component.js +195 -0
  160. package/esm2015/order/components/draft-order-variant-selector/draft-order-variant-selector.component.js +59 -0
  161. package/esm2015/order/components/order-detail/order-detail.component.js +2 -2
  162. package/esm2015/order/components/order-editor/order-editor.component.js +5 -11
  163. package/esm2015/order/components/order-list/order-list.component.js +20 -4
  164. package/esm2015/order/components/order-table/order-table.component.js +16 -5
  165. package/esm2015/order/components/select-address-dialog/select-address-dialog.component.js +91 -0
  166. package/esm2015/order/components/select-address-dialog/select-address-dialog.graphql.js +14 -0
  167. package/esm2015/order/components/select-customer-dialog/select-customer-dialog.component.js +59 -0
  168. package/esm2015/order/components/select-shipping-method-dialog/select-shipping-method-dialog.component.js +30 -0
  169. package/esm2015/order/order.module.js +13 -1
  170. package/esm2015/order/order.routes.js +26 -7
  171. package/esm2015/order/providers/routing/order-resolver.js +29 -12
  172. package/esm2015/order/providers/routing/order.guard.js +41 -0
  173. package/esm2015/order/public_api.js +9 -1
  174. package/esm2015/settings/components/country-list/country-list.component.js +2 -2
  175. package/esm2015/settings/components/profile/profile.component.js +2 -2
  176. package/esm2015/settings/components/zone-list/zone-list.component.js +2 -2
  177. package/esm2015/settings/components/zone-member-list/zone-member-list.component.js +2 -2
  178. package/esm2015/system/components/health-check/health-check.component.js +1 -1
  179. package/fesm2015/vendure-admin-ui-catalog.js +835 -61
  180. package/fesm2015/vendure-admin-ui-catalog.js.map +1 -1
  181. package/fesm2015/vendure-admin-ui-core.js +3122 -1514
  182. package/fesm2015/vendure-admin-ui-core.js.map +1 -1
  183. package/fesm2015/vendure-admin-ui-customer.js +7 -7
  184. package/fesm2015/vendure-admin-ui-customer.js.map +1 -1
  185. package/fesm2015/vendure-admin-ui-dashboard.js +5 -1
  186. package/fesm2015/vendure-admin-ui-dashboard.js.map +1 -1
  187. package/fesm2015/vendure-admin-ui-order.js +780 -232
  188. package/fesm2015/vendure-admin-ui-order.js.map +1 -1
  189. package/fesm2015/vendure-admin-ui-settings.js +4 -4
  190. package/fesm2015/vendure-admin-ui-settings.js.map +1 -1
  191. package/fesm2015/vendure-admin-ui-system.js +1 -1
  192. package/order/components/coupon-code-selector/coupon-code-selector.component.d.ts +18 -0
  193. package/order/components/draft-order-detail/draft-order-detail.component.d.ts +49 -0
  194. package/order/components/draft-order-variant-selector/draft-order-variant-selector.component.d.ts +21 -0
  195. package/order/components/order-editor/order-editor.component.d.ts +1 -6
  196. package/order/components/order-list/order-list.component.d.ts +1 -0
  197. package/order/components/order-table/order-table.component.d.ts +11 -2
  198. package/order/components/select-address-dialog/select-address-dialog.component.d.ts +24 -0
  199. package/order/components/select-address-dialog/select-address-dialog.graphql.d.ts +1 -0
  200. package/order/components/select-customer-dialog/select-customer-dialog.component.d.ts +22 -0
  201. package/order/components/select-shipping-method-dialog/select-shipping-method-dialog.component.d.ts +16 -0
  202. package/order/providers/routing/order-resolver.d.ts +8 -5
  203. package/order/providers/routing/order.guard.d.ts +9 -0
  204. package/order/public_api.d.ts +8 -0
  205. package/order/vendure-admin-ui-order.metadata.json +1 -1
  206. package/package.json +13 -12
  207. package/settings/components/zone-member-list/zone-member-list.component.d.ts +3 -1
  208. package/settings/vendure-admin-ui-settings.metadata.json +1 -1
  209. package/static/i18n-messages/cs.json +33 -0
  210. package/static/i18n-messages/de.json +33 -0
  211. package/static/i18n-messages/en.json +36 -4
  212. package/static/i18n-messages/es.json +33 -0
  213. package/static/i18n-messages/fr.json +33 -0
  214. package/static/i18n-messages/it.json +33 -0
  215. package/static/i18n-messages/pl.json +33 -0
  216. package/static/i18n-messages/pt_BR.json +33 -0
  217. package/static/i18n-messages/pt_PT.json +33 -0
  218. package/static/i18n-messages/ru.json +33 -0
  219. package/static/i18n-messages/uk.json +33 -0
  220. package/static/i18n-messages/zh_Hans.json +33 -0
  221. package/static/i18n-messages/zh_Hant.json +33 -0
  222. package/static/styles/global/_forms.scss +4 -2
  223. package/static/styles/global/_overrides.scss +1 -1
  224. package/static/styles/global/_utilities.scss +4 -0
  225. package/static/theme.min.css +1 -1
  226. package/system/vendure-admin-ui-system.metadata.json +1 -1
  227. package/core/shared/components/rich-text-editor/prosemirror/menu/images.d.ts +0 -4
  228. package/esm2015/core/shared/components/rich-text-editor/prosemirror/menu/images.js +0 -36
@@ -1,14 +1,16 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, ChangeDetectionStrategy, ChangeDetectorRef, EventEmitter, Input, Output, Injectable, ElementRef, ViewChildren, HostBinding, NgModule } from '@angular/core';
2
+ import { Component, ChangeDetectionStrategy, EventEmitter, Input, Output, Injectable, ChangeDetectorRef, ElementRef, ViewChildren, HostBinding, NgModule } from '@angular/core';
3
3
  import { FormGroup, FormControl, Validators, FormBuilder, FormArray } from '@angular/forms';
4
4
  import * as i1 from '@vendure/admin-ui/core';
5
- import { DataService, getAppConfig, I18nService, configurableDefinitionToInstance, GlobalFlag, configurableOperationValueIsValid, toConfigurableOperationInput, ServerConfigService, ModalService, HistoryEntryType, SortOrder, NotificationService, BaseDetailComponent, EditNoteDialogComponent, transformRelationCustomFieldInputs, BaseListComponent, LogicalOperator, LocalStorageService, AdjustmentType, BaseEntityResolver, createResolveData, CanDeactivateDetailGuard, detailBreadcrumb, SharedModule } from '@vendure/admin-ui/core';
5
+ import { DataService, getAppConfig, I18nService, HistoryEntryType, SortOrder, ModalService, NotificationService, ADDRESS_FRAGMENT, BaseDetailComponent, DeletionResult, ServerConfigService, configurableDefinitionToInstance, GlobalFlag, configurableOperationValueIsValid, toConfigurableOperationInput, EditNoteDialogComponent, transformRelationCustomFieldInputs, BaseListComponent, LogicalOperator, LocalStorageService, AdjustmentType, CanDeactivateDetailGuard, detailBreadcrumb, SharedModule } from '@vendure/admin-ui/core';
6
6
  import { marker } from '@biesbjerg/ngx-translate-extract-marker';
7
- import { isObject, summate, assertNever, notNullOrUndefined } from '@vendure/common/lib/shared-utils';
7
+ import { Subject, concat, EMPTY, of, combineLatest, merge, BehaviorSubject } from 'rxjs';
8
+ import { distinctUntilChanged, switchMap, map, startWith, catchError, retryWhen, delay, take, tap, debounceTime, mapTo, takeUntil, shareReplay, filter } from 'rxjs/operators';
8
9
  import * as i1$1 from '@angular/router';
9
- import { Router, ActivatedRoute, RouterModule } from '@angular/router';
10
- import { EMPTY, Subject, of, concat, merge, BehaviorSubject } from 'rxjs';
11
- import { switchMap, catchError, retryWhen, delay, take, map, startWith, mapTo, takeUntil, distinctUntilChanged, shareReplay, filter, debounceTime, tap } from 'rxjs/operators';
10
+ import { Router, ActivatedRoute, ActivationStart, RouterModule } from '@angular/router';
11
+ import { pick } from '@vendure/common/lib/pick';
12
+ import { gql } from 'apollo-angular';
13
+ import { isObject, summate, assertNever, notNullOrUndefined } from '@vendure/common/lib/shared-utils';
12
14
  import { simpleDeepClone } from '@vendure/common/lib/simple-deep-clone';
13
15
 
14
16
  class AddManualPaymentDialogComponent {
@@ -47,84 +49,670 @@ AddManualPaymentDialogComponent.ctorParameters = () => [
47
49
  { type: DataService }
48
50
  ];
49
51
 
50
- class CancelOrderDialogComponent {
51
- constructor(i18nService) {
52
- var _a;
53
- this.i18nService = i18nService;
54
- this.cancelAll = true;
55
- this.lineQuantities = {};
56
- this.reasons = (_a = getAppConfig().cancellationReasons) !== null && _a !== void 0 ? _a : [
57
- marker('order.cancel-reason-customer-request'),
58
- marker('order.cancel-reason-not-available'),
59
- ];
60
- this.reasons = this.reasons.map(r => this.i18nService.translate(r));
61
- }
62
- get selectionCount() {
63
- return Object.values(this.lineQuantities).reduce((sum, n) => sum + n, 0);
52
+ class CancelOrderDialogComponent {
53
+ constructor(i18nService) {
54
+ var _a;
55
+ this.i18nService = i18nService;
56
+ this.cancelAll = true;
57
+ this.lineQuantities = {};
58
+ this.reasons = (_a = getAppConfig().cancellationReasons) !== null && _a !== void 0 ? _a : [
59
+ marker('order.cancel-reason-customer-request'),
60
+ marker('order.cancel-reason-not-available'),
61
+ ];
62
+ this.reasons = this.reasons.map(r => this.i18nService.translate(r));
63
+ }
64
+ get selectionCount() {
65
+ return Object.values(this.lineQuantities).reduce((sum, n) => sum + n, 0);
66
+ }
67
+ ngOnInit() {
68
+ this.lineQuantities = this.order.lines.reduce((result, line) => {
69
+ return Object.assign(Object.assign({}, result), { [line.id]: line.quantity });
70
+ }, {});
71
+ }
72
+ radioChanged() {
73
+ if (this.cancelAll) {
74
+ for (const line of this.order.lines) {
75
+ this.lineQuantities[line.id] = line.quantity;
76
+ }
77
+ }
78
+ else {
79
+ for (const line of this.order.lines) {
80
+ this.lineQuantities[line.id] = 0;
81
+ }
82
+ }
83
+ }
84
+ checkIfAllSelected() {
85
+ var _a;
86
+ for (const [lineId, quantity] of Object.entries(this.lineQuantities)) {
87
+ const quantityInOrder = (_a = this.order.lines.find(line => line.id === lineId)) === null || _a === void 0 ? void 0 : _a.quantity;
88
+ if (quantityInOrder && quantity < quantityInOrder) {
89
+ return;
90
+ }
91
+ }
92
+ // If we got here, all of the selected quantities are equal to the order
93
+ // line quantities, i.e. everything is selected.
94
+ this.cancelAll = true;
95
+ }
96
+ select() {
97
+ this.resolveWith({
98
+ orderId: this.order.id,
99
+ lines: this.getLineInputs(),
100
+ reason: this.reason,
101
+ cancelShipping: this.cancelAll,
102
+ });
103
+ }
104
+ cancel() {
105
+ this.resolveWith();
106
+ }
107
+ getLineInputs() {
108
+ if (this.order.active) {
109
+ return;
110
+ }
111
+ return Object.entries(this.lineQuantities)
112
+ .map(([orderLineId, quantity]) => ({
113
+ orderLineId,
114
+ quantity,
115
+ }))
116
+ .filter(l => 0 < l.quantity);
117
+ }
118
+ }
119
+ CancelOrderDialogComponent.decorators = [
120
+ { type: Component, args: [{
121
+ selector: 'vdr-cancel-order-dialog',
122
+ template: "<ng-template vdrDialogTitle>{{ 'order.cancel-order' | translate }}</ng-template>\r\n\r\n<div class=\"fulfillment-wrapper\">\r\n <div class=\"order-lines\">\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.cancel' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tr\r\n *ngFor=\"let line of order.lines\"\r\n class=\"order-line\"\r\n [class.is-disabled]=\"cancelAll\"\r\n [class.is-cancelled]=\"line.quantity === 0\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle quantity\">{{ line.quantity }}</td>\r\n <td class=\"align-middle quantity\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n </td>\r\n <td class=\"align-middle fulfil\">\r\n <input\r\n *ngIf=\"line.quantity > 0 && !order.active; else nonEditable\"\r\n [(ngModel)]=\"lineQuantities[line.id]\"\r\n (input)=\"checkIfAllSelected()\"\r\n [disabled]=\"cancelAll\"\r\n type=\"number\"\r\n [max]=\"line.quantity\"\r\n min=\"0\"\r\n />\r\n <ng-template #nonEditable>{{ line.quantity }}</ng-template>\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n <div class=\"cancellation-details\">\r\n <ng-container *ngIf=\"order.active !== true\">\r\n <clr-radio-wrapper>\r\n <input\r\n type=\"radio\"\r\n clrRadio\r\n [value]=\"true\"\r\n [(ngModel)]=\"cancelAll\"\r\n name=\"options\"\r\n (ngModelChange)=\"radioChanged()\"\r\n />\r\n <label>{{ 'order.cancel-entire-order' | translate }}</label>\r\n </clr-radio-wrapper>\r\n <clr-radio-wrapper>\r\n <input\r\n type=\"radio\"\r\n clrRadio\r\n [value]=\"false\"\r\n [(ngModel)]=\"cancelAll\"\r\n name=\"options\"\r\n (ngModelChange)=\"radioChanged()\"\r\n />\r\n <label>{{ 'order.cancel-specified-items' | translate }}</label>\r\n </clr-radio-wrapper>\r\n </ng-container>\r\n <label class=\"clr-control-label\">{{ 'order.cancellation-reason' | translate }}</label>\r\n <ng-select\r\n [items]=\"reasons\"\r\n bindLabel=\"name\"\r\n autofocus\r\n bindValue=\"id\"\r\n [addTag]=\"true\"\r\n [(ngModel)]=\"reason\"\r\n ></ng-select>\r\n </div>\r\n</div>\r\n\r\n<ng-template vdrDialogButtons>\r\n <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n <button\r\n type=\"submit\"\r\n (click)=\"select()\"\r\n [disabled]=\"!reason || (!order.active && selectionCount === 0)\"\r\n class=\"btn btn-primary\"\r\n >\r\n <ng-container *ngIf=\"!order.active\">\r\n {{ 'order.cancel-selected-items' | translate }}\r\n </ng-container>\r\n <ng-container *ngIf=\"order.active\">\r\n {{ 'order.cancel-order' | translate }}\r\n </ng-container>\r\n </button>\r\n</ng-template>\r\n",
123
+ changeDetection: ChangeDetectionStrategy.OnPush,
124
+ styles: [":host{height:100%;display:flex;min-height:64vh}.fulfillment-wrapper{flex:1}@media screen and (min-width: 768px){.fulfillment-wrapper{display:flex;flex-direction:row}}@media screen and (min-width: 768px){.fulfillment-wrapper .cancellation-details{margin-top:0;margin-left:24px;width:250px}}.fulfillment-wrapper .order-lines{flex:1;overflow-y:auto}.fulfillment-wrapper .order-lines table{margin-top:0}.fulfillment-wrapper tr.ignore{color:var(--color-grey-300)}.fulfillment-wrapper .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.fulfillment-wrapper .is-disabled td,.fulfillment-wrapper .is-disabled td input{background-color:var(--color-component-bg-200)}\n"]
125
+ },] }
126
+ ];
127
+ CancelOrderDialogComponent.ctorParameters = () => [
128
+ { type: I18nService }
129
+ ];
130
+
131
+ class CouponCodeSelectorComponent {
132
+ constructor(dataService) {
133
+ this.dataService = dataService;
134
+ this.addCouponCode = new EventEmitter();
135
+ this.removeCouponCode = new EventEmitter();
136
+ this.couponCodeInput$ = new Subject();
137
+ }
138
+ ngOnInit() {
139
+ var _a;
140
+ this.availableCouponCodes$ = concat(this.couponCodeInput$.pipe(distinctUntilChanged(), switchMap(term => this.dataService.promotion.getPromotions(10, 0, {
141
+ couponCode: { contains: term },
142
+ }).single$), map(({ promotions }) =>
143
+ // tslint:disable-next-line:no-non-null-assertion
144
+ promotions.items.map(p => ({ code: p.couponCode, promotionName: p.name }))), startWith([])));
145
+ if (!this.control) {
146
+ this.control = new FormControl((_a = this.couponCodes) !== null && _a !== void 0 ? _a : []);
147
+ }
148
+ }
149
+ }
150
+ CouponCodeSelectorComponent.decorators = [
151
+ { type: Component, args: [{
152
+ selector: 'vdr-coupon-code-selector',
153
+ template: "<ng-select\r\n [items]=\"availableCouponCodes$ | async\"\r\n appendTo=\"body\"\r\n bindLabel=\"code\"\r\n bindValue=\"code\"\r\n [addTag]=\"false\"\r\n [multiple]=\"true\"\r\n [hideSelected]=\"true\"\r\n [minTermLength]=\"2\"\r\n typeToSearchText=\"\"\r\n [typeahead]=\"couponCodeInput$\"\r\n [formControl]=\"control\"\r\n (add)=\"addCouponCode.emit($event.code)\"\r\n (remove)=\"removeCouponCode.emit($event.value?.code)\"\r\n>\r\n <ng-template ng-option-tmp let-item=\"item\">\r\n <vdr-chip>{{ item.code }}</vdr-chip>\r\n {{ item.promotionName }}\r\n </ng-template>\r\n</ng-select>\r\n",
154
+ changeDetection: ChangeDetectionStrategy.OnPush,
155
+ styles: [""]
156
+ },] }
157
+ ];
158
+ CouponCodeSelectorComponent.ctorParameters = () => [
159
+ { type: DataService }
160
+ ];
161
+ CouponCodeSelectorComponent.propDecorators = {
162
+ couponCodes: [{ type: Input }],
163
+ control: [{ type: Input }],
164
+ addCouponCode: [{ type: Output }],
165
+ removeCouponCode: [{ type: Output }]
166
+ };
167
+
168
+ class OrderStateSelectDialogComponent {
169
+ constructor() {
170
+ this.nextStates = [];
171
+ this.message = '';
172
+ this.selectedState = '';
173
+ }
174
+ select() {
175
+ if (this.selectedState) {
176
+ this.resolveWith(this.selectedState);
177
+ }
178
+ }
179
+ cancel() {
180
+ this.resolveWith();
181
+ }
182
+ }
183
+ OrderStateSelectDialogComponent.decorators = [
184
+ { type: Component, args: [{
185
+ selector: 'vdr-order-state-select-dialog',
186
+ template: "<ng-template vdrDialogTitle>{{ 'order.select-state' | translate }}</ng-template>\r\n<p>{{ message | translate }}</p>\r\n<clr-select-container>\r\n <select clrSelect name=\"state\" [(ngModel)]=\"selectedState\">\r\n <option *ngFor=\"let state of nextStates\" [value]=\"state\">\r\n {{ state | stateI18nToken | translate }}\r\n </option>\r\n </select>\r\n</clr-select-container>\r\n<ng-template vdrDialogButtons>\r\n <button type=\"submit\" *ngIf=\"cancellable\" (click)=\"cancel()\" class=\"btn btn-secondary\">\r\n {{ 'common.cancel' | translate }}\r\n </button>\r\n <button type=\"submit\" (click)=\"select()\" class=\"btn btn-primary\" [disabled]=\"!selectedState\">\r\n {{ 'order.transition-to-state' | translate: { state: (selectedState | stateI18nToken | translate) } }}\r\n </button>\r\n</ng-template>\r\n",
187
+ changeDetection: ChangeDetectionStrategy.OnPush,
188
+ styles: [""]
189
+ },] }
190
+ ];
191
+
192
+ class OrderTransitionService {
193
+ constructor(dataService, modalService, notificationService, i18nService) {
194
+ this.dataService = dataService;
195
+ this.modalService = modalService;
196
+ this.notificationService = notificationService;
197
+ this.i18nService = i18nService;
198
+ }
199
+ /**
200
+ * Attempts to transition the Order to the last state it was in before it was transitioned
201
+ * to the "Modifying" state. If this fails, a manual prompt is used.
202
+ */
203
+ transitionToPreModifyingState(orderId, nextStates) {
204
+ return this.getPreModifyingState(orderId).pipe(switchMap(state => {
205
+ const manualTransitionOptions = {
206
+ orderId,
207
+ nextStates,
208
+ message: this.i18nService.translate(marker('order.unable-to-transition-to-state-try-another'), { state }),
209
+ cancellable: false,
210
+ retry: 10,
211
+ };
212
+ if (state) {
213
+ return this.transitionToStateOrThrow(orderId, state).pipe(catchError(err => this.manuallyTransitionToState(manualTransitionOptions)));
214
+ }
215
+ else {
216
+ return this.manuallyTransitionToState(manualTransitionOptions);
217
+ }
218
+ }));
219
+ }
220
+ /**
221
+ * Displays a modal for manually selecting the next state.
222
+ */
223
+ manuallyTransitionToState(options) {
224
+ return this.modalService
225
+ .fromComponent(OrderStateSelectDialogComponent, {
226
+ locals: {
227
+ nextStates: options.nextStates,
228
+ cancellable: options.cancellable,
229
+ message: options.message,
230
+ },
231
+ closable: false,
232
+ size: 'md',
233
+ })
234
+ .pipe(switchMap(result => {
235
+ if (result) {
236
+ return this.transitionToStateOrThrow(options.orderId, result);
237
+ }
238
+ else {
239
+ if (!options.cancellable) {
240
+ throw new Error(`An order state must be selected`);
241
+ }
242
+ else {
243
+ return EMPTY;
244
+ }
245
+ }
246
+ }), retryWhen(errors => errors.pipe(delay(2000), take(options.retry))));
247
+ }
248
+ /**
249
+ * Attempts to get the last state the Order was in before it was transitioned
250
+ * to the "Modifying" state.
251
+ */
252
+ getPreModifyingState(orderId) {
253
+ return this.dataService.order
254
+ .getOrderHistory(orderId, {
255
+ filter: {
256
+ type: {
257
+ eq: HistoryEntryType.ORDER_STATE_TRANSITION,
258
+ },
259
+ },
260
+ sort: {
261
+ createdAt: SortOrder.DESC,
262
+ },
263
+ })
264
+ .mapSingle(result => result.order)
265
+ .pipe(map(result => {
266
+ const item = result === null || result === void 0 ? void 0 : result.history.items.find(i => i.data.to === 'Modifying');
267
+ if (item) {
268
+ return item.data.from;
269
+ }
270
+ else {
271
+ return;
272
+ }
273
+ }));
274
+ }
275
+ transitionToStateOrThrow(orderId, state) {
276
+ return this.dataService.order.transitionToState(orderId, state).pipe(map(({ transitionOrderToState }) => {
277
+ switch (transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.__typename) {
278
+ case 'Order':
279
+ return transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.state;
280
+ case 'OrderStateTransitionError':
281
+ this.notificationService.error(transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.transitionError);
282
+ throw new Error(transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.transitionError);
283
+ }
284
+ }));
285
+ }
286
+ }
287
+ OrderTransitionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function OrderTransitionService_Factory() { return new OrderTransitionService(i0.ɵɵinject(i1.DataService), i0.ɵɵinject(i1.ModalService), i0.ɵɵinject(i1.NotificationService), i0.ɵɵinject(i1.I18nService)); }, token: OrderTransitionService, providedIn: "root" });
288
+ OrderTransitionService.decorators = [
289
+ { type: Injectable, args: [{
290
+ providedIn: 'root',
291
+ },] }
292
+ ];
293
+ OrderTransitionService.ctorParameters = () => [
294
+ { type: DataService },
295
+ { type: ModalService },
296
+ { type: NotificationService },
297
+ { type: I18nService }
298
+ ];
299
+
300
+ const GET_CUSTOMER_ADDRESSES = gql `
301
+ query GetCustomerAddresses($customerId: ID!) {
302
+ customer(id: $customerId) {
303
+ id
304
+ addresses {
305
+ ...Address
306
+ }
307
+ }
308
+ }
309
+ ${ADDRESS_FRAGMENT}
310
+ `;
311
+
312
+ class SelectAddressDialogComponent {
313
+ constructor(dataService, formBuilder) {
314
+ this.dataService = dataService;
315
+ this.formBuilder = formBuilder;
316
+ this.useExisting = true;
317
+ this.createNew = false;
318
+ }
319
+ ngOnInit() {
320
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
321
+ this.addressForm = this.formBuilder.group({
322
+ fullName: [(_b = (_a = this.currentAddress) === null || _a === void 0 ? void 0 : _a.fullName) !== null && _b !== void 0 ? _b : ''],
323
+ company: [(_d = (_c = this.currentAddress) === null || _c === void 0 ? void 0 : _c.company) !== null && _d !== void 0 ? _d : ''],
324
+ streetLine1: [(_f = (_e = this.currentAddress) === null || _e === void 0 ? void 0 : _e.streetLine1) !== null && _f !== void 0 ? _f : '', Validators.required],
325
+ streetLine2: [(_h = (_g = this.currentAddress) === null || _g === void 0 ? void 0 : _g.streetLine2) !== null && _h !== void 0 ? _h : ''],
326
+ city: [(_k = (_j = this.currentAddress) === null || _j === void 0 ? void 0 : _j.city) !== null && _k !== void 0 ? _k : '', Validators.required],
327
+ province: [(_m = (_l = this.currentAddress) === null || _l === void 0 ? void 0 : _l.province) !== null && _m !== void 0 ? _m : ''],
328
+ postalCode: [(_p = (_o = this.currentAddress) === null || _o === void 0 ? void 0 : _o.postalCode) !== null && _p !== void 0 ? _p : '', Validators.required],
329
+ countryCode: [(_r = (_q = this.currentAddress) === null || _q === void 0 ? void 0 : _q.countryCode) !== null && _r !== void 0 ? _r : '', Validators.required],
330
+ phoneNumber: [(_t = (_s = this.currentAddress) === null || _s === void 0 ? void 0 : _s.phoneNumber) !== null && _t !== void 0 ? _t : ''],
331
+ });
332
+ this.useExisting = !!this.customerId;
333
+ this.addresses$ = this.customerId
334
+ ? this.dataService
335
+ .query(GET_CUSTOMER_ADDRESSES, { customerId: this.customerId })
336
+ .mapSingle(({ customer }) => { var _a; return (_a = customer === null || customer === void 0 ? void 0 : customer.addresses) !== null && _a !== void 0 ? _a : []; })
337
+ .pipe(tap(addresses => {
338
+ if (this.currentAddress) {
339
+ this.selectedAddress = addresses.find(a => {
340
+ var _a, _b;
341
+ return a.streetLine1 === ((_a = this.currentAddress) === null || _a === void 0 ? void 0 : _a.streetLine1) &&
342
+ a.postalCode === ((_b = this.currentAddress) === null || _b === void 0 ? void 0 : _b.postalCode);
343
+ });
344
+ }
345
+ if (addresses.length === 0) {
346
+ this.createNew = true;
347
+ this.useExisting = false;
348
+ }
349
+ }))
350
+ : of([]);
351
+ this.availableCountries$ = this.dataService.settings
352
+ .getAvailableCountries()
353
+ .mapSingle(({ countries }) => countries.items);
354
+ }
355
+ trackByFn(item) {
356
+ return item.id;
357
+ }
358
+ addressIdFn(item) {
359
+ return item.streetLine1 + item.postalCode;
360
+ }
361
+ cancel() {
362
+ this.resolveWith();
363
+ }
364
+ select() {
365
+ if (this.useExisting && this.selectedAddress) {
366
+ this.resolveWith(Object.assign(Object.assign({}, pick(this.selectedAddress, [
367
+ 'fullName',
368
+ 'company',
369
+ 'streetLine1',
370
+ 'streetLine2',
371
+ 'city',
372
+ 'province',
373
+ 'phoneNumber',
374
+ 'postalCode',
375
+ ])), { countryCode: this.selectedAddress.country.code }));
376
+ }
377
+ if (this.createNew && this.addressForm.valid) {
378
+ const formValue = this.addressForm.value;
379
+ this.resolveWith(formValue);
380
+ }
381
+ }
382
+ }
383
+ SelectAddressDialogComponent.decorators = [
384
+ { type: Component, args: [{
385
+ selector: 'vdr-select-address-dialog',
386
+ template: "<ng-template vdrDialogTitle>{{ 'order.select-address' | translate }}</ng-template>\r\n\r\n<clr-tabs *ngIf=\"addresses$ | async as addresses\">\r\n <clr-tab *ngIf=\"customerId && addresses.length\">\r\n <button clrTabLink>{{ 'order.existing-address' | translate }}</button>\r\n <ng-template [(clrIfActive)]=\"useExisting\">\r\n <clr-tab-content>\r\n <vdr-radio-card-fieldset\r\n class=\"block mt4\"\r\n [idFn]=\"addressIdFn\"\r\n [selectedItemId]=\"selectedAddress && addressIdFn(selectedAddress)\"\r\n (selectItem)=\"selectedAddress = $event\"\r\n >\r\n <vdr-radio-card *ngFor=\"let address of addresses\" [item]=\"address\">\r\n <vdr-formatted-address [address]=\"address\"></vdr-formatted-address>\r\n </vdr-radio-card>\r\n </vdr-radio-card-fieldset>\r\n </clr-tab-content>\r\n </ng-template>\r\n </clr-tab>\r\n <clr-tab>\r\n <button clrTabLink>{{ 'customer.create-new-address' | translate }}</button>\r\n\r\n <ng-template [(clrIfActive)]=\"createNew\">\r\n <clr-tab-content>\r\n <vdr-address-form\r\n [formGroup]=\"addressForm\"\r\n [availableCountries]=\"availableCountries$ | async\"\r\n ></vdr-address-form>\r\n </clr-tab-content>\r\n </ng-template>\r\n </clr-tab>\r\n</clr-tabs>\r\n\r\n<ng-template vdrDialogButtons>\r\n <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n <button\r\n type=\"submit\"\r\n (click)=\"select()\"\r\n [disabled]=\"(useExisting && !selectedAddress) || (createNew && addressForm.invalid)\"\r\n class=\"btn btn-primary\"\r\n >\r\n {{ 'common.okay' | translate }}\r\n </button>\r\n</ng-template>\r\n",
387
+ changeDetection: ChangeDetectionStrategy.OnPush,
388
+ styles: [""]
389
+ },] }
390
+ ];
391
+ SelectAddressDialogComponent.ctorParameters = () => [
392
+ { type: DataService },
393
+ { type: FormBuilder }
394
+ ];
395
+
396
+ class SelectCustomerDialogComponent {
397
+ constructor(dataService, formBuilder) {
398
+ this.dataService = dataService;
399
+ this.formBuilder = formBuilder;
400
+ this.isLoading = false;
401
+ this.input$ = new Subject();
402
+ this.selectedCustomer = [];
403
+ this.useExisting = true;
404
+ this.createNew = false;
405
+ this.customerForm = this.formBuilder.group({
406
+ title: '',
407
+ firstName: ['', Validators.required],
408
+ lastName: ['', Validators.required],
409
+ phoneNumber: '',
410
+ emailAddress: ['', [Validators.required, Validators.email]],
411
+ });
412
+ }
413
+ ngOnInit() {
414
+ this.customers$ = concat(of([]), // default items
415
+ this.input$.pipe(debounceTime(200), distinctUntilChanged(), tap(() => (this.isLoading = true)), switchMap(term => this.dataService.customer
416
+ .getCustomerList(10, 0, term)
417
+ .mapStream(({ customers }) => customers.items)
418
+ .pipe(catchError(() => of([])), // empty list on error
419
+ tap(() => (this.isLoading = false))))));
420
+ }
421
+ trackByFn(item) {
422
+ return item.id;
423
+ }
424
+ cancel() {
425
+ this.resolveWith();
426
+ }
427
+ select() {
428
+ if (this.useExisting && this.selectedCustomer.length === 1) {
429
+ this.resolveWith(this.selectedCustomer[0]);
430
+ }
431
+ if (this.createNew && this.customerForm.valid) {
432
+ const formValue = this.customerForm.value;
433
+ this.resolveWith(formValue);
434
+ }
435
+ }
436
+ }
437
+ SelectCustomerDialogComponent.decorators = [
438
+ { type: Component, args: [{
439
+ selector: 'vdr-select-customer-dialog',
440
+ template: "<ng-template vdrDialogTitle>{{ 'order.set-customer-for-order' | translate }}</ng-template>\r\n\r\n<clr-tabs>\r\n <clr-tab>\r\n <button clrTabLink>{{ 'order.existing-customer' | translate }}</button>\r\n\r\n <ng-template [(clrIfActive)]=\"useExisting\">\r\n <clr-tab-content>\r\n <ng-select\r\n [items]=\"customers$ | async\"\r\n appendTo=\"body\"\r\n bindLabel=\"name\"\r\n [addTag]=\"false\"\r\n [multiple]=\"true\"\r\n [hideSelected]=\"true\"\r\n [trackByFn]=\"trackByFn\"\r\n [minTermLength]=\"2\"\r\n [loading]=\"isLoading\"\r\n [typeahead]=\"input$\"\r\n [(ngModel)]=\"selectedCustomer\"\r\n class=\"mt4\"\r\n >\r\n <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n <clr-icon shape=\"user\" class=\"is-solid\"></clr-icon\r\n ><span class=\"ml2 mr2\">{{ item.firstName }} {{ item.lastName }}</span>\r\n <vdr-chip>{{ item.emailAddress }}</vdr-chip>\r\n </ng-template>\r\n <ng-template ng-option-tmp let-item=\"item\">\r\n <clr-icon shape=\"user\" class=\"is-solid\"></clr-icon\r\n ><span class=\"ml2 mr2\">{{ item.firstName }} {{ item.lastName }}</span>\r\n <vdr-chip>{{ item.emailAddress }}</vdr-chip>\r\n </ng-template>\r\n </ng-select>\r\n </clr-tab-content>\r\n </ng-template>\r\n </clr-tab>\r\n <clr-tab>\r\n <button clrTabLink>{{ 'customer.create-new-customer' | translate }}</button>\r\n\r\n <ng-template [(clrIfActive)]=\"createNew\">\r\n <clr-tab-content>\r\n <form [formGroup]=\"customerForm\">\r\n <vdr-form-field [label]=\"'customer.title' | translate\" for=\"title\">\r\n <input id=\"title\" type=\"text\" formControlName=\"title\" />\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'customer.first-name' | translate\" for=\"firstName\">\r\n <input id=\"firstName\" type=\"text\" formControlName=\"firstName\" />\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'customer.last-name' | translate\" for=\"lastName\">\r\n <input id=\"lastName\" type=\"text\" formControlName=\"lastName\" />\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'customer.email-address' | translate\" for=\"emailAddress\">\r\n <input id=\"emailAddress\" type=\"text\" formControlName=\"emailAddress\" />\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'customer.phone-number' | translate\" for=\"phoneNumber\">\r\n <input id=\"phoneNumber\" type=\"text\" formControlName=\"phoneNumber\" />\r\n </vdr-form-field>\r\n </form>\r\n </clr-tab-content>\r\n </ng-template>\r\n </clr-tab>\r\n</clr-tabs>\r\n\r\n<ng-template vdrDialogButtons>\r\n <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n <button\r\n type=\"submit\"\r\n (click)=\"select()\"\r\n [disabled]=\"(useExisting && selectedCustomer.length === 0) || (createNew && customerForm.invalid)\"\r\n class=\"btn btn-primary\"\r\n >\r\n {{ 'common.okay' | translate }}\r\n </button>\r\n</ng-template>\r\n",
441
+ changeDetection: ChangeDetectionStrategy.OnPush,
442
+ styles: [""]
443
+ },] }
444
+ ];
445
+ SelectCustomerDialogComponent.ctorParameters = () => [
446
+ { type: DataService },
447
+ { type: FormBuilder }
448
+ ];
449
+
450
+ class SelectShippingMethodDialogComponent {
451
+ constructor() { }
452
+ ngOnInit() {
453
+ if (this.currentSelectionId) {
454
+ this.selectedMethod = this.eligibleShippingMethods.find(m => m.id === this.currentSelectionId);
455
+ }
456
+ }
457
+ methodIdFn(item) {
458
+ return item.id;
459
+ }
460
+ cancel() {
461
+ this.resolveWith();
462
+ }
463
+ select() {
464
+ if (this.selectedMethod) {
465
+ this.resolveWith(this.selectedMethod.id);
466
+ }
467
+ }
468
+ }
469
+ SelectShippingMethodDialogComponent.decorators = [
470
+ { type: Component, args: [{
471
+ selector: 'vdr-select-shipping-method-dialog',
472
+ template: "<ng-template vdrDialogTitle>{{ 'order.select-shipping-method' | translate }}</ng-template>\r\n<vdr-radio-card-fieldset\r\n [idFn]=\"methodIdFn\"\r\n [selectedItemId]=\"selectedMethod?.id\"\r\n (selectItem)=\"selectedMethod = $event\"\r\n>\r\n <vdr-radio-card *ngFor=\"let quote of eligibleShippingMethods\" [item]=\"quote\">\r\n <div class=\"result-details\">\r\n <vdr-labeled-data [label]=\"'settings.shipping-method' | translate\">\r\n {{ quote.name }}\r\n </vdr-labeled-data>\r\n <div class=\"price-row\">\r\n <vdr-labeled-data [label]=\"'common.price' | translate\">\r\n {{ quote.price | localeCurrency: currencyCode }}\r\n </vdr-labeled-data>\r\n <vdr-labeled-data [label]=\"'common.price-with-tax' | translate\">\r\n {{ quote.priceWithTax | localeCurrency: currencyCode }}\r\n </vdr-labeled-data>\r\n </div>\r\n <vdr-object-tree *ngIf=\"quote.metadata\" [value]=\"quote.metadata\"></vdr-object-tree>\r\n </div>\r\n </vdr-radio-card>\r\n</vdr-radio-card-fieldset>\r\n\r\n<ng-template vdrDialogButtons>\r\n <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n <button\r\n type=\"submit\"\r\n (click)=\"select()\"\r\n [disabled]=\"!selectedMethod\"\r\n class=\"btn btn-primary\"\r\n >\r\n {{ 'common.okay' | translate }}\r\n </button>\r\n</ng-template>\r\n",
473
+ changeDetection: ChangeDetectionStrategy.OnPush,
474
+ styles: [""]
475
+ },] }
476
+ ];
477
+ SelectShippingMethodDialogComponent.ctorParameters = () => [];
478
+
479
+ class DraftOrderDetailComponent extends BaseDetailComponent {
480
+ constructor(router, route, serverConfigService, changeDetector, dataService, notificationService, modalService, orderTransitionService) {
481
+ super(route, router, serverConfigService, dataService);
482
+ this.changeDetector = changeDetector;
483
+ this.dataService = dataService;
484
+ this.notificationService = notificationService;
485
+ this.modalService = modalService;
486
+ this.orderTransitionService = orderTransitionService;
487
+ this.detailForm = new FormGroup({});
488
+ this.fetchHistory = new Subject();
489
+ this.displayCouponCodeInput = false;
490
+ }
491
+ ngOnInit() {
492
+ this.init();
493
+ this.orderLineCustomFields = this.getCustomFieldConfig('OrderLine');
494
+ this.eligibleShippingMethods$ = this.entity$.pipe(switchMap(order => this.dataService.order
495
+ .getDraftOrderEligibleShippingMethods(order.id)
496
+ .mapSingle(({ eligibleShippingMethodsForDraftOrder }) => eligibleShippingMethodsForDraftOrder)));
497
+ this.customFields = this.getCustomFieldConfig('Order');
498
+ this.orderLineCustomFields = this.getCustomFieldConfig('OrderLine');
499
+ }
500
+ ngOnDestroy() {
501
+ this.destroy();
502
+ }
503
+ addItemToOrder(event) {
504
+ this.dataService.order.addItemToDraftOrder(this.id, event).subscribe(result => {
505
+ if (result.addItemToDraftOrder.__typename !== 'Order') {
506
+ this.notificationService.error(result.addItemToDraftOrder.message);
507
+ }
508
+ });
509
+ }
510
+ adjustOrderLine(event) {
511
+ this.dataService.order
512
+ .adjustDraftOrderLine(this.id, { orderLineId: event.lineId, quantity: event.quantity })
513
+ .subscribe(result => {
514
+ if (result.adjustDraftOrderLine.__typename !== 'Order') {
515
+ this.notificationService.error(result.adjustDraftOrderLine.message);
516
+ }
517
+ });
518
+ }
519
+ removeOrderLine(event) {
520
+ this.dataService.order.removeDraftOrderLine(this.id, event.lineId).subscribe(result => {
521
+ if (result.removeDraftOrderLine.__typename !== 'Order') {
522
+ this.notificationService.error(result.removeDraftOrderLine.message);
523
+ }
524
+ });
525
+ }
526
+ getOrderAddressLines(orderAddress) {
527
+ if (!orderAddress) {
528
+ return [];
529
+ }
530
+ return Object.values(orderAddress)
531
+ .filter(val => val !== 'OrderAddress')
532
+ .filter(line => !!line);
533
+ }
534
+ setCustomer() {
535
+ this.modalService.fromComponent(SelectCustomerDialogComponent).subscribe(result => {
536
+ if (this.hasId(result)) {
537
+ this.dataService.order
538
+ .setCustomerForDraftOrder(this.id, { customerId: result.id })
539
+ .subscribe();
540
+ }
541
+ else if (result) {
542
+ this.dataService.order.setCustomerForDraftOrder(this.id, { input: result }).subscribe();
543
+ }
544
+ });
545
+ }
546
+ setShippingAddress() {
547
+ this.entity$
548
+ .pipe(take(1), switchMap(order => {
549
+ var _a, _b;
550
+ return this.modalService.fromComponent(SelectAddressDialogComponent, {
551
+ locals: {
552
+ customerId: (_a = order.customer) === null || _a === void 0 ? void 0 : _a.id,
553
+ currentAddress: (_b = order.shippingAddress) !== null && _b !== void 0 ? _b : undefined,
554
+ },
555
+ });
556
+ }))
557
+ .subscribe(result => {
558
+ if (result) {
559
+ this.dataService.order.setDraftOrderShippingAddress(this.id, result).subscribe();
560
+ }
561
+ });
562
+ }
563
+ setBillingAddress() {
564
+ this.entity$
565
+ .pipe(take(1), switchMap(order => {
566
+ var _a, _b;
567
+ return this.modalService.fromComponent(SelectAddressDialogComponent, {
568
+ locals: {
569
+ customerId: (_a = order.customer) === null || _a === void 0 ? void 0 : _a.id,
570
+ currentAddress: (_b = order.billingAddress) !== null && _b !== void 0 ? _b : undefined,
571
+ },
572
+ });
573
+ }))
574
+ .subscribe(result => {
575
+ if (result) {
576
+ this.dataService.order.setDraftOrderBillingAddress(this.id, result).subscribe();
577
+ }
578
+ });
579
+ }
580
+ applyCouponCode(couponCode) {
581
+ this.dataService.order.applyCouponCodeToDraftOrder(this.id, couponCode).subscribe();
582
+ }
583
+ removeCouponCode(couponCode) {
584
+ this.dataService.order.removeCouponCodeFromDraftOrder(this.id, couponCode).subscribe();
585
+ }
586
+ setShippingMethod() {
587
+ combineLatest(this.entity$, this.eligibleShippingMethods$)
588
+ .pipe(take(1), switchMap(([order, methods]) => {
589
+ var _a, _b;
590
+ return this.modalService.fromComponent(SelectShippingMethodDialogComponent, {
591
+ locals: {
592
+ eligibleShippingMethods: methods,
593
+ currencyCode: order.currencyCode,
594
+ currentSelectionId: (_b = (_a = order.shippingLines) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.shippingMethod.id,
595
+ },
596
+ });
597
+ }))
598
+ .subscribe(result => {
599
+ if (result) {
600
+ this.dataService.order.setDraftOrderShippingMethod(this.id, result).subscribe();
601
+ }
602
+ });
603
+ }
604
+ updateCustomFields(customFieldsValue) {
605
+ this.dataService.order
606
+ .updateOrderCustomFields({
607
+ id: this.id,
608
+ customFields: customFieldsValue,
609
+ })
610
+ .subscribe();
611
+ }
612
+ deleteOrder() {
613
+ this.dataService.order.deleteDraftOrder(this.id).subscribe(({ deleteDraftOrder }) => {
614
+ if (deleteDraftOrder.result === DeletionResult.DELETED) {
615
+ this.notificationService.success(marker('common.notify-delete-success'), {
616
+ entity: 'Order',
617
+ });
618
+ this.router.navigate(['/orders']);
619
+ }
620
+ else if (deleteDraftOrder.message) {
621
+ this.notificationService.error(deleteDraftOrder.message);
622
+ }
623
+ });
624
+ }
625
+ completeOrder() {
626
+ this.dataService.order
627
+ .transitionToState(this.id, 'ArrangingPayment')
628
+ .subscribe(({ transitionOrderToState }) => {
629
+ if ((transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.__typename) === 'Order') {
630
+ this.router.navigate(['/orders', this.id]);
631
+ }
632
+ else if ((transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.__typename) === 'OrderStateTransitionError') {
633
+ this.notificationService.error(transitionOrderToState.transitionError);
634
+ }
635
+ });
636
+ }
637
+ hasId(input) {
638
+ return typeof input === 'object' && !!input.id;
639
+ }
640
+ setFormValues(entity) {
641
+ // empty
642
+ }
643
+ }
644
+ DraftOrderDetailComponent.decorators = [
645
+ { type: Component, args: [{
646
+ selector: 'vdr-draft-order-detail',
647
+ template: "<vdr-action-bar *ngIf=\"entity$ | async as order\">\r\n <vdr-ab-left>\r\n <div class=\"flex clr-align-items-center\">\r\n <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\r\n </div>\r\n </vdr-ab-left>\r\n\r\n <vdr-ab-right>\r\n <button\r\n class=\"btn btn-primary\"\r\n (click)=\"completeOrder()\"\r\n [disabled]=\"!order.customer || !order.lines.length || !order.shippingLines.length\"\r\n >\r\n <clr-icon shape=\"check\"></clr-icon>\r\n {{ 'order.complete-draft-order' | translate }}\r\n </button>\r\n <vdr-dropdown>\r\n <button class=\"icon-button\" vdrDropdownTrigger>\r\n <clr-icon shape=\"ellipsis-vertical\"></clr-icon>\r\n </button>\r\n <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n <button type=\"button\" class=\"btn\" vdrDropdownItem (click)=\"deleteOrder()\">\r\n <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n {{ 'order.delete-draft-order' | translate }}\r\n </button>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngIf=\"entity$ | async as order\">\r\n <div class=\"clr-row\">\r\n <div class=\"clr-col-lg-8\">\r\n <vdr-draft-order-variant-selector\r\n [orderLineCustomFields]=\"orderLineCustomFields\"\r\n [currencyCode]=\"order.currencyCode\"\r\n (addItem)=\"addItemToOrder($event)\"\r\n ></vdr-draft-order-variant-selector>\r\n <vdr-order-table\r\n [order]=\"order\"\r\n [orderLineCustomFields]=\"orderLineCustomFields\"\r\n [isDraft]=\"true\"\r\n (adjust)=\"adjustOrderLine($event)\"\r\n (remove)=\"removeOrderLine($event)\"\r\n ></vdr-order-table>\r\n <div class=\"flex\">\r\n <button\r\n *ngIf=\"order.couponCodes.length === 0 && !displayCouponCodeInput\"\r\n class=\"btn btn-link btn-sm mr2\"\r\n (click)=\"displayCouponCodeInput = !displayCouponCodeInput\"\r\n >\r\n {{ 'order.set-coupon-codes' | translate }}\r\n </button>\r\n <div *ngIf=\"order.couponCodes.length || displayCouponCodeInput\">\r\n <label>{{ 'order.set-coupon-codes' | translate }}</label>\r\n <vdr-coupon-code-selector\r\n [couponCodes]=\"order.couponCodes\"\r\n (addCouponCode)=\"applyCouponCode($event)\"\r\n (removeCouponCode)=\"removeCouponCode($event)\"\r\n ></vdr-coupon-code-selector>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"order.taxSummary.length\">\r\n <h4>{{ 'order.tax-summary' | translate }}</h4>\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th>{{ 'common.description' | translate }}</th>\r\n <th>{{ 'order.tax-rate' | translate }}</th>\r\n <th>{{ 'order.tax-base' | translate }}</th>\r\n <th>{{ 'order.tax-total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let row of order.taxSummary\">\r\n <td>{{ row.description }}</td>\r\n <td>{{ row.taxRate / 100 | percent }}</td>\r\n <td>{{ row.taxBase | localeCurrency: order.currencyCode }}</td>\r\n <td>{{ row.taxTotal | localeCurrency: order.currencyCode }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </ng-container>\r\n </div>\r\n <div class=\"clr-col-lg-4 order-cards\">\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n <clr-icon *ngIf=\"!order.customer\" shape=\"unknown-status\" class=\"is-warning\"></clr-icon>\r\n <clr-icon *ngIf=\"order.customer\" shape=\"check\" class=\"is-success\"></clr-icon>\r\n {{ 'order.customer' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <div class=\"card-text\">\r\n <vdr-customer-label\r\n class=\"block mb2\"\r\n *ngIf=\"order.customer\"\r\n [customer]=\"order.customer\"\r\n ></vdr-customer-label>\r\n <button class=\"btn btn-link btn-sm\" (click)=\"setCustomer()\">\r\n {{ 'order.set-customer-for-order' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"card-block\">\r\n <h4 class=\"card-title\">\r\n <clr-icon\r\n *ngIf=\"!order.billingAddress.streetLine1\"\r\n shape=\"unknown-status\"\r\n class=\"is-warning\"\r\n ></clr-icon>\r\n <clr-icon\r\n *ngIf=\"order.billingAddress.streetLine1\"\r\n shape=\"check\"\r\n class=\"is-success\"\r\n ></clr-icon>\r\n {{ 'order.billing-address' | translate }}\r\n </h4>\r\n <div class=\"card-text\">\r\n <vdr-formatted-address\r\n class=\"block mb2\"\r\n *ngIf=\"order.billingAddress\"\r\n [address]=\"order.billingAddress\"\r\n ></vdr-formatted-address>\r\n <button class=\"btn btn-link btn-sm\" (click)=\"setBillingAddress()\">\r\n {{ 'order.set-billing-address' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n <clr-icon\r\n *ngIf=\"!order.shippingAddress.streetLine1 || !order.shippingLines.length\"\r\n shape=\"unknown-status\"\r\n class=\"is-warning\"\r\n ></clr-icon>\r\n <clr-icon\r\n *ngIf=\"order.shippingAddress.streetLine1 && order.shippingLines.length\"\r\n shape=\"check\"\r\n class=\"is-success\"\r\n ></clr-icon>\r\n {{ 'order.shipping' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <div class=\"card-text\">\r\n <vdr-formatted-address\r\n class=\"block mb2\"\r\n *ngIf=\"order.shippingAddress\"\r\n [address]=\"order.shippingAddress\"\r\n ></vdr-formatted-address>\r\n <button class=\"btn btn-link btn-sm\" (click)=\"setShippingAddress()\">\r\n {{ 'order.set-shipping-address' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"card-block\">\r\n <div class=\"card-text\">\r\n <div *ngFor=\"let shippingLine of order.shippingLines\">\r\n {{ shippingLine.shippingMethod.name }}\r\n </div>\r\n <button class=\"btn btn-link btn-sm\" (click)=\"setShippingMethod()\">\r\n {{ 'order.set-shipping-method' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n <vdr-order-custom-fields-card\r\n [customFieldsConfig]=\"customFields\"\r\n [customFieldValues]=\"order.customFields\"\r\n (updateClick)=\"updateCustomFields($event)\"\r\n ></vdr-order-custom-fields-card>\r\n </div>\r\n </div>\r\n</div>\r\n",
648
+ changeDetection: ChangeDetectionStrategy.OnPush,
649
+ styles: [""]
650
+ },] }
651
+ ];
652
+ DraftOrderDetailComponent.ctorParameters = () => [
653
+ { type: Router },
654
+ { type: ActivatedRoute },
655
+ { type: ServerConfigService },
656
+ { type: ChangeDetectorRef },
657
+ { type: DataService },
658
+ { type: NotificationService },
659
+ { type: ModalService },
660
+ { type: OrderTransitionService }
661
+ ];
662
+
663
+ class DraftOrderVariantSelectorComponent {
664
+ constructor(dataService) {
665
+ this.dataService = dataService;
666
+ this.addItem = new EventEmitter();
667
+ this.customFieldsFormGroup = new FormGroup({});
668
+ this.selectedVariantId$ = new Subject();
669
+ this.quantity = 1;
64
670
  }
65
671
  ngOnInit() {
66
- this.lineQuantities = this.order.lines.reduce((result, line) => {
67
- return Object.assign(Object.assign({}, result), { [line.id]: line.quantity });
68
- }, {});
69
- }
70
- radioChanged() {
71
- if (this.cancelAll) {
72
- for (const line of this.order.lines) {
73
- this.lineQuantities[line.id] = line.quantity;
672
+ this.selectedVariant$ = this.selectedVariantId$.pipe(switchMap(id => {
673
+ if (id) {
674
+ return this.dataService.product
675
+ .getProductVariant(id)
676
+ .mapSingle(({ productVariant }) => productVariant);
74
677
  }
75
- }
76
- else {
77
- for (const line of this.order.lines) {
78
- this.lineQuantities[line.id] = 0;
79
- }
80
- }
81
- }
82
- checkIfAllSelected() {
83
- var _a;
84
- for (const [lineId, quantity] of Object.entries(this.lineQuantities)) {
85
- const quantityInOrder = (_a = this.order.lines.find(line => line.id === lineId)) === null || _a === void 0 ? void 0 : _a.quantity;
86
- if (quantityInOrder && quantity < quantityInOrder) {
87
- return;
678
+ else {
679
+ return [undefined];
88
680
  }
681
+ }));
682
+ for (const customField of this.orderLineCustomFields) {
683
+ this.customFieldsFormGroup.addControl(customField.name, new FormControl(''));
89
684
  }
90
- // If we got here, all of the selected quantities are equal to the order
91
- // line quantities, i.e. everything is selected.
92
- this.cancelAll = true;
93
- }
94
- select() {
95
- this.resolveWith({
96
- orderId: this.order.id,
97
- lines: this.getLineInputs(),
98
- reason: this.reason,
99
- cancelShipping: this.cancelAll,
100
- });
101
685
  }
102
- cancel() {
103
- this.resolveWith();
104
- }
105
- getLineInputs() {
106
- if (this.order.active) {
107
- return;
686
+ addItemClick(selectedVariant) {
687
+ if (selectedVariant) {
688
+ this.addItem.emit({
689
+ productVariantId: selectedVariant.id,
690
+ quantity: this.quantity,
691
+ customFields: this.orderLineCustomFields.length
692
+ ? this.customFieldsFormGroup.value
693
+ : undefined,
694
+ });
695
+ this.selectedVariantId$.next(undefined);
696
+ this.customFieldsFormGroup.reset();
108
697
  }
109
- return Object.entries(this.lineQuantities)
110
- .map(([orderLineId, quantity]) => ({
111
- orderLineId,
112
- quantity,
113
- }))
114
- .filter(l => 0 < l.quantity);
115
698
  }
116
699
  }
117
- CancelOrderDialogComponent.decorators = [
700
+ DraftOrderVariantSelectorComponent.decorators = [
118
701
  { type: Component, args: [{
119
- selector: 'vdr-cancel-order-dialog',
120
- template: "<ng-template vdrDialogTitle>{{ 'order.cancel-order' | translate }}</ng-template>\r\n\r\n<div class=\"fulfillment-wrapper\">\r\n <div class=\"order-lines\">\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.cancel' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tr\r\n *ngFor=\"let line of order.lines\"\r\n class=\"order-line\"\r\n [class.is-disabled]=\"cancelAll\"\r\n [class.is-cancelled]=\"line.quantity === 0\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle quantity\">{{ line.quantity }}</td>\r\n <td class=\"align-middle quantity\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n </td>\r\n <td class=\"align-middle fulfil\">\r\n <input\r\n *ngIf=\"line.quantity > 0 && !order.active; else nonEditable\"\r\n [(ngModel)]=\"lineQuantities[line.id]\"\r\n (input)=\"checkIfAllSelected()\"\r\n [disabled]=\"cancelAll\"\r\n type=\"number\"\r\n [max]=\"line.quantity\"\r\n min=\"0\"\r\n />\r\n <ng-template #nonEditable>{{ line.quantity }}</ng-template>\r\n </td>\r\n </tr>\r\n </table>\r\n </div>\r\n <div class=\"cancellation-details\">\r\n <ng-container *ngIf=\"order.active !== true\">\r\n <clr-radio-wrapper>\r\n <input\r\n type=\"radio\"\r\n clrRadio\r\n [value]=\"true\"\r\n [(ngModel)]=\"cancelAll\"\r\n name=\"options\"\r\n (ngModelChange)=\"radioChanged()\"\r\n />\r\n <label>{{ 'order.cancel-entire-order' | translate }}</label>\r\n </clr-radio-wrapper>\r\n <clr-radio-wrapper>\r\n <input\r\n type=\"radio\"\r\n clrRadio\r\n [value]=\"false\"\r\n [(ngModel)]=\"cancelAll\"\r\n name=\"options\"\r\n (ngModelChange)=\"radioChanged()\"\r\n />\r\n <label>{{ 'order.cancel-specified-items' | translate }}</label>\r\n </clr-radio-wrapper>\r\n </ng-container>\r\n <label class=\"clr-control-label\">{{ 'order.cancellation-reason' | translate }}</label>\r\n <ng-select\r\n [items]=\"reasons\"\r\n bindLabel=\"name\"\r\n autofocus\r\n bindValue=\"id\"\r\n [addTag]=\"true\"\r\n [(ngModel)]=\"reason\"\r\n ></ng-select>\r\n </div>\r\n</div>\r\n\r\n<ng-template vdrDialogButtons>\r\n <button type=\"button\" class=\"btn\" (click)=\"cancel()\">{{ 'common.cancel' | translate }}</button>\r\n <button\r\n type=\"submit\"\r\n (click)=\"select()\"\r\n [disabled]=\"!reason || (!order.active && selectionCount === 0)\"\r\n class=\"btn btn-primary\"\r\n >\r\n <ng-container *ngIf=\"!order.active\">\r\n {{ 'order.cancel-selected-items' | translate }}\r\n </ng-container>\r\n <ng-container *ngIf=\"order.active\">\r\n {{ 'order.cancel-order' | translate }}\r\n </ng-container>\r\n </button>\r\n</ng-template>\r\n",
702
+ selector: 'vdr-draft-order-variant-selector',
703
+ template: "<div class=\"card\">\r\n <div class=\"card-block\">\r\n <h4 class=\"card-title\">{{ 'order.add-item-to-order' | translate }}</h4>\r\n <vdr-product-selector\r\n (productSelected)=\"selectedVariantId$.next($event.productVariantId)\"\r\n ></vdr-product-selector>\r\n </div>\r\n <div class=\"card-block\" *ngIf=\"selectedVariant$ | async as selectedVariant\">\r\n <div class=\"variant-details\">\r\n <img class=\"mr2\" [src]=\"selectedVariant.featuredAsset || selectedVariant.product.featuredAsset | assetPreview: 32\">\r\n <div class=\"details\">\r\n <div>{{ selectedVariant?.name }}</div>\r\n <div class=\"small\">{{ selectedVariant?.sku }}</div>\r\n </div>\r\n <div class=\"details ml4\">\r\n <div class=\"small\">\r\n {{ 'catalog.stock-on-hand' | translate }}: {{ selectedVariant.stockOnHand }}\r\n </div>\r\n <div class=\"small\">\r\n {{ 'catalog.stock-allocated' | translate }}: {{ selectedVariant.stockAllocated }}\r\n </div>\r\n </div>\r\n <div class=\"flex-spacer\"></div>\r\n <div class=\"details\">\r\n <div>{{ selectedVariant?.priceWithTax | localeCurrency: currencyCode }}</div>\r\n <div class=\"small\" [title]=\"'order.net-price' | translate\">\r\n {{ selectedVariant?.price | localeCurrency: currencyCode }}\r\n </div>\r\n </div>\r\n <div>\r\n <input [disabled]=\"!selectedVariant\" type=\"number\" min=\"0\" [(ngModel)]=\"quantity\" />\r\n </div>\r\n <button\r\n [disabled]=\"!selectedVariant\"\r\n class=\"btn btn-small btn-primary\"\r\n (click)=\"addItemClick(selectedVariant)\"\r\n >\r\n {{ 'order.add-item-to-order' | translate }}\r\n </button>\r\n </div>\r\n <ng-container *ngIf=\"orderLineCustomFields.length\">\r\n <div class=\"custom-field\" *ngFor=\"let field of orderLineCustomFields\">\r\n <vdr-custom-field-control\r\n [compact]=\"true\"\r\n [readonly]=\"false\"\r\n [customField]=\"field\"\r\n [customFieldsFormGroup]=\"customFieldsFormGroup\"\r\n ></vdr-custom-field-control>\r\n </div>\r\n </ng-container>\r\n </div>\r\n</div>\r\n",
121
704
  changeDetection: ChangeDetectionStrategy.OnPush,
122
- styles: [":host{height:100%;display:flex;min-height:64vh}.fulfillment-wrapper{flex:1}@media screen and (min-width: 768px){.fulfillment-wrapper{display:flex;flex-direction:row}}@media screen and (min-width: 768px){.fulfillment-wrapper .cancellation-details{margin-top:0;margin-left:24px;width:250px}}.fulfillment-wrapper .order-lines{flex:1;overflow-y:auto}.fulfillment-wrapper .order-lines table{margin-top:0}.fulfillment-wrapper tr.ignore{color:var(--color-grey-300)}.fulfillment-wrapper .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.fulfillment-wrapper .is-disabled td,.fulfillment-wrapper .is-disabled td input{background-color:var(--color-component-bg-200)}\n"]
705
+ styles: [".variant-details{display:flex;align-items:center}.variant-details img{border-radius:var(--border-radius-img);width:32px;height:32px}.variant-details .details{font-size:.65rem;line-height:.7rem}.variant-details input{width:48px;margin:0 6px}.variant-details .small{font-size:11px;color:var(--color-text-300)}\n"]
123
706
  },] }
124
707
  ];
125
- CancelOrderDialogComponent.ctorParameters = () => [
126
- { type: I18nService }
127
- ];
708
+ DraftOrderVariantSelectorComponent.ctorParameters = () => [
709
+ { type: DataService }
710
+ ];
711
+ DraftOrderVariantSelectorComponent.propDecorators = {
712
+ currencyCode: [{ type: Input }],
713
+ orderLineCustomFields: [{ type: Input }],
714
+ addItem: [{ type: Output }]
715
+ };
128
716
 
129
717
  class FulfillOrderDialogComponent {
130
718
  constructor(dataService, changeDetector) {
@@ -526,138 +1114,6 @@ OrderCustomFieldsCardComponent.propDecorators = {
526
1114
  updateClick: [{ type: Output }]
527
1115
  };
528
1116
 
529
- class OrderStateSelectDialogComponent {
530
- constructor() {
531
- this.nextStates = [];
532
- this.message = '';
533
- this.selectedState = '';
534
- }
535
- select() {
536
- if (this.selectedState) {
537
- this.resolveWith(this.selectedState);
538
- }
539
- }
540
- cancel() {
541
- this.resolveWith();
542
- }
543
- }
544
- OrderStateSelectDialogComponent.decorators = [
545
- { type: Component, args: [{
546
- selector: 'vdr-order-state-select-dialog',
547
- template: "<ng-template vdrDialogTitle>{{ 'order.select-state' | translate }}</ng-template>\r\n<p>{{ message | translate }}</p>\r\n<clr-select-container>\r\n <select clrSelect name=\"state\" [(ngModel)]=\"selectedState\">\r\n <option *ngFor=\"let state of nextStates\" [value]=\"state\">\r\n {{ state | stateI18nToken | translate }}\r\n </option>\r\n </select>\r\n</clr-select-container>\r\n<ng-template vdrDialogButtons>\r\n <button type=\"submit\" *ngIf=\"cancellable\" (click)=\"cancel()\" class=\"btn btn-secondary\">\r\n {{ 'common.cancel' | translate }}\r\n </button>\r\n <button type=\"submit\" (click)=\"select()\" class=\"btn btn-primary\" [disabled]=\"!selectedState\">\r\n {{ 'order.transition-to-state' | translate: { state: (selectedState | stateI18nToken | translate) } }}\r\n </button>\r\n</ng-template>\r\n",
548
- changeDetection: ChangeDetectionStrategy.OnPush,
549
- styles: [""]
550
- },] }
551
- ];
552
-
553
- class OrderTransitionService {
554
- constructor(dataService, modalService, notificationService, i18nService) {
555
- this.dataService = dataService;
556
- this.modalService = modalService;
557
- this.notificationService = notificationService;
558
- this.i18nService = i18nService;
559
- }
560
- /**
561
- * Attempts to transition the Order to the last state it was in before it was transitioned
562
- * to the "Modifying" state. If this fails, a manual prompt is used.
563
- */
564
- transitionToPreModifyingState(orderId, nextStates) {
565
- return this.getPreModifyingState(orderId).pipe(switchMap(state => {
566
- const manualTransitionOptions = {
567
- orderId,
568
- nextStates,
569
- message: this.i18nService.translate(marker('order.unable-to-transition-to-state-try-another'), { state }),
570
- cancellable: false,
571
- retry: 10,
572
- };
573
- if (state) {
574
- return this.transitionToStateOrThrow(orderId, state).pipe(catchError(err => this.manuallyTransitionToState(manualTransitionOptions)));
575
- }
576
- else {
577
- return this.manuallyTransitionToState(manualTransitionOptions);
578
- }
579
- }));
580
- }
581
- /**
582
- * Displays a modal for manually selecting the next state.
583
- */
584
- manuallyTransitionToState(options) {
585
- return this.modalService
586
- .fromComponent(OrderStateSelectDialogComponent, {
587
- locals: {
588
- nextStates: options.nextStates,
589
- cancellable: options.cancellable,
590
- message: options.message,
591
- },
592
- closable: false,
593
- size: 'md',
594
- })
595
- .pipe(switchMap(result => {
596
- if (result) {
597
- return this.transitionToStateOrThrow(options.orderId, result);
598
- }
599
- else {
600
- if (!options.cancellable) {
601
- throw new Error(`An order state must be selected`);
602
- }
603
- else {
604
- return EMPTY;
605
- }
606
- }
607
- }), retryWhen(errors => errors.pipe(delay(2000), take(options.retry))));
608
- }
609
- /**
610
- * Attempts to get the last state the Order was in before it was transitioned
611
- * to the "Modifying" state.
612
- */
613
- getPreModifyingState(orderId) {
614
- return this.dataService.order
615
- .getOrderHistory(orderId, {
616
- filter: {
617
- type: {
618
- eq: HistoryEntryType.ORDER_STATE_TRANSITION,
619
- },
620
- },
621
- sort: {
622
- createdAt: SortOrder.DESC,
623
- },
624
- })
625
- .mapSingle(result => result.order)
626
- .pipe(map(result => {
627
- const item = result === null || result === void 0 ? void 0 : result.history.items.find(i => i.data.to === 'Modifying');
628
- if (item) {
629
- return item.data.from;
630
- }
631
- else {
632
- return;
633
- }
634
- }));
635
- }
636
- transitionToStateOrThrow(orderId, state) {
637
- return this.dataService.order.transitionToState(orderId, state).pipe(map(({ transitionOrderToState }) => {
638
- switch (transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.__typename) {
639
- case 'Order':
640
- return transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.state;
641
- case 'OrderStateTransitionError':
642
- this.notificationService.error(transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.transitionError);
643
- throw new Error(transitionOrderToState === null || transitionOrderToState === void 0 ? void 0 : transitionOrderToState.transitionError);
644
- }
645
- }));
646
- }
647
- }
648
- OrderTransitionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function OrderTransitionService_Factory() { return new OrderTransitionService(i0.ɵɵinject(i1.DataService), i0.ɵɵinject(i1.ModalService), i0.ɵɵinject(i1.NotificationService), i0.ɵɵinject(i1.I18nService)); }, token: OrderTransitionService, providedIn: "root" });
649
- OrderTransitionService.decorators = [
650
- { type: Injectable, args: [{
651
- providedIn: 'root',
652
- },] }
653
- ];
654
- OrderTransitionService.ctorParameters = () => [
655
- { type: DataService },
656
- { type: ModalService },
657
- { type: NotificationService },
658
- { type: I18nService }
659
- ];
660
-
661
1117
  class OrderProcessGraphDialogComponent {
662
1118
  constructor(serverConfigService) {
663
1119
  this.serverConfigService = serverConfigService;
@@ -1352,7 +1808,7 @@ class OrderDetailComponent extends BaseDetailComponent {
1352
1808
  OrderDetailComponent.decorators = [
1353
1809
  { type: Component, args: [{
1354
1810
  selector: 'vdr-order-detail',
1355
- template: "<vdr-action-bar *ngIf=\"entity$ | async as order\">\r\n <vdr-ab-left>\r\n <div class=\"flex clr-align-items-center\">\r\n <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n <vdr-order-state-label [state]=\"order.state\">\r\n <button\r\n class=\"icon-button\"\r\n (click)=\"openStateDiagram()\"\r\n [title]=\"'order.order-state-diagram' | translate\"\r\n >\r\n <clr-icon shape=\"list\"></clr-icon>\r\n </button>\r\n </vdr-order-state-label>\r\n </div>\r\n </vdr-ab-left>\r\n\r\n <vdr-ab-right>\r\n <vdr-action-bar-items locationId=\"order-detail\"></vdr-action-bar-items>\r\n <button\r\n class=\"btn btn-primary\"\r\n *ngIf=\"\r\n (order.state === 'ArrangingPayment' || order.state === 'ArrangingAdditionalPayment') &&\r\n (hasUnsettledModifications(order) || 0 < outstandingPaymentAmount(order))\r\n \"\r\n (click)=\"addManualPayment(order)\"\r\n >\r\n {{ 'order.add-payment-to-order' | translate }}\r\n ({{ outstandingPaymentAmount(order) | localeCurrency: order.currencyCode }})\r\n </button>\r\n <button\r\n class=\"btn btn-primary\"\r\n *ngIf=\"\r\n order.active === false &&\r\n order.state !== 'ArrangingAdditionalPayment' &&\r\n 0 < outstandingPaymentAmount(order)\r\n \"\r\n (click)=\"transitionToState('ArrangingAdditionalPayment')\"\r\n >\r\n {{ 'order.arrange-additional-payment' | translate }}\r\n </button>\r\n <button class=\"btn btn-primary\" (click)=\"fulfillOrder()\" [disabled]=\"!canAddFulfillment(order)\">\r\n {{ 'order.fulfill-order' | translate }}\r\n </button>\r\n <vdr-dropdown>\r\n <button class=\"icon-button\" vdrDropdownTrigger>\r\n <clr-icon shape=\"ellipsis-vertical\"></clr-icon>\r\n </button>\r\n <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n <ng-container *ngIf=\"order.nextStates.includes('Modifying')\">\r\n <button type=\"button\" class=\"btn\" vdrDropdownItem (click)=\"transitionToModifying()\">\r\n <clr-icon shape=\"pencil\"></clr-icon>\r\n {{ 'order.modify-order' | translate }}\r\n </button>\r\n <div class=\"dropdown-divider\"></div>\r\n </ng-container>\r\n <button\r\n type=\"button\"\r\n class=\"btn\"\r\n vdrDropdownItem\r\n *ngIf=\"order.nextStates.includes('Cancelled')\"\r\n (click)=\"cancelOrRefund(order)\"\r\n >\r\n <clr-icon shape=\"error-standard\" class=\"is-error\"></clr-icon>\r\n <ng-container *ngIf=\"orderHasSettledPayments(order); else cancelOnly\">\r\n {{ 'order.refund-and-cancel-order' | translate }}\r\n </ng-container>\r\n <ng-template #cancelOnly>\r\n {{ 'order.cancel-order' | translate }}\r\n </ng-template>\r\n </button>\r\n\r\n <ng-container *ngIf=\"(nextStates$ | async)?.length\">\r\n <div class=\"dropdown-divider\"></div>\r\n <button\r\n *ngFor=\"let nextState of nextStates$ | async\"\r\n type=\"button\"\r\n class=\"btn\"\r\n vdrDropdownItem\r\n (click)=\"transitionToState(nextState)\"\r\n >\r\n <clr-icon shape=\"step-forward-2\"></clr-icon>\r\n {{\r\n 'order.transition-to-state'\r\n | translate: { state: (nextState | stateI18nToken | translate) }\r\n }}\r\n </button>\r\n </ng-container>\r\n <div class=\"dropdown-divider\"></div>\r\n <button type=\"button\" class=\"btn\" vdrDropdownItem (click)=\"manuallyTransitionToState(order)\">\r\n <clr-icon shape=\"step-forward-2\" class=\"is-warning\"></clr-icon>\r\n {{ 'order.manually-transition-to-state' | translate }}\r\n </button>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngIf=\"entity$ | async as order\">\r\n <div class=\"clr-row\">\r\n <div class=\"clr-col-lg-8\">\r\n <vdr-order-table\r\n [order]=\"order\"\r\n [orderLineCustomFields]=\"orderLineCustomFields\"\r\n ></vdr-order-table>\r\n <h4>{{ 'order.tax-summary' | translate }}</h4>\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th>{{ 'common.description' | translate }}</th>\r\n <th>{{ 'order.tax-rate' | translate }}</th>\r\n <th>{{ 'order.tax-base' | translate }}</th>\r\n <th>{{ 'order.tax-total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let row of order.taxSummary\">\r\n <td>{{ row.description }}</td>\r\n <td>{{ row.taxRate / 100 | percent }}</td>\r\n <td>{{ row.taxBase | localeCurrency: order.currencyCode }}</td>\r\n <td>{{ row.taxTotal | localeCurrency: order.currencyCode }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <vdr-custom-detail-component-host\r\n locationId=\"order-detail\"\r\n [entity$]=\"entity$\"\r\n [detailForm]=\"detailForm\"\r\n ></vdr-custom-detail-component-host>\r\n\r\n <vdr-order-history\r\n [order]=\"order\"\r\n [history]=\"history$ | async\"\r\n (addNote)=\"addNote($event)\"\r\n (updateNote)=\"updateNote($event)\"\r\n (deleteNote)=\"deleteNote($event)\"\r\n ></vdr-order-history>\r\n </div>\r\n <div class=\"clr-col-lg-4 order-cards\">\r\n <vdr-order-custom-fields-card\r\n [customFieldsConfig]=\"customFields\"\r\n [customFieldValues]=\"order.customFields\"\r\n (updateClick)=\"updateCustomFields($event)\"\r\n ></vdr-order-custom-fields-card>\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n {{ 'order.customer' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <div class=\"card-text\">\r\n <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\r\n <h6 *ngIf=\"getOrderAddressLines(order.shippingAddress).length\">\r\n {{ 'order.shipping-address' | translate }}\r\n </h6>\r\n <vdr-formatted-address [address]=\"order.shippingAddress\"></vdr-formatted-address>\r\n <h6 *ngIf=\"getOrderAddressLines(order.billingAddress).length\">\r\n {{ 'order.billing-address' | translate }}\r\n </h6>\r\n <vdr-formatted-address [address]=\"order.billingAddress\"></vdr-formatted-address>\r\n </div>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"order.payments && order.payments.length\">\r\n <vdr-order-payment-card\r\n *ngFor=\"let payment of order.payments\"\r\n [currencyCode]=\"order.currencyCode\"\r\n [payment]=\"payment\"\r\n (settlePayment)=\"settlePayment($event)\"\r\n (transitionPaymentState)=\"transitionPaymentState($event)\"\r\n (settleRefund)=\"settleRefund($event)\"\r\n ></vdr-order-payment-card>\r\n </ng-container>\r\n <ng-container *ngFor=\"let fulfillment of order.fulfillments\">\r\n <vdr-fulfillment-card\r\n [fulfillment]=\"fulfillment\"\r\n [order]=\"order\"\r\n (transitionState)=\"transitionFulfillment(fulfillment.id, $event)\"\r\n ></vdr-fulfillment-card>\r\n </ng-container>\r\n </div>\r\n </div>\r\n</div>\r\n",
1811
+ template: "<vdr-action-bar *ngIf=\"entity$ | async as order\">\r\n <vdr-ab-left>\r\n <div class=\"flex clr-align-items-center\">\r\n <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n <vdr-order-state-label [state]=\"order.state\">\r\n <button\r\n class=\"icon-button\"\r\n (click)=\"openStateDiagram()\"\r\n [title]=\"'order.order-state-diagram' | translate\"\r\n >\r\n <clr-icon shape=\"list\"></clr-icon>\r\n </button>\r\n </vdr-order-state-label>\r\n </div>\r\n </vdr-ab-left>\r\n\r\n <vdr-ab-right>\r\n <vdr-action-bar-items locationId=\"order-detail\"></vdr-action-bar-items>\r\n <button\r\n class=\"btn btn-primary\"\r\n *ngIf=\"\r\n (order.state === 'ArrangingPayment' || order.state === 'ArrangingAdditionalPayment') &&\r\n (hasUnsettledModifications(order) || 0 < outstandingPaymentAmount(order))\r\n \"\r\n (click)=\"addManualPayment(order)\"\r\n >\r\n {{ 'order.add-payment-to-order' | translate }}\r\n ({{ outstandingPaymentAmount(order) | localeCurrency: order.currencyCode }})\r\n </button>\r\n <button\r\n class=\"btn btn-primary\"\r\n *ngIf=\"\r\n order.active === false &&\r\n order.state !== 'ArrangingAdditionalPayment' &&\r\n order.state !== 'ArrangingPayment' &&\r\n 0 < outstandingPaymentAmount(order)\r\n \"\r\n (click)=\"transitionToState('ArrangingAdditionalPayment')\"\r\n >\r\n {{ 'order.arrange-additional-payment' | translate }}\r\n </button>\r\n <button class=\"btn btn-primary\" (click)=\"fulfillOrder()\" [disabled]=\"!canAddFulfillment(order)\">\r\n {{ 'order.fulfill-order' | translate }}\r\n </button>\r\n <vdr-dropdown>\r\n <button class=\"icon-button\" vdrDropdownTrigger>\r\n <clr-icon shape=\"ellipsis-vertical\"></clr-icon>\r\n </button>\r\n <vdr-dropdown-menu vdrPosition=\"bottom-right\">\r\n <ng-container *ngIf=\"order.nextStates.includes('Modifying')\">\r\n <button type=\"button\" class=\"btn\" vdrDropdownItem (click)=\"transitionToModifying()\">\r\n <clr-icon shape=\"pencil\"></clr-icon>\r\n {{ 'order.modify-order' | translate }}\r\n </button>\r\n <div class=\"dropdown-divider\"></div>\r\n </ng-container>\r\n <button\r\n type=\"button\"\r\n class=\"btn\"\r\n vdrDropdownItem\r\n *ngIf=\"order.nextStates.includes('Cancelled')\"\r\n (click)=\"cancelOrRefund(order)\"\r\n >\r\n <clr-icon shape=\"error-standard\" class=\"is-error\"></clr-icon>\r\n <ng-container *ngIf=\"orderHasSettledPayments(order); else cancelOnly\">\r\n {{ 'order.refund-and-cancel-order' | translate }}\r\n </ng-container>\r\n <ng-template #cancelOnly>\r\n {{ 'order.cancel-order' | translate }}\r\n </ng-template>\r\n </button>\r\n\r\n <ng-container *ngIf=\"(nextStates$ | async)?.length\">\r\n <div class=\"dropdown-divider\"></div>\r\n <button\r\n *ngFor=\"let nextState of nextStates$ | async\"\r\n type=\"button\"\r\n class=\"btn\"\r\n vdrDropdownItem\r\n (click)=\"transitionToState(nextState)\"\r\n >\r\n <clr-icon shape=\"step-forward-2\"></clr-icon>\r\n {{\r\n 'order.transition-to-state'\r\n | translate: { state: (nextState | stateI18nToken | translate) }\r\n }}\r\n </button>\r\n </ng-container>\r\n <div class=\"dropdown-divider\"></div>\r\n <button type=\"button\" class=\"btn\" vdrDropdownItem (click)=\"manuallyTransitionToState(order)\">\r\n <clr-icon shape=\"step-forward-2\" class=\"is-warning\"></clr-icon>\r\n {{ 'order.manually-transition-to-state' | translate }}\r\n </button>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngIf=\"entity$ | async as order\">\r\n <div class=\"clr-row\">\r\n <div class=\"clr-col-lg-8\">\r\n <vdr-order-table\r\n [order]=\"order\"\r\n [orderLineCustomFields]=\"orderLineCustomFields\"\r\n ></vdr-order-table>\r\n <h4>{{ 'order.tax-summary' | translate }}</h4>\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th>{{ 'common.description' | translate }}</th>\r\n <th>{{ 'order.tax-rate' | translate }}</th>\r\n <th>{{ 'order.tax-base' | translate }}</th>\r\n <th>{{ 'order.tax-total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr *ngFor=\"let row of order.taxSummary\">\r\n <td>{{ row.description }}</td>\r\n <td>{{ row.taxRate / 100 | percent }}</td>\r\n <td>{{ row.taxBase | localeCurrency: order.currencyCode }}</td>\r\n <td>{{ row.taxTotal | localeCurrency: order.currencyCode }}</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <vdr-custom-detail-component-host\r\n locationId=\"order-detail\"\r\n [entity$]=\"entity$\"\r\n [detailForm]=\"detailForm\"\r\n ></vdr-custom-detail-component-host>\r\n\r\n <vdr-order-history\r\n [order]=\"order\"\r\n [history]=\"history$ | async\"\r\n (addNote)=\"addNote($event)\"\r\n (updateNote)=\"updateNote($event)\"\r\n (deleteNote)=\"deleteNote($event)\"\r\n ></vdr-order-history>\r\n </div>\r\n <div class=\"clr-col-lg-4 order-cards\">\r\n <vdr-order-custom-fields-card\r\n [customFieldsConfig]=\"customFields\"\r\n [customFieldValues]=\"order.customFields\"\r\n (updateClick)=\"updateCustomFields($event)\"\r\n ></vdr-order-custom-fields-card>\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n {{ 'order.customer' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <div class=\"card-text\">\r\n <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\r\n <h6 *ngIf=\"getOrderAddressLines(order.shippingAddress).length\">\r\n {{ 'order.shipping-address' | translate }}\r\n </h6>\r\n <vdr-formatted-address [address]=\"order.shippingAddress\"></vdr-formatted-address>\r\n <h6 *ngIf=\"getOrderAddressLines(order.billingAddress).length\">\r\n {{ 'order.billing-address' | translate }}\r\n </h6>\r\n <vdr-formatted-address [address]=\"order.billingAddress\"></vdr-formatted-address>\r\n </div>\r\n </div>\r\n </div>\r\n <ng-container *ngIf=\"order.payments && order.payments.length\">\r\n <vdr-order-payment-card\r\n *ngFor=\"let payment of order.payments\"\r\n [currencyCode]=\"order.currencyCode\"\r\n [payment]=\"payment\"\r\n (settlePayment)=\"settlePayment($event)\"\r\n (transitionPaymentState)=\"transitionPaymentState($event)\"\r\n (settleRefund)=\"settleRefund($event)\"\r\n ></vdr-order-payment-card>\r\n </ng-container>\r\n <ng-container *ngFor=\"let fulfillment of order.fulfillments\">\r\n <vdr-fulfillment-card\r\n [fulfillment]=\"fulfillment\"\r\n [order]=\"order\"\r\n (transitionState)=\"transitionFulfillment(fulfillment.id, $event)\"\r\n ></vdr-fulfillment-card>\r\n </ng-container>\r\n </div>\r\n </div>\r\n</div>\r\n",
1356
1812
  changeDetection: ChangeDetectionStrategy.OnPush,
1357
1813
  styles: [".shipping-address{list-style-type:none;line-height:1.3em}.order-cards h6{margin-top:6px;color:var(--color-text-200)}\n"]
1358
1814
  },] }
@@ -1425,7 +1881,6 @@ class OrderEditorComponent extends BaseDetailComponent {
1425
1881
  this.notificationService = notificationService;
1426
1882
  this.modalService = modalService;
1427
1883
  this.orderTransitionService = orderTransitionService;
1428
- this.couponCodeInput$ = new Subject();
1429
1884
  this.detailForm = new FormGroup({});
1430
1885
  this.couponCodesControl = new FormControl();
1431
1886
  this.modifyOrderInput = {
@@ -1522,11 +1977,6 @@ class OrderEditorComponent extends BaseDetailComponent {
1522
1977
  this.orderLineCustomFieldsFormArray.push(formGroup);
1523
1978
  }
1524
1979
  });
1525
- this.availableCouponCodes$ = concat(this.couponCodeInput$.pipe(distinctUntilChanged(), switchMap(term => this.dataService.promotion.getPromotions(10, 0, {
1526
- couponCode: { contains: term },
1527
- }).single$), map(({ promotions }) =>
1528
- // tslint:disable-next-line:no-non-null-assertion
1529
- promotions.items.map(p => ({ code: p.couponCode, promotionName: p.name }))), startWith([])));
1530
1980
  this.addItemCustomFieldsFormArray = new FormArray([]);
1531
1981
  this.addItemCustomFieldsForm = new FormGroup({});
1532
1982
  for (const customField of this.orderLineCustomFields) {
@@ -1772,9 +2222,9 @@ class OrderEditorComponent extends BaseDetailComponent {
1772
2222
  OrderEditorComponent.decorators = [
1773
2223
  { type: Component, args: [{
1774
2224
  selector: 'vdr-order-editor',
1775
- template: "<vdr-action-bar *ngIf=\"entity$ | async as order\">\r\n <vdr-ab-left>\r\n <div class=\"flex clr-align-items-center\">\r\n <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\r\n </div>\r\n </vdr-ab-left>\r\n\r\n <vdr-ab-right>\r\n <button class=\"btn btn-secondary\" (click)=\"transitionToPriorState(order)\">\r\n {{ 'order.cancel-modification' | translate }}\r\n </button>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngIf=\"entity$ | async as order\">\r\n <div class=\"clr-row\">\r\n <div class=\"clr-col-lg-8\">\r\n <table class=\"order-table table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th *ngIf=\"orderLineCustomFields.length\">{{ 'common.custom-fields' | translate }}</th>\r\n <th>{{ 'order.total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr\r\n *ngFor=\"let line of order.lines; let i = index\"\r\n class=\"order-line\"\r\n [class.is-cancelled]=\"line.quantity === 0\"\r\n [class.modified]=\"isLineModified(line)\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img\r\n *ngIf=\"line.featuredAsset\"\r\n [src]=\"line.featuredAsset | assetPreview: 'tiny'\"\r\n />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.unitPrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n <input\r\n type=\"number\"\r\n min=\"0\"\r\n [value]=\"line.quantity\"\r\n (input)=\"updateLineQuantity(line, $event.target.value)\"\r\n />\r\n <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\r\n <vdr-line-fulfillment\r\n [line]=\"line\"\r\n [orderState]=\"order.state\"\r\n ></vdr-line-fulfillment>\r\n </td>\r\n <td *ngIf=\"orderLineCustomFields.length\" class=\"order-line-custom-field align-middle\">\r\n <vdr-tabbed-custom-fields\r\n entityName=\"OrderLine\"\r\n [customFields]=\"orderLineCustomFields\"\r\n [customFieldsFormGroup]=\"orderLineCustomFieldsFormArray.get([i])\"\r\n [compact]=\"true\"\r\n ></vdr-tabbed-custom-fields>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{ line.linePriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.linePrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr\r\n *ngFor=\"let addedLine of addedLines; trackBy: trackByProductVariantId; let i = index\"\r\n class=\"modified\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img\r\n *ngIf=\"addedLine.productAsset\"\r\n [src]=\"addedLine.productAsset | assetPreview: 'tiny'\"\r\n />\r\n </td>\r\n <td class=\"align-middle name\">{{ addedLine.productVariantName }}</td>\r\n <td class=\"align-middle sku\">{{ addedLine.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ addedLine.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ addedLine.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n <input\r\n type=\"number\"\r\n min=\"0\"\r\n [value]=\"addedLine.quantity\"\r\n (input)=\"updateAddedItemQuantity(addedLine, $event.target.value)\"\r\n />\r\n <button class=\"icon-button\" (click)=\"removeAddedItem(i)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </td>\r\n <td *ngIf=\"orderLineCustomFields.length\" class=\"order-line-custom-field align-middle\">\r\n <ng-container *ngFor=\"let customField of orderLineCustomFields\">\r\n <vdr-custom-field-control\r\n [customField]=\"customField\"\r\n [customFieldsFormGroup]=\"addItemCustomFieldsFormArray.get([i])\"\r\n entityName=\"OrderLine\"\r\n [compact]=\"true\"\r\n ></vdr-custom-field-control>\r\n </ng-container>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{\r\n (addedLine.priceWithTax * addedLine.quantity) / 100\r\n | currency: order.currencyCode\r\n }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{\r\n (addedLine.price * addedLine.quantity) / 100\r\n | currency: order.currencyCode\r\n }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"surcharge\" *ngFor=\"let surcharge of order.surcharges\">\r\n <td class=\"align-middle name left\" colspan=\"2\">{{ surcharge.description }}</td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\"></td>\r\n <td></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"align-middle total\">\r\n {{ surcharge.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surcharge.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr\r\n class=\"surcharge modified\"\r\n *ngFor=\"let surcharge of modifyOrderInput.surcharges; let i = index\"\r\n >\r\n <td class=\"align-middle name left\" colspan=\"2\">\r\n {{ surcharge.description }}\r\n <button class=\"icon-button\" (click)=\"removeSurcharge(i)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\"></td>\r\n <td></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"align-middle total\">\r\n <ng-container *ngIf=\"getSurchargePrices(surcharge) as surchargePrice\">\r\n {{ surchargePrice.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surchargePrice.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </ng-container>\r\n </td>\r\n </tr>\r\n <tr class=\"shipping\">\r\n <td class=\"left clr-align-middle\">{{ 'order.shipping' | translate }}</td>\r\n <td class=\"clr-align-middle\">{{ order.shippingLines[0]?.shippingMethod?.name }}</td>\r\n <td colspan=\"3\"></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.shippingWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.shipping | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <h4 class=\"mb2\">{{ 'order.modifications' | translate }}</h4>\r\n <clr-accordion>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.add-item-to-order' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-product-selector class=\"mb4\" (productSelected)=\"addItemSelectedVariant = $event\">\r\n </vdr-product-selector>\r\n <div *ngIf=\"addItemSelectedVariant\" class=\"flex mb4\">\r\n <img\r\n *ngIf=\"addItemSelectedVariant.productAsset as asset\"\r\n [src]=\"asset | assetPreview: 'tiny'\"\r\n class=\"mr4\"\r\n />\r\n <div>\r\n <strong class=\"mr4\">{{ addItemSelectedVariant.productVariantName }}</strong>\r\n <small>{{ addItemSelectedVariant.sku }}</small>\r\n <div>\r\n {{\r\n getSelectedItemPrice(addItemSelectedVariant)\r\n | localeCurrency: order.currencyCode\r\n }}\r\n </div>\r\n </div>\r\n </div>\r\n <ng-container *ngFor=\"let customField of orderLineCustomFields\">\r\n <vdr-custom-field-control\r\n [readonly]=\"!addItemSelectedVariant\"\r\n [customField]=\"customField\"\r\n [customFieldsFormGroup]=\"addItemCustomFieldsForm\"\r\n entityName=\"OrderLine\"\r\n [compact]=\"true\"\r\n ></vdr-custom-field-control>\r\n </ng-container>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"!addItemSelectedVariant || addItemCustomFieldsForm.invalid\"\r\n (click)=\"addItemToOrder(addItemSelectedVariant)\"\r\n >\r\n {{ 'order.add-item-to-order' | translate }}\r\n </button>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.set-coupon-codes' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <ng-select\r\n [items]=\"availableCouponCodes$ | async\"\r\n appendTo=\"body\"\r\n bindLabel=\"code\"\r\n bindValue=\"code\"\r\n [addTag]=\"false\"\r\n [multiple]=\"true\"\r\n [hideSelected]=\"true\"\r\n [minTermLength]=\"2\"\r\n typeToSearchText=\"\"\r\n [typeahead]=\"couponCodeInput$\"\r\n [formControl]=\"couponCodesControl\"\r\n >\r\n <ng-template ng-option-tmp let-item=\"item\">\r\n <vdr-chip>{{ item.code }}</vdr-chip>\r\n {{ item.promotionName }}\r\n </ng-template>\r\n </ng-select>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.add-surcharge' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <form [formGroup]=\"surchargeForm\" (submit)=\"addSurcharge(surchargeForm.value)\">\r\n <vdr-form-field [label]=\"'common.description' | translate\" for=\"description\"\r\n ><input id=\"description\" type=\"text\" formControlName=\"description\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'order.product-sku' | translate\" for=\"sku\"\r\n ><input id=\"sku\" type=\"text\" formControlName=\"sku\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'common.price' | translate\" for=\"price\">\r\n <vdr-currency-input\r\n [currencyCode]=\"order.currencyCode\"\r\n id=\"price\"\r\n formControlName=\"price\"\r\n ></vdr-currency-input>\r\n </vdr-form-field>\r\n <vdr-form-field\r\n [label]=\"\r\n 'catalog.price-includes-tax-at'\r\n | translate: { rate: surchargeForm.get('taxRate')?.value }\r\n \"\r\n for=\"priceIncludesTax\"\r\n ><input\r\n id=\"priceIncludesTax\"\r\n type=\"checkbox\"\r\n clrCheckbox\r\n formControlName=\"priceIncludesTax\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'order.tax-rate' | translate\" for=\"taxRate\">\r\n <vdr-affixed-input suffix=\"%\"\r\n ><input\r\n id=\"taxRate\"\r\n type=\"number\"\r\n min=\"0\"\r\n max=\"100\"\r\n formControlName=\"taxRate\"\r\n /></vdr-affixed-input>\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'order.tax-description' | translate\" for=\"taxDescription\"\r\n ><input id=\"taxDescription\" type=\"text\" formControlName=\"taxDescription\"\r\n /></vdr-form-field>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"\r\n surchargeForm.invalid ||\r\n surchargeForm.pristine ||\r\n surchargeForm.get('price')?.value === 0\r\n \"\r\n >\r\n {{ 'order.add-surcharge' | translate }}\r\n </button>\r\n </form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.edit-shipping-address' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-address-form\r\n [formGroup]=\"shippingAddressForm\"\r\n [availableCountries]=\"availableCountries$ | async\"\r\n [customFields]=\"addressCustomFields\"\r\n ></vdr-address-form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.edit-billing-address' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-address-form\r\n [formGroup]=\"billingAddressForm\"\r\n [availableCountries]=\"availableCountries$ | async\"\r\n [customFields]=\"addressCustomFields\"\r\n ></vdr-address-form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n </clr-accordion>\r\n </div>\r\n <div class=\"clr-col-lg-4 order-cards\">\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n {{ 'order.modification-summary' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <ul>\r\n <li *ngIf=\"modifyOrderInput.addItems?.length\">\r\n {{\r\n 'order.modification-adding-items'\r\n | translate: { count: modifyOrderInput.addItems?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"modifyOrderInput.adjustOrderLines?.length\">\r\n {{\r\n 'order.modification-adjusting-lines'\r\n | translate: { count: modifyOrderInput.adjustOrderLines?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"modifyOrderInput.surcharges?.length\">\r\n {{\r\n 'order.modification-adding-surcharges'\r\n | translate: { count: modifyOrderInput.surcharges?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"shippingAddressForm.dirty\">\r\n {{ 'order.modification-updating-shipping-address' | translate }}\r\n </li>\r\n <li *ngIf=\"billingAddressForm.dirty\">\r\n {{ 'order.modification-updating-billing-address' | translate }}\r\n </li>\r\n </ul>\r\n </div>\r\n <div class=\"card-block\">\r\n <label class=\"clr-control-label\">{{ 'order.note' | translate }}</label>\r\n <textarea [(ngModel)]=\"note\" name=\"note\" clrTextarea required></textarea>\r\n <clr-checkbox-wrapper class=\"\">\r\n <input type=\"checkbox\" clrCheckbox [(ngModel)]=\"recalculateShipping\" />\r\n <label>{{ 'order.modification-recalculate-shipping' | translate }}</label>\r\n </clr-checkbox-wrapper>\r\n </div>\r\n <div class=\"card-footer\">\r\n <button\r\n class=\"btn btn-primary\"\r\n [disabled]=\"!canPreviewChanges()\"\r\n (click)=\"previewAndModify(order)\"\r\n >\r\n {{ 'order.preview-changes' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n",
2225
+ template: "<vdr-action-bar *ngIf=\"entity$ | async as order\">\r\n <vdr-ab-left>\r\n <div class=\"flex clr-align-items-center\">\r\n <vdr-entity-info [entity]=\"entity$ | async\"></vdr-entity-info>\r\n <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\r\n </div>\r\n </vdr-ab-left>\r\n\r\n <vdr-ab-right>\r\n <button class=\"btn btn-secondary\" (click)=\"transitionToPriorState(order)\">\r\n {{ 'order.cancel-modification' | translate }}\r\n </button>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngIf=\"entity$ | async as order\">\r\n <div class=\"clr-row\">\r\n <div class=\"clr-col-lg-8\">\r\n <table class=\"order-table table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th *ngIf=\"orderLineCustomFields.length\">{{ 'common.custom-fields' | translate }}</th>\r\n <th>{{ 'order.total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr\r\n *ngFor=\"let line of order.lines; let i = index\"\r\n class=\"order-line\"\r\n [class.is-cancelled]=\"line.quantity === 0\"\r\n [class.modified]=\"isLineModified(line)\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img\r\n *ngIf=\"line.featuredAsset\"\r\n [src]=\"line.featuredAsset | assetPreview: 'tiny'\"\r\n />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.unitPrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n <input\r\n type=\"number\"\r\n min=\"0\"\r\n [value]=\"line.quantity\"\r\n (input)=\"updateLineQuantity(line, $event.target.value)\"\r\n />\r\n <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\r\n <vdr-line-fulfillment\r\n [line]=\"line\"\r\n [orderState]=\"order.state\"\r\n ></vdr-line-fulfillment>\r\n </td>\r\n <td *ngIf=\"orderLineCustomFields.length\" class=\"order-line-custom-field align-middle\">\r\n <vdr-tabbed-custom-fields\r\n entityName=\"OrderLine\"\r\n [customFields]=\"orderLineCustomFields\"\r\n [customFieldsFormGroup]=\"orderLineCustomFieldsFormArray.get([i])\"\r\n [compact]=\"true\"\r\n ></vdr-tabbed-custom-fields>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{ line.linePriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.linePrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr\r\n *ngFor=\"let addedLine of addedLines; trackBy: trackByProductVariantId; let i = index\"\r\n class=\"modified\"\r\n >\r\n <td class=\"align-middle thumb\">\r\n <img\r\n *ngIf=\"addedLine.productAsset\"\r\n [src]=\"addedLine.productAsset | assetPreview: 'tiny'\"\r\n />\r\n </td>\r\n <td class=\"align-middle name\">{{ addedLine.productVariantName }}</td>\r\n <td class=\"align-middle sku\">{{ addedLine.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ addedLine.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ addedLine.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n <input\r\n type=\"number\"\r\n min=\"0\"\r\n [value]=\"addedLine.quantity\"\r\n (input)=\"updateAddedItemQuantity(addedLine, $event.target.value)\"\r\n />\r\n <button class=\"icon-button\" (click)=\"removeAddedItem(i)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </td>\r\n <td *ngIf=\"orderLineCustomFields.length\" class=\"order-line-custom-field align-middle\">\r\n <ng-container *ngFor=\"let customField of orderLineCustomFields\">\r\n <vdr-custom-field-control\r\n [customField]=\"customField\"\r\n [customFieldsFormGroup]=\"addItemCustomFieldsFormArray.get([i])\"\r\n entityName=\"OrderLine\"\r\n [compact]=\"true\"\r\n ></vdr-custom-field-control>\r\n </ng-container>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{\r\n (addedLine.priceWithTax * addedLine.quantity) / 100\r\n | currency: order.currencyCode\r\n }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{\r\n (addedLine.price * addedLine.quantity) / 100\r\n | currency: order.currencyCode\r\n }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"surcharge\" *ngFor=\"let surcharge of order.surcharges\">\r\n <td class=\"align-middle name left\" colspan=\"2\">{{ surcharge.description }}</td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\"></td>\r\n <td></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"align-middle total\">\r\n {{ surcharge.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surcharge.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr\r\n class=\"surcharge modified\"\r\n *ngFor=\"let surcharge of modifyOrderInput.surcharges; let i = index\"\r\n >\r\n <td class=\"align-middle name left\" colspan=\"2\">\r\n {{ surcharge.description }}\r\n <button class=\"icon-button\" (click)=\"removeSurcharge(i)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\"></td>\r\n <td></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"align-middle total\">\r\n <ng-container *ngIf=\"getSurchargePrices(surcharge) as surchargePrice\">\r\n {{ surchargePrice.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surchargePrice.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </ng-container>\r\n </td>\r\n </tr>\r\n <tr class=\"shipping\">\r\n <td class=\"left clr-align-middle\">{{ 'order.shipping' | translate }}</td>\r\n <td class=\"clr-align-middle\">{{ order.shippingLines[0]?.shippingMethod?.name }}</td>\r\n <td colspan=\"3\"></td>\r\n <td *ngIf=\"orderLineCustomFields.length\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.shippingWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.shipping | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n\r\n <h4 class=\"mb2\">{{ 'order.modifications' | translate }}</h4>\r\n <clr-accordion>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.add-item-to-order' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-product-selector class=\"mb4\" (productSelected)=\"addItemSelectedVariant = $event\">\r\n </vdr-product-selector>\r\n <div *ngIf=\"addItemSelectedVariant\" class=\"flex mb4\">\r\n <img\r\n *ngIf=\"addItemSelectedVariant.productAsset as asset\"\r\n [src]=\"asset | assetPreview: 'tiny'\"\r\n class=\"mr4\"\r\n />\r\n <div>\r\n <strong class=\"mr4\">{{ addItemSelectedVariant.productVariantName }}</strong>\r\n <small>{{ addItemSelectedVariant.sku }}</small>\r\n <div>\r\n {{\r\n getSelectedItemPrice(addItemSelectedVariant)\r\n | localeCurrency: order.currencyCode\r\n }}\r\n </div>\r\n </div>\r\n </div>\r\n <ng-container *ngFor=\"let customField of orderLineCustomFields\">\r\n <vdr-custom-field-control\r\n [readonly]=\"!addItemSelectedVariant\"\r\n [customField]=\"customField\"\r\n [customFieldsFormGroup]=\"addItemCustomFieldsForm\"\r\n entityName=\"OrderLine\"\r\n [compact]=\"true\"\r\n ></vdr-custom-field-control>\r\n </ng-container>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"!addItemSelectedVariant || addItemCustomFieldsForm.invalid\"\r\n (click)=\"addItemToOrder(addItemSelectedVariant)\"\r\n >\r\n {{ 'order.add-item-to-order' | translate }}\r\n </button>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.set-coupon-codes' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-coupon-code-selector\r\n [control]=\"couponCodesControl\"\r\n ></vdr-coupon-code-selector>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.add-surcharge' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <form [formGroup]=\"surchargeForm\" (submit)=\"addSurcharge(surchargeForm.value)\">\r\n <vdr-form-field [label]=\"'common.description' | translate\" for=\"description\"\r\n ><input id=\"description\" type=\"text\" formControlName=\"description\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'order.product-sku' | translate\" for=\"sku\"\r\n ><input id=\"sku\" type=\"text\" formControlName=\"sku\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'common.price' | translate\" for=\"price\">\r\n <vdr-currency-input\r\n [currencyCode]=\"order.currencyCode\"\r\n id=\"price\"\r\n formControlName=\"price\"\r\n ></vdr-currency-input>\r\n </vdr-form-field>\r\n <vdr-form-field\r\n [label]=\"\r\n 'catalog.price-includes-tax-at'\r\n | translate: { rate: surchargeForm.get('taxRate')?.value }\r\n \"\r\n for=\"priceIncludesTax\"\r\n ><input\r\n id=\"priceIncludesTax\"\r\n type=\"checkbox\"\r\n clrCheckbox\r\n formControlName=\"priceIncludesTax\"\r\n /></vdr-form-field>\r\n <vdr-form-field [label]=\"'order.tax-rate' | translate\" for=\"taxRate\">\r\n <vdr-affixed-input suffix=\"%\"\r\n ><input\r\n id=\"taxRate\"\r\n type=\"number\"\r\n min=\"0\"\r\n max=\"100\"\r\n formControlName=\"taxRate\"\r\n /></vdr-affixed-input>\r\n </vdr-form-field>\r\n <vdr-form-field [label]=\"'order.tax-description' | translate\" for=\"taxDescription\"\r\n ><input id=\"taxDescription\" type=\"text\" formControlName=\"taxDescription\"\r\n /></vdr-form-field>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"\r\n surchargeForm.invalid ||\r\n surchargeForm.pristine ||\r\n surchargeForm.get('price')?.value === 0\r\n \"\r\n >\r\n {{ 'order.add-surcharge' | translate }}\r\n </button>\r\n </form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.edit-shipping-address' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-address-form\r\n [formGroup]=\"shippingAddressForm\"\r\n [availableCountries]=\"availableCountries$ | async\"\r\n [customFields]=\"addressCustomFields\"\r\n ></vdr-address-form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n <clr-accordion-panel>\r\n <clr-accordion-title>{{ 'order.edit-billing-address' | translate }}</clr-accordion-title>\r\n <clr-accordion-content *clrIfExpanded>\r\n <vdr-address-form\r\n [formGroup]=\"billingAddressForm\"\r\n [availableCountries]=\"availableCountries$ | async\"\r\n [customFields]=\"addressCustomFields\"\r\n ></vdr-address-form>\r\n </clr-accordion-content>\r\n </clr-accordion-panel>\r\n </clr-accordion>\r\n </div>\r\n <div class=\"clr-col-lg-4 order-cards\">\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n {{ 'order.modification-summary' | translate }}\r\n </div>\r\n <div class=\"card-block\">\r\n <ul>\r\n <li *ngIf=\"modifyOrderInput.addItems?.length\">\r\n {{\r\n 'order.modification-adding-items'\r\n | translate: { count: modifyOrderInput.addItems?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"modifyOrderInput.adjustOrderLines?.length\">\r\n {{\r\n 'order.modification-adjusting-lines'\r\n | translate: { count: modifyOrderInput.adjustOrderLines?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"modifyOrderInput.surcharges?.length\">\r\n {{\r\n 'order.modification-adding-surcharges'\r\n | translate: { count: modifyOrderInput.surcharges?.length }\r\n }}\r\n </li>\r\n <li *ngIf=\"shippingAddressForm.dirty\">\r\n {{ 'order.modification-updating-shipping-address' | translate }}\r\n </li>\r\n <li *ngIf=\"billingAddressForm.dirty\">\r\n {{ 'order.modification-updating-billing-address' | translate }}\r\n </li>\r\n </ul>\r\n </div>\r\n <div class=\"card-block\">\r\n <label class=\"clr-control-label\">{{ 'order.note' | translate }}</label>\r\n <textarea [(ngModel)]=\"note\" name=\"note\" clrTextarea required></textarea>\r\n <clr-checkbox-wrapper class=\"\">\r\n <input type=\"checkbox\" clrCheckbox [(ngModel)]=\"recalculateShipping\" />\r\n <label>{{ 'order.modification-recalculate-shipping' | translate }}</label>\r\n </clr-checkbox-wrapper>\r\n </div>\r\n <div class=\"card-footer\">\r\n <button\r\n class=\"btn btn-primary\"\r\n [disabled]=\"!canPreviewChanges()\"\r\n (click)=\"previewAndModify(order)\"\r\n >\r\n {{ 'order.preview-changes' | translate }}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n",
1776
2226
  changeDetection: ChangeDetectionStrategy.OnPush,
1777
- styles: [".order-table .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.order-table .sub-total td{border-top:1px dashed var(--color-component-border-200)}.order-table .total td{font-weight:bold;border-top:1px dashed var(--color-component-border-200)}.order-table td.custom-fields-row{border-top-style:dashed;border-top-color:var(--color-grey-200)}.order-table .order-line-custom-fields{display:flex;flex-wrap:wrap}.order-table .order-line-custom-fields .custom-field{text-align:start;max-width:200px;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px;margin-right:18px}.order-table .order-line-custom-field{background-color:var(--color-component-bg-100)}.order-table .order-line-custom-field .custom-field-ellipsis{color:var(--color-text-300)}.order-table .net-price{font-size:11px;color:var(--color-text-300)}.order-table .promotions-label{-webkit-text-decoration:underline dotted var(--color-text-200);text-decoration:underline dotted var(--color-text-200);font-size:11px;margin-top:6px;cursor:pointer;text-transform:lowercase}.order-table .thumb img{width:50px;height:50px}.order-table tr.modified td{background-color:var(--color-warning-100)}.order-table .order-line-custom-field{text-align:start}\n"]
2227
+ styles: [".order-table .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.order-table .sub-total td{border-top:1px dashed var(--color-component-border-200)}.order-table .total td{font-weight:bold;border-top:1px dashed var(--color-component-border-200)}.order-table td.custom-fields-row{border-top-style:dashed;border-top-color:var(--color-grey-200)}.order-table img{border-radius:var(--border-radius-img)}.order-table .order-line-custom-fields{display:flex;flex-wrap:wrap}.order-table .order-line-custom-fields .custom-field{text-align:start;max-width:200px;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px;margin-right:18px}.order-table .draft-qty{max-width:48px}.order-table .order-line-custom-field{background-color:var(--color-component-bg-100)}.order-table .order-line-custom-field .custom-field-ellipsis{color:var(--color-text-300)}.order-table .net-price{font-size:11px;color:var(--color-text-300)}.order-table .promotions-label{-webkit-text-decoration:underline dotted var(--color-text-200);text-decoration:underline dotted var(--color-text-200);font-size:11px;margin-top:6px;cursor:pointer;text-transform:lowercase}.order-table .thumb img{width:50px;height:50px}.order-table tr.modified td{background-color:var(--color-warning-100)}.order-table .order-line-custom-field{text-align:start}\n"]
1778
2228
  },] }
1779
2229
  ];
1780
2230
  OrderEditorComponent.ctorParameters = () => [
@@ -1942,6 +2392,7 @@ OrderHistoryComponent.propDecorators = {
1942
2392
 
1943
2393
  class OrderListComponent extends BaseListComponent {
1944
2394
  constructor(serverConfigService, dataService, localStorageService, router, route) {
2395
+ var _a;
1945
2396
  super(router, route);
1946
2397
  this.serverConfigService = serverConfigService;
1947
2398
  this.dataService = dataService;
@@ -1956,7 +2407,7 @@ class OrderListComponent extends BaseListComponent {
1956
2407
  label: marker('order.filter-preset-open'),
1957
2408
  config: {
1958
2409
  active: false,
1959
- states: this.orderStates.filter(s => s !== 'Delivered' && s !== 'Cancelled' && s !== 'Shipped'),
2410
+ states: this.orderStates.filter(s => s !== 'Delivered' && s !== 'Cancelled' && s !== 'Shipped' && s !== 'Draft'),
1960
2411
  },
1961
2412
  },
1962
2413
  {
@@ -1982,7 +2433,16 @@ class OrderListComponent extends BaseListComponent {
1982
2433
  active: true,
1983
2434
  },
1984
2435
  },
2436
+ {
2437
+ name: 'draft',
2438
+ label: marker('order.filter-preset-draft'),
2439
+ config: {
2440
+ active: false,
2441
+ states: ['Draft'],
2442
+ },
2443
+ },
1985
2444
  ];
2445
+ this.canCreateDraftOrder = false;
1986
2446
  super.setQueryFn(
1987
2447
  // tslint:disable-next-line:no-shadowed-variable
1988
2448
  (take, skip) => this.dataService.order.getOrders({ take, skip }).refetchOnChannelChange(), data => data.orders,
@@ -1992,6 +2452,12 @@ class OrderListComponent extends BaseListComponent {
1992
2452
  if (lastFilters) {
1993
2453
  this.setQueryParam(lastFilters, { replaceUrl: true });
1994
2454
  }
2455
+ this.canCreateDraftOrder = !!((_a = this.serverConfigService
2456
+ .getOrderProcessStates()
2457
+ .find(state => state.name === 'Created')) === null || _a === void 0 ? void 0 : _a.to.includes('Draft'));
2458
+ if (!this.canCreateDraftOrder) {
2459
+ this.filterPresets = this.filterPresets.filter(p => p.name !== 'draft');
2460
+ }
1995
2461
  }
1996
2462
  ngOnInit() {
1997
2463
  var _a;
@@ -2115,9 +2581,9 @@ class OrderListComponent extends BaseListComponent {
2115
2581
  OrderListComponent.decorators = [
2116
2582
  { type: Component, args: [{
2117
2583
  selector: 'vdr-order-list',
2118
- template: "<vdr-action-bar>\r\n <vdr-ab-left>\r\n <div class=\"search-form\">\r\n <div class=\"btn-group btn-outline-primary\" *ngIf=\"activePreset$ | async as activePreset\">\r\n <button\r\n class=\"btn\"\r\n *ngFor=\"let preset of filterPresets\"\r\n [class.btn-primary]=\"activePreset === preset.name\"\r\n (click)=\"selectFilterPreset(preset.name)\"\r\n >\r\n {{ preset.label | translate }}\r\n </button>\r\n <button\r\n class=\"btn\"\r\n [class.btn-primary]=\"activePreset === 'custom'\"\r\n (click)=\"selectFilterPreset('custom')\"\r\n >\r\n {{ 'order.filter-custom' | translate }}\r\n <clr-icon shape=\"angle down\"></clr-icon>\r\n </button>\r\n </div>\r\n <input\r\n type=\"text\"\r\n name=\"searchTerm\"\r\n [formControl]=\"searchControl\"\r\n [placeholder]=\"'order.search-by-order-filters' | translate\"\r\n class=\"search-input\"\r\n />\r\n </div>\r\n <div class=\"custom-filters\" [class.expanded]=\"(activePreset$ | async) === 'custom'\">\r\n <form [formGroup]=\"customFilterForm\">\r\n <div class=\"flex align-center\">\r\n <ng-select\r\n [items]=\"orderStates\"\r\n appendTo=\"body\"\r\n [addTag]=\"false\"\r\n [multiple]=\"true\"\r\n formControlName=\"states\"\r\n [placeholder]=\"'state.all-orders' | translate\"\r\n [clearable]=\"true\"\r\n [searchable]=\"false\"\r\n >\r\n <ng-template ng-option-tmp let-item=\"item\">{{ item | stateI18nToken | translate }}</ng-template>\r\n <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n <span class=\"ng-value-label\"> {{ item | stateI18nToken | translate }}</span>\r\n <span class=\"ng-value-icon right\" (click)=\"clear(item)\" aria-hidden=\"true\">\u00D7</span>\r\n </ng-template>\r\n </ng-select>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"customFilterForm.pristine\"\r\n (click)=\"applyCustomFilters()\"\r\n >\r\n {{ 'order.apply-filters' | translate }}\r\n <clr-icon shape=\"filter\"></clr-icon>\r\n </button>\r\n </div>\r\n <div class=\"flex\">\r\n <div>\r\n <label>{{ 'order.placed-at-start' | translate }}</label>\r\n <vdr-datetime-picker formControlName=\"placedAtStart\"></vdr-datetime-picker>\r\n </div>\r\n <div>\r\n <label>{{ 'order.placed-at-end' | translate }}</label>\r\n <vdr-datetime-picker formControlName=\"placedAtEnd\"></vdr-datetime-picker>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n </vdr-ab-left>\r\n <vdr-ab-right>\r\n <vdr-action-bar-items locationId=\"order-list\"></vdr-action-bar-items>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<vdr-data-table\r\n [items]=\"items$ | async\"\r\n [itemsPerPage]=\"itemsPerPage$ | async\"\r\n [totalItems]=\"totalItems$ | async\"\r\n [currentPage]=\"currentPage$ | async\"\r\n (pageChange)=\"setPageNumber($event)\"\r\n (itemsPerPageChange)=\"setItemsPerPage($event)\"\r\n>\r\n <vdr-dt-column>{{ 'common.code' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.customer' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.state' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.total' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'common.updated-at' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.placed-at' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.shipping' | translate }}</vdr-dt-column>\r\n <vdr-dt-column></vdr-dt-column>\r\n <ng-template let-order=\"item\">\r\n <td class=\"left align-middle\">{{ order.code }}</td>\r\n <td class=\"left align-middle\">\r\n <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\r\n </td>\r\n <td class=\"left align-middle\">\r\n <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\r\n </td>\r\n <td class=\"left align-middle\">{{ order.totalWithTax | localeCurrency: order.currencyCode }}</td>\r\n <td class=\"left align-middle\">{{ order.updatedAt | timeAgo }}</td>\r\n <td class=\"left align-middle\">{{ order.orderPlacedAt | localeDate: 'medium' }}</td>\r\n <td class=\"left align-middle\">{{ getShippingNames(order) }}</td>\r\n <td class=\"right align-middle\">\r\n <vdr-table-row-action\r\n iconShape=\"shopping-cart\"\r\n [label]=\"'common.open' | translate\"\r\n [linkTo]=\"order.state === 'Modifying' ? ['./', order.id, 'modify'] : ['./', order.id]\"\r\n ></vdr-table-row-action>\r\n </td>\r\n </ng-template>\r\n</vdr-data-table>\r\n",
2584
+ template: "<vdr-action-bar>\r\n <vdr-ab-left>\r\n <div class=\"search-form\">\r\n <div class=\"filter-presets btn-group btn-outline-primary\" *ngIf=\"activePreset$ | async as activePreset\">\r\n <button\r\n class=\"btn\"\r\n *ngFor=\"let preset of filterPresets\"\r\n [class.btn-primary]=\"activePreset === preset.name\"\r\n (click)=\"selectFilterPreset(preset.name)\"\r\n >\r\n {{ preset.label | translate }}\r\n </button>\r\n <button\r\n class=\"btn\"\r\n [class.btn-primary]=\"activePreset === 'custom'\"\r\n (click)=\"selectFilterPreset('custom')\"\r\n >\r\n {{ 'order.filter-custom' | translate }}\r\n <clr-icon shape=\"angle down\"></clr-icon>\r\n </button>\r\n </div>\r\n <input\r\n type=\"text\"\r\n name=\"searchTerm\"\r\n [formControl]=\"searchControl\"\r\n [placeholder]=\"'order.search-by-order-filters' | translate\"\r\n class=\"search-input\"\r\n />\r\n </div>\r\n <div class=\"custom-filters\" [class.expanded]=\"(activePreset$ | async) === 'custom'\">\r\n <form [formGroup]=\"customFilterForm\">\r\n <div class=\"flex align-center\">\r\n <ng-select\r\n [items]=\"orderStates\"\r\n appendTo=\"body\"\r\n [addTag]=\"false\"\r\n [multiple]=\"true\"\r\n formControlName=\"states\"\r\n [placeholder]=\"'state.all-orders' | translate\"\r\n [clearable]=\"true\"\r\n [searchable]=\"false\"\r\n >\r\n <ng-template ng-option-tmp let-item=\"item\">{{\r\n item | stateI18nToken | translate\r\n }}</ng-template>\r\n <ng-template ng-label-tmp let-item=\"item\" let-clear=\"clear\">\r\n <span class=\"ng-value-label\"> {{ item | stateI18nToken | translate }}</span>\r\n <span class=\"ng-value-icon right\" (click)=\"clear(item)\" aria-hidden=\"true\"\r\n >\u00D7</span\r\n >\r\n </ng-template>\r\n </ng-select>\r\n <button\r\n class=\"btn btn-secondary\"\r\n [disabled]=\"customFilterForm.pristine\"\r\n (click)=\"applyCustomFilters()\"\r\n >\r\n {{ 'order.apply-filters' | translate }}\r\n <clr-icon shape=\"filter\"></clr-icon>\r\n </button>\r\n </div>\r\n <div class=\"flex\">\r\n <div>\r\n <label>{{ 'order.placed-at-start' | translate }}</label>\r\n <vdr-datetime-picker formControlName=\"placedAtStart\"></vdr-datetime-picker>\r\n </div>\r\n <div>\r\n <label>{{ 'order.placed-at-end' | translate }}</label>\r\n <vdr-datetime-picker formControlName=\"placedAtEnd\"></vdr-datetime-picker>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n </vdr-ab-left>\r\n <vdr-ab-right>\r\n <vdr-action-bar-items locationId=\"order-list\"></vdr-action-bar-items>\r\n <ng-container *ngIf=\"canCreateDraftOrder\">\r\n <a class=\"btn btn-primary mt1\" *vdrIfPermissions=\"['CreateOrder']\" [routerLink]=\"['./draft/create']\">\r\n <clr-icon shape=\"plus\"></clr-icon>\r\n {{ 'catalog.create-draft-order' | translate }}\r\n </a>\r\n </ng-container>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<vdr-data-table\r\n [items]=\"items$ | async\"\r\n [itemsPerPage]=\"itemsPerPage$ | async\"\r\n [totalItems]=\"totalItems$ | async\"\r\n [currentPage]=\"currentPage$ | async\"\r\n (pageChange)=\"setPageNumber($event)\"\r\n (itemsPerPageChange)=\"setItemsPerPage($event)\"\r\n>\r\n <vdr-dt-column>{{ 'common.code' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.customer' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.state' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.total' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'common.updated-at' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.placed-at' | translate }}</vdr-dt-column>\r\n <vdr-dt-column>{{ 'order.shipping' | translate }}</vdr-dt-column>\r\n <vdr-dt-column></vdr-dt-column>\r\n <ng-template let-order=\"item\">\r\n <td class=\"left align-middle\">{{ order.code }}</td>\r\n <td class=\"left align-middle\">\r\n <vdr-customer-label [customer]=\"order.customer\"></vdr-customer-label>\r\n </td>\r\n <td class=\"left align-middle\">\r\n <vdr-order-state-label [state]=\"order.state\"></vdr-order-state-label>\r\n </td>\r\n <td class=\"left align-middle\">{{ order.totalWithTax | localeCurrency: order.currencyCode }}</td>\r\n <td class=\"left align-middle\">{{ order.updatedAt | timeAgo }}</td>\r\n <td class=\"left align-middle\">{{ order.orderPlacedAt | localeDate: 'medium' }}</td>\r\n <td class=\"left align-middle\">{{ getShippingNames(order) }}</td>\r\n <td class=\"right align-middle\">\r\n <vdr-table-row-action\r\n iconShape=\"shopping-cart\"\r\n [label]=\"'common.open' | translate\"\r\n [linkTo]=\"\r\n order.state === 'Modifying'\r\n ? ['./', order.id, 'modify']\r\n : order.state === 'Draft'\r\n ? ['./draft', order.id]\r\n : ['./', order.id]\r\n \"\r\n ></vdr-table-row-action>\r\n </td>\r\n </ng-template>\r\n</vdr-data-table>\r\n",
2119
2585
  changeDetection: ChangeDetectionStrategy.OnPush,
2120
- styles: [".search-form{display:flex;flex-direction:column;align-items:baseline;width:100%;margin-bottom:6px}@media screen and (min-width: 768px){.search-form{flex-direction:row}}.search-input{margin-left:6px;margin-top:6px;min-width:300px}.custom-filters{overflow:hidden;max-height:0;padding-bottom:6px}.custom-filters.expanded{max-height:initial}.custom-filters>form{display:flex;flex-direction:column;align-items:center}.custom-filters>form>div{width:100%}ng-select{flex:1;min-width:200px;height:36px}ng-select ::ng-deep .ng-select-container{height:36px}\n"]
2586
+ styles: [".search-form{display:flex;flex-direction:column;align-items:baseline;width:100%;max-width:100vw;margin-bottom:6px}.filter-presets{max-width:90vw;overflow-x:auto}.search-input{margin-top:6px;min-width:300px}.custom-filters{overflow:hidden;max-height:0;padding-bottom:6px}.custom-filters.expanded{max-height:initial}.custom-filters>form{display:flex;flex-direction:column;align-items:center}.custom-filters>form>div{width:100%}ng-select{flex:1;min-width:200px;height:36px}ng-select ::ng-deep .ng-select-container{height:36px}\n"]
2121
2587
  },] }
2122
2588
  ];
2123
2589
  OrderListComponent.ctorParameters = () => [
@@ -2338,6 +2804,9 @@ OrderProcessGraphComponent.propDecorators = {
2338
2804
 
2339
2805
  class OrderTableComponent {
2340
2806
  constructor() {
2807
+ this.isDraft = false;
2808
+ this.adjust = new EventEmitter();
2809
+ this.remove = new EventEmitter();
2341
2810
  this.orderLineCustomFieldsVisible = false;
2342
2811
  this.customFieldsForLine = {};
2343
2812
  }
@@ -2351,6 +2820,11 @@ class OrderTableComponent {
2351
2820
  this.orderLineCustomFieldsVisible = this.orderLineCustomFields.length < 2;
2352
2821
  this.getLineCustomFields();
2353
2822
  }
2823
+ draftInputBlur(line, quantity) {
2824
+ if (line.quantity !== quantity) {
2825
+ this.adjust.emit({ lineId: line.id, quantity });
2826
+ }
2827
+ }
2354
2828
  toggleOrderLineCustomFields() {
2355
2829
  this.orderLineCustomFieldsVisible = !this.orderLineCustomFieldsVisible;
2356
2830
  }
@@ -2399,14 +2873,17 @@ class OrderTableComponent {
2399
2873
  OrderTableComponent.decorators = [
2400
2874
  { type: Component, args: [{
2401
2875
  selector: 'vdr-order-table',
2402
- template: "<table class=\"order-table table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th>{{ 'order.total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-container *ngFor=\"let line of order.lines\">\r\n <tr class=\"order-line\" [class.is-cancelled]=\"line.quantity === 0\">\r\n <td class=\"align-middle thumb\">\r\n <img *ngIf=\"line.featuredAsset\" [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.unitPrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n {{ line.quantity }}\r\n <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\r\n <vdr-line-fulfillment [line]=\"line\" [orderState]=\"order.state\"></vdr-line-fulfillment>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{ line.linePriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.linePrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n\r\n <ng-container *ngIf=\"getLineDiscounts(line) as discounts\">\r\n <vdr-dropdown *ngIf=\"discounts.length\">\r\n <div class=\"promotions-label\" vdrDropdownTrigger>\r\n {{ 'order.promotions-applied' | translate }}\r\n </div>\r\n <vdr-dropdown-menu>\r\n <div class=\"line-promotion\" *ngFor=\"let discount of discounts\">\r\n <a class=\"promotion-name\" [routerLink]=\"getPromotionLink(discount)\">{{\r\n discount.description\r\n }}</a>\r\n <div class=\"promotion-amount\">\r\n {{ discount.amountWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ discount.amount | localeCurrency: order.currencyCode }}\r\n </div>\r\n </div>\r\n </div>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </ng-container>\r\n </td>\r\n </tr>\r\n <ng-container *ngIf=\"customFieldsForLine[line.id] as customFields\">\r\n <tr *ngIf=\"customFields.length\">\r\n <td colspan=\"6\" class=\"custom-fields-row\">\r\n <div class=\"order-line-custom-fields\">\r\n <div class=\"custom-field\" *ngFor=\"let field of customFields\">\r\n <vdr-custom-field-control\r\n [compact]=\"true\"\r\n [readonly]=\"true\"\r\n [customField]=\"field.config\"\r\n [customFieldsFormGroup]=\"field.formGroup\"\r\n ></vdr-custom-field-control>\r\n </div>\r\n </div>\r\n </td>\r\n </tr>\r\n </ng-container>\r\n </ng-container>\r\n <tr class=\"surcharge\" *ngFor=\"let surcharge of order.surcharges\">\r\n <td class=\"align-middle name left\" colspan=\"2\">{{ surcharge.description }}</td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\" colspan=\"2\"></td>\r\n <td class=\"align-middle total\">\r\n {{ surcharge.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surcharge.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <ng-container *ngFor=\"let discount of order.discounts\">\r\n <tr class=\"order-adjustment\" *ngIf=\"discount.type !== 'OTHER'\">\r\n <td colspan=\"5\" class=\"left clr-align-middle\">\r\n <a [routerLink]=\"getPromotionLink(discount)\">{{ discount.description }}</a>\r\n <vdr-chip *ngIf=\"getCouponCodeForAdjustment(order, discount) as couponCode\">{{\r\n couponCode\r\n }}</vdr-chip>\r\n </td>\r\n <td class=\"clr-align-middle\">\r\n {{ discount.amountWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ discount.amount | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </ng-container>\r\n <tr class=\"sub-total\">\r\n <td class=\"left clr-align-middle\">{{ 'order.sub-total' | translate }}</td>\r\n <td colspan=\"4\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.subTotalWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.subTotal | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"shipping\">\r\n <td class=\"left clr-align-middle\">{{ 'order.shipping' | translate }}</td>\r\n <td class=\"clr-align-middle\">{{ getShippingNames(order) }}</td>\r\n <td colspan=\"3\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.shippingWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.shipping | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"total\">\r\n <td class=\"left clr-align-middle\">{{ 'order.total' | translate }}</td>\r\n <td colspan=\"4\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.totalWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.total | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n",
2876
+ template: "<table class=\"order-table table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'order.product-name' | translate }}</th>\r\n <th>{{ 'order.product-sku' | translate }}</th>\r\n <th>{{ 'order.unit-price' | translate }}</th>\r\n <th>{{ 'order.quantity' | translate }}</th>\r\n <th>{{ 'order.total' | translate }}</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-container *ngFor=\"let line of order.lines\">\r\n <tr class=\"order-line\" [class.is-cancelled]=\"line.quantity === 0\">\r\n <td class=\"align-middle thumb\">\r\n <img *ngIf=\"line.featuredAsset\" [src]=\"line.featuredAsset | assetPreview: 'tiny'\" />\r\n </td>\r\n <td class=\"align-middle name\">{{ line.productVariant.name }}</td>\r\n <td class=\"align-middle sku\">{{ line.productVariant.sku }}</td>\r\n <td class=\"align-middle unit-price\">\r\n {{ line.unitPriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.unitPrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n <td class=\"align-middle quantity\">\r\n <ng-container *ngIf=\"!isDraft; else draft\">\r\n {{ line.quantity }}\r\n </ng-container>\r\n <ng-template #draft>\r\n <div class=\"flex\">\r\n <input\r\n class=\"draft-qty\"\r\n type=\"number\"\r\n min=\"0\"\r\n #qtyInput\r\n [value]=\"line.quantity\"\r\n (blur)=\"draftInputBlur(line, qtyInput.valueAsNumber)\"\r\n />\r\n <button class=\"icon-button\" (click)=\"remove.emit({ lineId: line.id })\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </div>\r\n </ng-template>\r\n <vdr-line-refunds [line]=\"line\" [payments]=\"order.payments\"></vdr-line-refunds>\r\n <vdr-line-fulfillment [line]=\"line\" [orderState]=\"order.state\"></vdr-line-fulfillment>\r\n </td>\r\n <td class=\"align-middle total\">\r\n {{ line.linePriceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ line.linePrice | localeCurrency: order.currencyCode }}\r\n </div>\r\n\r\n <ng-container *ngIf=\"getLineDiscounts(line) as discounts\">\r\n <vdr-dropdown *ngIf=\"discounts.length\">\r\n <div class=\"promotions-label\" vdrDropdownTrigger>\r\n {{ 'order.promotions-applied' | translate }}\r\n </div>\r\n <vdr-dropdown-menu>\r\n <div class=\"line-promotion\" *ngFor=\"let discount of discounts\">\r\n <a class=\"promotion-name\" [routerLink]=\"getPromotionLink(discount)\">{{\r\n discount.description\r\n }}</a>\r\n <div class=\"promotion-amount\">\r\n {{ discount.amountWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ discount.amount | localeCurrency: order.currencyCode }}\r\n </div>\r\n </div>\r\n </div>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </ng-container>\r\n </td>\r\n </tr>\r\n <ng-container *ngIf=\"customFieldsForLine[line.id] as customFields\">\r\n <tr *ngIf=\"customFields.length\">\r\n <td colspan=\"6\" class=\"custom-fields-row\">\r\n <div class=\"order-line-custom-fields\">\r\n <div class=\"custom-field\" *ngFor=\"let field of customFields\">\r\n <vdr-custom-field-control\r\n [compact]=\"true\"\r\n [readonly]=\"true\"\r\n [customField]=\"field.config\"\r\n [customFieldsFormGroup]=\"field.formGroup\"\r\n ></vdr-custom-field-control>\r\n </div>\r\n </div>\r\n </td>\r\n </tr>\r\n </ng-container>\r\n </ng-container>\r\n <tr class=\"surcharge\" *ngFor=\"let surcharge of order.surcharges\">\r\n <td class=\"align-middle name left\" colspan=\"2\">{{ surcharge.description }}</td>\r\n <td class=\"align-middle sku\">{{ surcharge.sku }}</td>\r\n <td class=\"align-middle\" colspan=\"2\"></td>\r\n <td class=\"align-middle total\">\r\n {{ surcharge.priceWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ surcharge.price | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <ng-container *ngFor=\"let discount of order.discounts\">\r\n <tr class=\"order-adjustment\" *ngIf=\"discount.type !== 'OTHER'\">\r\n <td colspan=\"5\" class=\"left clr-align-middle\">\r\n <a [routerLink]=\"getPromotionLink(discount)\">{{ discount.description }}</a>\r\n <vdr-chip *ngIf=\"getCouponCodeForAdjustment(order, discount) as couponCode\">{{\r\n couponCode\r\n }}</vdr-chip>\r\n </td>\r\n <td class=\"clr-align-middle\">\r\n {{ discount.amountWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ discount.amount | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </ng-container>\r\n <tr class=\"sub-total\">\r\n <td class=\"left clr-align-middle\">{{ 'order.sub-total' | translate }}</td>\r\n <td colspan=\"4\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.subTotalWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.subTotal | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"shipping\">\r\n <td class=\"left clr-align-middle\">{{ 'order.shipping' | translate }}</td>\r\n <td class=\"clr-align-middle\">{{ getShippingNames(order) }}</td>\r\n <td colspan=\"3\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.shippingWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.shipping | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n <tr class=\"total\">\r\n <td class=\"left clr-align-middle\">{{ 'order.total' | translate }}</td>\r\n <td colspan=\"4\"></td>\r\n <td class=\"clr-align-middle\">\r\n {{ order.totalWithTax | localeCurrency: order.currencyCode }}\r\n <div class=\"net-price\" [title]=\"'order.net-price' | translate\">\r\n {{ order.total | localeCurrency: order.currencyCode }}\r\n </div>\r\n </td>\r\n </tr>\r\n </tbody>\r\n</table>\r\n",
2403
2877
  changeDetection: ChangeDetectionStrategy.OnPush,
2404
- styles: [".order-table .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.order-table .sub-total td{border-top:1px dashed var(--color-component-border-200)}.order-table .total td{font-weight:bold;border-top:1px dashed var(--color-component-border-200)}.order-table td.custom-fields-row{border-top-style:dashed;border-top-color:var(--color-grey-200)}.order-table .order-line-custom-fields{display:flex;flex-wrap:wrap}.order-table .order-line-custom-fields .custom-field{text-align:start;max-width:200px;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px;margin-right:18px}.order-table .order-line-custom-field{background-color:var(--color-component-bg-100)}.order-table .order-line-custom-field .custom-field-ellipsis{color:var(--color-text-300)}.order-table .net-price{font-size:11px;color:var(--color-text-300)}.order-table .promotions-label{-webkit-text-decoration:underline dotted var(--color-text-200);text-decoration:underline dotted var(--color-text-200);font-size:11px;margin-top:6px;cursor:pointer;text-transform:lowercase}.order-table .thumb img{width:50px;height:50px}::ng-deep .line-promotion{display:flex;justify-content:space-between;padding:6px 12px}::ng-deep .line-promotion .promotion-amount{margin-left:12px}::ng-deep .line-promotion .net-price{font-size:11px;color:var(--color-text-300)}\n"]
2878
+ styles: [".order-table .is-cancelled td{text-decoration:line-through;background-color:var(--color-component-bg-200)}.order-table .sub-total td{border-top:1px dashed var(--color-component-border-200)}.order-table .total td{font-weight:bold;border-top:1px dashed var(--color-component-border-200)}.order-table td.custom-fields-row{border-top-style:dashed;border-top-color:var(--color-grey-200)}.order-table img{border-radius:var(--border-radius-img)}.order-table .order-line-custom-fields{display:flex;flex-wrap:wrap}.order-table .order-line-custom-fields .custom-field{text-align:start;max-width:200px;overflow:hidden;text-overflow:ellipsis;margin-bottom:6px;margin-right:18px}.order-table .draft-qty{max-width:48px}.order-table .order-line-custom-field{background-color:var(--color-component-bg-100)}.order-table .order-line-custom-field .custom-field-ellipsis{color:var(--color-text-300)}.order-table .net-price{font-size:11px;color:var(--color-text-300)}.order-table .promotions-label{-webkit-text-decoration:underline dotted var(--color-text-200);text-decoration:underline dotted var(--color-text-200);font-size:11px;margin-top:6px;cursor:pointer;text-transform:lowercase}.order-table .thumb img{width:50px;height:50px}::ng-deep .line-promotion{display:flex;justify-content:space-between;padding:6px 12px}::ng-deep .line-promotion .promotion-amount{margin-left:12px}::ng-deep .line-promotion .net-price{font-size:11px;color:var(--color-text-300)}\n"]
2405
2879
  },] }
2406
2880
  ];
2407
2881
  OrderTableComponent.propDecorators = {
2408
2882
  order: [{ type: Input }],
2409
- orderLineCustomFields: [{ type: Input }]
2883
+ orderLineCustomFields: [{ type: Input }],
2884
+ isDraft: [{ type: Input }],
2885
+ adjust: [{ type: Output }],
2886
+ remove: [{ type: Output }]
2410
2887
  };
2411
2888
 
2412
2889
  class PaymentDetailComponent {
@@ -2490,16 +2967,30 @@ SimpleItemListComponent.propDecorators = {
2490
2967
  /**
2491
2968
  * Resolves the id from the path into a Customer entity.
2492
2969
  */
2493
- class OrderResolver extends BaseEntityResolver {
2970
+ class OrderResolver {
2494
2971
  constructor(router, dataService) {
2495
- super(router, {
2496
- __typename: 'Order',
2497
- id: '',
2498
- code: '',
2499
- createdAt: '',
2500
- updatedAt: '',
2501
- total: 0,
2502
- }, id => dataService.order.getOrder(id).mapStream(data => data.order));
2972
+ this.router = router;
2973
+ this.dataService = dataService;
2974
+ }
2975
+ /** @internal */
2976
+ resolve(route, state) {
2977
+ const id = route.paramMap.get('id');
2978
+ // Complete the entity stream upon navigating away
2979
+ const navigateAway$ = this.router.events.pipe(filter(event => event instanceof ActivationStart));
2980
+ const stream = this.dataService.order
2981
+ .getOrder(id)
2982
+ .mapStream(data => data.order)
2983
+ .pipe(switchMap(order => {
2984
+ if ((order === null || order === void 0 ? void 0 : order.state) === 'Draft' && route.component !== DraftOrderDetailComponent) {
2985
+ // Make sure Draft orders only get displayed with the DraftOrderDetailComponent
2986
+ this.router.navigate(['/orders/draft', id]);
2987
+ return EMPTY;
2988
+ }
2989
+ else {
2990
+ return [order];
2991
+ }
2992
+ }), takeUntil(navigateAway$), filter(notNullOrUndefined), shareReplay(1));
2993
+ return stream.pipe(take(1), map(() => stream));
2503
2994
  }
2504
2995
  }
2505
2996
  OrderResolver.ɵprov = i0.ɵɵdefineInjectable({ factory: function OrderResolver_Factory() { return new OrderResolver(i0.ɵɵinject(i1$1.Router), i0.ɵɵinject(i1.DataService)); }, token: OrderResolver, providedIn: "root" });
@@ -2513,11 +3004,47 @@ OrderResolver.ctorParameters = () => [
2513
3004
  { type: DataService }
2514
3005
  ];
2515
3006
 
3007
+ class OrderGuard {
3008
+ constructor(dataService, router) {
3009
+ this.dataService = dataService;
3010
+ this.router = router;
3011
+ }
3012
+ canActivate(route, state) {
3013
+ const isDraft = state.url.includes('orders/draft');
3014
+ const id = route.paramMap.get('id');
3015
+ if (isDraft) {
3016
+ if (id === 'create') {
3017
+ return this.dataService.order
3018
+ .createDraftOrder()
3019
+ .pipe(map(({ createDraftOrder }) => this.router.parseUrl(`/orders/draft/${createDraftOrder.id}`)));
3020
+ }
3021
+ else {
3022
+ return true;
3023
+ }
3024
+ }
3025
+ else {
3026
+ return true;
3027
+ }
3028
+ }
3029
+ }
3030
+ OrderGuard.ɵprov = i0.ɵɵdefineInjectable({ factory: function OrderGuard_Factory() { return new OrderGuard(i0.ɵɵinject(i1.DataService), i0.ɵɵinject(i1$1.Router)); }, token: OrderGuard, providedIn: "root" });
3031
+ OrderGuard.decorators = [
3032
+ { type: Injectable, args: [{
3033
+ providedIn: 'root',
3034
+ },] }
3035
+ ];
3036
+ OrderGuard.ctorParameters = () => [
3037
+ { type: DataService },
3038
+ { type: Router }
3039
+ ];
3040
+
2516
3041
  const ɵ0 = {
2517
3042
  breadcrumb: marker('breadcrumb.orders'),
2518
3043
  }, ɵ1 = {
2519
3044
  breadcrumb: orderBreadcrumb,
2520
3045
  }, ɵ2 = {
3046
+ breadcrumb: orderBreadcrumb,
3047
+ }, ɵ3 = {
2521
3048
  breadcrumb: modifyingOrderBreadcrumb,
2522
3049
  };
2523
3050
  const orderRoutes = [
@@ -2526,19 +3053,34 @@ const orderRoutes = [
2526
3053
  component: OrderListComponent,
2527
3054
  data: ɵ0,
2528
3055
  },
3056
+ {
3057
+ path: 'draft/:id',
3058
+ component: DraftOrderDetailComponent,
3059
+ resolve: {
3060
+ entity: OrderResolver,
3061
+ },
3062
+ canActivate: [OrderGuard],
3063
+ canDeactivate: [CanDeactivateDetailGuard],
3064
+ data: ɵ1,
3065
+ },
2529
3066
  {
2530
3067
  path: ':id',
2531
3068
  component: OrderDetailComponent,
2532
- resolve: createResolveData(OrderResolver),
3069
+ resolve: {
3070
+ entity: OrderResolver,
3071
+ },
3072
+ canActivate: [OrderGuard],
2533
3073
  canDeactivate: [CanDeactivateDetailGuard],
2534
- data: ɵ1,
3074
+ data: ɵ2,
2535
3075
  },
2536
3076
  {
2537
3077
  path: ':id/modify',
2538
3078
  component: OrderEditorComponent,
2539
- resolve: createResolveData(OrderResolver),
3079
+ resolve: {
3080
+ entity: OrderResolver,
3081
+ },
2540
3082
  // canDeactivate: [CanDeactivateDetailGuard],
2541
- data: ɵ2,
3083
+ data: ɵ3,
2542
3084
  },
2543
3085
  ];
2544
3086
  function orderBreadcrumb(data, params) {
@@ -2593,6 +3135,12 @@ OrderModule.decorators = [
2593
3135
  ModificationDetailComponent,
2594
3136
  AddManualPaymentDialogComponent,
2595
3137
  OrderStateSelectDialogComponent,
3138
+ DraftOrderDetailComponent,
3139
+ DraftOrderVariantSelectorComponent,
3140
+ SelectCustomerDialogComponent,
3141
+ SelectAddressDialogComponent,
3142
+ CouponCodeSelectorComponent,
3143
+ SelectShippingMethodDialogComponent,
2596
3144
  ],
2597
3145
  },] }
2598
3146
  ];
@@ -2603,5 +3151,5 @@ OrderModule.decorators = [
2603
3151
  * Generated bundle index. Do not edit.
2604
3152
  */
2605
3153
 
2606
- export { AddManualPaymentDialogComponent, CancelOrderDialogComponent, FulfillOrderDialogComponent, FulfillmentCardComponent, FulfillmentDetailComponent, FulfillmentStateLabelComponent, LineFulfillmentComponent, LineRefundsComponent, ModificationDetailComponent, NODE_HEIGHT, OrderCustomFieldsCardComponent, OrderDetailComponent, OrderEditResultType, OrderEditorComponent, OrderEditsPreviewDialogComponent, OrderHistoryComponent, OrderListComponent, OrderModule, OrderPaymentCardComponent, OrderProcessEdgeComponent, OrderProcessGraphComponent, OrderProcessGraphDialogComponent, OrderProcessNodeComponent, OrderResolver, OrderStateSelectDialogComponent, OrderTableComponent, OrderTransitionService, PaymentDetailComponent, PaymentStateLabelComponent, RefundOrderDialogComponent, RefundStateLabelComponent, SettleRefundDialogComponent, SimpleItemListComponent, modifyingOrderBreadcrumb, orderBreadcrumb, orderRoutes, ɵ0, ɵ1, ɵ2 };
3154
+ export { AddManualPaymentDialogComponent, CancelOrderDialogComponent, CouponCodeSelectorComponent, DraftOrderDetailComponent, DraftOrderVariantSelectorComponent, FulfillOrderDialogComponent, FulfillmentCardComponent, FulfillmentDetailComponent, FulfillmentStateLabelComponent, GET_CUSTOMER_ADDRESSES, LineFulfillmentComponent, LineRefundsComponent, ModificationDetailComponent, NODE_HEIGHT, OrderCustomFieldsCardComponent, OrderDetailComponent, OrderEditResultType, OrderEditorComponent, OrderEditsPreviewDialogComponent, OrderGuard, OrderHistoryComponent, OrderListComponent, OrderModule, OrderPaymentCardComponent, OrderProcessEdgeComponent, OrderProcessGraphComponent, OrderProcessGraphDialogComponent, OrderProcessNodeComponent, OrderResolver, OrderStateSelectDialogComponent, OrderTableComponent, OrderTransitionService, PaymentDetailComponent, PaymentStateLabelComponent, RefundOrderDialogComponent, RefundStateLabelComponent, SelectAddressDialogComponent, SelectCustomerDialogComponent, SelectShippingMethodDialogComponent, SettleRefundDialogComponent, SimpleItemListComponent, modifyingOrderBreadcrumb, orderBreadcrumb, orderRoutes, ɵ0, ɵ1, ɵ2, ɵ3 };
2607
3155
  //# sourceMappingURL=vendure-admin-ui-order.js.map