From e191d536f0b1ab85cd439505656a789673e84fba Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Fri, 11 Oct 2019 22:51:47 +0000 Subject: [PATCH] lp1846552 Adjust character formatting & subfolder - Switch character formatting to UNIX instead of DOS/Windows - Move copy-location-order components into new copy-location folder - Adjust link in Local Admin page to link to new Angular UI Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/eg2/src/app/staff/admin/local/admin-local.module.ts renamed: Open-ILS/src/eg2/src/app/staff/admin/local/copy-location-order.component.html -> Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-order.component.html renamed: Open-ILS/src/eg2/src/app/staff/admin/local/copy-location-order.component.ts -> Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-order.component.ts new file: Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-routing.module.ts new file: Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location.module.ts modified: Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts modified: Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.html modified: Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.ts modified: Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.html modified: Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.ts --- .../admin/local/admin-local-splash.component.html | 2 +- .../app/staff/admin/local/admin-local.module.ts | 8 +- .../copy-location-order.component.html | 44 +-- .../copy-location-order.component.ts | 416 ++++++++++----------- .../copy-location/copy-location-routing.module.ts | 15 + .../local/copy-location/copy-location.module.ts | 27 ++ .../src/app/staff/admin/local/routing.module.ts | 3 +- .../staff/admin/local/share/card.component.html | 2 - .../app/staff/admin/local/share/card.component.ts | 1 - .../admin/local/share/table-list.component.html | 4 +- .../admin/local/share/table-list.component.ts | 1 - 11 files changed, 275 insertions(+), 248 deletions(-) rename Open-ILS/src/eg2/src/app/staff/admin/local/{ => copy-location}/copy-location-order.component.html (97%) rename Open-ILS/src/eg2/src/app/staff/admin/local/{ => copy-location}/copy-location-order.component.ts (96%) create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-routing.module.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location.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 02565dfafa..ec22b850e3 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 @@ -30,7 +30,7 @@ + routerLink="/staff/admin/local/asset/copy_location_order"> - - -
-

Context Org Unit

-
- -
-
-

To move an item, drag it up or down with the mouse.

- - - -
{{selected_node.name}} ({{selected_node.shortname}})
+
+ + +
+

Context Org Unit

+
+ +
+
+

To move an item, drag it up or down with the mouse.

+ + + +
{{selected_node.name}} ({{selected_node.shortname}})
\ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location-order.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-order.component.ts similarity index 96% rename from Open-ILS/src/eg2/src/app/staff/admin/local/copy-location-order.component.ts rename to Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-order.component.ts index 756600e9b8..cdf7360669 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location-order.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-order.component.ts @@ -1,209 +1,207 @@ -import {Component, OnInit, HostListener} from '@angular/core'; -import {PcrudService} from '@eg/core/pcrud.service'; -import {AuthService} from '@eg/core/auth.service'; -import {ToastService} from '@eg/share/toast/toast.service'; -import { IdlService } from '@eg/core/idl.service'; - - - -class Category { - name:string; - owning_lib:string; - shortname:string; - unhashed_element:any; -} - -@Component({ - templateUrl: './copy-location-order.component.html' -}) - -export class CopyLocationOrderComponent implements OnInit { - orders:any; - locations:any; - id_log=[]; - lib_tree=[]; - active_libraries=[]; - mouse_x_position:number; - mouse_y_position:number; - detect_mouse_down=false; - detect_mouse = false; - selected_node:any; - - position_styling={ - backgroundColor:"white", - boxShadow:"5px 4px 10px 2px #5B5A5A", - textAlign:"center", - padding:"3px", - width:'80px', - position:'fixed', - } - - constructor( - private pcrud: PcrudService, - private idl: IdlService, - private toast: ToastService, - private auth: AuthService, - ) { - } - - ngOnInit() { - //this.createTree(); - //this.filterGrid(this.auth.user().ws_ou()); - }; - - detectMouseLeave(){ - this.detect_mouse=false; - } - - toggleDragAndDrop(toggle){ - - this.detect_mouse=toggle; - } - - disableMouseUp(){ - this.detect_mouse_down=false; - } - onMouseDown(is_mouse_down){ - this.detect_mouse_down=is_mouse_down; - } - - - displaySelectedNode(node){ - this.selected_node=node; - } - - /** - * Initializes the search for the library tree and the array of the library locations. - * @param org The authorized user passed in during initialization. - */ - filterGrid(org) { - // fetch the locations and order entries - if(!this.orders) { - this.pcrud.search('acplo', {org : org}, {order_by : {acplo : 'position'}}) - .subscribe(elements => console.log("Order",elements)); - this.mappingLocation(); - } - } - - - /** - * Maps the values of the specified category to an array of objects, whose keys hold the necessary values. - */ - mappingLocation(){ - this.locations=[]; - this.pcrud.search('acpl', - {owning_lib:this.id_log, deleted : 'f'} - ).subscribe(element => { - var categ = new Category(); - var unhashed_element=element; - var hashed_element = this.idl.toHash(element, false); - var found_library = this.findLibrary(hashed_element.owning_lib) - categ.name=hashed_element.name; - categ.owning_lib= found_library.name; - categ.shortname=found_library.shortname; - categ.unhashed_element=unhashed_element; - this.locations.push(categ); - }); - this.id_log=[]; - } - - /** - * Finds the Library name, using the library id. - * @param lib_id The id that is to be used to find the name. - */ - findLibrary(lib_id){ - var lib_name; - this.active_libraries.forEach(library=>{ - if(library.id==lib_id){ - lib_name= { - name:library.name, - shortname:library.shortname - }; - } - }) - return lib_name; - } - - /** - * Starts from parent, logs id, looks for a specific key, checks to see if it has any children. If so - * rinse repeat. - * @param parent_node The uppermost parent node. - */ - nodeTrailing(parent_node){ - this.findParent(parent_node); - } - - /** - * Creates a tree of the different library branches - * @param node The parent node, of which, the branches 'branch out' - */ - createBranch(node){ - this.lib_tree.push(node); - node.children.forEach(child => { - this.createBranch(child); - }); - } - - /** - * Checks if the node passed in has a parent node. If so, follow that branch, while saving the child nodes, - * until the root node is found. - * @param node The node that is to be checked for a parent. - */ - findParent(node){ - this.id_log.push(node.id); - this.active_libraries.push(node); - var filteredTree= this.lib_tree.filter(branch=> branch.ou_type.depth<=(node.ou_type.depth-1)); //Creates a filtered branch - filteredTree.forEach(branch =>{ - if - ( - ( branch.id==node.parent_ou) - && this.isChild(branch.children, node) - ) - { - this.findParent(branch); - } - }) - } - - /** - * Using the given parameters, checks if the 'node' passed is the parent of the 'children' parameter passed in. - * @param children The array of children nodes that is to be checked. - * @param node The assumed parent node. - */ - isChild(children, node){ - var names_are_equal = false; - children.forEach(child => { - if(child.shortname==node.shortname){ - names_are_equal= true; - } - }) - return names_are_equal; - } - - onChange(object){ - if(this.lib_tree.length==0){ - this.createBranch(this.idl.toHash(object, false)); - } - this.nodeTrailing(this.idl.toHash(object, false)) - this.mappingLocation(); - } - - applyChanges(new_locations){ - var library_locations=[]; - new_locations.forEach(element => { - library_locations.push(element.unhashed_element) - }); - var library =this.pcrud.update(library_locations); - - console.log(library.subscribe(object=> console.log(object))) - } - - @HostListener('mousemove', ['$event']) - mouseMove($event: MouseEvent) { - this.mouse_y_position=$event.clientY; - this.mouse_x_position=$event.clientX; - } - - -} - +import {Component, OnInit, HostListener} from '@angular/core'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {AuthService} from '@eg/core/auth.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import { IdlService } from '@eg/core/idl.service'; + +class Category { + name:string; + owning_lib:string; + shortname:string; + unhashed_element:any; +} + +@Component({ + templateUrl: './copy-location-order.component.html' +}) + +export class CopyLocationOrderComponent implements OnInit { + orders:any; + locations:any; + id_log=[]; + lib_tree=[]; + active_libraries=[]; + mouse_x_position:number; + mouse_y_position:number; + detect_mouse_down=false; + detect_mouse = false; + selected_node:any; + + position_styling={ + backgroundColor:"white", + boxShadow:"5px 4px 10px 2px #5B5A5A", + textAlign:"center", + padding:"3px", + width:'80px', + position:'fixed', + } + + constructor( + private pcrud: PcrudService, + private idl: IdlService, + private toast: ToastService, + private auth: AuthService, + ) { + } + + ngOnInit() { + //this.createTree(); + //this.filterGrid(this.auth.user().ws_ou()); + }; + + detectMouseLeave(){ + this.detect_mouse=false; + } + + toggleDragAndDrop(toggle){ + + this.detect_mouse=toggle; + } + + disableMouseUp(){ + this.detect_mouse_down=false; + } + onMouseDown(is_mouse_down){ + this.detect_mouse_down=is_mouse_down; + } + + + displaySelectedNode(node){ + this.selected_node=node; + } + + /** + * Initializes the search for the library tree and the array of the library locations. + * @param org The authorized user passed in during initialization. + */ + filterGrid(org) { + // fetch the locations and order entries + if(!this.orders) { + this.pcrud.search('acplo', {org : org}, {order_by : {acplo : 'position'}}) + .subscribe(elements => console.log("Order",elements)); + this.mappingLocation(); + } + } + + + /** + * Maps the values of the specified category to an array of objects, whose keys hold the necessary values. + */ + mappingLocation(){ + this.locations=[]; + this.pcrud.search('acpl', + {owning_lib:this.id_log, deleted : 'f'} + ).subscribe(element => { + var categ = new Category(); + var unhashed_element=element; + var hashed_element = this.idl.toHash(element, false); + var found_library = this.findLibrary(hashed_element.owning_lib) + categ.name=hashed_element.name; + categ.owning_lib= found_library.name; + categ.shortname=found_library.shortname; + categ.unhashed_element=unhashed_element; + this.locations.push(categ); + }); + this.id_log=[]; + } + + /** + * Finds the Library name, using the library id. + * @param lib_id The id that is to be used to find the name. + */ + findLibrary(lib_id){ + var lib_name; + this.active_libraries.forEach(library=>{ + if(library.id==lib_id){ + lib_name= { + name:library.name, + shortname:library.shortname + }; + } + }) + return lib_name; + } + + /** + * Starts from parent, logs id, looks for a specific key, checks to see if it has any children. If so + * rinse repeat. + * @param parent_node The uppermost parent node. + */ + nodeTrailing(parent_node){ + this.findParent(parent_node); + } + + /** + * Creates a tree of the different library branches + * @param node The parent node, of which, the branches 'branch out' + */ + createBranch(node){ + this.lib_tree.push(node); + node.children.forEach(child => { + this.createBranch(child); + }); + } + + /** + * Checks if the node passed in has a parent node. If so, follow that branch, while saving the child nodes, + * until the root node is found. + * @param node The node that is to be checked for a parent. + */ + findParent(node){ + this.id_log.push(node.id); + this.active_libraries.push(node); + var filteredTree= this.lib_tree.filter(branch=> branch.ou_type.depth<=(node.ou_type.depth-1)); //Creates a filtered branch + filteredTree.forEach(branch =>{ + if + ( + ( branch.id==node.parent_ou) + && this.isChild(branch.children, node) + ) + { + this.findParent(branch); + } + }) + } + + /** + * Using the given parameters, checks if the 'node' passed is the parent of the 'children' parameter passed in. + * @param children The array of children nodes that is to be checked. + * @param node The assumed parent node. + */ + isChild(children, node){ + var names_are_equal = false; + children.forEach(child => { + if(child.shortname==node.shortname){ + names_are_equal= true; + } + }) + return names_are_equal; + } + + onChange(object){ + if(this.lib_tree.length==0){ + this.createBranch(this.idl.toHash(object, false)); + } + this.nodeTrailing(this.idl.toHash(object, false)) + this.mappingLocation(); + } + + applyChanges(new_locations){ + var library_locations=[]; + new_locations.forEach(element => { + library_locations.push(element.unhashed_element) + }); + var library =this.pcrud.update(library_locations); + + console.log(library.subscribe(object=> console.log(object))) + } + + @HostListener('mousemove', ['$event']) + mouseMove($event: MouseEvent) { + this.mouse_y_position=$event.clientY; + this.mouse_x_position=$event.clientX; + } + + +} + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-routing.module.ts new file mode 100644 index 0000000000..126f0b15ee --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location-routing.module.ts @@ -0,0 +1,15 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {CopyLocationOrderComponent} from './copy-location-order.component'; + +const routes: Routes = [{ + path: '', + component: CopyLocationOrderComponent +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class CopyLocationRoutingModule {} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location.module.ts new file mode 100644 index 0000000000..442509e4b1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/copy-location/copy-location.module.ts @@ -0,0 +1,27 @@ +import {NgModule} from '@angular/core'; +import {AdminCommonModule} from '@eg/staff/admin/common.module'; +import {TreeModule} from '@eg/share/tree/tree.module'; +import {CopyLocationRoutingModule} from './copy-location-routing.module'; +import {CopyLocationOrderComponent} from './copy-location-order.component'; +import {TableListComponent} from '@eg/staff/admin/local/share/table-list.component'; +import {CardComponent} from '@eg/staff/admin/local/share/card.component'; + + @NgModule({ + declarations: [ + CopyLocationOrderComponent, + TableListComponent, + CardComponent + ], + imports: [ + AdminCommonModule, + CopyLocationRoutingModule, + TreeModule + ], + exports: [ + ], + providers: [ + ] +}) + +export class CopyLocationModule { +} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts index 865fd7e5d0..41625af656 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts @@ -5,7 +5,6 @@ import {BasicAdminPageComponent} from '@eg/staff/admin/basic-admin-page.componen import {AddressAlertComponent} from './address-alert.component'; import {AdminCarouselComponent} from './admin-carousel.component'; import {StandingPenaltyComponent} from './standing-penalty.component'; -import {CopyLocationOrderComponent} from './copy-location-order.component'; const routes: Routes = [{ path: 'splash', @@ -25,7 +24,7 @@ const routes: Routes = [{ component: StandingPenaltyComponent }, { path: 'asset/copy_location_order', - component: CopyLocationOrderComponent + loadChildren: '@eg/staff/admin/local/copy-location/copy-location.module#CopyLocationModule' }, { path: ':schema/:table', component: BasicAdminPageComponent diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.html index 33eb983e94..410ef3e1cd 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/share/card.component.html @@ -1,5 +1,3 @@ - -
@@ -14,4 +12,4 @@
-
+ \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.ts index de92637602..dd4609852c 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/share/table-list.component.ts @@ -1,4 +1,3 @@ - import {Component, OnInit, Input,Output,EventEmitter} from '@angular/core'; /** -- 2.11.0