@vendure/admin-ui 1.7.2 → 1.7.4

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 (39) hide show
  1. package/bundles/vendure-admin-ui-catalog.umd.js +27 -17
  2. package/bundles/vendure-admin-ui-catalog.umd.js.map +1 -1
  3. package/bundles/vendure-admin-ui-core.umd.js +2 -2
  4. package/bundles/vendure-admin-ui-core.umd.js.map +1 -1
  5. package/bundles/vendure-admin-ui-customer.umd.js.map +1 -1
  6. package/bundles/vendure-admin-ui-marketing.umd.js +2 -2
  7. package/bundles/vendure-admin-ui-marketing.umd.js.map +1 -1
  8. package/bundles/vendure-admin-ui-settings.umd.js +2 -0
  9. package/bundles/vendure-admin-ui-settings.umd.js.map +1 -1
  10. package/catalog/components/product-variants-editor/product-variants-editor.component.d.ts +2 -2
  11. package/catalog/vendure-admin-ui-catalog.metadata.json +1 -1
  12. package/core/common/version.d.ts +1 -1
  13. package/core/vendure-admin-ui-core.metadata.json +1 -1
  14. package/esm2015/catalog/components/generate-product-variants/generate-product-variants.component.js +1 -1
  15. package/esm2015/catalog/components/product-variants-editor/product-variants-editor.component.js +28 -18
  16. package/esm2015/core/common/generated-types.js +1 -1
  17. package/esm2015/core/common/introspection-result.js +1 -1
  18. package/esm2015/core/common/utilities/configurable-operation-utils.js +2 -2
  19. package/esm2015/core/common/version.js +2 -2
  20. package/esm2015/core/data/definitions/order-definitions.js +443 -443
  21. package/esm2015/core/data/definitions/product-definitions.js +743 -743
  22. package/esm2015/core/shared/components/custom-field-control/custom-field-control.component.js +1 -1
  23. package/esm2015/core/shared/dynamic-form-inputs/select-form-input/select-form-input.component.js +1 -1
  24. package/esm2015/core/shared/pipes/custom-field-label.pipe.js +1 -1
  25. package/esm2015/core/shared/pipes/locale-currency.pipe.js +1 -1
  26. package/esm2015/customer/components/customer-group-list/customer-group-list.component.js +1 -1
  27. package/esm2015/marketing/components/promotion-detail/promotion-detail.component.js +3 -3
  28. package/esm2015/settings/components/shipping-method-detail/shipping-method-detail.component.js +3 -1
  29. package/fesm2015/vendure-admin-ui-catalog.js +27 -17
  30. package/fesm2015/vendure-admin-ui-catalog.js.map +1 -1
  31. package/fesm2015/vendure-admin-ui-core.js +1211 -1211
  32. package/fesm2015/vendure-admin-ui-core.js.map +1 -1
  33. package/fesm2015/vendure-admin-ui-customer.js.map +1 -1
  34. package/fesm2015/vendure-admin-ui-marketing.js +2 -2
  35. package/fesm2015/vendure-admin-ui-marketing.js.map +1 -1
  36. package/fesm2015/vendure-admin-ui-settings.js +2 -0
  37. package/fesm2015/vendure-admin-ui-settings.js.map +1 -1
  38. package/marketing/vendure-admin-ui-marketing.metadata.json +1 -1
  39. package/package.json +2 -2
@@ -2262,14 +2262,16 @@ class ProductVariantsEditorComponent {
2262
2262
  });
2263
2263
  }
2264
2264
  }
2265
- addOption(groupId, optionName) {
2266
- var _a;
2267
- (_a = this.optionGroups.find(g => g.id === groupId)) === null || _a === void 0 ? void 0 : _a.values.push({ name: optionName, locked: false });
2268
- this.generateVariants();
2269
- this.optionsChanged = true;
2265
+ addOption(index, optionName) {
2266
+ const group = this.optionGroups[index];
2267
+ if (group) {
2268
+ group.values.push({ name: optionName, locked: false });
2269
+ this.generateVariants();
2270
+ this.optionsChanged = true;
2271
+ }
2270
2272
  }
2271
- removeOption(groupId, { id, name }) {
2272
- const optionGroup = this.optionGroups.find(g => g.id === groupId);
2273
+ removeOption(index, { id, name }) {
2274
+ const optionGroup = this.optionGroups[index];
2273
2275
  if (optionGroup) {
2274
2276
  if (!id) {
2275
2277
  optionGroup.values = optionGroup.values.filter(v => v.name !== name);
@@ -2488,15 +2490,23 @@ class ProductVariantsEditorComponent {
2488
2490
  .reduce((flat, o) => [...flat, ...o], []);
2489
2491
  const variants = this.generatedVariants
2490
2492
  .filter(v => v.enabled && !v.existing)
2491
- .map(v => ({
2492
- price: v.price,
2493
- sku: v.sku,
2494
- stock: v.stock,
2495
- optionIds: v.options
2496
- .map(name => options.find(o => o.name === name.name))
2497
- .filter(notNullOrUndefined)
2498
- .map(o => o.id),
2499
- }));
2493
+ .map(v => {
2494
+ const optionIds = groups.map((group, index) => {
2495
+ const option = group.options.find(o => o.name === v.options[index].name);
2496
+ if (option) {
2497
+ return option.id;
2498
+ }
2499
+ else {
2500
+ throw new Error(`Could not find a matching option for group ${group.name}`);
2501
+ }
2502
+ });
2503
+ return {
2504
+ price: v.price,
2505
+ sku: v.sku,
2506
+ stock: v.stock,
2507
+ optionIds,
2508
+ };
2509
+ });
2500
2510
  return this.productDetailService.createProductVariants(this.product, variants, options, this.languageCode);
2501
2511
  }
2502
2512
  deleteObsoleteVariants(input) {
@@ -2563,7 +2573,7 @@ class ProductVariantsEditorComponent {
2563
2573
  ProductVariantsEditorComponent.decorators = [
2564
2574
  { type: Component, args: [{
2565
2575
  selector: 'vdr-product-variants-editor',
2566
- template: "<vdr-action-bar>\r\n <vdr-ab-right>\r\n <button\r\n class=\"btn btn-primary\"\r\n (click)=\"save()\"\r\n [disabled]=\"(!formValueChanged && !optionsChanged) || getVariantsToAdd().length === 0\"\r\n >\r\n {{ 'common.add-new-variants' | translate: { count: getVariantsToAdd().length } }}\r\n </button>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngFor=\"let group of optionGroups\" class=\"option-groups\">\r\n <div class=\"name\">\r\n <label>{{ 'catalog.option' | translate }}</label>\r\n <input clrInput [(ngModel)]=\"group.name\" name=\"name\" [readonly]=\"!group.isNew\" />\r\n </div>\r\n <div class=\"values\">\r\n <label>{{ 'catalog.option-values' | translate }}</label>\r\n <vdr-option-value-input\r\n #optionValueInputComponent\r\n [options]=\"group.values\"\r\n [groupName]=\"group.name\"\r\n [disabled]=\"group.name === ''\"\r\n (add)=\"addOption(group.id, $event.name)\"\r\n (remove)=\"removeOption(group.id, $event)\"\r\n ></vdr-option-value-input>\r\n </div>\r\n <div>\r\n <button\r\n [disabled]=\"group.locked\"\r\n class=\"btn btn-icon btn-danger-outline mt5\" (click)=\"removeOptionGroup(group)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </div>\r\n</div>\r\n<button class=\"btn btn-primary-outline btn-sm\" (click)=\"addOptionGroup()\">\r\n <clr-icon shape=\"plus\"></clr-icon>\r\n {{ 'catalog.add-option' | translate }}\r\n</button>\r\n\r\n<div class=\"variants-preview\">\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'catalog.variant' | translate }}</th>\r\n <th>{{ 'catalog.sku' | translate }}</th>\r\n <th>{{ 'catalog.price' | translate }}</th>\r\n <th>{{ 'catalog.stock-on-hand' | translate }}</th>\r\n <th></th>\r\n </tr>\r\n </thead>\r\n <tr *ngFor=\"let variant of generatedVariants\" [class.disabled]=\"!variant.enabled || variant.existing\">\r\n <td class=\"left\">\r\n <clr-checkbox-wrapper *ngIf=\"!variant.existing\">\r\n <input\r\n type=\"checkbox\"\r\n [(ngModel)]=\"variant.enabled\"\r\n name=\"enabled\"\r\n clrCheckbox\r\n (ngModelChange)=\"formValueChanged = true\"\r\n />\r\n <label>{{ 'common.create' | translate }}</label>\r\n </clr-checkbox-wrapper>\r\n </td>\r\n <td>\r\n {{ getVariantName(variant) | translate }}\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <input\r\n clrInput\r\n type=\"text\"\r\n [(ngModel)]=\"variant.sku\"\r\n [placeholder]=\"'catalog.sku' | translate\"\r\n name=\"sku\"\r\n required\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n />\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.sku }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <vdr-currency-input\r\n clrInput\r\n [(ngModel)]=\"variant.price\"\r\n name=\"price\"\r\n [currencyCode]=\"currencyCode\"\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n ></vdr-currency-input>\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.price | localeCurrency: currencyCode }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <input\r\n clrInput\r\n type=\"number\"\r\n [(ngModel)]=\"variant.stock\"\r\n name=\"stock\"\r\n min=\"0\"\r\n step=\"1\"\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n />\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.stock }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <vdr-dropdown *ngIf=\"variant.productVariantId as productVariantId\">\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\r\n type=\"button\"\r\n class=\"delete-button\"\r\n (click)=\"deleteVariant(productVariantId, variant.options)\"\r\n vdrDropdownItem\r\n >\r\n <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n {{ 'common.delete' | translate }}\r\n </button>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>\r\n",
2576
+ template: "<vdr-action-bar>\r\n <vdr-ab-right>\r\n <button\r\n class=\"btn btn-primary\"\r\n (click)=\"save()\"\r\n [disabled]=\"(!formValueChanged && !optionsChanged) || getVariantsToAdd().length === 0\"\r\n >\r\n {{ 'common.add-new-variants' | translate: { count: getVariantsToAdd().length } }}\r\n </button>\r\n </vdr-ab-right>\r\n</vdr-action-bar>\r\n\r\n<div *ngFor=\"let group of optionGroups; index as i\" class=\"option-groups\">\r\n <div class=\"name\">\r\n <label>{{ 'catalog.option' | translate }}</label>\r\n <input clrInput [(ngModel)]=\"group.name\" name=\"name\" [readonly]=\"!group.isNew\" />\r\n </div>\r\n <div class=\"values\">\r\n <label>{{ 'catalog.option-values' | translate }}</label>\r\n <vdr-option-value-input\r\n #optionValueInputComponent\r\n [options]=\"group.values\"\r\n [groupName]=\"group.name\"\r\n [disabled]=\"group.name === ''\"\r\n (add)=\"addOption(i, $event.name)\"\r\n (remove)=\"removeOption(i, $event)\"\r\n ></vdr-option-value-input>\r\n </div>\r\n <div>\r\n <button\r\n [disabled]=\"group.locked\"\r\n class=\"btn btn-icon btn-danger-outline mt5\" (click)=\"removeOptionGroup(group)\">\r\n <clr-icon shape=\"trash\"></clr-icon>\r\n </button>\r\n </div>\r\n</div>\r\n<button class=\"btn btn-primary-outline btn-sm\" (click)=\"addOptionGroup()\">\r\n <clr-icon shape=\"plus\"></clr-icon>\r\n {{ 'catalog.add-option' | translate }}\r\n</button>\r\n\r\n<div class=\"variants-preview\">\r\n <table class=\"table\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>{{ 'catalog.variant' | translate }}</th>\r\n <th>{{ 'catalog.sku' | translate }}</th>\r\n <th>{{ 'catalog.price' | translate }}</th>\r\n <th>{{ 'catalog.stock-on-hand' | translate }}</th>\r\n <th></th>\r\n </tr>\r\n </thead>\r\n <tr *ngFor=\"let variant of generatedVariants\" [class.disabled]=\"!variant.enabled || variant.existing\">\r\n <td class=\"left\">\r\n <clr-checkbox-wrapper *ngIf=\"!variant.existing\">\r\n <input\r\n type=\"checkbox\"\r\n [(ngModel)]=\"variant.enabled\"\r\n name=\"enabled\"\r\n clrCheckbox\r\n (ngModelChange)=\"formValueChanged = true\"\r\n />\r\n <label>{{ 'common.create' | translate }}</label>\r\n </clr-checkbox-wrapper>\r\n </td>\r\n <td>\r\n {{ getVariantName(variant) | translate }}\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <input\r\n clrInput\r\n type=\"text\"\r\n [(ngModel)]=\"variant.sku\"\r\n [placeholder]=\"'catalog.sku' | translate\"\r\n name=\"sku\"\r\n required\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n />\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.sku }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <vdr-currency-input\r\n clrInput\r\n [(ngModel)]=\"variant.price\"\r\n name=\"price\"\r\n [currencyCode]=\"currencyCode\"\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n ></vdr-currency-input>\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.price | localeCurrency: currencyCode }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <div class=\"flex center\">\r\n <clr-input-container *ngIf=\"!variant.existing\">\r\n <input\r\n clrInput\r\n type=\"number\"\r\n [(ngModel)]=\"variant.stock\"\r\n name=\"stock\"\r\n min=\"0\"\r\n step=\"1\"\r\n (ngModelChange)=\"onFormChanged(variant)\"\r\n />\r\n </clr-input-container>\r\n <span *ngIf=\"variant.existing\">{{ variant.stock }}</span>\r\n </div>\r\n </td>\r\n <td>\r\n <vdr-dropdown *ngIf=\"variant.productVariantId as productVariantId\">\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\r\n type=\"button\"\r\n class=\"delete-button\"\r\n (click)=\"deleteVariant(productVariantId, variant.options)\"\r\n vdrDropdownItem\r\n >\r\n <clr-icon shape=\"trash\" class=\"is-danger\"></clr-icon>\r\n {{ 'common.delete' | translate }}\r\n </button>\r\n </vdr-dropdown-menu>\r\n </vdr-dropdown>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>\r\n",
2567
2577
  changeDetection: ChangeDetectionStrategy.Default,
2568
2578
  styles: [".option-groups{display:flex}.option-groups:first-of-type{margin-top:24px}.values{flex:1;margin:0 6px}.variants-preview tr.disabled td{background-color:var(--color-component-bg-100);color:var(--color-grey-400)}\n"]
2569
2579
  },] }