From: Galen Charlton Date: Tue, 7 Dec 2021 23:43:18 +0000 (-0500) Subject: LP#1942220: implement 'Add Items To Selected Lineitems' X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=98b04af32d278529f77c47a4e9cc0a831077ddba;p=working%2FEvergreen.git LP#1942220: implement 'Add Items To Selected Lineitems' Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.html new file mode 100644 index 0000000000..c55f8427e1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.html @@ -0,0 +1,26 @@ + +
+ + + +
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.ts new file mode 100644 index 0000000000..6f2237c625 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-copies-dialog.component.ts @@ -0,0 +1,18 @@ +import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +@Component({ + selector: 'eg-acq-add-copies-dialog', + templateUrl: './add-copies-dialog.component.html' +}) + +export class AddCopiesDialogComponent extends DialogComponent { + @Input() ids: number[]; + lineitemWithCopies: IdlObject; + constructor(private modal: NgbModal) { super(modal); } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.html index 310017e838..7b7717b840 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-copies.component.html @@ -16,9 +16,9 @@
Collection Code
Fund
Circ Modifier
-
Callnumber
+
Callnumber
- Barcode + Barcode
@@ -35,6 +35,7 @@
@@ -47,6 +48,7 @@
Apply -
@@ -38,7 +38,7 @@ -
+
Distribution formulas applied to this lineitem
    @@ -58,7 +58,7 @@
- + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copies.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copies.component.ts index ac5788ecfb..60cb0f2838 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copies.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copies.component.ts @@ -26,11 +26,23 @@ interface FormulaApplication { } @Component({ + selector: 'eg-lineitem-copies', templateUrl: 'copies.component.html' }) export class LineitemCopiesComponent implements OnInit, AfterViewInit { + static newCopyId = -1; + // modes are 'normal' and 'multiAdd' + // normal = manage copies for a single line item whose + // ID is taken from the route + // multiAdd = embedded in a modal and applying the results + // to selected LIs + @Input() mode = 'normal'; + + // emited only in multiAdd mode + @Output() lineitemWithCopies = new EventEmitter(); + lineitemId: number; lineitem: IdlObject; copyCount = 1; @@ -63,13 +75,19 @@ export class LineitemCopiesComponent implements OnInit, AfterViewInit { this.formulaFilter.owner = this.org.fullPath(this.auth.user().ws_ou(), true); - this.route.paramMap.subscribe((params: ParamMap) => { - const id = +params.get('lineitemId'); - if (id !== this.lineitemId) { - this.lineitemId = id; - if (id) { this.load(); } - } - }); + if (this.mode === 'multiAdd') { + this.load(); + } else { + // normal mode, we're checking the route to initalize + // ourselves + this.route.paramMap.subscribe((params: ParamMap) => { + const id = +params.get('lineitemId'); + if (id !== this.lineitemId) { + this.lineitemId = id; + if (id) { this.load(); } + } + }); + } this.liService.getLiAttrDefs(); } @@ -82,13 +100,23 @@ export class LineitemCopiesComponent implements OnInit, AfterViewInit { params = {toCache: true, fromCache: true}; } - return this.liService.getFleshedLineitems([this.lineitemId], params) - .pipe(tap(liStruct => this.lineitem = liStruct.lineitem)).toPromise() - .then(_ => { - this.liLocked = - this.lineitem.state().match(/on-order|received|cancelled/); - }) - .then(_ => this.applyCount()); + if (this.mode === 'multiAdd') { + this.lineitem = this.idl.create('jub'); + this.lineitem.lineitem_details([]); + this.lineitem.distribution_formulas([]); + this.liLocked = false; // trusting our invoker in multiAdd mode + this.applyCount(); + this.lineitemWithCopies.emit(this.lineitem); + return Promise.resolve(true); + } else { + return this.liService.getFleshedLineitems([this.lineitemId], params) + .pipe(tap(liStruct => this.lineitem = liStruct.lineitem)).toPromise() + .then(_ => { + this.liLocked = + this.lineitem.state().match(/on-order|received|cancelled/); + }) + .then(_ => this.applyCount()); + } } ngAfterViewInit() { @@ -163,11 +191,16 @@ export class LineitemCopiesComponent implements OnInit, AfterViewInit { app.creator(this.auth.user().id()); app.formula(formula.id()); - this.pcrud.create(app).toPromise().then(a => { - a.creator(this.auth.user()); - a.formula(formula); - this.lineitem.distribution_formulas().push(a); - }); + if (this.mode === 'multiAdd') { + app.isnew(true); + this.lineitem.distribution_formulas().push(app); + } else { + this.pcrud.create(app).toPromise().then(a => { + a.creator(this.auth.user()); + a.formula(formula); + this.lineitem.distribution_formulas().push(a); + }); + } } // Grab values applied by distribution formulas and cache them before diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html index 43f13b3245..660cc13ac7 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.html @@ -49,7 +49,7 @@ (onChange)="valueChange('circ_modifier', $event)">
-
+
{{copy.cn_label()}} @@ -65,7 +65,7 @@ - + {{copy.barcode()}} diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts index d6b5aaab7d..e30e45c870 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/copy-attrs.component.ts @@ -18,6 +18,7 @@ export class LineitemCopyAttrsComponent implements OnInit { @Input() lineitem: IdlObject; @Input() rowIndex: number; + @Input() batchAdd = false; fundEntries: ComboboxEntry[]; circModEntries: ComboboxEntry[]; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.html index a560505ceb..c240536af6 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.html @@ -2,8 +2,14 @@ + +
+ + +
+
@@ -13,6 +19,8 @@ queryParamsHandling="merge" i18n>Add Brief Record +