From 91fb40bd77952f76b06642558a6769f3facd6570 Mon Sep 17 00:00:00 2001 From: Benjamin Howarth Date: Tue, 24 Sep 2019 17:41:11 +0100 Subject: [PATCH] #92 changed variant editor to use new package.manifest format, tested & now persists to dataNtext in cmsPropertyData. --- .../variant-editor.controller.js | 15 +++-- .../package.manifest | 62 ++++++++++++++++++- .../TeaCommerce.Umbraco.Configuration.csproj | 5 +- 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/Source/TeaCommerce.Umbraco.Application/PropertyEditors/variant-editor.controller.js b/Source/TeaCommerce.Umbraco.Application/PropertyEditors/variant-editor.controller.js index 8ec0310..d3fb4cb 100644 --- a/Source/TeaCommerce.Umbraco.Application/PropertyEditors/variant-editor.controller.js +++ b/Source/TeaCommerce.Umbraco.Application/PropertyEditors/variant-editor.controller.js @@ -197,13 +197,16 @@ if ($scope.variantGroups) { for (var i = 0; i < $scope.variantGroups.length; i++) { var variantGroup = $scope.variantGroups[i]; - for (var y = 0; y < variantGroup.items.length; y++) { - var item = variantGroup.items[y]; - if (item.checked) { - if (!checkedGroups[variantGroup.id]) { - checkedGroups[variantGroup.id] = []; + // BH: avoid empty attribute groups, issue #91 + if (variantGroup.items !== null && variantGroups.items.length > 0) { + for (var y = 0; y < variantGroup.items.length; y++) { + var item = variantGroup.items[y]; + if (item.checked) { + if (!checkedGroups[variantGroup.id]) { + checkedGroups[variantGroup.id] = []; + } + checkedGroups[variantGroup.id].push({ name: item.name, id: item.id, groupName: variantGroup.name, groupId: variantGroup.id }); } - checkedGroups[variantGroup.id].push({ name: item.name, id: item.id, groupName: variantGroup.name, groupId: variantGroup.id }); } } } diff --git a/Source/TeaCommerce.Umbraco.Application/package.manifest b/Source/TeaCommerce.Umbraco.Application/package.manifest index 5aed611..256fe83 100644 --- a/Source/TeaCommerce.Umbraco.Application/package.manifest +++ b/Source/TeaCommerce.Umbraco.Application/package.manifest @@ -23,10 +23,70 @@ hideLabel: false, valueType: 'STRING' } + },{ + alias: 'TeaCommerce.VariantEditor', + name: 'Tea Commerce: Variant editor', + editor: { + view: '~/App_Plugins/TeaCommerce/PropertyEditors/variant-editor.html', + hideLabel: false, + valueType: 'JSON' + }, + prevalues: { + fields: [ + { + label: 'Variant Attribute Groups XPath Or Node', + description: 'Enter an XPath statement to locate node containing all attribute groups or select the node.', + key: 'xpathOrNode', + view: '~/App_Plugins/TeaCommerce/PropertyEditors/variant-editor-node-type.html' + }, + { + label: 'Variant document type', + description: '[Optional] A document type that makes it possible to enrich each variant combination with extra information.', + key: 'variantDocumentType', + view: 'textstring' + }, + { + label: 'Extra list information', + description: '[Optional] Comma-separated list of property aliases from the ', + key: 'extraListInformation', + view: 'textstring' + }, + { + label: 'Variant group document types', + description: '[Optional] Comma-separated list of the variant group document types that can be chosen from. e.g. "Color,Size".', + key: 'variantGroupDocumentTypes', + view: 'textstring' + }, + { + label: 'Variant group name', + description: '[Optional] Comma-separated list of the variant group node names that can be chosen from. e.g. "Color,Size".', + key: 'variantGroupNodeName', + view: 'textstring' + }, + { + label: 'Force editor to choose all variant groups', + description: 'Editor will be forced to choose at least one variant type from each variant group when creating variants.', + key: 'forceEditorToChooseAllVariantGroups', + view: 'boolean' + }, + { + label: 'Hide Label', + description: 'Hide the Umbraco property title and description, making the Variant Editor span the entire page width', + key: 'hideLabel', + view: 'boolean' + } + ] + } }], javascript: [ '~/App_Plugins/TeaCommerce/PropertyEditors/store-picker.controller.js', '~/App_Plugins/TeaCommerce/PropertyEditors/vat-group-picker.controller.js', - '~/App_Plugins/TeaCommerce/PropertyEditors/stock-management.controller.js' + '~/App_Plugins/TeaCommerce/PropertyEditors/stock-management.controller.js', + '~/App_Plugins/TeaCommerce/PropertyEditors/js.cookie.js', + '~/App_Plugins/TeaCommerce/PropertyEditors/variant-editor-node-type.js', + '~/App_Plugins/TeaCommerce/PropertyEditors/variant-editor.controller.js' + ], + css: [ + '~/App_Plugins/TeaCommerce/PropertyEditors/variant-editor.css' ] } \ No newline at end of file diff --git a/Source/TeaCommerce.Umbraco.Configuration/TeaCommerce.Umbraco.Configuration.csproj b/Source/TeaCommerce.Umbraco.Configuration/TeaCommerce.Umbraco.Configuration.csproj index 3c9a5fc..1f9fe97 100644 --- a/Source/TeaCommerce.Umbraco.Configuration/TeaCommerce.Umbraco.Configuration.csproj +++ b/Source/TeaCommerce.Umbraco.Configuration/TeaCommerce.Umbraco.Configuration.csproj @@ -131,7 +131,6 @@ - @@ -148,7 +147,9 @@ - + + +