Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(list => {
this.state = list.hasTableData() ? CollectionViewState.Table : CollectionViewState.List;
this.listRep = list;
this.updateItems(list.value());
})
.catch((reject: ErrorWrapper) => {
function getDefaultTableState(exts: Ro.Extensions) {
if (exts.renderEagerly()) {
return exts.tableViewColumns() || exts.tableViewTitle() ? CollectionViewState.Table : CollectionViewState.List;
}
return CollectionViewState.Summary;
}
get header() {
return this.state === CollectionViewState.Table ? this.collection.header : null;
}
}
private isTable = () => this.collection.currentState === CollectionViewState.Table;
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 doTable = () => {
this.urlManager.setListState(CollectionViewState.Table, this.onPaneId);
}
private readonly updateItems = (value: Ro.Link[]) => {
this.items = this.viewModelFactory.getItems(value,
this.state === CollectionViewState.Table,
this.routeData,
this);
const totalCount = this.listRep.pagination()!.totalCount;
const count = this.items.length;
this.size = count;
if (count > 0) {
this.description = () => Msg.pageMessage(this.page, this.numPages, count, totalCount);
} else {
this.description = () => Msg.noItemsFound;
}
}
readonly refresh = (routeData: PaneRouteData) => {
this.routeData = routeData;
if (this.state !== routeData.state) {
if (routeData.state === CollectionViewState.Table && !this.hasTableData()) {
this.recreate(this.page, this.pageSize)
.then(list => {
this.state = list.hasTableData() ? CollectionViewState.Table : CollectionViewState.List;
this.listRep = list;
this.updateItems(list.value());
})
.catch((reject: ErrorWrapper) => {
this.error.handleError(reject);
});
} else {
this.state = routeData.state;
this.updateItems(this.listRep.value());
}
}
}
if (state == null) {
state = getDefaultTableState(this.collectionRep.extensions());
}
this.editing = routeData.interactionMode === InteractionMode.Edit;
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));