nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
244 lines • 11.4 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component } from '@angular/core';
import { UrlManagerService } from '../url-manager.service';
import { ContextService } from '../context.service';
import { ActivatedRoute } from '@angular/router';
import { ColorService } from '../color.service';
import { ErrorService } from '../error.service';
import { CollectionViewState } from '../route-data';
import { ViewModelFactoryService } from '../view-model-factory.service';
import * as Models from '../models';
import { ConfigService } from '../config.service';
import { LoggerService } from '../logger.service';
import { safeUnsubscribe } from '../helpers-components';
var ListComponent = (function () {
function ListComponent(activatedRoute, urlManager, context, color, viewModelFactory, error, configService, loggerService) {
var _this = this;
this.activatedRoute = activatedRoute;
this.urlManager = urlManager;
this.context = context;
this.color = color;
this.viewModelFactory = viewModelFactory;
this.error = error;
this.configService = configService;
this.loggerService = loggerService;
this.toggleActionMenu = function () { return _this.collection.toggleActionMenu(); };
this.reloadList = function () { return _this.collection.reload(); };
this.pageFirst = function () { return _this.collection.pageFirst(); };
this.pagePrevious = function () { return _this.collection.pagePrevious(); };
this.pageNext = function () { return _this.collection.pageNext(); };
this.pageLast = function () { return _this.collection.pageLast(); };
this.disableActions = function () { return _this.collection.noActions() ? true : null; };
this.hideAllCheckbox = function () { return _this.collection.noActions() || _this.collection.items.length === 0; };
this.pageFirstDisabled = function () { return _this.collection.pageFirstDisabled() ? true : null; };
this.pagePreviousDisabled = function () { return _this.collection.pagePreviousDisabled() ? true : null; };
this.pageNextDisabled = function () { return _this.collection.pageNextDisabled() ? true : null; };
this.pageLastDisabled = function () { return _this.collection.pageLastDisabled() ? true : null; };
this.showActions = function () { return _this.collection.showActions(); };
this.doTable = function () { return _this.collection.doTable(); };
this.doList = function () { return _this.collection.doList(); };
this.doSummary = function () { return _this.collection.doSummary(); };
this.hasTableData = function () { return _this.collection.hasTableData(); };
this.actionButton = {
value: "Actions",
doClick: function () { return _this.toggleActionMenu(); },
show: function () { return true; },
disabled: function () { return _this.disableActions(); },
tempDisabled: function () { return null; },
title: function () { return _this.actionsTooltip; },
accesskey: "a"
};
this.reloadButton = {
value: "Reload",
doClick: function () { return _this.reloadList(); },
show: function () { return true; },
disabled: function () { return null; },
tempDisabled: function () { return null; },
title: function () { return ""; },
accesskey: null
};
this.firstButton = {
value: "First",
doClick: function () { return _this.pageFirst(); },
show: function () { return true; },
disabled: function () { return _this.pageFirstDisabled(); },
tempDisabled: function () { return null; },
title: function () { return ""; },
accesskey: null
};
this.previousButton = {
value: "Previous",
doClick: function () { return _this.pagePrevious(); },
show: function () { return true; },
disabled: function () { return _this.pagePreviousDisabled(); },
tempDisabled: function () { return null; },
title: function () { return ""; },
accesskey: null
};
this.nextButton = {
value: "Next",
doClick: function () { return _this.pageNext(); },
show: function () { return true; },
disabled: function () { return _this.pageNextDisabled(); },
tempDisabled: function () { return null; },
title: function () { return ""; },
accesskey: null
};
this.lastButton = {
value: "Last",
doClick: function () { return _this.pageLast(); },
show: function () { return true; },
disabled: function () { return _this.pageLastDisabled(); },
tempDisabled: function () { return null; },
title: function () { return ""; },
accesskey: null
};
this.title = "";
this.currentState = CollectionViewState.List;
}
Object.defineProperty(ListComponent.prototype, "actionsTooltip", {
get: function () {
return this.collection.actionsTooltip();
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "message", {
get: function () {
return this.collection.getMessage();
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "description", {
get: function () {
return this.collection.description();
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "size", {
get: function () {
return this.collection.size;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "items", {
get: function () {
return this.collection.items;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "header", {
get: function () {
return this.collection.header;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "actionHolders", {
get: function () {
return [this.actionButton, this.reloadButton, this.firstButton, this.previousButton, this.nextButton, this.lastButton];
},
enumerable: true,
configurable: true
});
Object.defineProperty(ListComponent.prototype, "state", {
get: function () {
return CollectionViewState[this.currentState].toString().toLowerCase();
},
enumerable: true,
configurable: true
});
ListComponent.prototype.getActionExtensions = function (routeData) {
return routeData.objectId
? this.context.getActionExtensionsFromObject(routeData.paneId, Models.ObjectIdWrapper.fromObjectId(routeData.objectId, this.configService.config.keySeparator), routeData.actionId)
: this.context.getActionExtensionsFromMenu(routeData.menuId, routeData.actionId);
};
ListComponent.prototype.setup = function (routeData) {
var _this = this;
this.cachedRouteData = routeData;
var cachedList = this.context.getCachedList(routeData.paneId, routeData.page, routeData.pageSize);
this.getActionExtensions(routeData)
.then(function (ext) {
return _this.title = ext.friendlyName();
})
.catch(function (reject) { return _this.error.handleError(reject); });
var listKey = this.urlManager.getListCacheIndex(routeData.paneId, routeData.page, routeData.pageSize);
if (this.collection && this.collection.id === listKey) {
// same collection/page
this.currentState = routeData.state;
this.collection.refresh(routeData);
}
else if (this.collection && cachedList) {
// same collection different page
this.currentState = routeData.state;
this.collection.reset(cachedList, routeData);
}
else if (cachedList) {
// new collection
this.collection = this.viewModelFactory.listViewModel(cachedList, routeData);
this.currentState = routeData.state;
this.collection.refresh(routeData);
}
else {
// should never get here
this.loggerService.throw("ListComponent:setup Missing cachedList");
}
if (this.collection) {
// if any previous messages clear them
this.collection.resetMessage();
}
this.selectedDialogId = routeData.dialogId;
};
// now this is a child investigate reworking so object is passed in from parent
ListComponent.prototype.ngOnInit = function () {
var _this = this;
this.activatedRouteDataSub = this.activatedRoute.data.subscribe(function (data) {
var paneId = data.pane;
if (!_this.paneRouteDataSub) {
_this.paneRouteDataSub =
_this.urlManager.getPaneRouteDataObservable(paneId)
.subscribe(function (paneRouteData) {
if (!paneRouteData.isEqual(_this.lastPaneRouteData)) {
_this.lastPaneRouteData = paneRouteData;
_this.setup(paneRouteData);
}
});
}
;
});
};
ListComponent.prototype.ngOnDestroy = function () {
safeUnsubscribe(this.paneRouteDataSub);
safeUnsubscribe(this.activatedRouteDataSub);
};
return ListComponent;
}());
ListComponent = __decorate([
Component({
selector: 'nof-list',
template: require('./list.component.html'),
styles: [require('./list.component.css')]
}),
__metadata("design:paramtypes", [ActivatedRoute,
UrlManagerService,
ContextService,
ColorService,
ViewModelFactoryService,
ErrorService,
ConfigService,
LoggerService])
], ListComponent);
export { ListComponent };
//# sourceMappingURL=list.component.js.map