From: Bill Erickson Date: Tue, 9 Jun 2020 21:22:08 +0000 (-0400) Subject: LPXXX Angular Volcopy X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c2d27ab073a7fcdfffc6b775b7bb85a310f15a99;p=working%2FEvergreen.git LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index b1406ad4b8..3f30820bb4 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -172,7 +172,7 @@ spellcheck="false" [required]="true" [ngModel]="volNode.target.label()" - (onChange)="applyVolValue(volNode.target, 'label', $event)"> + (change)="applyVolValue(volNode.target, 'label', $event.target.value)">
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html index 1c62cca96e..97256b1a6d 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.html @@ -1,12 +1,10 @@ - -
-
- -
+
+
+
- +
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts index f0916c45fd..6502392fd6 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts @@ -1,8 +1,11 @@ import {Component, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {tap} from 'rxjs/operators'; -import {IdlObject} from '@eg/core/idl.service'; +import {IdlObject, IdlService} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; import {OrgService} from '@eg/core/org.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; import {VolCopyContext} from './volcopy'; @@ -40,7 +43,11 @@ export class VolCopyComponent implements OnInit { private router: Router, private route: ActivatedRoute, private renderer: Renderer2, + private evt: EventService, + private idl: IdlService, private org: OrgService, + private net: NetService, + private auth: AuthService, private pcrud: PcrudService, private holdings: HoldingsService ) { } @@ -128,6 +135,67 @@ export class VolCopyComponent implements OnInit { {}, {idlist: true, atomic: true} ).toPromise().then(volIds =>this.fetchVols(volIds)); } + + + save() { + this.loadingProgress.reset(); + this.loading = true; + + // Volume update API wants volumes fleshed with copies, instead + // of the other way around, which is what we have here. + const volumes: IdlObject[] = []; + + this.context.volNodes().forEach(volNode => { + const newVol = this.idl.clone(volNode.target); + const copies: IdlObject[] = []; + + volNode.children.forEach(copyNode => { + const copy = copyNode.target; + + if (copy.ischanged() || copy.isnew() || copy.isdeleted()) { + const copyClone = this.idl.clone(copy); + // De-flesh call number + copyClone.call_number(copy.call_number().id()); + copies.push(copyClone); + } + }); + + newVol.copies(copies); + + if (newVol.ischanged() || newVol.isnew() || copies.length > 0) { + volumes.push(newVol); + } + }); + + // TODO: deletedVols and deletedCopies + + if (volumes.length > 0) { + this.saveApi(volumes); + } + } + + saveApi(volumes: IdlObject[], override?: boolean) { + + let method = 'open-ils.cat.asset.volume.fleshed.batch.update'; + if (override) { method += '.override'; } + + this.net.request('open-ils.cat', + method, this.auth.token(), volumes).toPromise() + + .then(resp => { + + const evt = this.evt.parse(resp); + + // TODO: confirm / handle overrides + + if (evt) { + alert(evt); + return; + } + + return this.load(); + }); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index c44a7f7a0b..98c2eb6d4b 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -250,6 +250,8 @@ export class SandboxComponent implements OnInit { const query: any = new Array(); query.push(base); + console.log(JSON.stringify(this.eventsDataSource.filters)); + Object.keys(this.eventsDataSource.filters).forEach(key => { Object.keys(this.eventsDataSource.filters[key]).forEach(key2 => { query.push(this.eventsDataSource.filters[key][key2]);