From: Jane Sandberg Date: Wed, 12 Dec 2018 23:38:15 +0000 (-0800) Subject: Adding an editor X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2225ec60319687344ccf27889f6398ea95347fab;p=working%2FEvergreen.git Adding an editor Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html index 2c4c527659..b4c8f7e62d 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html +++ b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html @@ -2,8 +2,9 @@ - + @@ -30,3 +31,5 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts index b2095d8fb2..554c8d507e 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts @@ -1,8 +1,13 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import {GridComponent} from '@eg/share/grid/grid.component'; import { GridDataSource } from '@eg/share/grid/grid'; +import {IdlObject} from '@eg/core/idl.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {Pager} from '@eg/share/util/pager'; +import {ToastService} from '@eg/share/toast/toast.service'; import { Router, ActivatedRoute, ParamMap } from '@angular/router'; +import {StringComponent} from '@eg/share/string/string.component'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; @Component({ selector: 'eg-current-reservations', @@ -13,8 +18,15 @@ export class CurrentReservationsComponent implements OnInit { gridSource: GridDataSource; patronId: number; + @ViewChild('grid') grid: GridComponent; + @ViewChild('editDialog') editDialog: FmRecordEditorComponent; + @ViewChild('successString') successString: StringComponent; + + editSelected: (rows: IdlObject[]) => void; + constructor( private route: ActivatedRoute, + private toast: ToastService, private pcrud: PcrudService ){ this.gridSource = new GridDataSource(); @@ -37,8 +49,29 @@ export class CurrentReservationsComponent implements OnInit { this.route.paramMap.subscribe((params: ParamMap) => { this.patronId = +params.get('patron_id'); }); + + this.editSelected = (idlThings: IdlObject[]) => { + const editOneThing = (thing: IdlObject) => { + if (!thing) return; + this.showEditDialog(thing).then( + () => editOneThing(idlThings.shift())); + } + editOneThing(idlThings.shift()); }; + } + showEditDialog(idlThing: IdlObject) { + this.editDialog.mode = 'update'; + this.editDialog.recId = idlThing.id(); + return this.editDialog.open({size: 'lg'}).then( + ok => { + this.successString.current() + .then(str => this.toast.success(str)); + this.grid.reload(); + }, + err => {} + ); + } }