@rws-framework/components
Version:
43 lines (32 loc) • 1.57 kB
text/typescript
import { RWSViewComponent, RWSView } from '@rws-framework/client';
import { observable, attr } from '@microsoft/fast-element';
import { ActionType, IExtraColumnFormatter, IFlexTableColumn } from '../../../rws-table/component';
import { ITypeInfo, ITypesResponse } from '../../../../../types/IBackendCore';
('rws-resource-list')
class RWSResourceListComponent extends RWSViewComponent {
resource: string;
emptyLabel: string = 'No records';
dbModelData: ITypesResponse = null;
resourceList: any[] = [];
columns: IFlexTableColumn[] = [];
fields: string[] = [];
extraFormatters: {[header_key: string] : IExtraColumnFormatter} = {};
headerTranslations: {[header_key: string] : string} = {};
actions: ActionType[] = [];
async connectedCallback()
{
super.connectedCallback();
const makeColumns: IFlexTableColumn[] = [];
for(const key in Object.keys(this.dbModelData.data.types)){
const responseObject: ITypeInfo = this.dbModelData.data.types[key];
makeColumns.push({
key: responseObject.fieldName,
header: responseObject.fieldName,
});
}
this.columns = makeColumns;
this.resourceList = await this.apiService.back.get(`${this.resource}:list`);
}
}
RWSResourceListComponent.defineComponent();
export { RWSResourceListComponent };