From: Bill Erickson Date: Mon, 20 Nov 2017 02:01:23 +0000 (-0500) Subject: LP#626157 Ang2 experiments / nav X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f34676cf148d9bbf8230f5e20e51b01e52844883;p=working%2FEvergreen.git LP#626157 Ang2 experiments / nav Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/webby-src/src/app/base.module.ts b/Open-ILS/webby-src/src/app/base.module.ts index df83aa8de6..02a487b736 100644 --- a/Open-ILS/webby-src/src/app/base.module.ts +++ b/Open-ILS/webby-src/src/app/base.module.ts @@ -11,6 +11,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { EgBaseComponent } from './base.component'; import { EgBaseRoutingModule } from './base-routing.module'; import { WelcomeComponent } from './welcome.component'; +import { EgIdlService } from '@eg/core/eg-idl.service'; @NgModule({ declarations: [ @@ -22,7 +23,7 @@ import { WelcomeComponent } from './welcome.component'; BrowserModule, NgbModule.forRoot() ], - providers: [], + providers: [EgIdlService], bootstrap: [EgBaseComponent] }) diff --git a/Open-ILS/webby-src/src/app/core/eg-idl.service.ts b/Open-ILS/webby-src/src/app/core/eg-idl.service.ts new file mode 100644 index 0000000000..787d6a927d --- /dev/null +++ b/Open-ILS/webby-src/src/app/core/eg-idl.service.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@angular/core'; + +// Added globally by /IDL2js +declare var _preload_fieldmapper_IDL: Object; + +@Injectable() +export class EgIdlService { + + classes: Object; + + parseIdl(): void { + let this_ = this; + + // retain a copy of the full IDL within the this + this.classes = _preload_fieldmapper_IDL; + + /** + * Creates the class constructor and getter/setter + * methods for each IDL class. + */ + + let mkclass = function(cls, fields) { + this_.classes[cls].classname = cls; + + this_[cls] = function(seed) { + this.a = seed || []; + this.classname = cls; + this._isfieldmapper = true; + } + + /** creates the getter/setter methods for each field */ + fields.forEach(function(field, idx) { + this_[cls].prototype[fields[idx].name] = function(n) { + if (arguments.length==1) this.a[idx] = n; + return this.a[idx]; + } + }); + + // global class constructors required for JSON_v1.js + window[cls] = this_[cls]; + } + + for (var cls in this_.classes) + mkclass(cls, this_.classes[cls].fields); + }; + +} diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts index 710590594a..adb2e21b98 100644 --- a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { EgNetService } from '@eg/core/eg-net.service'; +import { EgIdlService } from '@eg/core/eg-idl.service'; @Component({ templateUrl: 'bcsearch.component.html' @@ -13,7 +14,8 @@ export class EgBcSearchComponent implements OnInit { constructor( private route: ActivatedRoute, - private egNet: EgNetService + private egNet: EgNetService, + private egIdl : EgIdlService ) {} ngOnInit() { @@ -42,7 +44,10 @@ export class EgBcSearchComponent implements OnInit { x => console.log(x), e => console.log('echo event: ' + e), () => console.log('done') - ) + ); + + this.egIdl.parseIdl(); + console.log(this.egIdl.aou); } diff --git a/Open-ILS/webby-src/src/app/staff/nav.component.ts b/Open-ILS/webby-src/src/app/staff/nav.component.ts index 06f17e498a..0b2dbd34a8 100644 --- a/Open-ILS/webby-src/src/app/staff/nav.component.ts +++ b/Open-ILS/webby-src/src/app/staff/nav.component.ts @@ -2,8 +2,8 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; @Component({ - selector: 'eg-staff-nav-bar'; - templateUrl: 'nav.component.html' + selector: 'eg-staff-nav-bar', + templateUrl: 'nav.component.html' }) export class EgStaffNavComponent implements OnInit { diff --git a/Open-ILS/webby-src/src/app/staff/staff.component.ts b/Open-ILS/webby-src/src/app/staff/staff.component.ts index c209fb7a5c..2c13840fe1 100644 --- a/Open-ILS/webby-src/src/app/staff/staff.component.ts +++ b/Open-ILS/webby-src/src/app/staff/staff.component.ts @@ -6,7 +6,6 @@ import { ActivatedRoute, Router } from '@angular/router'; }) export class EgStaffComponent implements OnInit { - title = 'EgStaff'; constructor(private route: ActivatedRoute) {} diff --git a/Open-ILS/webby-src/src/index.html b/Open-ILS/webby-src/src/index.html index b1d2497bc5..6036b5d439 100644 --- a/Open-ILS/webby-src/src/index.html +++ b/Open-ILS/webby-src/src/index.html @@ -16,6 +16,7 @@ +