From: Mike Risher Date: Tue, 17 Sep 2019 21:33:04 +0000 (+0000) Subject: lp1844169-search-filter-groups X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7339f31906955455ed812bb6eab56e1538171889;p=working%2FEvergreen.git lp1844169-search-filter-groups 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 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 --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html index 223d1817cc..c01a044483 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html @@ -49,7 +49,7 @@ + routerLink="/staff/admin/local/actor/search_filter_group"> + + + +
+ + +
+ + + + + + 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 index 0000000000..a1279c1218 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-entries.component.ts @@ -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 index 0000000000..9763794dc8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group-routing.module.ts @@ -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 index 0000000000..8a49b0b6ea --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ 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 index 0000000000..f9aeddba34 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.component.ts @@ -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 { + 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 index 0000000000..c7671c5bb4 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/search-filter/search-filter-group.module.ts @@ -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