From 64185354778e716d021159c653b6367ca3c2e366 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 6 Sep 2019 14:57:13 -0400 Subject: [PATCH] LP#1840327: (follow-up) various fixes and improvements * Fixed inabiilty to set the name for a new standing penalty * Fixed the 'Delete Selected' action * adjust for recId => recordId change to FM record editor * remove a bit of copy-and-paste-itis * Lint repairs Signed-off-by: Galen Charlton --- .../share/fm-editor/fm-editor.component.ts | 2 +- .../local/standing-penalty.component.html | 6 +- .../admin/local/standing-penalty.component.ts | 64 +++++++++++-------- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index e5ed4006ba..c775fe3b54 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -460,7 +460,7 @@ export class FmRecordEditorComponent let promise = null; const fieldOptions = this.fieldOptions[field.name] || {}; - + if (this.mode === 'view') { field.readOnly = true; } else if (fieldOptions.isReadonlyOverride) { diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/standing-penalty.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/standing-penalty.component.html index 351d1cbda5..e8cfaf047a 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/standing-penalty.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/standing-penalty.component.html @@ -2,9 +2,13 @@ + + + +
- GridRowFlairEntry; canCreate: boolean; canDelete: boolean; deleteSelected: (rows: IdlObject[]) => void; - + permissions: {[name: string]: boolean}; // Default sort field, used when no grid sorting is applied. @Input() sortField: string; - @Input() idlClass: string = "csp"; + @Input() idlClass = 'csp'; // Size of create/edito dialog. Uses large by default. @Input() dialogSize: 'sm' | 'lg' = 'lg'; // Optional comma-separated list of read-only fields // @Input() readonlyFields: string; - @Input() set recordId(id: number) { - this.recId = id; - // Only force new data collection when recordId() - // is invoked after ngInit() has already run. - if (this.initDone) { - this.partsGrid.reload(); - } - } - constructor( private pcrud: PcrudService, private toast: ToastService @@ -70,42 +63,59 @@ export class StandingPenaltyComponent implements OnInit { // Default sort field orderBy[this.idlClass] = this.sortField; } - + const searchOps = { offset: pager.offset, limit: pager.limit, order_by: orderBy }; return this.pcrud.retrieveAll('csp', searchOps, {fleshSelectors: true}); - } - - this.cspRowFlairCallback = (row: any): GridRowFlairEntry => { + }; + + this.cspRowFlairCallback = (row: any): GridRowFlairEntry => { const flair = {icon: null, title: null}; if (row.id() < 100) { flair.icon = 'not_interested'; flair.title = this.cspFlairTooltip.text; } return flair; - } + }; + + this.deleteSelected = (idlThings: IdlObject[]) => { + idlThings.forEach(idlThing => idlThing.isdeleted(true)); + this.pcrud.autoApply(idlThings).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() + ); + }; + } - cspReadonlyOverride = (field: string, copy: IdlObject): boolean => { - if (copy.id() >= 100) { + cspReadonlyOverride = (field: string, csp: IdlObject): boolean => { + if (csp.id() >= 100 || csp.id() === undefined) { return true; } return false; } cspGridCellClassCallback = (row: any, col: GridColumn): string => { - if (col.name === "id" && row.a[0] < 100) { - return "text-danger"; + if (col.name === 'id' && row.a[0] < 100) { + return 'text-danger'; } - return ""; - }; + return ''; + } showEditDialog(standingPenalty: IdlObject): Promise { this.editDialog.mode = 'update'; - this.editDialog.recId = standingPenalty["id"](); + this.editDialog.recordId = standingPenalty['id'](); return new Promise((resolve, reject) => { this.editDialog.open({size: this.dialogSize}).subscribe( result => { @@ -139,7 +149,7 @@ export class StandingPenaltyComponent implements OnInit { 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.recId = null; + this.editDialog.recordId = null; this.editDialog.record = null; this.editDialog.open({size: this.dialogSize}).subscribe( ok => { @@ -155,6 +165,6 @@ export class StandingPenaltyComponent implements OnInit { } ); } - + } -- 2.43.2