nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
133 lines • 5.9 kB
JavaScript
import keys from 'lodash/keys';
import isEqual from 'lodash/isEqual';
export var ViewType;
(function (ViewType) {
ViewType[ViewType["Home"] = 0] = "Home";
ViewType[ViewType["Object"] = 1] = "Object";
ViewType[ViewType["List"] = 2] = "List";
ViewType[ViewType["Error"] = 3] = "Error";
ViewType[ViewType["Recent"] = 4] = "Recent";
ViewType[ViewType["Attachment"] = 5] = "Attachment";
ViewType[ViewType["ApplicationProperties"] = 6] = "ApplicationProperties";
ViewType[ViewType["MultiLineDialog"] = 7] = "MultiLineDialog";
})(ViewType || (ViewType = {}));
export var CollectionViewState;
(function (CollectionViewState) {
CollectionViewState[CollectionViewState["Summary"] = 0] = "Summary";
CollectionViewState[CollectionViewState["List"] = 1] = "List";
CollectionViewState[CollectionViewState["Table"] = 2] = "Table";
})(CollectionViewState || (CollectionViewState = {}));
export var ApplicationMode;
(function (ApplicationMode) {
ApplicationMode[ApplicationMode["Gemini"] = 0] = "Gemini";
ApplicationMode[ApplicationMode["Cicero"] = 1] = "Cicero";
})(ApplicationMode || (ApplicationMode = {}));
export var InteractionMode;
(function (InteractionMode) {
InteractionMode[InteractionMode["View"] = 0] = "View";
InteractionMode[InteractionMode["Edit"] = 1] = "Edit";
InteractionMode[InteractionMode["Transient"] = 2] = "Transient";
InteractionMode[InteractionMode["Form"] = 3] = "Form";
InteractionMode[InteractionMode["NotPersistent"] = 4] = "NotPersistent";
})(InteractionMode || (InteractionMode = {}));
var RouteData = (function () {
function RouteData(configService, loggerService) {
var _this = this;
this.configService = configService;
this.loggerService = loggerService;
this.pane = function (pane) {
if (pane === Pane.Pane1) {
return _this.pane1;
}
if (pane === Pane.Pane2) {
return _this.pane2;
}
return _this.loggerService.throw('RouteData:pane ${pane} is not a valid pane index on RouteData');
};
this.pane1 = new PaneRouteData(Pane.Pane1, configService.config.doUrlValidation, loggerService);
this.pane2 = new PaneRouteData(Pane.Pane2, configService.config.doUrlValidation, loggerService);
}
return RouteData;
}());
export { RouteData };
export var Pane;
(function (Pane) {
Pane[Pane["Pane1"] = 1] = "Pane1";
Pane[Pane["Pane2"] = 2] = "Pane2";
})(Pane || (Pane = {}));
export function getOtherPane(paneId) {
return paneId === Pane.Pane1 ? Pane.Pane2 : Pane.Pane1;
}
var PaneRouteData = (function () {
function PaneRouteData(paneId, doUrlValidation, loggerService) {
this.paneId = paneId;
this.doUrlValidation = doUrlValidation;
this.loggerService = loggerService;
this.isNull = {
condition: function (val) { return !val; },
name: "is null"
};
this.isNotNull = {
condition: function (val) { return val; },
name: "is not null"
};
this.isLength0 = {
condition: function (val) { return val && val.length === 0; },
name: "is length 0"
};
this.isEmptyMap = {
condition: function (val) { return keys(val).length === 0; },
name: "is an empty map"
};
}
PaneRouteData.prototype.isValid = function (name) {
if (!this.hasOwnProperty(name)) {
this.loggerService.throw("PaneRouteData:isValid " + name + " is not a valid property on PaneRouteData");
}
};
PaneRouteData.prototype.assertMustBe = function (context, name, contextCondition, valueCondition) {
// make sure context and name are valid
this.isValid(context);
this.isValid(name);
if (contextCondition.condition(this[context])) {
if (!valueCondition.condition(this[name])) {
this.loggerService.throw("PaneRouteData:assertMustBe Expect that " + name + " " + valueCondition.name + " when " + context + " " + contextCondition.name + " within url \"" + this.validatingUrl + "\"");
}
}
};
PaneRouteData.prototype.assertMustBeEmptyOutsideContext = function (context, name) {
this.assertMustBe(context, name, this.isNull, this.isEmptyMap);
};
PaneRouteData.prototype.assertMustBeNullOutsideContext = function (context, name) {
this.assertMustBe(context, name, this.isNull, this.isNull);
};
PaneRouteData.prototype.assertMustBeNullInContext = function (context, name) {
this.assertMustBe(context, name, this.isNotNull, this.isNull);
};
PaneRouteData.prototype.assertMustBeZeroLengthInContext = function (context, name) {
this.assertMustBe(context, name, this.isNotNull, this.isLength0);
};
PaneRouteData.prototype.validate = function (url) {
this.validatingUrl = url;
if (this.doUrlValidation) {
// Can add more conditions here
this.assertMustBeNullInContext("objectId", "menuId");
this.assertMustBeNullInContext("menuId", "objectId");
}
};
PaneRouteData.prototype.isEqual = function (other) {
if (!this.rawParms || !other || !other.rawParms) {
return false;
}
return isEqual(this.rawParms, other.rawParms);
};
PaneRouteData.prototype.isEqualIgnoringReload = function (other) {
if (!this.rawParmsWithoutReload || !other || !other.rawParmsWithoutReload) {
return false;
}
return isEqual(this.rawParmsWithoutReload, other.rawParmsWithoutReload);
};
return PaneRouteData;
}());
export { PaneRouteData };
//# sourceMappingURL=route-data.js.map