From: Bill Erickson Date: Fri, 31 May 2019 15:47:03 +0000 (-0400) Subject: LP1803787 Migrate grid action/button click handlers; lint X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=03537881dbc08980994400af9ef5af6f1eabfd07;p=working%2FEvergreen.git LP1803787 Migrate grid action/button click handlers; lint Migrate the basic admin page and sandbox grids to use the click handlers for grid toolbar buttons and actions, so the actions may be performed against class methods instead of anonymous functions. Minor lint repairs. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/share/print/hatch.service.ts b/Open-ILS/src/eg2/src/app/share/print/hatch.service.ts index 015088765a..bd087b7747 100644 --- a/Open-ILS/src/eg2/src/app/share/print/hatch.service.ts +++ b/Open-ILS/src/eg2/src/app/share/print/hatch.service.ts @@ -27,7 +27,7 @@ export class HatchService { isAvailable: boolean; msgId: number; - messages: {[msgid:number]: HatchMessage}; + messages: {[msgid: number]: HatchMessage}; constructor() { this.isAvailable = null; @@ -62,7 +62,7 @@ export class HatchService { this.handleResponse(event.data); } - }); + }); return this.isAvailable = true; } @@ -87,7 +87,7 @@ export class HatchService { // Handle the data sent back to the browser from Hatch. handleResponse(data: any) { - const msg = this.messages[data.msgid]; + const msg = this.messages[data.msgid]; if (!msg) { console.warn(`No Hatch request found with ID ${data.msgid}`); return; diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts index 978b46f19a..77d007bcd0 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts @@ -38,7 +38,7 @@ export class OrgUnitTypeComponent implements OnInit { loadAoutTree() { this.pcrud.search('aout', {depth: 0}, - {flesh: -1, flesh_fields: {aout: ['children','org_units']}}, + {flesh: -1, flesh_fields: {aout: ['children', 'org_units']}}, {anonymous: true} ).subscribe(aoutTree => this.ingestAoutTree(aoutTree)); } diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html index 720fa0f307..aa2164432c 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html @@ -153,12 +153,12 @@ [cellClassCallback]="btGridCellClassCallback" [sortable]="true"> + (onClick)="complimentEvergreen($event)" [disableOnRows]="notOneSelectedRow"> + (onClick)="complimentEvergreen2($event)"> diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html index 7a47a3d424..8d67f2edc1 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html @@ -51,14 +51,14 @@ + label="New {{idlClassDef.label}}" i18n-label (onClick)="createNew($event)"> + label="Apply Translations" i18n-label (onClick)="translate($event)"> - + - + diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts index 106f3640b2..509f95cce6 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts @@ -76,15 +76,11 @@ export class AdminPageComponent implements OnInit { idlClassDef: any; pkeyField: string; - createNew: () => void; - deleteSelected: (rows: IdlObject[]) => void; - editSelected: (rows: IdlObject[]) => void; // True if any columns on the object support translations translateRowIdx: number; translateFieldIdx: number; translatableFields: string[]; - translate: () => void; contextOrg: IdlObject; orgFieldLabel: string; @@ -175,93 +171,6 @@ export class AdminPageComponent implements OnInit { this.grid.onRowActivate.subscribe( (idlThing: IdlObject) => this.showEditDialog(idlThing) ); - - this.editSelected = (idlThings: IdlObject[]) => { - - // Edit each IDL thing one at a time - const editOneThing = (thing: IdlObject) => { - if (!thing) { return; } - - this.showEditDialog(thing).then( - () => editOneThing(idlThings.shift())); - }; - - editOneThing(idlThings.shift()); - }; - - this.createNew = () => { - 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.record = null; - this.editDialog.open({size: this.dialogSize}).then( - ok => { - this.createString.current() - .then(str => this.toast.success(str)); - this.grid.reload(); - }, - rejection => { - if (!rejection.dismissed) { - this.createErrString.current() - .then(str => this.toast.danger(str)); - } - } - ); - }; - - this.deleteSelected = (idlThings: IdlObject[]) => { - idlThings.forEach(idlThing => idlThing.isdeleted(true)); - this.pcrud.autoApply(idlThings).subscribe( - val => console.debug('deleted: ' + val), - err => {}, - () => this.grid.reload() - ); - }; - - // Open the field translation dialog. - // Link the next/previous actions to cycle through each translatable - // field on each row. - this.translate = () => { - this.translateRowIdx = 0; - this.translateFieldIdx = 0; - this.translator.fieldName = this.translatableFields[this.translateFieldIdx]; - this.translator.idlObject = this.dataSource.data[this.translateRowIdx]; - - this.translator.nextString = () => { - - if (this.translateFieldIdx < this.translatableFields.length - 1) { - this.translateFieldIdx++; - - } else if (this.translateRowIdx < this.dataSource.data.length - 1) { - this.translateRowIdx++; - this.translateFieldIdx = 0; - } - - this.translator.idlObject = - this.dataSource.data[this.translateRowIdx]; - this.translator.fieldName = - this.translatableFields[this.translateFieldIdx]; - }; - - this.translator.prevString = () => { - - if (this.translateFieldIdx > 0) { - this.translateFieldIdx--; - - } else if (this.translateRowIdx > 0) { - this.translateRowIdx--; - this.translateFieldIdx = 0; - } - - this.translator.idlObject = - this.dataSource.data[this.translateRowIdx]; - this.translator.fieldName = - this.translatableFields[this.translateFieldIdx]; - }; - - this.translator.open({size: 'lg'}); - }; } checkCreatePerms() { @@ -371,6 +280,91 @@ export class AdminPageComponent implements OnInit { ); } + editSelected(idlThings: IdlObject[]) { + + // Edit each IDL thing one at a time + const editOneThing = (thing: IdlObject) => { + if (!thing) { return; } + + this.showEditDialog(thing).then( + () => editOneThing(idlThings.shift())); + }; + + editOneThing(idlThings.shift()); + } + + deleteSelected(idlThings: IdlObject[]) { + idlThings.forEach(idlThing => idlThing.isdeleted(true)); + this.pcrud.autoApply(idlThings).subscribe( + val => console.debug('deleted: ' + val), + err => {}, + () => this.grid.reload() + ); + } + + createNew() { + 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.record = null; + this.editDialog.open({size: this.dialogSize}).then( + ok => { + this.createString.current() + .then(str => this.toast.success(str)); + this.grid.reload(); + }, + rejection => { + if (!rejection.dismissed) { + this.createErrString.current() + .then(str => this.toast.danger(str)); + } + } + ); + } + // Open the field translation dialog. + // Link the next/previous actions to cycle through each translatable + // field on each row. + translate() { + this.translateRowIdx = 0; + this.translateFieldIdx = 0; + this.translator.fieldName = this.translatableFields[this.translateFieldIdx]; + this.translator.idlObject = this.dataSource.data[this.translateRowIdx]; + + this.translator.nextString = () => { + + if (this.translateFieldIdx < this.translatableFields.length - 1) { + this.translateFieldIdx++; + + } else if (this.translateRowIdx < this.dataSource.data.length - 1) { + this.translateRowIdx++; + this.translateFieldIdx = 0; + } + + this.translator.idlObject = + this.dataSource.data[this.translateRowIdx]; + this.translator.fieldName = + this.translatableFields[this.translateFieldIdx]; + }; + + this.translator.prevString = () => { + + if (this.translateFieldIdx > 0) { + this.translateFieldIdx--; + + } else if (this.translateRowIdx > 0) { + this.translateRowIdx--; + this.translateFieldIdx = 0; + } + + this.translator.idlObject = + this.dataSource.data[this.translateRowIdx]; + this.translator.fieldName = + this.translatableFields[this.translateFieldIdx]; + }; + + this.translator.open({size: 'lg'}); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.ts b/Open-ILS/src/eg2/src/app/staff/staff.component.ts index dc58de1030..952a46852d 100644 --- a/Open-ILS/src/eg2/src/app/staff/staff.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.ts @@ -110,7 +110,7 @@ export class StaffComponent implements OnInit { * Make sure to fire the contextmenu Event on Shift+F10 */ fireContextMenuEvent(): void { - let event = new MouseEvent("contextmenu", { + const event = new MouseEvent('contextmenu', { bubbles: true, cancelable: false, view: window, @@ -118,9 +118,7 @@ export class StaffComponent implements OnInit { buttons: 0, }); document.activeElement.dispatchEvent(event); - }; - - + } /* @ViewChild('egAccessKeyInfo')