From 04706504be7f54a31724b6753927e912a13eb6fe Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 28 Jul 2022 19:11:57 +0000 Subject: [PATCH] LP#1942220: (follow-up) add LID batch update to LI actions menu Signed-off-by: Galen Charlton --- .../batch-update-copies-dialog.component.html | 70 +++++++++++++++++ .../batch-update-copies-dialog.component.ts | 87 ++++++++++++++++++++++ .../staff/acq/lineitem/copy-attrs.component.html | 6 +- .../app/staff/acq/lineitem/copy-attrs.component.ts | 12 ++- .../acq/lineitem/lineitem-list.component.html | 3 + .../staff/acq/lineitem/lineitem-list.component.ts | 36 +++++++++ .../src/app/staff/acq/lineitem/lineitem.module.ts | 2 + 7 files changed, 211 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.html new file mode 100644 index 0000000000..72e71b122b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.html @@ -0,0 +1,70 @@ + +
+
Owning Branch
+
Shelving Location
+
Collection Code
+
Fund
+
Circ Modifier
+
+
+
+ + +
+ + + +
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.ts new file mode 100644 index 0000000000..fb60ffc580 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.ts @@ -0,0 +1,87 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs'; +import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {IdlObject} from '@eg/core/idl.service'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; +import {LineitemCopyAttrsComponent} from './copy-attrs.component'; + +@Component({ + selector: 'eg-acq-batch-update-copies-dialog', + templateUrl: './batch-update-copies-dialog.component.html' +}) + +export class BatchUpdateCopiesDialogComponent extends DialogComponent { + + @Input() ids: number[]; + + copyCount = 0; + selectedFormula: ComboboxEntry; + formulaFilter = {owner: []}; + templateCopy: IdlObject; + + constructor( + private modal: NgbModal, + private org: OrgService, + private auth: AuthService + ) { + super(modal); + } + + open(args?: NgbModalOptions): Observable { + if (!args) { + args = {}; + } + + this.copyCount = 1; + this.selectedFormula = null; + this.formulaFilter.owner = + this.org.fullPath(this.auth.user().ws_ou(), true); + + return super.open(args); + } + + canApply(): boolean { + if (!this.templateCopy) { return false; } + + if (this.copyCount > 0 || + this.selectedFormula?.id || + this.templateCopy.owning_lib() || + this.templateCopy.location() || + this.templateCopy.collection_code() || + this.templateCopy.fund() || + this.templateCopy.circ_modifier()) { + return true; + } else { + return false; + } + } + + compileBatchChange(): any { + const changes = { + item_count: this.copyCount, + _dist_formula: this.selectedFormula?.id + }; + if (this.templateCopy.owning_lib()) { + changes['owning_lib'] = this.templateCopy.owning_lib(); + } + if (this.templateCopy.location()) { + changes['location'] = this.templateCopy.location(); + } + if (this.templateCopy.collection_code()) { + changes['collection_code'] = this.templateCopy.collection_code(); + } + if (this.templateCopy.fund()) { + changes['fund'] = this.templateCopy.fund(); + } + if (this.templateCopy.circ_modifier()) { + changes['circ_modifier'] = this.templateCopy.owning_lib(); + } + return changes; + } + +} + + 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 aeb04cd9fb..2d8ce9da71 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 @@ -54,7 +54,7 @@ (onChange)="valueChange('circ_modifier', $event)"> -
+
{{copy.cn_label()}} @@ -70,7 +70,7 @@ - + {{copy.barcode()}} @@ -85,7 +85,7 @@
{{copy.receiver()?.usrname()}}
- +
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 5874573731..f07bc3a23d 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 @@ -20,8 +20,10 @@ export class LineitemCopyAttrsComponent implements OnInit { @Input() lineitem: IdlObject; @Input() rowIndex: number; @Input() batchAdd = false; + @Input() gatherParamsOnly = false; @Output() becameDirty = new EventEmitter(); + @Output() templateCopy = new EventEmitter(); fundEntries: ComboboxEntry[]; _fundBalanceCache: string[] = []; @@ -78,10 +80,15 @@ export class LineitemCopyAttrsComponent implements OnInit { ngOnInit() { - if (this.batchMode) { // stub batch copy + if (this.gatherParamsOnly) { + this.batchMode = false; + this.batchAdd = false; + } + + if (this.batchMode || this.gatherParamsOnly) { // stub batch copy this.copy = this.idl.create('acqlid'); this.copy.isnew(true); - + this.templateCopy.emit(this.copy); } else { // When a batch selector value changes, duplicate the selected @@ -213,6 +220,7 @@ export class LineitemCopyAttrsComponent implements OnInit { fieldIsDisabled(field: string) { if (this.batchMode) { return false; } + if (this.gatherParamsOnly) { return false; } if (this.embedded || // inline expandy view this.copy.isdeleted() || 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 8368690eab..825c7489f6 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 @@ -3,6 +3,7 @@ + @@ -42,6 +43,8 @@ [disabled]="!canDeleteLis() || !selectedIds().length" i18n>Delete Selected Line Items + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts index 135a7e981b..14a3047f11 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts @@ -19,6 +19,7 @@ import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {CancelDialogComponent} from './cancel-dialog.component'; import {DeleteLineitemsDialogComponent} from './delete-lineitems-dialog.component'; import {AddCopiesDialogComponent} from './add-copies-dialog.component'; +import {BatchUpdateCopiesDialogComponent} from './batch-update-copies-dialog.component'; import {LinkInvoiceDialogComponent} from './link-invoice-dialog.component'; import {ExportAttributesDialogComponent} from './export-attributes-dialog.component'; import {ClaimPolicyDialogComponent} from './claim-policy-dialog.component'; @@ -123,6 +124,7 @@ export class LineitemListComponent implements OnInit { @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent; @ViewChild('deleteLineitemsDialog') deleteLineitemsDialog: DeleteLineitemsDialogComponent; @ViewChild('addCopiesDialog') addCopiesDialog: AddCopiesDialogComponent; + @ViewChild('batchUpdateCopiesDialog') batchUpdateCopiesDialog: BatchUpdateCopiesDialogComponent; @ViewChild('linkInvoiceDialog') linkInvoiceDialog: LinkInvoiceDialogComponent; @ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent; @ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent; @@ -791,6 +793,40 @@ export class LineitemListComponent implements OnInit { }); } + batchUpdateCopiesOnLineitems() { + const ids = Object.keys(this.selected).filter(id => this.selected[id]); + + this.batchUpdateCopiesDialog.ids = ids.map(i => Number(i)); + this.batchUpdateCopiesDialog.open({size: 'xl'}).subscribe(batchChanges => { + if (!batchChanges) { return; } + + this.saving = true; + this.progressMax = ids.length; + this.progressValue = 0; + + this.net.request( + 'open-ils.acq', + 'open-ils.acq.lineitem.batch_update', + this.auth.token(), { lineitems: ids }, + batchChanges, batchChanges._dist_formula + ).subscribe( + response => { + const evt = this.evt.parse(response); + if (!evt) { + delete this.liService.liCache[response]; + this.progressValue++; + } + }, + err => {}, + () => { + this.saving = false; + this.loadPageOfLis(); + this.liService.activateStateChange.emit(Number(ids[0])); + } + ); + }); + } + exportSingleAttributeList() { const ids = Object.keys(this.selected).filter(id => this.selected[id]).map(i => Number(i)); this.exportAttributesDialog.ids = ids; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts index 8247e35b05..d98742a502 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts @@ -21,6 +21,7 @@ import {CancelDialogComponent} from './cancel-dialog.component'; import {AddToPoDialogComponent} from './add-to-po-dialog.component'; import {DeleteLineitemsDialogComponent} from './delete-lineitems-dialog.component'; import {AddCopiesDialogComponent} from './add-copies-dialog.component'; +import {BatchUpdateCopiesDialogComponent} from './batch-update-copies-dialog.component'; import {LinkInvoiceDialogComponent} from './link-invoice-dialog.component'; import {ExportAttributesDialogComponent} from './export-attributes-dialog.component'; import {ClaimPolicyDialogComponent} from './claim-policy-dialog.component'; @@ -44,6 +45,7 @@ import {AcqCommonModule} from '../acq-common.module'; AddToPoDialogComponent, DeleteLineitemsDialogComponent, AddCopiesDialogComponent, + BatchUpdateCopiesDialogComponent, LinkInvoiceDialogComponent, ExportAttributesDialogComponent, ClaimPolicyDialogComponent, -- 2.11.0