Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
readonly reset = (routeData: PaneRouteData, resetting: boolean) => {
let state = routeData.collections[this.collectionRep.collectionId()];
// collections are always shown as summary on transient
if (routeData.interactionMode === InteractionMode.Transient) {
state = CollectionViewState.Summary;
}
function getDefaultTableState(exts: Ro.Extensions) {
if (exts.renderEagerly()) {
return exts.tableViewColumns() || exts.tableViewTitle() ? CollectionViewState.Table : CollectionViewState.List;
}
return CollectionViewState.Summary;
}
if (state == null) {
state = getDefaultTableState(this.collectionRep.extensions());
}
this.editing = routeData.interactionMode === InteractionMode.Edit;
if (resetting || state !== this.currentState) {
function getDefaultTableState(exts: Ro.Extensions) {
if (exts.renderEagerly()) {
return exts.tableViewColumns() || exts.tableViewTitle() ? CollectionViewState.Table : CollectionViewState.List;
}
return CollectionViewState.Summary;
}
private isSummary = () => this.collection.currentState === CollectionViewState.Summary;
if (resetting || state !== this.currentState) {
const size = this.collectionRep.size();
const itemLinks = this.collectionRep.value();
if (size == null || size > 0) {
this.mayHaveItems = true;
}
this.details = Helpers.getCollectionDetails(size);
const getDetails = itemLinks == null || state === CollectionViewState.Table;
const actions = this.collectionRep.actionMembers();
this.setActions(actions, routeData);
if (state === CollectionViewState.Summary) {
this.items = [];
} else if (getDetails) {
this.context.getCollectionDetails(this.collectionRep as Ro.CollectionMember, state, resetting).
then(details => {
this.items = this.viewModelFactory.getItems(details.value(),
state === CollectionViewState.Table,
routeData,
this);
this.details = Helpers.getCollectionDetails(this.items.length);
}).
catch((reject: ErrorWrapper) => this.error.handleError(reject));
} else {
this.items = this.viewModelFactory.getItems(itemLinks!, this.currentState === CollectionViewState.Table, routeData, this);
}
this.currentState = state;
}
readonly doSummary = () => this.urlManager.setCollectionMemberState(this.collectionRep.collectionId(), CollectionViewState.Summary, this.onPaneId);
readonly doList = () => this.urlManager.setCollectionMemberState(this.collectionRep.collectionId(), CollectionViewState.List, this.onPaneId);
readonly doSummary = () => {
this.urlManager.setListState(CollectionViewState.Summary, this.onPaneId);
}