diff --git a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue index 854e87495..703b973ec 100644 --- a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue +++ b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue @@ -8,7 +8,26 @@ {{ label }} -
+
+
+ +
+ +
+
+
+

{{ value }}

@@ -39,9 +58,25 @@ export default { value: { type: [String, Number], default: '' }, showEdit: { type: Boolean, default: false }, }, + data() { + return { + isEditing: false, + editedValue: this.value, + }; + }, methods: { + focusInput() { + this.$refs.inputfield.focus(); + }, onEdit() { - this.$emit('edit'); + this.isEditing = true; + this.$nextTick(() => { + this.focusInput(); + }); + }, + onUpdate() { + this.isEditing = false; + this.$emit('update', this.editedValue); }, }, }; @@ -54,6 +89,7 @@ export default { .title-wrap { display: flex; align-items: center; + margin-bottom: var(--space-mini); } .title { display: flex; @@ -66,10 +102,10 @@ export default { .edit-button { display: none; } -.value-wrap { +.value--view { display: flex; - &:hover { + &.is-editable:hover { .value { background: var(--color-background); } diff --git a/app/javascript/dashboard/modules/contact/stories/ContactAttribute.stories.js b/app/javascript/dashboard/modules/contact/stories/ContactAttribute.stories.js index 0f75af150..4deab66f2 100644 --- a/app/javascript/dashboard/modules/contact/stories/ContactAttribute.stories.js +++ b/app/javascript/dashboard/modules/contact/stories/ContactAttribute.stories.js @@ -34,7 +34,7 @@ export default { const Template = (args, { argTypes }) => ({ props: Object.keys(argTypes), components: { ContactAttribute }, - template: '', + template: '', }); export const DefaultAttribute = Template.bind({});