distribution formulas: start work
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 26 Mar 2021 22:13:01 +0000 (18:13 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 26 Mar 2021 22:13:01 +0000 (18:13 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/admin/acq/admin-acq-splash.component.html
Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/routing.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/acq/routing.module.ts

index 59790a3..355b744 100644 (file)
@@ -16,6 +16,8 @@
       <!-- TODO
       routerLink="/staff/admin/acq/distribution_formula"></eg-link-table-link>
       -->
+    <eg-link-table-link i18n-label label="Distribution Formulas (new)"
+      routerLink="/staff/admin/acq/distribution_formula"></eg-link-table-link>
     <eg-link-table-link i18n-label label="EDI Accounts"
       routerLink="/staff/admin/acq/edi_account"></eg-link-table-link>
     <eg-link-table-link i18n-label label="EDI Messages"
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.html b/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.html
new file mode 100644 (file)
index 0000000..2df555c
--- /dev/null
@@ -0,0 +1,78 @@
+<eg-staff-banner bannerText="Distribution Formulas" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-title i18n-prefix prefix="Distribution Formulas"></eg-title>
+
+<ng-template #successStrTmpl i18n>{{idlClassDef.label}} Update Succeeded</ng-template>
+<eg-string #successString [template]="successStrTmpl"></eg-string>
+
+<ng-template #updateFailedStrTmpl i18n>Update of {{idlClassDef.label}} failed</ng-template>
+<eg-string #updateFailedString [template]="updateFailedStrTmpl"></eg-string>
+
+<ng-template #deleteFailedStrTmpl i18n>Delete of {{idlClassDef.label}} failed or was not allowed</ng-template>
+<eg-string #deleteFailedString [template]="deleteFailedStrTmpl"></eg-string>
+
+<ng-template #deleteSuccessStrTmpl i18n>{{idlClassDef.label}} Successfully Deleted</ng-template>
+<eg-string #deleteSuccessString [template]="deleteSuccessStrTmpl"></eg-string>
+
+<ng-template #createStrTmpl i18n>{{idlClassDef.label}} Successfully Created</ng-template>
+<eg-string #createString [template]="createStrTmpl"></eg-string>
+
+<ng-template #createErrStrTmpl i18n>Failed to create new {{idlClassDef.label}}</ng-template>
+<eg-string #createErrString [template]="createErrStrTmpl"></eg-string>
+
+<ng-container *ngIf="orgField">
+  <div class="row">
+    <div class="col-lg-6">
+      <ng-container *ngIf="orgField">
+        <eg-org-family-select
+          [limitPerms]="viewPerms" 
+          [selectedOrgId]="contextOrg.id()"
+          [(ngModel)]="searchOrgs"
+          (ngModelChange)="grid.reload()">
+        </eg-org-family-select>
+      </ng-container>
+    </div>
+  </div>
+  <hr/>
+</ng-container>
+
+<!-- idlObject and fieldName applied programmatically -->
+<eg-translate #translator></eg-translate>
+
+<ng-container *ngIf="helpTemplate">
+  <ng-container *ngTemplateOutlet="helpTemplate"></ng-container>
+</ng-container>
+
+<ng-template #configFieldLink let-row="row" let-col="col">
+  <a i18n-title title="Link To {{col.label}}"
+    [attr.href]="configFieldLinkUrl(row, col)">{{configLinkLabel(row, col)}}</a>
+</ng-template>
+
+<eg-grid #grid idlClass="{{idlClass}}" [dataSource]="dataSource" hideFields="{{hideGridFields}}"
+    [sortable]="true" persistKey="{{persistKey}}" autoGeneratedColumnOrder="{{fieldOrder}}"
+    [filterable]="true" [stickyHeader]="true"
+    [cellTextGenerator]="cellTextGenerator">
+  <eg-grid-toolbar-button [disabled]="!canCreate" 
+    label="New {{idlClassDef.label}}" i18n-label (onClick)="createNew()">
+  </eg-grid-toolbar-button>
+  <eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)">
+  </eg-grid-toolbar-action>
+  <eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)">
+  </eg-grid-toolbar-action>
+
+  <eg-grid-column path="name"></eg-grid-column>
+  <eg-grid-column path="owner"></eg-grid-column>
+  <eg-grid-column path="skip_count" [hidden]="true"></eg-grid-column>
+  <eg-grid-column path="id" [hidden]="true"></eg-grid-column>
+
+
+</eg-grid>
+
+<eg-fm-record-editor #editDialog idlClass="{{idlClass}}" 
+    [fieldOptions]="fieldOptions"
+    [fieldOrder]="fieldOrder"
+    [defaultNewRecord]="defaultNewRecord"
+    [preloadLinkedValues]="true"
+    [readonlyFields]="readonlyFields">
+</eg-fm-record-editor>
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.component.ts
new file mode 100644 (file)
index 0000000..e1052cc
--- /dev/null
@@ -0,0 +1,104 @@
+import {Component, Input, ViewChild, OnInit} from '@angular/core';
+import {Location} from '@angular/common';
+import {FormatService} from '@eg/core/format.service';
+import {GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component';
+import {Pager} from '@eg/share/util/pager';
+import {ActivatedRoute} from '@angular/router';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {OrgService} from '@eg/core/org.service';
+import {PermService} from '@eg/core/perm.service';
+import {AuthService} from '@eg/core/auth.service';
+import {NetService} from '@eg/core/net.service';
+import {StringComponent} from '@eg/share/string/string.component';
+
+@Component({
+    templateUrl: './distribution-formulas.component.html'
+})
+
+export class DistributionFormulasComponent extends AdminPageComponent implements OnInit {
+    idlClass = 'acqdf';
+    classLabel: string;
+
+    @ViewChild('grid', { static: true }) grid: GridComponent;
+
+    cellTextGenerator: GridCellTextGenerator;
+
+    constructor(
+        route: ActivatedRoute,
+        ngLocation: Location,
+        format: FormatService,
+        idl: IdlService,
+        org: OrgService,
+        auth: AuthService,
+        pcrud: PcrudService,
+        perm: PermService,
+        toast: ToastService,
+        private net: NetService
+    ) {
+        super(route, ngLocation, format, idl, org, auth, pcrud, perm, toast);
+        this.dataSource = new GridDataSource();
+    }
+
+    ngOnInit() {
+        this.cellTextGenerator = {
+            name: row => row.name()
+        };
+        this.fieldOrder = 'name,code,year,org,active,currency_type,balance_stop_percentage,balance_warning_percentage,propagate,rollover';
+        this.defaultNewRecord = this.idl.create('acqdf');
+        this.defaultNewRecord.owner(this.auth.user().ws_ou());
+
+        this.dataSource.getRows = (pager: Pager, sort: any[]) => {
+            const orderBy: any = {};
+            if (sort.length) {
+                // Sort specified from grid
+                orderBy[this.idlClass] = sort[0].name + ' ' + sort[0].dir;
+            } else if (this.sortField) {
+                // Default sort field
+                orderBy[this.idlClass] = this.sortField;
+            }
+
+            const searchOps = {
+                offset: pager.offset,
+                limit: pager.limit,
+                order_by: orderBy
+            };
+            const reqOps = {
+                fleshSelectors: true,
+            };
+
+            if (!this.contextOrg && !Object.keys(this.dataSource.filters).length) {
+                // No org filter -- fetch all rows
+                return this.pcrud.retrieveAll(
+                    this.idlClass, searchOps, reqOps);
+            }
+
+            const search: any = new Array();
+            const orgFilter: any = {};
+
+            if (this.orgField && (this.searchOrgs || this.contextOrg)) {
+                orgFilter[this.orgField] =
+                    this.searchOrgs.orgIds || [this.contextOrg.id()];
+                search.push(orgFilter);
+            }
+
+            Object.keys(this.dataSource.filters).forEach(key => {
+                Object.keys(this.dataSource.filters[key]).forEach(key2 => {
+                    search.push(this.dataSource.filters[key][key2]);
+                });
+            });
+
+            return this.pcrud.search(
+                this.idlClass, search, searchOps, reqOps);
+        };
+
+        super.ngOnInit();
+
+        this.classLabel = this.idlClassDef.label;
+        this.includeOrgDescendants = true;
+    }
+
+}
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/distribution-formulas.module.ts
new file mode 100644 (file)
index 0000000..86365d7
--- /dev/null
@@ -0,0 +1,23 @@
+import {NgModule} from '@angular/core';
+import {StaffCommonModule} from '@eg/staff/common.module';
+import {AdminCommonModule} from '@eg/staff/admin/common.module';
+import {DistributionFormulasRoutingModule} from './routing.module';
+import {DistributionFormulasComponent} from './distribution-formulas.component';
+
+@NgModule({
+  declarations: [
+    DistributionFormulasComponent
+  ],
+  imports: [
+    StaffCommonModule,
+    AdminCommonModule,
+    DistributionFormulasRoutingModule
+  ],
+  exports: [
+  ],
+  providers: [
+  ]
+})
+
+export class DistributionFormulasModule {
+}
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/acq/distribution_formula/routing.module.ts
new file mode 100644 (file)
index 0000000..e67b402
--- /dev/null
@@ -0,0 +1,15 @@
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {DistributionFormulasComponent} from './distribution-formulas.component';
+
+const routes: Routes = [{
+    path: '',
+    component: DistributionFormulasComponent
+}];
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule]
+})
+
+export class DistributionFormulasRoutingModule {}
index a1a011e..0ae8e0a 100644 (file)
@@ -32,6 +32,10 @@ const routes: Routes = [{
     path: 'claim_type',
     redirectTo: 'claiming' // from legacy auto-generated admin page
 }, {
+    path: 'distribution_formula',
+    loadChildren: () =>
+      import('./distribution_formula/distribution-formulas.module').then(m => m.DistributionFormulasModule)
+}, {
     path: 'edi_attr_set',
     loadChildren: () =>
       import('./edi_attr_set/edi-attr-sets.module').then(m => m.EdiAttrSetsModule)