From: Kyle Huckins Date: Sat, 26 Feb 2022 22:20:00 +0000 (+0000) Subject: lp1778311 On The Fly Resizing of Grids WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=260da9fafdea9f4c83c458a0634a2277268fcd2b;p=working%2FEvergreen.git lp1778311 On The Fly Resizing of Grids WIP - Introduce resizing component - Refactor grid into html table Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html modified: Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts modified: Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.html modified: Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts modified: Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html modified: Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts modified: Open-ILS/src/eg2/src/app/share/grid/grid.component.css modified: Open-ILS/src/eg2/src/app/share/grid/grid.component.html modified: Open-ILS/src/eg2/src/app/share/grid/grid.module.ts new file: Open-ILS/src/eg2/src/app/share/grid/resizable.component.html new file: Open-ILS/src/eg2/src/app/share/grid/resizable.component.ts new file: Open-ILS/src/eg2/src/app/share/grid/resizable.css new file: Open-ILS/src/eg2/src/app/share/grid/resizable.directive.ts new file: Open-ILS/src/eg2/src/app/share/grid/resizable.style.less --- diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html index fed22766ba..597144f13e 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.html @@ -7,13 +7,11 @@ -
-
- + *ngFor="let row of context.dataSource.getPageOfRows(context.pager); let idx = index"(keydown)="onGridKeyDown($event)" > -
+ -
+
-
+ {{context.pager.rowNumber(idx)}} -
-
+ + @@ -39,11 +37,11 @@ -
+ -
-
-
-
- + + \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts index 14c6b4c7f4..e99636e9b8 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-body.component.ts @@ -5,7 +5,7 @@ import {GridComponent} from './grid.component'; import {NgbPopover} from '@ng-bootstrap/ng-bootstrap'; @Component({ - selector: 'eg-grid-body', + selector: 'eg-grid-body, [eg-grid-body]', templateUrl: './grid-body.component.html' }) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.html index ca24c00afd..5451d2fcdf 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.html @@ -1,20 +1,19 @@ -
-
-
Expand
-
+ Expand + call_made -
-
-
-
Shrink
-
+ + + Shrink + call_received -
-
-
+ + diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts index bb597cd86e..3c8b9cb39a 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts @@ -2,7 +2,7 @@ import {Component, Input, OnInit} from '@angular/core'; import {GridContext, GridColumn, GridColumnSet} from './grid'; @Component({ - selector: 'eg-grid-column-width', + selector: 'eg-grid-column-width, [eg-grid-column-width]', templateUrl: './grid-column-width.component.html' }) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html index a68076514c..cc7d302c60 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html @@ -1,23 +1,23 @@ -
+ -
-
+
-
# -
-
+ notifications -
-
+ arrow_downwards {{col.label}} -
-
-
- -
-
-
-
- -
- -
-
+ diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts index f7c857a4ab..6a7338296e 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-print.component.ts @@ -4,7 +4,7 @@ import {PrintService} from '@eg/share/print/print.service'; import {GridContext} from '@eg/share/grid/grid'; @Component({ - selector: 'eg-grid-print', + selector: 'eg-grid-print, [eg-grid-print]', templateUrl: './grid-print.component.html' }) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.css b/Open-ILS/src/eg2/src/app/share/grid/grid.component.css index 83a907c72a..77b7ab4072 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.css +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.css @@ -1,11 +1,9 @@ .eg-grid { - width: 100%; - color: rgba(0,0,0,.87); + color: rgba(0,0,0,.87); } .eg-grid-row { - display: flex; border-bottom: 1px solid rgba(0,0,0,.12); padding-left: 10px; padding-right: 10px; @@ -54,6 +52,11 @@ white-space: normal; } +.eg-grid-resizable th { + resize: horizontal; + overflow: auto; +} + .eg-grid-body-cell { } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html index 2ab6be0505..ebcf24f9e5 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.html +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.html @@ -1,18 +1,18 @@ - -
- - - + + -
- -
+ + + - + + + @@ -35,7 +35,8 @@ - - - + + + +
diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts index 0757fab28e..9e285b351a 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.module.ts @@ -16,6 +16,8 @@ import {GridColumnWidthComponent} from './grid-column-width.component'; import {GridPrintComponent} from './grid-print.component'; import {GridFilterControlComponent} from './grid-filter-control.component'; import {GridToolbarActionsEditorComponent} from './grid-toolbar-actions-editor.component'; +import {ResizableComponent} from './resizable.component'; +import {ResizableDirective} from './resizable.directive'; @NgModule({ @@ -35,7 +37,9 @@ import {GridToolbarActionsEditorComponent} from './grid-toolbar-actions-editor.c GridColumnWidthComponent, GridPrintComponent, GridFilterControlComponent, - GridToolbarActionsEditorComponent + GridToolbarActionsEditorComponent, + ResizableComponent, + ResizableDirective ], imports: [ EgCommonModule, @@ -47,7 +51,8 @@ import {GridToolbarActionsEditorComponent} from './grid-toolbar-actions-editor.c GridColumnComponent, GridToolbarButtonComponent, GridToolbarCheckboxComponent, - GridToolbarActionComponent + GridToolbarActionComponent, + ResizableComponent ], providers: [ ] diff --git a/Open-ILS/src/eg2/src/app/share/grid/resizable.component.html b/Open-ILS/src/eg2/src/app/share/grid/resizable.component.html new file mode 100644 index 0000000000..0795e06e02 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/resizable.component.html @@ -0,0 +1,6 @@ +
+
+ +
+
+
\ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/share/grid/resizable.component.ts b/Open-ILS/src/eg2/src/app/share/grid/resizable.component.ts new file mode 100644 index 0000000000..44cfeb4e67 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/resizable.component.ts @@ -0,0 +1,15 @@ +import { Component, ElementRef, HostBinding } from "@angular/core"; + +@Component({ + selector: "th[resizable]", + templateUrl: "./resizable.component.html", + styleUrls: ["./resizable.style.less"] +}) +export class ResizableComponent { + @HostBinding("style.width.px") + width: number | null = null; + + onResize(width: number) { + this.width = width; + } +} diff --git a/Open-ILS/src/eg2/src/app/share/grid/resizable.css b/Open-ILS/src/eg2/src/app/share/grid/resizable.css new file mode 100644 index 0000000000..6f5d12775f --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/resizable.css @@ -0,0 +1,35 @@ +:host { + &:last-child .bar { + display: none; + } +} + +.resizable-wrapper { + display: flex; + justify-content: flex-end; +} + +.resizable-content { + flex: 2; +} + +.resizable-bar { + position: absolute; + top: 0; + bottom: 0; + width: 2px; + margin: 0 -16px 0 16px; + justify-self: flex-end; + border-left: 2px solid transparent; + border-right: 2px solid transparent; + background: blueviolet; + background-clip: content-box; + cursor: ew-resize; + opacity: 0; + transition: opacity .3s; + + &:hover, + &:active { + opacity: 1; + } +} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/share/grid/resizable.directive.ts b/Open-ILS/src/eg2/src/app/share/grid/resizable.directive.ts new file mode 100644 index 0000000000..06fad98ae2 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/resizable.directive.ts @@ -0,0 +1,36 @@ +import { DOCUMENT } from "@angular/common"; +import { Directive, ElementRef, Inject, Output } from "@angular/core"; +import { + distinctUntilChanged, map, switchMap, takeUntil, tap +} from "rxjs/operators"; +import { fromEvent } from "rxjs"; + +@Directive({ + selector: "[resizable]" +}) +export class ResizableDirective { + @Output() + readonly resizable = fromEvent( + this.elementRef.nativeElement, + "mousedown" + ).pipe( + tap(e => e.preventDefault()), + switchMap(() => { + const { width, right } = this.elementRef.nativeElement + .closest("th") + .getBoundingClientRect(); + + return fromEvent(this.documentRef, "mousemove").pipe( + map(({ clientX }) => width + clientX - right), + distinctUntilChanged(), + takeUntil(fromEvent(this.documentRef, "mouseup")) + ); + }) + ); + + constructor( + @Inject(DOCUMENT) private readonly documentRef: Document, + @Inject(ElementRef) + private readonly elementRef: ElementRef + ) {} +} diff --git a/Open-ILS/src/eg2/src/app/share/grid/resizable.style.less b/Open-ILS/src/eg2/src/app/share/grid/resizable.style.less new file mode 100644 index 0000000000..997ad05165 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/grid/resizable.style.less @@ -0,0 +1,35 @@ +:host { + &:last-child .bar { + display: none; + } +} + +.resizable-wrapper { + display: flex; + justify-content: flex-end; +} + +.resizable-content { + flex: 1; +} + +.resizable-bar { + position: absolute; + top: 0; + bottom: 0; + width: 2px; + margin: 0 -16px 0 16px; + justify-self: flex-end; + border-left: 2px solid transparent; + border-right: 2px solid transparent; + background: blueviolet; + background-clip: content-box; + cursor: ew-resize; + opacity: 0; + transition: opacity .3s; + + &:hover, + &:active { + opacity: 1; + } +} \ No newline at end of file