lp1844169-search-filter-groups
authorMike Risher <mrisher@catalyte.io>
Tue, 17 Sep 2019 21:33:04 +0000 (21:33 +0000)
committerMike Risher <mrisher@catalyte.io>
Tue, 5 Nov 2019 20:42:00 +0000 (20:42 +0000)
Port search filter groups admin from DOJO UI to Angular. Each search
filter group has its own edit page, from which you can edit search
filter group entries.

Signed-off-by: Mike Risher <mrisher@catalyte.io>
 Changes to be committed:
modified:   eg2/src/app/staff/admin/local/admin-local-splash.component.html
modified:   eg2/src/app/staff/admin/local/routing.module.ts
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.html
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.ts
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group-routing.module.ts
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.html
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.ts
new file:   eg2/src/app/staff/admin/local/search-filter/search-filter-group.module.ts

Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-routing.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.module.ts [new file with mode: 0644]

index 223d181..c01a044 100644 (file)
@@ -49,7 +49,7 @@
     <eg-link-table-link i18n-label label="Permission Tree Display Entries" 
       url="/eg/staff/admin/local/permission/grp_tree_display_entry"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Search Filter Groups" 
-      url="/eg/staff/admin/local/actor/search_filter_group"></eg-link-table-link>
+      routerLink="/staff/admin/local/actor/search_filter_group"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Shelving Location Groups" 
       url="/eg/staff/admin/local/asset/copy_location_group"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Shelving Location Order" 
index 15a9153..576ecfb 100644 (file)
@@ -20,6 +20,9 @@ const routes: Routes = [{
     path: 'container/carousel',
     component: AdminCarouselComponent
 }, {
+    path: 'actor/search_filter_group',
+    loadChildren: '@eg/staff/admin/local/search-filter/search-filter-group.module#SearchFilterGroupModule'
+}, {
     path: 'config/standing_penalty',
     component: StandingPenaltyComponent
 }, {
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.html
new file mode 100644 (file)
index 0000000..cf8b3d1
--- /dev/null
@@ -0,0 +1,16 @@
+<eg-title i18n-prefix prefix="Search Filter Group Entries Configuration"></eg-title>
+<eg-staff-banner bannerText="Search Filter Group" i18n-bannerText>
+</eg-staff-banner>
+
+<div class="col-lg-6 offset-lg-3">
+    <eg-fm-record-editor displayMode="inline" hiddenFieldsList="id,create_date"
+        idlClass="asfg" mode="update" recordId="{{this.currentId}}">
+    </eg-fm-record-editor>
+</div>
+
+<eg-staff-banner bannerText="Search Filter Group Entries Configuration" i18n-bannerText>
+</eg-staff-banner>
+<eg-admin-page idlClass="asfge" disableOrgFilter="true" 
+    [dataSource]="dataSource">
+</eg-admin-page>
+<!-- [defaultNewRecord]="defaultNewRecord" -->
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.ts
new file mode 100644 (file)
index 0000000..a1279c1
--- /dev/null
@@ -0,0 +1,46 @@
+import {Component, Input} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {GridDataSource} from '@eg/share/grid/grid';
+import {Pager} from '@eg/share/util/pager';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {IdlObject, IdlService } from '@eg/core/idl.service';
+
+ @Component({
+     templateUrl: './search-filter-group-entries.component.html'
+ })
+
+ export class SearchFilterGroupEntriesComponent {
+    
+    @Input() idlClass = 'asfge';
+    @Input() sortField: string;
+    @Input() dataSource: GridDataSource;
+    @Input() dialogSize: 'sm' | 'lg' = 'lg';
+
+    // This is the ID of the search filter group being edited currently
+    currentId: number;
+    defaultNewRecord: IdlObject;
+
+    constructor(
+        private route: ActivatedRoute,
+        private pcrud: PcrudService,
+        private idl: IdlService,
+    ) {
+    }
+
+    ngOnInit() {
+        this.currentId = parseInt(this.route.snapshot.paramMap.get('id'));
+        this.defaultNewRecord = this.idl.create('asfge');
+        this.defaultNewRecord.grp(this.currentId);
+        this.dataSource = new GridDataSource();
+        this.dataSource.getRows = (pager: Pager, sort: any[]) => {
+            const searchOps = {
+                offset: pager.offset,
+                limit: pager.limit,
+                order_by: {},
+                flesh: 1,
+                flesh_fields: {asfge: ["query"]}
+            };
+            return this.pcrud.search(this.idlClass, {grp: this.currentId}, searchOps);
+        };
+    }
+ }
\ No newline at end of file
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-routing.module.ts
new file mode 100644 (file)
index 0000000..9763794
--- /dev/null
@@ -0,0 +1,19 @@
+import {NgModule} from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {SearchFilterGroupComponent} from './search-filter-group.component';
+import {SearchFilterGroupEntriesComponent} from './search-filter-group-entries.component';
+
+const routes: Routes = [{
+    path: ':id',
+    component: SearchFilterGroupEntriesComponent
+  }, {
+    path: '',
+    component: SearchFilterGroupComponent
+}];
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule]
+})
+
+export class SearchFilterGroupRoutingModule {}
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.html
new file mode 100644 (file)
index 0000000..8a49b0b
--- /dev/null
@@ -0,0 +1,28 @@
+<eg-title i18n-prefix prefix="Search Filter Group Administration"></eg-title>
+<eg-staff-banner bannerText="Search Filter Group Configuration" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-string #createString i18n-text text="New Search Filter Group Added"></eg-string>
+<eg-string #createErrString i18n-text text="Failed to Create New Search Filter Group">
+</eg-string>
+<eg-string #deleteFailedString i18n-text text="Delete of Search Filter Group failed or 
+    was not allowed">    
+</eg-string>
+<eg-string #deleteSuccessString i18n-text text="Delete of Search Filter Group succeeded">
+</eg-string>
+
+<eg-grid #grid idlClass="asfg" [dataSource]="gridDataSource" 
+[sortable]="true" persistKey="{{persistKey}}">
+<eg-grid-column label="ID" path="id" name="id" datatype="id" [hidden]="true"></eg-grid-column>
+    <eg-grid-toolbar-button
+    label="New Search Filter Group" i18n-label [action]="createNew">
+    </eg-grid-toolbar-button>
+    <eg-grid-toolbar-action label="Edit Selected" i18n-label [action]="editSelected">
+    </eg-grid-toolbar-action>
+    <eg-grid-toolbar-action label="Delete Selected" i18n-label 
+    (onClick)="deleteSelected($event)">
+    </eg-grid-toolbar-action>
+</eg-grid>
+
+<eg-fm-record-editor #editDialog idlClass="asfg">
+</eg-fm-record-editor>
\ No newline at end of file
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.ts
new file mode 100644 (file)
index 0000000..f9aeddb
--- /dev/null
@@ -0,0 +1,96 @@
+import {Pager} from '@eg/share/util/pager';
+import {Component, Input, ViewChild} from '@angular/core';
+import { Router, ActivatedRoute }    from '@angular/router';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
+import {GridDataSource} from '@eg/share/grid/grid';
+import {GridComponent} from '@eg/share/grid/grid.component';
+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 {StringComponent} from '@eg/share/string/string.component';
+import { AdminPageComponent } from '../../../share/admin-page/admin-page.component';
+
+ @Component({
+    templateUrl: './search-filter-group.component.html'
+ })
+
+ export class SearchFilterGroupComponent extends AdminPageComponent {
+
+    @Input() idlClass: string = "asfg";
+    @Input() sortField: string;
+    @Input() gridDataSource: GridDataSource;
+    @Input() dialogSize: 'sm' | 'lg' = 'lg';
+
+    @ViewChild('grid') grid: GridComponent;
+    @ViewChild('createString') createString: StringComponent;
+    @ViewChild('createErrString') createErrString: StringComponent;
+    @ViewChild('deleteFailedString') deleteFailedString: StringComponent;
+    @ViewChild('deleteSuccessString') deleteSuccessString: StringComponent;
+
+    constructor(
+        route: ActivatedRoute,
+        idl: IdlService,
+        org: OrgService,
+        auth: AuthService,
+        pcrud: PcrudService,
+        perm: PermService,
+        toast: ToastService,
+        private router:Router
+    ) {
+        super(route, idl, org, auth, pcrud, perm, toast);
+    }
+
+    ngOnInit() {
+        this.gridDataSource = new GridDataSource();
+        this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
+            const searchOps = {
+                offset: pager.offset,
+                limit: pager.limit,
+                order_by: {}
+            };
+            return this.pcrud.retrieveAll("asfg", searchOps);
+        };
+        this.grid.onRowActivate.subscribe(
+            (idlThing: IdlObject) => {
+                let idToEdit = idlThing.a[0];
+                this.navigateToEditPage(idToEdit);
+            }
+        );
+    }
+
+    createNew = () => {
+        this.editDialog.mode = 'create';
+        this.editDialog.recordId = null;
+        this.editDialog.record = null;
+        this.editDialog.hiddenFieldsList=["id","create_date"]
+        this.editDialog.open({size: this.dialogSize}).subscribe(
+            ok => {
+                this.createString.current()
+                    .then(str => this.toast.success(str));
+                this.grid.reload();
+            },
+            rejection => {
+                if (!rejection.dismissed) {
+                    this.createErrString.current()
+                        .then(str => this.toast.danger(str));
+                }
+            }
+        );
+    };
+
+    editSelected = (sfGroups: IdlObject[]) => {
+        let idToEdit = sfGroups[0].a[0];
+        this.navigateToEditPage(idToEdit);
+    }
+
+    navigateToEditPage(id: any) {
+        this.router.navigate(["/staff/admin/local/actor/search_filter_group/" + id]);
+    }
+
+    showEditDialog(idlThing: IdlObject): Promise<any> {
+        return;
+    }
+
+ }
\ No newline at end of file
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.module.ts
new file mode 100644 (file)
index 0000000..c7671c5
--- /dev/null
@@ -0,0 +1,25 @@
+import {NgModule} from '@angular/core';
+import {AdminCommonModule} from '@eg/staff/admin/common.module';
+import {TreeModule} from '@eg/share/tree/tree.module';
+import {SearchFilterGroupComponent} from './search-filter-group.component';
+import {SearchFilterGroupEntriesComponent} from './search-filter-group-entries.component';
+import {SearchFilterGroupRoutingModule} from './search-filter-group-routing.module';
+
+@NgModule({
+  declarations: [
+    SearchFilterGroupComponent,
+    SearchFilterGroupEntriesComponent
+  ],
+  imports: [
+    AdminCommonModule,
+    SearchFilterGroupRoutingModule,
+    TreeModule
+  ],
+  exports: [
+  ],
+  providers: [
+  ]
+})
+
+export class SearchFilterGroupModule {
+}
\ No newline at end of file