<eg-staff-banner bannerText="SVF Record Attribute Coded Value Map Configuration" i18n-bannerText>
</eg-staff-banner>
-<eg-grid #grid idlClass="ccvm" [dataSource]="gridDataSource" [sortable]="true">
- <eg-grid-toolbar-button
- label="New SVF Record Attribute Coded Value Map" i18n-label (onClick)="createNew()">
- </eg-grid-toolbar-button>
- <eg-grid-toolbar-action label="Edit Selected" i18n-label [action]="editSelected">
- </eg-grid-toolbar-action>
- <eg-grid-toolbar-action label="Delete Selected" i18n-label
- [action]="deleteSelected"></eg-grid-toolbar-action>
-
- <eg-grid-column path='id' i18n-label label="ID"></eg-grid-column>
- <eg-grid-column path='ctype' i18n-label label="SVF Attribute"></eg-grid-column>
- <eg-grid-column path='code' i18n-label label="Code"></eg-grid-column>
- <eg-grid-column path='value' i18n-label label='value'></eg-grid-column>
- <eg-grid-column path='description' i18n-label label='description'></eg-grid-column>
- <eg-grid-column path='opac_visible' i18n-label label='OPAC Visible'></eg-grid-column>
- <eg-grid-column path='search_label' i18n-label label='Search Label'></eg-grid-column>
- <eg-grid-column path='is_simple' i18n-label label='Is Simple Selector'></eg-grid-column>
- <eg-grid-column path='concept_uri' i18n-label label='Concept URI'></eg-grid-column>
- <ng-template #compDefTmpl let-row="row">
- <div *ngIf="row.ctype().composite() == 't'">
- <a href="staff/admin/server/config/coded_value_map/composite_def/{{row.id()}}">
- Manage
- </a>
- </div>
- </ng-template>
- <eg-grid-column i18n-label label="Composite Definition"
- [cellTemplate]="compDefTmpl"></eg-grid-column>
-</eg-grid>
+<eg-admin-page idlClass="ccvm" [templateFields]="[{name: 'Composite Definition', template: compDefTmpl}]">
+</eg-admin-page>
-<eg-fm-record-editor #editDialog idlClass="ccvm">
-</eg-fm-record-editor>
-<eg-string #createString i18n-text text="New Map Added"></eg-string>
-<eg-string #createErrString i18n-text text="Failed to Create New Map">
-</eg-string>
-<eg-string #deleteFailedString i18n-text
- text="Delete of Map failed or was not allowed"></eg-string>
-<eg-string #deleteSuccessString i18n-text
- text="Delete of Map succeeded"></eg-string>
-<eg-string #updateFailedString i18n-text
- text="Update of Map failed"></eg-string>
-<eg-string #updateSuccessString i18n-text
- text="Update of Map succeeded"></eg-string>
\ No newline at end of file
+<ng-template #compDefTmpl let-row="row">
+ <div *ngIf="row.ctype().composite() == 't'">
+ <a routerLink="/staff/admin/server/config/coded_value_map/composite_def/{{row.id()}}">
+ Manage
+ </a>
+ </div>
+</ng-template>
-import {Pager} from '@eg/share/util/pager';
-import {Component, ViewChild, OnInit} from '@angular/core';
-import {IdlObject} from '@eg/core/idl.service';
-import {GridDataSource} from '@eg/share/grid/grid';
-import {GridComponent} from '@eg/share/grid/grid.component';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
-import {StringComponent} from '@eg/share/string/string.component';
+import {Component} from '@angular/core';
@Component({
templateUrl: './coded-value-maps.component.html'
})
-export class CodedValueMapsComponent implements OnInit {
-
- gridDataSource: GridDataSource = new GridDataSource();
- @ViewChild('createString', { static: true }) createString: StringComponent;
- @ViewChild('createErrString', { static: true }) createErrString: StringComponent;
- @ViewChild('updateSuccessString', { static: true }) updateSuccessString: StringComponent;
- @ViewChild('updateFailedString', { static: true }) updateFailedString: StringComponent;
- @ViewChild('deleteFailedString', { static: true }) deleteFailedString: StringComponent;
- @ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent;
-
- @ViewChild('grid', {static: true}) grid: GridComponent;
- @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
-
- constructor(
- private pcrud: PcrudService,
- private toast: ToastService,
- ) {
- }
-
- ngOnInit() {
- this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
- return this.pcrud.retrieveAll('ccvm', {order_by: {ccvm: 'id'}}, {fleshSelectors: true});
- };
- this.grid.onRowActivate.subscribe(
- (idlThing: IdlObject) => this.showEditDialog(idlThing)
- );
- }
-
- showEditDialog(standingPenalty: IdlObject): Promise<any> {
- this.editDialog.mode = 'update';
- this.editDialog.recordId = standingPenalty['id']();
- return new Promise((resolve, reject) => {
- this.editDialog.open({size: 'lg'}).subscribe(
- result => {
- this.updateSuccessString.current()
- .then(str => this.toast.success(str));
- this.grid.reload();
- resolve(result);
- },
- error => {
- this.updateFailedString.current()
- .then(str => this.toast.danger(str));
- reject(error);
- }
- );
- });
- }
-
- editSelected = (maps: IdlObject[]) => {
- const editOneThing = (map: IdlObject) => {
- this.showEditDialog(map).then(
- () => editOneThing(maps.shift()));
- };
- editOneThing(maps.shift());
- }
-
- deleteSelected = (idlThings: IdlObject[]) => {
- idlThings.forEach(idlThing => idlThing.isdeleted(true));
- this.pcrud.autoApply(idlThings).subscribe(
- val => {
- console.debug('deleted: ' + val);
- this.deleteSuccessString.current()
- .then(str => this.toast.success(str));
- },
- err => {
- this.deleteFailedString.current()
- .then(str => this.toast.danger(str));
- },
- () => this.grid.reload()
- );
- }
-
- createNew = () => {
- this.editDialog.mode = 'create';
- this.editDialog.recordId = null;
- this.editDialog.record = null;
- this.editDialog.open({size: 'lg'}).subscribe(
- ok => {
- this.createString.current()
- .then(str => this.toast.success(str));
- this.grid.reload();
- },
- rejection => {
- if (!rejection.dismissed) {
- this.createErrString.current()
- .then(str => this.toast.danger(str));
- }
- }
- );
- }
-
- }
+export class CodedValueMapsComponent { }