@rws-framework/components
Version:
52 lines (38 loc) • 1.74 kB
text/typescript
import { ITypesResponse } from '../../../types/IBackendCore';
import { observable, attr } from '@microsoft/fast-element';
import { RWSViewComponent, RWSView } from '@rws-framework/client';
import { RWSResourceListComponent } from './variants/list/component';
import { RWSResourceFormComponent } from './variants/form/component';
import { IRWSResourceQuery } from '../../../types/IRWSResource';
import { ActionType, IExtraColumnFormatter, IFlexTableColumn } from '../rws-table/component';
RWSResourceListComponent;
RWSResourceFormComponent;
('rws-resource')
class RWSApiResource extends RWSViewComponent {
resource: string;
resourceLabel: string = null;
createEntryLabel = 'Create entry';
listEntryLabel = 'Entries list';
createEnabled = 'true';
emptyLabel: string = 'No records';
dbModelData: IKDBTypesResponse = null;
viewType: 'list' | 'form' = 'list';
fields: string[] = [];
extraFormatters: {[header_key: string] : IExtraColumnFormatter} = {};
headerTranslations: {[header_key: string] : string} = {};
listActions: ActionType[] = [];
back: (resource: any) => Promise<void> = async (resource: any) => {
this.viewType = 'list';
};
async connectedCallback(): Promise<void>
{
super.connectedCallback();
this.dbModelData = await this.apiService.getResource(this.resource);
}
toggleForm()
{
this.viewType = this.viewType === 'form' ? 'list' : 'form';
}
}
RWSApiResource.defineComponent();
export { RWSApiResource };