LP1840050 org unit admin UI WIP
authorBill Erickson <berickxx@gmail.com>
Wed, 14 Aug 2019 19:15:09 +0000 (15:15 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 14 Aug 2019 19:15:09 +0000 (15:15 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts

index 9a0ef8f..3aad241 100644 (file)
   dialogBody="Delete Org Unit {{selected ? selected.label : ''}}?">
 </eg-confirm-dialog>
 
+<ng-template #treeNodeLabelTmpl let-org="org">
+  <span *ngIf="org" i18n>{{org.name()}} ({{org.shortname()}})</span>
+</ng-template>
+<eg-string #treeNodeLabel key='admin.server.org_unit.treenode' 
+  [template]="treeNodeLabelTmpl"></eg-string>
+
 <div class="row">
   <div class="col-lg-4">
     <h3 i18n>Org Units</h3>
@@ -92,7 +98,7 @@
                   <eg-fm-record-editor idlClass="aoa" readonlyFields="org_unit" 
                     [mode]="currentOrg().billing_address().isnew() ? 'create': 'update'" 
                     [hideBanner]="true" displayMode="inline" hiddenFields="id"
-                    (recordSaved)="orgSaved($event ? $event.org_unit() : null)"
+                    (recordSaved)="orgSaved()"
                     [recordId]="currentOrg().billing_address().isnew() ? null : currentOrg().billing_address().id()"
                     [record]="currentOrg().billing_address().isnew() ? currentOrg().billing_address() : null"
                     fieldOrder="address_type,street1,street2,city,county,state,country,post_code,san,valid"
                 </ng-template>
               </ngb-tab>
               <ngb-tab title="Holds Address" i18n-title id="holds">
+                <ng-template ngbTabContent>
+                  <eg-fm-record-editor idlClass="aoa" readonlyFields="org_unit" 
+                    [mode]="currentOrg().holds_address().isnew() ? 'create': 'update'" 
+                    [hideBanner]="true" displayMode="inline" hiddenFields="id"
+                    (recordSaved)="orgSaved()"
+                    [recordId]="currentOrg().holds_address().isnew() ? null : currentOrg().holds_address().id()"
+                    [record]="currentOrg().holds_address().isnew() ? currentOrg().holds_address() : null"
+                    fieldOrder="address_type,street1,street2,city,county,state,country,post_code,san,valid"
+                    >
+                  </eg-fm-record-editor>
+                </ng-template>
               </ngb-tab>
               <ngb-tab title="Mailing Address" i18n-title id="mailing">
+                <ng-template ngbTabContent>
+                  <eg-fm-record-editor idlClass="aoa" readonlyFields="org_unit" 
+                    [mode]="currentOrg().mailing_address().isnew() ? 'create': 'update'" 
+                    [hideBanner]="true" displayMode="inline" hiddenFields="id"
+                    (recordSaved)="orgSaved()"
+                    [recordId]="currentOrg().mailing_address().isnew() ? null : currentOrg().mailing_address().id()"
+                    [record]="currentOrg().mailing_address().isnew() ? currentOrg().mailing_address() : null"
+                    fieldOrder="address_type,street1,street2,city,county,state,country,post_code,san,valid"
+                    >
+                  </eg-fm-record-editor>
+                </ng-template>
               </ngb-tab>
               <ngb-tab title="ILL Address" i18n-title id="ill">
+                <ng-template ngbTabContent>
+                  <eg-fm-record-editor idlClass="aoa" readonlyFields="org_unit" 
+                    [mode]="currentOrg().ill_address().isnew() ? 'create': 'update'" 
+                    [hideBanner]="true" displayMode="inline" hiddenFields="id"
+                    (recordSaved)="orgSaved()"
+                    [recordId]="currentOrg().ill_address().isnew() ? null : currentOrg().ill_address().id()"
+                    [record]="currentOrg().ill_address().isnew() ? currentOrg().ill_address() : null"
+                    fieldOrder="address_type,street1,street2,city,county,state,country,post_code,san,valid"
+                    >
+                  </eg-fm-record-editor>
+                </ng-template>
               </ngb-tab>
             </ngb-tabset>
           </div>
index 2a45303..6afef79 100644 (file)
@@ -7,6 +7,7 @@ import {AuthService} from '@eg/core/auth.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {ToastService} from '@eg/share/toast/toast.service';
 import {StringComponent} from '@eg/share/string/string.component';
+import {StringService} from '@eg/share/string/string.service';
 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
 
@@ -26,6 +27,7 @@ export class OrgUnitComponent implements OnInit {
         private org: OrgService,
         private auth: AuthService,
         private pcrud: PcrudService,
+        private strings: StringService,
         private toast: ToastService
     ) {}
 
@@ -40,6 +42,9 @@ export class OrgUnitComponent implements OnInit {
     }
 
     orgSaved(orgId: number) {
+        if (!orgId && this.currentOrg()) {
+            orgId = this.currentOrg().id();
+        }
         this.loadAouTree(orgId).then(_ => this.postUpdate(this.editString));
     }
 
@@ -77,6 +82,11 @@ export class OrgUnitComponent implements OnInit {
                 callerData: {orgUnit: orgNode}
             });
 
+            // Apply the compiled label asynchronously
+            this.strings.interpolate(
+                'admin.server.org_unit.treenode', {org: orgNode}
+            ).then(label => treeNode.label = label);
+
             orgNode.children().forEach(childNode =>
                 treeNode.children.push(handleNode(childNode))
             );