From fdcc322660731a4334865f09564ef21bdab4fa2f Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 31 Aug 2021 13:54:34 +0530 Subject: [PATCH] feat: Add the ability to create custom attribute (#2903) --- app/javascript/dashboard/api/attributes.js | 9 + .../i18n/locale/en/attributesMgmt.json | 34 ++- .../settings/attributes/AddAttribute.vue | 201 ++++++++++++++++++ .../dashboard/settings/attributes/Index.vue | 24 ++- app/javascript/dashboard/store/index.js | 2 + .../dashboard/store/modules/attributes.js | 91 ++++++++ .../modules/specs/attributes/actions.spec.js | 93 ++++++++ .../modules/specs/attributes/fixtures.js | 16 ++ .../modules/specs/attributes/getters.spec.js | 30 +++ .../specs/attributes/mutations.spec.js | 44 ++++ .../dashboard/store/mutation-types.js | 7 + app/models/custom_attribute_definition.rb | 2 +- 12 files changed, 550 insertions(+), 3 deletions(-) create mode 100644 app/javascript/dashboard/api/attributes.js create mode 100644 app/javascript/dashboard/routes/dashboard/settings/attributes/AddAttribute.vue create mode 100644 app/javascript/dashboard/store/modules/attributes.js create mode 100644 app/javascript/dashboard/store/modules/specs/attributes/actions.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/attributes/fixtures.js create mode 100644 app/javascript/dashboard/store/modules/specs/attributes/getters.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/attributes/mutations.spec.js diff --git a/app/javascript/dashboard/api/attributes.js b/app/javascript/dashboard/api/attributes.js new file mode 100644 index 000000000..c93807837 --- /dev/null +++ b/app/javascript/dashboard/api/attributes.js @@ -0,0 +1,9 @@ +import ApiClient from './ApiClient'; + +class AttributeAPI extends ApiClient { + constructor() { + super('custom_attribute_definitions', { accountScoped: true }); + } +} + +export default new AttributeAPI(); diff --git a/app/javascript/dashboard/i18n/locale/en/attributesMgmt.json b/app/javascript/dashboard/i18n/locale/en/attributesMgmt.json index af8c41e6f..275cdf81d 100644 --- a/app/javascript/dashboard/i18n/locale/en/attributesMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/attributesMgmt.json @@ -1,6 +1,38 @@ { "ATTRIBUTES_MGMT": { "HEADER": "Attributes", - "HEADER_BTN_TXT": "Add Attribute" + "HEADER_BTN_TXT": "Add Attribute", + "ADD": { + "TITLE": "Add attribute", + "SUBMIT": "Create", + "CANCEL_BUTTON_TEXT": "Cancel", + "FORM": { + "NAME": { + "LABEL": "Display Name", + "PLACEHOLDER": "Enter attribute display name" + }, + "DESC": { + "LABEL": "Description", + "PLACEHOLDER": "Enter attribute description" + }, + "MODEL": { + "LABEL": "Model", + "PLACEHOLDER": "Please select a model", + "ERROR": "Model is required" + }, + "TYPE": { + "LABEL": "Type", + "PLACEHOLDER": "Please select a type", + "ERROR": "Type is required" + }, + "KEY": { + "LABEL": "Key" + } + }, + "API": { + "SUCCESS_MESSAGE": "Attribute added successfully", + "ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later" + } + } } } diff --git a/app/javascript/dashboard/routes/dashboard/settings/attributes/AddAttribute.vue b/app/javascript/dashboard/routes/dashboard/settings/attributes/AddAttribute.vue new file mode 100644 index 000000000..ba00f54b1 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/attributes/AddAttribute.vue @@ -0,0 +1,201 @@ +