nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
52 lines • 2.49 kB
JavaScript
import * as Models from '../models';
import filter from 'lodash/filter';
import map from 'lodash/map';
import range from 'lodash/range';
import takeRight from 'lodash/takeRight';
var MultiLineDialogViewModel = (function () {
function MultiLineDialogViewModel(color, context, viewModelFactory, urlManager, error, routeData, action, holder) {
var _this = this;
this.color = color;
this.context = context;
this.viewModelFactory = viewModelFactory;
this.urlManager = urlManager;
this.error = error;
this.routeData = routeData;
this.action = action;
this.createRow = function (i) {
return _this.viewModelFactory.dialogViewModel(_this.routeData, _this.action, null, true, i);
};
this.objectFriendlyName = "";
this.objectTitle = "";
this.header = function () { return _this.dialogs.length === 0 ? [] : map(_this.dialogs[0].parameters, function (p) { return p.title; }); };
this.invokeAndAdd = function (index) {
_this.dialogs[index].doInvoke();
_this.context.clearDialogCachedValues();
return _this.add(index);
};
this.pushNewDialog = function () { return _this.dialogs.push(_this.createRow(_this.dialogs.length)) - 1; };
this.add = function (index) {
if (index === _this.dialogs.length - 1) {
// if this is last dialog always add another
return _this.pushNewDialog();
}
else if (takeRight(_this.dialogs)[0].submitted) {
// if the last dialog is submitted add another
return _this.pushNewDialog();
}
return 0;
};
this.submittedCount = function () { return filter(_this.dialogs, function (d) { return d.submitted; }).length; };
if (holder instanceof Models.DomainObjectRepresentation) {
this.objectTitle = holder.title();
this.objectFriendlyName = holder.extensions().friendlyName();
}
var initialCount = action.extensions().multipleLines() || 1;
this.dialogs = map(range(initialCount), function (i) { return _this.createRow(i); });
this.title = this.dialogs[0].title;
this.action.parent.etagDigest = "*";
}
return MultiLineDialogViewModel;
}());
export { MultiLineDialogViewModel };
//# sourceMappingURL=multi-line-dialog-view-model.js.map