From becacfc38235bf3d20ea3bc61e5adda7f6b414ad Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Wed, 8 Mar 2023 23:23:08 +0330 Subject: [PATCH] refactor(soffit-pwa): form template --- .../soffit-pwa/src/ui/stuff/lottery-form.ts | 30 +++++++++++++++---- .../src/ui/stuff/supply-chain-form.ts | 6 +--- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/uniquely/soffit-pwa/src/ui/stuff/lottery-form.ts b/uniquely/soffit-pwa/src/ui/stuff/lottery-form.ts index 2ed58ef345..2eaface3e7 100644 --- a/uniquely/soffit-pwa/src/ui/stuff/lottery-form.ts +++ b/uniquely/soffit-pwa/src/ui/stuff/lottery-form.ts @@ -72,7 +72,7 @@ export class AlwatrLotteryForm extends LocalizeMixin(SignalMixin(AlwatrBaseEleme @property({type: Boolean, reflect: true}) disabled = false; - async submit(): Promise { + protected async submit(): Promise { const bodyJson = this.getFormData(); this._logger.logMethodArgs('submit', bodyJson); @@ -91,11 +91,11 @@ export class AlwatrLotteryForm extends LocalizeMixin(SignalMixin(AlwatrBaseEleme } } - async cancel(): Promise { + protected async cancel(): Promise { this.dispatchEvent(new CustomEvent('form-canceled')); } - getFormData(): Record { + protected getFormData(): Record { this._logger.logMethod('getFormData'); const data: Record = {}; for (const inputElement of this.renderRoot.querySelectorAll( @@ -107,6 +107,14 @@ export class AlwatrLotteryForm extends LocalizeMixin(SignalMixin(AlwatrBaseEleme } override render(): unknown { + this._logger.logMethod('render'); + return [ + this.inputTemplate(), + this.partButtonTemplate(), + ]; + } + + protected inputTemplate(): unknown { this._logger.logMethod('render'); return html` + `; + } + + protected partButtonTemplate(): unknown { + return html`
- ${message('submit_form')} - ${message('cancel')} + ${message('submit_form')} + + ${message('cancel')}
`; } diff --git a/uniquely/soffit-pwa/src/ui/stuff/supply-chain-form.ts b/uniquely/soffit-pwa/src/ui/stuff/supply-chain-form.ts index c3e898f735..ba5260db5e 100644 --- a/uniquely/soffit-pwa/src/ui/stuff/supply-chain-form.ts +++ b/uniquely/soffit-pwa/src/ui/stuff/supply-chain-form.ts @@ -20,7 +20,7 @@ declare global { export class AlwatrSupplyChainForm extends AlwatrLotteryForm { static override formId = 'supply-chain'; - override render(): unknown { + override inputTemplate(): unknown { this._logger.logMethod('render'); return html` -
- ${message('submit_form')} - ${message('cancel')} -
`; } }