implement removing columns

pull/6834/head
Jens Ulferts 6 years ago
parent 8f73f489c3
commit 0e957ca081
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 4
      frontend/src/app/modules/grids/context_menus/column.directive.ts
  2. 38
      frontend/src/app/modules/grids/grid.component.ts

@ -90,7 +90,6 @@ export class GridColumnContextMenu extends OpContextMenuTrigger {
linkText: "Add column before", linkText: "Add column before",
onClick: () => { onClick: () => {
grid.addColumn(columnNumber - 1); grid.addColumn(columnNumber - 1);
//this.wpTableSortBy.addDescending(c);
return true; return true;
} }
}, },
@ -98,14 +97,13 @@ export class GridColumnContextMenu extends OpContextMenuTrigger {
linkText: "Add column after", linkText: "Add column after",
onClick: () => { onClick: () => {
grid.addColumn(columnNumber); grid.addColumn(columnNumber);
//this.wpTableSortBy.addAscending(c);
return true; return true;
} }
}, },
{ {
linkText: "Remove column", linkText: "Remove column",
onClick: () => { onClick: () => {
//this.wpTableGroupBy.setBy(c); grid.removeColumn(columnNumber);
return true; return true;
} }
} }

@ -252,29 +252,45 @@ export class GridComponent implements OnDestroy, OnInit {
this.buildAreas(); this.buildAreas();
} }
public addColumn(after:number) { public addColumn(column:number) {
this.numColumns++; this.numColumns++;
this.addAreas(this.buildGridAreasColumn(this.numColumns)); this.addAreas(this.buildGridAreasColumn(this.numColumns));
this.gridWidgetAreas.filter((area) => { this.gridWidgetAreas.filter((area) => {
return area.startColumn > after; return area.startColumn > column;
}).forEach((area) => { }).forEach((area) => {
area.moveRight(); area.moveRight();
}); });
} }
//public addColumnBefore(before:number) { public removeColumn(column:number) {
// this.numColumns++; this.numColumns--;
// this.gridAreas.push(...this.buildGridAreasColumn(this.numColumns)); // remove widgets that only span the removed column
this.widgetResources = this.widgetResources.filter((widget) => {
return !(widget.startColumn === column && widget.endColumn === column + 1);
});
//shrink widgets that span more than the removed column
this.widgetResources.forEach((widget) => {
if (widget.startColumn <= column && widget.endColumn >= column + 1) {
//shrink widgets that span more than the removed column
widget.endColumn--;
}
});
// this.gridWidgetAreas.filter((area) => { // move all widgets that are after the removed column
// return area.startColumn >= before; // so that they appear to keep their place.
// }).forEach((area) => { this.widgetResources.filter((widget) => {
// area.moveRight(); return widget.startColumn > column;
// }); }).forEach((widget) => {
//} widget.startColumn--;
widget.endColumn--;
});
this.buildAreas();
}
private buildAreas() { private buildAreas() {
this.gridAreas = this.buildGridAreas(); this.gridAreas = this.buildGridAreas();

Loading…
Cancel
Save