persist changes to the wp-table widget

pull/7185/head
Jens Ulferts 6 years ago
parent e63b1fa021
commit 2aaced8c6a
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 3
      frontend/src/app/components/wp-query/url-params-helper.ts
  2. 7
      frontend/src/app/modules/grids/grid/area.service.ts
  3. 2
      frontend/src/app/modules/grids/grid/grid.component.html
  4. 4
      frontend/src/app/modules/grids/grid/grid.component.ts
  5. 4
      frontend/src/app/modules/grids/widgets/abstract-widget.component.ts
  6. 22
      frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts
  7. 1
      frontend/src/app/modules/grids/widgets/wp-widget/wp-widget.component.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;
}

@ -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[] = [];

@ -52,7 +52,7 @@
</div>
<ndc-dynamic [ndcDynamicComponent]="widgetComponent(area.widget)"
[ndcDynamicInputs]="{ resource: area.widget }"
[ndcDynamicOutputs]="{}">
[ndcDynamicOutputs]="widgetComponentOutput(area.widget)">
</ndc-dynamic>
</div>
<resizer *ngIf="!drag.currentlyDragging"

@ -74,6 +74,10 @@ export class GridComponent implements OnDestroy, OnInit {
}
}
public widgetComponentOutput(resource:GridWidgetResource) {
return { resourceChanged: this.layout.saveGrid.bind(this.layout) };
}
public get gridColumnStyle() {
return this.sanitization.bypassSecurityTrustStyle(`repeat(${this.layout.numColumns}, 1fr)`);
}

@ -1,4 +1,4 @@
import {HostBinding, Input} from "@angular/core";
import {HostBinding, Input, EventEmitter, Output} from "@angular/core";
import {GridWidgetResource} from "app/modules/hal/resources/grid-widget-resource";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
@ -10,5 +10,7 @@ export abstract class AbstractWidgetComponent {
@Input() resource:GridWidgetResource;
@Output() resourceChanged = new EventEmitter<GridWidgetResource>();
constructor(protected i18n:I18nService) { }
}

@ -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<WorkPackageTableConfiguration> = {
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() {

@ -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 {

Loading…
Cancel
Save