From 26ba8e6ff7ab41210f262b2adeb007fe0070f7b8 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas Date: Fri, 21 May 2021 19:22:47 +0530 Subject: [PATCH] feat: Create custom attributes for a contact from CRM (#2299) * feat: Creates cutom attributes for a contact from CRM * Review fixes * Change inline forms edit icon size * Review fixes * Fix validation labels color Co-authored-by: Muhsin Keloth --- .storybook/preview.js | 2 + .../dashboard/i18n/locale/en/contact.json | 24 ++++- .../contact/components/AddCustomAttribute.vue | 97 +++++++++++++++++++ .../contact/components/ContactAttribute.vue | 2 +- .../contact/components/ContactFields.vue | 39 +++++++- .../contact/components/ContactPanel.vue | 49 +++++++++- .../contact/components/ManageLayout.vue | 8 +- .../stories/AddCustomAttribute.stories.js | 32 ++++++ .../contact/stories/ContactFields.stories.js | 3 +- .../contacts/pages/ContactManageView.vue | 3 + 10 files changed, 248 insertions(+), 11 deletions(-) create mode 100644 app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue create mode 100644 app/javascript/dashboard/modules/contact/stories/AddCustomAttribute.stories.js diff --git a/.storybook/preview.js b/.storybook/preview.js index 40a2ce3ea..c62c3ef00 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -2,6 +2,7 @@ import { addDecorator } from '@storybook/vue'; import Vue from 'vue'; import Vuex from 'vuex'; import VueI18n from 'vue-i18n'; +import Vuelidate from 'vuelidate'; import WootUiKit from '../app/javascript/dashboard/components'; import i18n from '../app/javascript/dashboard/i18n'; @@ -9,6 +10,7 @@ import i18n from '../app/javascript/dashboard/i18n'; import '../app/javascript/dashboard/assets/scss/storybook.scss'; Vue.use(VueI18n); +Vue.use(Vuelidate); Vue.use(WootUiKit); Vue.use(Vuex); diff --git a/app/javascript/dashboard/i18n/locale/en/contact.json b/app/javascript/dashboard/i18n/locale/en/contact.json index 6a94011a5..80a33f25a 100644 --- a/app/javascript/dashboard/i18n/locale/en/contact.json +++ b/app/javascript/dashboard/i18n/locale/en/contact.json @@ -17,9 +17,6 @@ "NO_RECORDS_FOUND": "There are no previous conversations associated to this contact.", "TITLE": "Previous Conversations" }, - "CUSTOM_ATTRIBUTES": { - "TITLE": "Custom Attributes" - }, "LABELS": { "TITLE": "Conversation Labels", "MODAL": { @@ -170,5 +167,26 @@ "FOOTER": { "BUTTON": "View all notes" } + }, + "CUSTOM_ATTRIBUTES": { + "TITLE": "Custom Attributes", + "BUTTON": "Add custom attribute", + "ADD": { + "TITLE": "Create custom attribute", + "DESC": "Add custom information to this contact." + }, + "FORM": { + "CREATE": "Add attribute", + "CANCEL": "Cancel", + "NAME": { + "LABEL": "Custom attribute name", + "PLACEHOLDER": "Eg: shopify id", + "ERROR": "Invalid custom attribute name" + }, + "VALUE": { + "LABEL": "Attribute value", + "PLACEHOLDER": "Eg: 11901 " + } + } } } diff --git a/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue b/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue new file mode 100644 index 000000000..36540a341 --- /dev/null +++ b/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue @@ -0,0 +1,97 @@ + + + diff --git a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue index dd02ac338..74b92ba32 100644 --- a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue +++ b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue @@ -34,7 +34,7 @@ +
+ +
+ + {{ $t('CUSTOM_ATTRIBUTES.ADD.TITLE') }} + diff --git a/app/javascript/dashboard/modules/contact/components/ContactPanel.vue b/app/javascript/dashboard/modules/contact/components/ContactPanel.vue index 3deeee7ff..7ce914ce9 100644 --- a/app/javascript/dashboard/modules/contact/components/ContactPanel.vue +++ b/app/javascript/dashboard/modules/contact/components/ContactPanel.vue @@ -5,7 +5,11 @@ @message="toggleConversationModal" @edit="toggleEditModal" /> - + + diff --git a/app/javascript/dashboard/modules/contact/components/ManageLayout.vue b/app/javascript/dashboard/modules/contact/components/ManageLayout.vue index 87884e14e..363ed19df 100644 --- a/app/javascript/dashboard/modules/contact/components/ManageLayout.vue +++ b/app/javascript/dashboard/modules/contact/components/ManageLayout.vue @@ -55,10 +55,14 @@ export default { .wrap { @include three-column-grid(27.2rem); - background: var(--color-background); + min-height: 0; + + background: var(--color-background-light); border-top: 1px solid var(--color-border); } - +.left { + overflow: auto; +} .center { border-right: 1px solid var(--color-border); border-left: 1px solid var(--color-border); diff --git a/app/javascript/dashboard/modules/contact/stories/AddCustomAttribute.stories.js b/app/javascript/dashboard/modules/contact/stories/AddCustomAttribute.stories.js new file mode 100644 index 000000000..603cb5167 --- /dev/null +++ b/app/javascript/dashboard/modules/contact/stories/AddCustomAttribute.stories.js @@ -0,0 +1,32 @@ +import AddCustomAttribute from '../components/AddCustomAttribute'; +import { action } from '@storybook/addon-actions'; + +export default { + title: 'Components/Contact/AddCustomAttribute', + component: AddCustomAttribute, + argTypes: { + show: { + defaultValue: true, + control: { + type: 'boolean', + }, + }, + isCreating: { + defaultValue: false, + control: { + type: 'boolean', + }, + }, + }, +}; + +const Template = (args, { argTypes }) => ({ + props: Object.keys(argTypes), + components: { AddCustomAttribute }, + template: '', +}); + +export const DefaultAttribute = Template.bind({}); +DefaultAttribute.args = { + onCreate: action('edit'), +}; diff --git a/app/javascript/dashboard/modules/contact/stories/ContactFields.stories.js b/app/javascript/dashboard/modules/contact/stories/ContactFields.stories.js index 01a99f254..3b0b02be5 100644 --- a/app/javascript/dashboard/modules/contact/stories/ContactFields.stories.js +++ b/app/javascript/dashboard/modules/contact/stories/ContactFields.stories.js @@ -10,7 +10,7 @@ const Template = (args, { argTypes }) => ({ props: Object.keys(argTypes), components: { ContactFields }, template: - '', + '', }); export const DefaultContactFields = Template.bind({}); @@ -39,4 +39,5 @@ DefaultContactFields.args = { }, }, onUpdate: action('update'), + onCreate: action('create'), }; diff --git a/app/javascript/dashboard/routes/dashboard/contacts/pages/ContactManageView.vue b/app/javascript/dashboard/routes/dashboard/contacts/pages/ContactManageView.vue index 8b7707b3c..a94068801 100644 --- a/app/javascript/dashboard/routes/dashboard/contacts/pages/ContactManageView.vue +++ b/app/javascript/dashboard/routes/dashboard/contacts/pages/ContactManageView.vue @@ -73,6 +73,9 @@ export default {