UNPKG

nakedobjects.spa

Version:

Single Page Application client for a Naked Objects application.

58 lines 2.64 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { getParametersAndCurrentValue } from './command-result'; import { Command } from './Command'; import * as Models from '../models'; import * as Usermessages from '../user-messages'; var OK = (function (_super) { __extends(OK, _super); function OK() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.shortCommand = "ok"; _this.fullCommand = Usermessages.okCommand; _this.helpText = Usermessages.okHelp; _this.minArguments = 0; _this.maxArguments = 0; return _this; } OK.prototype.isAvailableInCurrentContext = function () { return this.isDialog(); }; OK.prototype.doExecute = function (args, chained) { var _this = this; return this.getActionForCurrentDialog().then(function (action) { if (chained && action.isNotQueryOnly()) { return _this.returnResult("", _this.mayNotBeChained(Usermessages.queryOnlyRider), function () { }, true); } var fieldMap; if (_this.isForm()) { var obj = action.parent; fieldMap = _this.context.getObjectCachedValues(obj.id()); //Props passed in as pseudo-params to action } else { fieldMap = getParametersAndCurrentValue(action, _this.context); } return _this.context.invokeAction(action, fieldMap).then(function (result) { return _this.returnResult("", null, function () { return _this.urlManager.closeDialogReplaceHistory(_this.routeData().dialogId); }); }).catch(function (reject) { if (reject.error instanceof Models.ErrorMap) { var paramFriendlyName = function (paramId) { return Models.friendlyNameForParam(action, paramId); }; return _this.handleErrorResponse(reject.error, paramFriendlyName); } return Promise.reject(reject); }); }); }; ; return OK; }(Command)); export { OK }; //# sourceMappingURL=ok.js.map