diff --git a/src/component/form/form.js b/src/component/form/form.js index 87cd64236..748b6a65f 100644 --- a/src/component/form/form.js +++ b/src/component/form/form.js @@ -35,6 +35,7 @@ }, _createItems: function () { + var self = this; var o = this.options; return BI.map(o.items, function (idx, item) { @@ -51,6 +52,11 @@ eventName: "EVENT_CHANGE", action: function () { this.validate(); + if (self.isAllValid()) { + self.fireEvent("EVENT_VALID"); + } else { + self.fireEvent("EVENT_ERROR"); + } } }] }; @@ -88,4 +94,6 @@ } }); +BI.Form.EVENT_VALID = "EVENT_VALID"; +BI.Form.EVENT_ERROR = "EVENT_ERROR"; BI.shortcut("bi.custom_form", BI.Form); diff --git a/typescript/component/form/form.ts b/typescript/component/form/form.ts new file mode 100644 index 000000000..c802c6362 --- /dev/null +++ b/typescript/component/form/form.ts @@ -0,0 +1,15 @@ +import { Widget } from "../../core/widget"; + +export declare class Form extends Widget { + static xtype: string; + static EVENT_VALID: string; + static EVENT_ERROR: string; + + isAllValid(): boolean; + + validateWithNoTip(): boolean[]; + + validate(): boolean[]; + + getValue(): T[]; +} \ No newline at end of file diff --git a/typescript/index.ts b/typescript/index.ts index 619ab72ce..efecf3fec 100644 --- a/typescript/index.ts +++ b/typescript/index.ts @@ -25,6 +25,7 @@ import { SearchTextValueCombo } from "./case/combo/searchtextvaluecombo/combo.se import { SignEditor } from "./case/editor/editor.sign"; import { StateEditor } from './case/editor/editor.state'; import { AllValueMultiTextValueCombo } from "./component/allvaluemultitextvaluecombo/allvalue.multitextvalue.combo"; +import { Form } from './component/form/form'; import { AbstractTreeValueChooser } from "./component/treevaluechooser/abstract.treevaluechooser"; import { AbstractListTreeValueChooser } from "./component/treevaluechooser/abstract.treevaluechooser.list"; import { Action, ActionFactory } from "./core/action/action"; @@ -216,6 +217,7 @@ export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils { SmallTextValueCombo: typeof SmallTextValueCombo; BubbleCombo: typeof BubbleCombo; AllValueMultiTextValueCombo: typeof AllValueMultiTextValueCombo; + Form: typeof Form; IconTextItem: typeof IconTextItem; MultiSelectItem: typeof MultiSelectItem; AbstractLabel: typeof AbstractLabel; @@ -508,6 +510,7 @@ export { Switch, HorizontalLayout, ShelterEditor, + Form, TextTrigger, SelectTextTrigger, DateInterval,