From 2aaced8c6a92580bb5098c5d531e4361167c3b85 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Fri, 22 Mar 2019 11:02:04 +0100 Subject: [PATCH] persist changes to the wp-table widget --- .../components/wp-query/url-params-helper.ts | 3 ++- .../app/modules/grids/grid/area.service.ts | 7 +++++- .../modules/grids/grid/grid.component.html | 2 +- .../app/modules/grids/grid/grid.component.ts | 4 ++++ .../widgets/abstract-widget.component.ts | 4 +++- .../widgets/wp-table/wp-table.component.ts | 22 ++++++++++++++++--- .../widgets/wp-widget/wp-widget.component.ts | 1 - 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/components/wp-query/url-params-helper.ts b/frontend/src/app/components/wp-query/url-params-helper.ts index 1fff418901..455b3ea9c1 100644 --- a/frontend/src/app/components/wp-query/url-params-helper.ts +++ b/frontend/src/app/components/wp-query/url-params-helper.ts @@ -84,7 +84,8 @@ export class UrlParamsHelperService { private encodeColumns(paramsData:any, query:QueryResource) { paramsData.c = query.columns.map(function (column) { return column.id!; - }) + }); + return paramsData; } diff --git a/frontend/src/app/modules/grids/grid/area.service.ts b/frontend/src/app/modules/grids/grid/area.service.ts index c38ffcf7d1..d492997e34 100644 --- a/frontend/src/app/modules/grids/grid/area.service.ts +++ b/frontend/src/app/modules/grids/grid/area.service.ts @@ -48,13 +48,18 @@ export class GridAreaService { this.resource.widgets = this.widgetResources; this.resource.rowCount = this.numRows; + this.resource.columnCount = this.numColumns; if (save) { - this.gridDm.update(this.resource, this.schema); + this.saveGrid(); } } + public saveGrid() { + this.gridDm.update(this.resource, this.schema); + } + private buildGridAreas() { let cells:GridArea[] = []; diff --git a/frontend/src/app/modules/grids/grid/grid.component.html b/frontend/src/app/modules/grids/grid/grid.component.html index 87da0e8c75..30b0a9e65f 100644 --- a/frontend/src/app/modules/grids/grid/grid.component.html +++ b/frontend/src/app/modules/grids/grid/grid.component.html @@ -52,7 +52,7 @@ + [ndcDynamicOutputs]="widgetComponentOutput(area.widget)"> (); + constructor(protected i18n:I18nService) { } } diff --git a/frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts b/frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts index 9f4433e9cb..9e774e32a6 100644 --- a/frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts +++ b/frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts @@ -7,6 +7,8 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service"; import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space"; import {untilComponentDestroyed} from 'ng2-rx-componentdestroyed'; import {WorkPackageIsolatedQuerySpaceDirective} from "core-app/modules/work_packages/query-space/wp-isolated-query-space.directive"; +import {skip} from 'rxjs/operators'; +import {UrlParamsHelperService} from "core-components/wp-query/url-params-helper"; @Component({ templateUrl: '../wp-widget/wp-widget.component.html', @@ -14,7 +16,7 @@ import {WorkPackageIsolatedQuerySpaceDirective} from "core-app/modules/work_pack }) export class WidgetWpTableComponent extends WidgetWpListComponent implements OnInit, OnDestroy, AfterViewInit { public text = { title: this.i18n.t('js.grid.widgets.work_packages_table.title') }; - public queryProps = {}; + public queryProps:any = {}; public configuration:Partial = { actionsColumnEnabled: false, @@ -23,11 +25,18 @@ export class WidgetWpTableComponent extends WidgetWpListComponent implements OnI contextMenuEnabled: false }; + constructor(protected i18n:I18nService, + protected urlParamsHelper:UrlParamsHelperService) { + super(i18n); + } + @ViewChild(WorkPackageIsolatedQuerySpaceDirective) public querySpaceDirective:WorkPackageIsolatedQuerySpaceDirective; ngOnInit() { + if (this.resource.options.queryProps) { + this.queryProps = this.resource.options.queryProps; + } super.ngOnInit(); - } ngAfterViewInit() { @@ -37,8 +46,15 @@ export class WidgetWpTableComponent extends WidgetWpListComponent implements OnI .query .values$() .pipe( + // 2 because ... well it is a magic number and works + skip(2), untilComponentDestroyed(this) - ).subscribe(() => console.log('query updated')); + ).subscribe((query) => { + let queryProps = this.urlParamsHelper.buildV3GetQueryFromQueryResource(query); + + this.resource.options = { queryProps: queryProps }; + this.resourceChanged.emit(this.resource); + }); } ngOnDestroy() { diff --git a/frontend/src/app/modules/grids/widgets/wp-widget/wp-widget.component.ts b/frontend/src/app/modules/grids/widgets/wp-widget/wp-widget.component.ts index 815f58d566..1eb8d2d052 100644 --- a/frontend/src/app/modules/grids/widgets/wp-widget/wp-widget.component.ts +++ b/frontend/src/app/modules/grids/widgets/wp-widget/wp-widget.component.ts @@ -2,7 +2,6 @@ import {AbstractWidgetComponent} from "app/modules/grids/widgets/abstract-widget import {OnInit} from "@angular/core"; import { WorkPackageTableConfiguration, - WorkPackageTableConfigurationObject } from "core-components/wp-table/wp-table-configuration"; export class WidgetWpListComponent extends AbstractWidgetComponent implements OnInit {