@veloceapps/sdk 8.0.0-118 → 8.0.0-119

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,6 +67,26 @@ const getGuidedSellingConfigurationRequest = (data, context) => {
67
67
  },
68
68
  };
69
69
  };
70
+ const generateConfigurationLineItem = (props, qty = 1) => {
71
+ const id = UUID.UUID();
72
+ const attributes = Object.entries(props.attributesMap ?? {}).map(([name, value]) => ({
73
+ name,
74
+ value,
75
+ cfgStatus: 'User',
76
+ }));
77
+ const lineItems = [];
78
+ return {
79
+ id,
80
+ type: props.product.typeName ?? '',
81
+ cfgStatus: 'Default',
82
+ actionCode: 'ADD',
83
+ qty,
84
+ attributes,
85
+ lineItems,
86
+ productName: props.product.name,
87
+ productId: props.product.id ?? '',
88
+ };
89
+ };
70
90
 
71
91
  class ContextService {
72
92
  constructor(contextApiService) {
@@ -82,6 +102,18 @@ class ContextService {
82
102
  get mode() {
83
103
  return this.resolve().properties.mode;
84
104
  }
105
+ get isEditMode$() {
106
+ return this.resolve$().pipe(map(() => {
107
+ const context = this.resolve();
108
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
109
+ return true;
110
+ }
111
+ if (context.mode === ConfigurationContextMode.QUOTE) {
112
+ return context.properties.Status === 'Draft';
113
+ }
114
+ return false;
115
+ }));
116
+ }
85
117
  resolve() {
86
118
  if (!this.context.value) {
87
119
  throw new Error('Context is not initialized yet!');
@@ -1797,13 +1829,12 @@ class FlowStateConfigurationService {
1797
1829
  if (!stateId) {
1798
1830
  return of();
1799
1831
  }
1800
- return this.configurationService.configureExternal$(props).pipe(switchMap(lineItem => this.flowStateApiService
1801
- .newConfiguration(stateId, { lineItem })
1802
- .pipe(tap$1(r => this.configurationStateId$.next(r.stateId)))), switchMap(() => {
1832
+ const lineItem = generateConfigurationLineItem(props, props.qty);
1833
+ return this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1803
1834
  if (!this.configurationStateId) {
1804
1835
  return of();
1805
1836
  }
1806
- return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
1837
+ return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1807
1838
  }));
1808
1839
  }
1809
1840
  else {
@@ -2453,5 +2484,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
2453
2484
  * Generated bundle index. Do not edit.
2454
2485
  */
2455
2486
 
2456
- export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
2487
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
2457
2488
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map