From: Bill Erickson Date: Fri, 20 Apr 2018 19:05:32 +0000 (-0400) Subject: LP#1626157 fm editor custom templates; misc; X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f4ea350fc6fb60a34d40426af27debaea722bf10;p=working%2FEvergreen.git LP#1626157 fm editor custom templates; misc; Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts b/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts index ddbe6938a5..bb1fada38c 100644 --- a/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts +++ b/Open-ILS/src/eg2/src/app/share/accesskey/accesskey.directive.ts @@ -19,8 +19,15 @@ import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service'; }) export class EgAccessKeyDirective implements OnInit { + // Space-separated list of key combinations + // E.g. "ctrl+h", "alt+h ctrl+y" @Input() keySpec: string; + + // Description to display in the accesskey info dialog @Input() keyDesc: string; + + // Context info to display in the accesskey info dialog + // E.g. "navbar" @Input() keyCtx: string; constructor( @@ -28,20 +35,21 @@ export class EgAccessKeyDirective implements OnInit { private keyService: EgAccessKeyService ) { } - ngOnInit() { - /* - console.debug( - `EgAccessKey assigning '${this.keySpec}' => ${this.keyDesc}`); - */ - - this.keyService.assign({ - key: this.keySpec, - desc: this.keyDesc, - ctx: this.keyCtx, - action: () => {this.elm.nativeElement.click()} - }); + if (!this.keySpec) { + console.warn("EgAccessKey no keySpec provided"); + return; + } + + this.keySpec.split(/ /).forEach(keySpec => { + this.keyService.assign({ + key: keySpec, + desc: this.keyDesc, + ctx: this.keyCtx, + action: () => {this.elm.nativeElement.click()} + }); + }) } } diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html index f19f6bc61d..ab1bdfb4cb 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html @@ -14,94 +14,103 @@
- - - {{record[field.name]()}} - - - - - - + + + + - + - - - + {{record[field.name]()}} + + + - - + + - - - - - - - - - - - - + (ngModelChange)="record[field.name]($event)"/> + + + + + + + + + + + + + + + + +
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 9f13fb107b..3ba94a3c47 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 @@ -1,10 +1,31 @@ -import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core'; +import {Component, OnInit, Input, + Output, EventEmitter, TemplateRef} from '@angular/core'; import {EgIdlService, EgIdlObject} from '@eg/core/idl.service'; import {EgAuthService} from '@eg/core/auth.service'; import {EgPcrudService} from '@eg/core/pcrud.service'; import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; +interface CustomFieldTemplate { + template: TemplateRef, + + // Allow the caller to pass in a free-form context blob to + // be addedto the caller's custom template context, along + // with our stock context. + context?: [fields: string]: any +} + +interface CustomFieldContext { + // Current create/edit/view record + record: EgIdlObject, + + // IDL field definition blob + field: any, + + // additional context values passed via CustomFieldTemplate + [fields: string]: any; +} + @Component({ selector: 'fm-record-editor', templateUrl: './fm-editor.component.html' @@ -18,20 +39,21 @@ export class FmRecordEditorComponent // mode: 'create' for creating a new record, // 'update' for editing an existing record // 'view' for viewing an existing record without editing - @Input() mode: string; + @Input() mode: 'create' | 'update' | 'view' = 'create'; - // Record ID to view/update. Value is dynamic. + // Record ID to view/update. Value is dynamic. Records are not + // fetched until .open() is called. recId: any; @Input() set recordId(id: any) { if (id) this.recId = id; } // IDL record we are editing - // TODO: allow this to be provided by the caller? + // TODO: allow this to be update in real time by the caller? record: EgIdlObject; - // TODO - // customFieldTemplates + @Input() customFieldTemplates: + {[fieldName:string] : CustomFieldTemplate} = {}; // list of fields that should not be displayed @Input() hiddenFieldsList: string[] = []; @@ -233,13 +255,27 @@ export class FmRecordEditorComponent this.orgDefaultAllowedList.includes(field.name); } - // TODO custom field templates + if (this.customFieldTemplates[field.name]) { + field.template = this.customFieldTemplates[field.name].template; + field.context = this.customFieldTemplates[field.name].context; + } + }); // Wait for all network calls to complete return Promise.all(promises); } + // Returns a context object to be inserted into a custom + // field template. + customTemplateFieldContext(fieldDef: any): FmEditorCustomFieldContext { + return Object.assign( + { record : this.record, + field: fieldDef // from this.fields + }, fieldDef.context || {} + ); + } + save() { let recToSave = this.idl.clone(this.record); this.convertDatatypesToIdl(recToSave); diff --git a/Open-ILS/src/eg2/src/app/staff/login.component.html b/Open-ILS/src/eg2/src/app/staff/login.component.html index dcf953fc98..ba474f809f 100644 --- a/Open-ILS/src/eg2/src/app/staff/login.component.html +++ b/Open-ILS/src/eg2/src/app/staff/login.component.html @@ -3,7 +3,7 @@
Sign In
-
+
diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.css b/Open-ILS/src/eg2/src/app/staff/nav.component.css index ee4f93e89b..63d3e37b29 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.css +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.css @@ -4,8 +4,8 @@ } /* move the caret closer to the dropdown text */ -#staff-navbar .dropdown-toggle::after { - margin-left:0px; +#staff-navbar { + padding-left: 0px; } #staff-navbar { @@ -16,7 +16,7 @@ } #staff-navbar .navbar-nav { - padding: 3px; + padding: 4px; } /* align top of dropdown w/ bottom of nav */ diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index 4b1dd4b883..8ca7cceac1 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -186,16 +186,16 @@ -