From 486f14a107a26e1b945821fa5727c195c3d68736 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Thu, 18 Nov 2021 20:19:40 -0800 Subject: [PATCH] LP1843970: Refactor Coded Value Map grid to use eg-admin-page Also adds a new @Input to eg-admin-page that accepts arbitrary columns based on s Signed-off-by: Jane Sandberg Signed-off-by: Bill Erickson --- .../coded-value-maps.component.html | 50 ++-------- .../coded-value-maps/coded-value-maps.component.ts | 103 +-------------------- .../coded-value-maps/coded-value-maps.module.ts | 2 + .../share/admin-page/admin-page.component.html | 4 + .../staff/share/admin-page/admin-page.component.ts | 9 ++ 5 files changed, 26 insertions(+), 142 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.html index 228e5143aa..1c86d6b115 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.html @@ -1,46 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - \ No newline at end of file + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.ts index f89a79e428..c3f78666c5 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.component.ts @@ -1,106 +1,7 @@ -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 { - 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 { } diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.module.ts index 36457f18ce..d42ea90afa 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/coded-value-maps/coded-value-maps.module.ts @@ -6,6 +6,7 @@ import {CodedValueMapsComponent} from './coded-value-maps.component'; import {CompositeDefComponent} from './composite-def.component'; import {CompositeNewPointComponent} from './composite-new.component'; import {CodedValueMapsRoutingModule} from './coded-value-maps-routing.module'; +import {AdminPageModule} from '@eg/staff/share/admin-page/admin-page.module'; @NgModule({ declarations: [ @@ -17,6 +18,7 @@ import {CodedValueMapsRoutingModule} from './coded-value-maps-routing.module'; StaffCommonModule, FmRecordEditorModule, TreeModule, + AdminPageModule, CodedValueMapsRoutingModule ], exports: [ diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html index d55a91d34c..58b940be97 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html @@ -70,6 +70,10 @@ + + + + ; + name: string; +} -- 2.11.0