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

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

Loading…
Cancel
Save