LPXXX Angular Volcopy statcat filter
authorBill Erickson <berickxx@gmail.com>
Fri, 3 Jul 2020 14:42:34 +0000 (10:42 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 3 Jul 2020 14:42:34 +0000 (10:42 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/config.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts

index d3793ab..32d7912 100644 (file)
         <li class="list-group-item">
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
-              id="hide-classification-column" 
+              id="circ_lib_mod_with_owning_lib-column" 
               [(ngModel)]="volcopy.defaults.values.circ_lib_mod_with_owning_lib">
             <label class="form-check-label" 
-              for="hide-circ_lib_mod_with_owning_lib-column" i18n>
+              for="circ_lib_mod_with_owning_lib-column" i18n>
               Change Circ Lib When Owning Lib Changes
             </label>
           </div>
         </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <label class="mr-2" for="statcat_filter" i18n>
+              Stat Cat Filter
+            </label>
+            <eg-org-select
+              domId="statcat_filter"
+              placeholder="Stat Cat Filter..." i18n-placeholder
+              [initialOrgId]="volcopy.defaults.values.statcat_filter"
+              (onChange)="volcopy.defaults.values.statcat_filter = $event ? $event.id() : null">
+            </eg-org-select>
+          </div>
+        </li>
       </ul>
     </div>
   </div>
         <li class="list-group-item">
           <div class="form-check form-check-inline">
             <input class="form-check-input" type="checkbox" 
+              id="show-statcat_filter-attr" 
+              [(ngModel)]="volcopy.defaults.hidden.statcat_filter">
+            <label class="form-check-label" for="show-statcat_filter-attr" i18n>
+              Stat Cat Filter
+            </label>
+          </div>
+        </li>
+        <li class="list-group-item">
+          <div class="form-check form-check-inline">
+            <input class="form-check-input" type="checkbox" 
               id="show-statcats-attr" 
               [(ngModel)]="volcopy.defaults.hidden.statcats">
             <label class="form-check-label" for="show-statcats-attr" i18n>
index 4f9a269..d4e953a 100644 (file)
       </div>
     </div>
 
+    <div class="border rounded m-1" *ngIf="displayAttr('statcat_filter')">
+      <div class="batch-header font-weight-bold p-2" i18n>Add Item Tags</div>
+      <div class="p-1">
+        <eg-org-select
+          domId="statcat_filter-select"
+          placeholder="Stat Cat Filter..." i18n-placeholder
+          [initialOrgId]="statCatFilter"
+          (onChange)="statCatFilter = $event ? $event.id() : null">
+        </eg-org-select>
+      </div>
+    </div>
+
     <ng-container *ngIf="displayAttr('statcats')">
       <div *ngFor="let cat of statCats()">
         <ng-template #statCatTemplate>
index 818edef..98cc60c 100644 (file)
@@ -47,6 +47,8 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     loanDurationLabelMap: {[level: number]: string} = {};
     fineLevelLabelMap: {[level: number]: string} = {};
 
+    statCatFilter: number;
+
     @ViewChild('loanDurationShort', {static: false})
         loanDurationShort: StringComponent;
     @ViewChild('loanDurationNormal', {static: false})
@@ -95,6 +97,7 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     ) { }
 
     ngOnInit() {
+        this.statCatFilter = this.volcopy.defaults.values.statcat_filter;
     }
 
     ngAfterViewInit() {
@@ -115,7 +118,16 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit {
     }
 
     statCats(): IdlObject[] {
-        return this.volcopy.commonData.acp_stat_cat;
+        if (this.statCatFilter) {
+            const orgs = this.org.descendants(this.statCatFilter, true);
+
+            return this.volcopy.commonData.acp_stat_cat.filter(
+                sc => orgs.includes(sc.owner()))
+
+        } else {
+
+            return this.volcopy.commonData.acp_stat_cat;
+        }
     }