From 36c41446eae4f90be1d589784dfd563e519d7939 Mon Sep 17 00:00:00 2001 From: Avior Date: Tue, 8 Oct 2019 17:35:29 +0200 Subject: [PATCH] Added a Mode Switcher --- FormManager.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/FormManager.ts b/FormManager.ts index d7a690a..236ef74 100644 --- a/FormManager.ts +++ b/FormManager.ts @@ -322,6 +322,26 @@ export default class FormManager { ajax.send() } + public setMode(mode: FMMode) { + if (mode == FMMode.ViewMode) { + for (const name in this.inputs) { + if (this.inputs.hasOwnProperty(name)) { + const input = this.inputs[name]; + input.element.setAttribute("disabled", "") + } + } + } + if (mode == FMMode.EditMode) { + for (const name in this.inputs) { + if (this.inputs.hasOwnProperty(name)) { + const input = this.inputs[name]; + input.element.removeAttribute("disabled") + } + + } + } + } + /** * Clear the fields in the form * @@ -339,6 +359,10 @@ export default class FormManager { } } +export enum FMMode { + EditMode, + ViewMode +} /** * TODO: FMFileInput