From: Zavier Banks Date: Mon, 9 Dec 2019 20:20:06 +0000 (+0000) Subject: LP XXXXXXXXXXX Circulation Matrix Matchpoint Angular Port X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=80535c3ac4a87f5e488127848714f641dda8cd04;p=working%2FEvergreen.git LP XXXXXXXXXXX Circulation Matrix Matchpoint Angular Port I have ported over the Circulation matrix matchpoint page from dojo to angular2 Signed-off-by: Zavier Banks --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html index e051d37c42..3ea4006ac9 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html @@ -20,7 +20,7 @@ + url="/eg2/en-US/staff/admin/local/config/circ_matrix_matchpoint"> diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.html new file mode 100644 index 0000000000..b7866c0fc9 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.ts new file mode 100644 index 0000000000..07076b4781 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.component.ts @@ -0,0 +1,135 @@ +import {Pager} from '@eg/share/util/pager'; +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource, GridColumn, GridRowFlairEntry} from '@eg/share/grid/grid'; +import {IdlObject} from '@eg/core/idl.service'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; +import {StringComponent} from '@eg/share/string/string.component'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {ToastService} from '@eg/share/toast/toast.service'; + +@Component({ + templateUrl: './circ-matrix-matchpoint.component.html' +}) + +export class CircMatrixMatchpointComponent implements OnInit { + recId: number; + gridDataSource: GridDataSource; + initDone = false; + dataSource: GridDataSource = new GridDataSource(); + + @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent; + @ViewChild('grid', { static: true }) grid: GridComponent; + @ViewChild('successString', { static: true }) successString: StringComponent; + @ViewChild('createString', { static: false }) createString: StringComponent; + @ViewChild('createErrString', { static: false }) createErrString: StringComponent; + @ViewChild('updateFailedString', { static: false }) updateFailedString: StringComponent; + @ViewChild('deleteFailedString', { static: true }) deleteFailedString: StringComponent; + @ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent; + + @Input() idlClass = 'ccmm'; + // Default sort field, used when no grid sorting is applied. + @Input() sortField: string; + + @Input() dialogSize: 'sm' | 'lg' = 'lg'; + + + constructor( + private pcrud: PcrudService, + private toast: ToastService + ) { + this.gridDataSource = new GridDataSource(); + } + + ngOnInit() { + + this.initDone = true; + this.dataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + if (sort.length) { + // Sort specified from grid + orderBy[this.idlClass] = sort[0].name + ' ' + sort[0].dir; + } else if (this.sortField) { + // Default sort field + orderBy[this.idlClass] = this.sortField; + } + + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + return this.pcrud.retrieveAll('ccmm', searchOps, {fleshSelectors: true}); + } + + } + + deleteSelected = (idlObjects: IdlObject[]) => { + idlObjects.forEach(idlObject => idlObject.isdeleted(true)); + this.pcrud.autoApply(idlObjects).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() + ); + }; + + showEditDialog(field: IdlObject): Promise { + this.editDialog.mode = 'update'; + this.editDialog.recordId = field['id'](); + return new Promise((resolve, reject) => { + this.editDialog.open({size: this.dialogSize}).subscribe( + result => { + this.successString.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(fields: IdlObject[]) { + // Edit each IDL thing one at a time + const editOneThing = (field: IdlObject) => { + if (!field) { return; } + + this.showEditDialog(field).then( + () => editOneThing(fields.shift())); + }; + editOneThing(fields.shift()); + } + + createNew() { + this.editDialog.mode = 'create'; + // We reuse the same editor for all actions. Be sure + // create action does not try to modify an existing record. + this.editDialog.recordId = null; + this.editDialog.record = null; + this.editDialog.open({size: this.dialogSize}).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)); + } + } + ); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.module.ts new file mode 100644 index 0000000000..136b344de1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.module.ts @@ -0,0 +1,26 @@ +import {NgModule} from '@angular/core'; +import {TreeModule} from '@eg/share/tree/tree.module'; +import {StaffCommonModule} from '@eg/staff/common.module'; +import {CircMatrixMatchpointRoutingModule} from './routing.module'; +import {AdminCommonModule} from '@eg/staff/admin/common.module'; +import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component' + +@NgModule({ + declarations: [ + CircMatrixMatchpointComponent + ], + imports: [ + AdminCommonModule, + CircMatrixMatchpointRoutingModule, + TreeModule + ], + exports: [ + ], + providers: [ + ] +}) + +export class CircMatrixMathpointModule { +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/routing.module.ts new file mode 100644 index 0000000000..424ac395e0 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/circ_matrix_matchpoint/routing.module.ts @@ -0,0 +1,14 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {CircMatrixMatchpointComponent} from './circ-matrix-matchpoint.component' +const routes: Routes = [{ + path: '', + component: CircMatrixMatchpointComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class CircMatrixMatchpointRoutingModule {} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts index 39c6be7179..0081a3ff1f 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts @@ -23,6 +23,9 @@ const routes: Routes = [{ path: 'config/standing_penalty', component: StandingPenaltyComponent }, { + path: 'config/circ_matrix_matchpoint', + loadChildren: '@eg/staff/admin/local/circ_matrix_matchpoint/circ-matrix-matchpoint.module#CircMatrixMathpointModule' +}, { path: ':schema/:table', component: BasicAdminPageComponent }];