UNPKG

react-antd-admin-panel

Version:

Easy prototyping admin panel using React and Antd

110 lines 2.9 kB
export default class Action { constructor() { this._type = 'submit'; this._class = 'undefined'; this._post = undefined; this._actions = []; // Space for any sub-actions, such as the drawer. this.callCallback = () => console.log('No action implemented'); // For the callback this._onError = () => { }; this._onComplete = () => { }; this._hideClear = false; } click(args) { switch (this._type) { case 'submit': this._formula.submit(args, this); break; case 'callback': this.callCallback(args, this); // this.callCompletes(args); break; default: break; } } hideClear() { this._hideClear = true; return this; } callback(value) { this._type = 'callback'; this.callCallback = value; return this; } onError(func) { this._onError = func; return this; } onComplete(func) { this._onComplete = func; return this; } callErrors() { var _a; (_a = this._onError) === null || _a === void 0 ? void 0 : _a.call(this); /* Object.keys(this._onError).forEach((r: string) => { this._onError[r](); }) */ } callCompletes(args) { var _a; (_a = this._onComplete) === null || _a === void 0 ? void 0 : _a.call(this, args); /* Object.keys(this._onComplete).forEach((r: string) => { this._onComplete[r](); }) */ } key(value) { this._key = value; return this; } post(value) { this._postKey = value; return this; } icon(value) { this._icon = value; return this; } label(value) { this._label = value; return this; } type(value) { this._type = value; return this; } bind(value) { this._bind = value; return this; } route(value) { this._route = value; return this; } action(value) { if (!this._actions.some((r) => r._label === value._label)) { this._actions.push(value); } return this; } section(section) { this._section = section; return this; } formula(formula) { this._formula = formula; return this; } component(component) { this._component = component; return this; } fontawesome(v) { this._fontawesome = v; return this; } access(v) { this._access = v; return this; } disabled(v) { this._disabled = v; return this; } } //# sourceMappingURL=Action.js.map