From 6192389a3b4441b8b46d2eb795e954077ffea427 Mon Sep 17 00:00:00 2001 From: James Chang Date: Sun, 18 Apr 2021 09:36:04 -0400 Subject: [PATCH] Customize text on recordActionMenu --- .../special/editPersonalBestInterface.vue | 24 ++++++++++++------- frontend/components/menu/recordActionMenu.vue | 14 +++++++---- frontend/models/personalBest.ts | 4 ++++ frontend/types/index.ts | 9 +++++++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/frontend/components/interface/crud/special/editPersonalBestInterface.vue b/frontend/components/interface/crud/special/editPersonalBestInterface.vue index 1262c5f..c4fd915 100644 --- a/frontend/components/interface/crud/special/editPersonalBestInterface.vue +++ b/frontend/components/interface/crud/special/editPersonalBestInterface.vue @@ -152,13 +152,15 @@ export default { watch: { pbClass(val) { - if (!isObject(val)) return - // eslint-disable-next-line camelcase - if (!val?.setSize) { - this.setInputValue('setSize', null) - } else { - this.setInputValue('setSize', val.setSize) + if (isObject(val)) { + if (!val?.setSize) { + this.setInputValue('setSize', null) + } else { + this.setInputValue('setSize', val.setSize) + } } + + if (val && this.getInputValue('setSize')) this.focusTimeElapsedInput() }, timeElapsed(val) { if (!val) return @@ -181,13 +183,17 @@ export default { mounted() { // focus the time field if the event and pbClass are set if (this.event && this.pbClass) { - setTimeout(() => { - this.$refs.timeElapsed[0].focus() - }, 0) + this.focusTimeElapsedInput() } }, methods: { + focusTimeElapsedInput() { + setTimeout(() => { + this.$refs.timeElapsed[0].focus() + }, 0) + }, + isNumber(evt) { const charCode = evt.which ? evt.which : evt.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) { diff --git a/frontend/components/menu/recordActionMenu.vue b/frontend/components/menu/recordActionMenu.vue index 9d22060..2b9d5f7 100644 --- a/frontend/components/menu/recordActionMenu.vue +++ b/frontend/components/menu/recordActionMenu.vue @@ -48,9 +48,11 @@ @click="openEditDialog('edit')" > - mdi-pencil + {{ recordInfo.editOptions.icon || 'mdi-pencil' }} - Edit + {{ + recordInfo.editOptions.text || 'Edit' + }} - mdi-content-copy + + {{ recordInfo.copyOptions.icon || 'mdi-content-copy' }} - Duplicate + {{ + recordInfo.copyOptions.text || 'Duplicate' + }} >{ }, editOptions: { fields: ['publicComments', 'product.id'], + icon: 'mdi-comment-edit', + text: 'Comments', }, viewOptions: { fields: [ @@ -355,6 +357,8 @@ export const PersonalBest = >{ copyOptions: { fields: ['event.id', 'pbClass.id', 'setSize'], component: EditPersonalBestInterface, + icon: 'mdi-plus', + text: 'New PB', }, expandTypes: [], diff --git a/frontend/types/index.ts b/frontend/types/index.ts index 069c42d..a0edfe7 100644 --- a/frontend/types/index.ts +++ b/frontend/types/index.ts @@ -113,6 +113,10 @@ export type RecordInfo = { component?: any // if not createX, the custom create operation name operationName?: string + // replacement icon + icon?: string + // replacement text + text?: string } deleteOptions?: { @@ -138,6 +142,11 @@ export type RecordInfo = { fields: string[] // custom component component?: any + + // replacement icon + icon?: string + // replacement text + text?: string } shareOptions?: {