LP#1775466 Grid column width config
authorBill Erickson <berickxx@gmail.com>
Thu, 10 May 2018 17:31:10 +0000 (13:31 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 6 Jun 2018 20:59:25 +0000 (16:59 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.component.css
Open-ILS/src/eg2/src/app/share/grid/grid.component.html
Open-ILS/src/eg2/src/app/share/grid/grid.module.ts
Open-ILS/src/eg2/src/app/share/grid/grid.service.ts

index 631c21e..913c6de 100644 (file)
@@ -36,8 +36,8 @@ export class EgGridColumnComponent implements OnInit {
         let col = new EgGridColumn();
         col.name = this.name;
         col.path = this.path;
-        col.label = this.label || this.name;
-        col.flex = this.flex || 2;
+        col.label = this.label;
+        col.flex = this.flex;
         col.hidden = this.hidden;
         col.cellTemplate = this.cellTemplate;
         col.isPkey = this.pkey;
index 4c985c2..6d4f471 100644 (file)
       <span title="Show Grid Options" i18n-title class="material-icons">arrow_drop_down</span>
     </button>
     <div class="dropdown-menu" ngbDropdownMenu>
-      <a class="dropdown-item label-with-material-icon" (click)="columnConfDialog.open({size:'lg'})">
+      <a class="dropdown-item label-with-material-icon" 
+        (click)="columnConfDialog.open({size:'lg'})">
         <span class="material-icons">build</span>
         <span  class="ml-2" i18n>Manage Columns</span>
       </a>
+      <a class="dropdown-item label-with-material-icon" 
+        (click)="colWidthConfig.isVisible = !colWidthConfig.isVisible">
+        <span class="material-icons">compare_arrows</span>
+        <span  class="ml-2" i18n>Manage Column Widths</span>
+      </a>
       <div class="dropdown-divider"></div>
 
       <a class="dropdown-item label-with-material-icon" 
index 5f1f828..547e0f0 100644 (file)
@@ -4,6 +4,7 @@ import {Pager} from '@eg/share/util/pager';
 import {EgGridService, EgGridColumn, EgGridColumnSet, EgGridToolbarButton} 
   from '@eg/share/grid/grid.service';
 import {EgDialogComponent} from '@eg/share/dialog/dialog.component';
+import {EgGridColumnWidthComponent} from './grid-column-width.component';
 
 @Component({
   selector: 'eg-grid-toolbar',
@@ -16,6 +17,7 @@ export class EgGridToolbarComponent implements OnInit {
     @Input() pager: Pager;
     @Input() toolbarButtons: EgGridToolbarButton[];
     @Input() columnSet: EgGridColumnSet;
+    @Input() colWidthConfig: EgGridColumnWidthComponent;
 
     ngOnInit() {
 
index 57bb252..144a3fa 100644 (file)
     border-color: #b8daff;
 }
 
-/*
-.eg-grid-header-cell a.sortable span {
-*/
 .eg-grid-header-cell-sort-label {
   cursor: pointer;
-  color: #007bff;
-  text-decoration:underline;
+  text-decoration: underline;
 }
 
 .eg-grid-header-cell-sort-arrow {
@@ -40,7 +36,7 @@
 }
 
 .eg-grid-cell {
-    flex: 1; /* applied per column */
+    flex: 2; /* applied per column */
     padding: 6px;
 }
 
   flex: none;
 }
 
+/* depends on width of .eg-grid-cell-skinny */
+.eg-grid-column-width-header {
+  width: 4.4em;
+  text-align: center;
+  flex: none;
+  display: inline-flex;
+  vertical-align: middle;
+  align-items: center;
+}
+
+.eg-grid-column-width-config .eg-grid-cell {
+    border-left: 2px dashed grey;
+}
+
+.eg-grid-column-width-icon {
+  cursor: pointer;
+  font-size: 18px;
+  color: #007bff;
+}
+
+.eg-grid-column-config-dialog {
+  height: auto;
+  max-height: 400px;
+  overflow: auto;
+  box-shadow: none;
+}
+
 .eg-grid-column-config-dialog .visible {
   color: #000;
   background-color: rgb(201, 221, 225);
@@ -64,3 +87,4 @@
 }
 
 
+
index ac9ed9a..8a1ad18 100644 (file)
@@ -1,8 +1,12 @@
 
 <div class="eg-grid">
-  <eg-grid-toolbar [dataSource]="dataSource" [pager]="pager" 
-    [toolbarButtons]="toolbarButtons" [columnSet]="columnSet"></eg-grid-toolbar>
+  <eg-grid-toolbar 
+    [dataSource]="dataSource" [pager]="pager" 
+    [toolbarButtons]="toolbarButtons" [columnSet]="columnSet"
+    [colWidthConfig]="colWidthConfig">
+  </eg-grid-toolbar>
   <eg-grid-header [columnSet]="columnSet" [dataSource]="dataSource"></eg-grid-header>
+  <eg-grid-column-width #colWidthConfig [columnSet]="columnSet"></eg-grid-column-width>
 
   <div class="eg-grid-row eg-grid-body-row"
     [ngClass]="{'eg-grid-row-selected': selector[idx]}"
index bd36327..62981ae 100644 (file)
@@ -8,6 +8,7 @@ import {EgGridToolbarComponent} from './grid-toolbar.component';
 import {EgGridService} from './grid.service';
 import {EgGridToolbarButtonComponent} from './grid-toolbar-button.component';
 import {EgGridColumnConfigComponent} from './grid-column-config.component';
+import {EgGridColumnWidthComponent} from './grid-column-width.component';
 
 
 @NgModule({
@@ -18,7 +19,8 @@ import {EgGridColumnConfigComponent} from './grid-column-config.component';
         EgGridHeaderComponent,
         EgGridToolbarComponent,
         EgGridToolbarButtonComponent,
-        EgGridColumnConfigComponent
+        EgGridColumnConfigComponent,
+        EgGridColumnWidthComponent
     ],
     imports: [
         EgCommonModule
index 6891907..20b0b4f 100644 (file)
@@ -104,6 +104,8 @@ export class EgGridColumnSet {
         if (this.columns.filter(c => c.name == col.name).length) return;
 
         if (col.isPkey) this.pkeyColumn = col;
+        if (!col.flex) col.flex = 2;
+        if (!col.label) col.label = col.name;
 
         col.visible = !col.hidden;