From 22dcedda7999ba950c679ffacdcdf9ae1e15b61f Mon Sep 17 00:00:00 2001 From: thefalconx33 Date: Mon, 5 Aug 2019 17:16:35 +0530 Subject: [PATCH] Focus on form section's first input --- ui/components/Form/FormActions.vue | 55 +++++++++++++++--------------- ui/components/Form/FormLayout.vue | 8 ++--- ui/components/controls/Table.vue | 8 +++-- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/ui/components/Form/FormActions.vue b/ui/components/Form/FormActions.vue index d3c0b75d..dbeb172f 100644 --- a/ui/components/Form/FormActions.vue +++ b/ui/components/Form/FormActions.vue @@ -2,7 +2,12 @@
{{ title }}
- {{ _('Save') }} + {{ _('Save') }} {{ _('Submit') }} {{ _('Revert') }}
@@ -31,7 +36,7 @@ export default { showNextAction: false, showPrint: false, disableSave: false - } + }; }, created() { this.doc.on('change', () => { @@ -44,36 +49,32 @@ export default { this.isDirty = this.doc._dirty; this.showSubmit = - this.meta.isSubmittable - && !this.isDirty - && !this.doc.isNew() - && this.doc.submitted === 0; + this.meta.isSubmittable && + !this.isDirty && + !this.doc.isNew() && + this.doc.submitted === 0; this.showRevert = - this.meta.isSubmittable - && !this.isDirty - && !this.doc.isNew() - && this.doc.submitted === 1; + this.meta.isSubmittable && + !this.isDirty && + !this.doc.isNew() && + this.doc.submitted === 1; - this.showNextAction = 1 + this.showNextAction = 1; - this.showNextAction = - !this.doc.isNew() - && this.links.length; + this.showNextAction = !this.doc.isNew() && this.links.length; - this.showPrint = - this.doc.submitted === 1 - && this.meta.print + this.showPrint = this.doc.submitted === 1 && this.meta.print; - this.showSave = - this.doc.isNew() ? - true : - this.meta.isSubmittable ? - (this.isDirty ? true : false) : - true; + this.showSave = this.doc.isNew() + ? true + : this.meta.isSubmittable + ? this.isDirty + ? true + : false + : true; - this.disableSave = - this.doc.isNew() ? false : !this.isDirty; + this.disableSave = this.doc.isNew() ? false : !this.isDirty; } }, computed: { @@ -84,12 +85,12 @@ export default { const _ = this._; if (this.doc.isNew()) { - return _('New {0}', _(this.doc.doctype)); + return _('New {0}', _(this.meta.label || this.doc.doctype)); } const titleField = this.meta.titleField || 'name'; return this.doc[titleField]; } } -} +}; diff --git a/ui/components/Form/FormLayout.vue b/ui/components/Form/FormLayout.vue index 0a1d1651..35b23f30 100644 --- a/ui/components/Form/FormLayout.vue +++ b/ui/components/Form/FormLayout.vue @@ -2,19 +2,19 @@
diff --git a/ui/components/controls/Table.vue b/ui/components/controls/Table.vue index 7c50fd74..f6bf8127 100644 --- a/ui/components/controls/Table.vue +++ b/ui/components/controls/Table.vue @@ -69,7 +69,7 @@
Remove - Add Row + Add Row
@@ -100,7 +100,11 @@ export default { const { index, fieldname } = this.currentlyFocused; if (this.isEditing(index, fieldname)) { // FIX: enter pressing on a cell with a value throws error. - // this.deactivateEditing(); + // Problem: input gets undefined on deactivating + setTimeout(() => { + this.deactivateEditing(); + }, 300); + this.activateFocus(index, fieldname); } else { this.activateEditing(index, fieldname);