Skip to content

Commit

Permalink
feat(workspace): workspaces table view are now printable (#1291)
Browse files Browse the repository at this point in the history
* feat(workspace): workspaces table view are now printable

* feat(entity-table): add an id to entity table

* chore(deps): add jspdf-autotable dependency

* wip

* wip

* wip

* wip

* lint

* refactor(workspaces): create common method to build actions on workspaces

* refactor(workspace actions): move to datePipe transformer
  • Loading branch information
pelord authored Jun 15, 2023
1 parent b83ec47 commit 1b62cd4
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 374 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"hammerjs": "^2.0.8",
"html2canvas": "^1.4.1",
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.29",
"jszip": "^3.10.1",
"jwt-decode": "^2.2.0",
"moment": "^2.29.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="table-container" [ngStyle]="{'height': tableHeight}">
<table mat-table matSort [ngClass]="getTableClass()" [dataSource]="dataSource" [trackBy]="getTrackByFunction()" (matSortChange)="onSort($event)">
<table id="currentWorkspaceTable" mat-table matSort [ngClass]="getTableClass()" [dataSource]="dataSource" [trackBy]="getTrackByFunction()" (matSortChange)="onSort($event)">
<ng-container matColumnDef="selectionCheckbox" class="mat-cell-checkbox">
<th mat-header-cell *matHeaderCellDef>
<ng-container *ngIf="selectMany">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface GeoWorkspaceOptions {
pageSize?: number;
pageSizeOptions?: number[];
searchIndexEnabled?: boolean;
printable?: boolean;
}

export interface GeoWorkspaceQueryOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class WmsWorkspaceService {
interface WFSoptions extends WFSDataSourceOptions, OgcFilterableDataSourceOptions { }

let wks;
let wksLayerOption = {
let wksLayerOption: GeoWorkspaceOptions = {
printable: layer.options.workspace?.printable,
srcId: layer.id,
workspaceId: undefined,
enabled: false,
Expand Down
4 changes: 4 additions & 0 deletions packages/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"@igo2/context": "1.15.3",
"rxjs": "^7.5.6"
},
"optionalDependencies": {
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.29"
},
"dependencies": {
"tslib": "^2.4.0"
},
Expand Down
141 changes: 20 additions & 121 deletions packages/integration/src/lib/workspace/shared/edition-actions.service.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { Inject, Injectable, OnDestroy } from '@angular/core';

import {
Action,
EntityStoreFilterCustomFuncStrategy,
EntityStoreFilterSelectionStrategy,
Widget
} from '@igo2/common';
import { Action, Widget } from '@igo2/common';

import { BehaviorSubject, Subscription } from 'rxjs';
import {
EditionWorkspace,
mapExtentStrategyActiveToolTip,
noElementSelected,
ExportOptions,
OgcFilterWidget,
OgcFilterableDataSource,
} from '@igo2/geo';
import { EditionWorkspace, OgcFilterWidget } from '@igo2/geo';
import { StorageService, StorageServiceEvent, StorageServiceEventEnum, LanguageService, MediaService} from '@igo2/core';
import { StorageState } from '../../storage/storage.state';
import { map, skipWhile } from 'rxjs/operators';
import { skipWhile } from 'rxjs/operators';
import { ToolState } from '../../tool/tool.state';
import { handleZoomAuto } from './workspace.utils';
import { getWorkspaceActions, handleZoomAuto } from './workspace.utils';
import { DatePipe } from '@angular/common';

@Injectable({
providedIn: 'root'
Expand All @@ -47,7 +36,8 @@ export class EditionActionsService implements OnDestroy {
private storageState: StorageState,
public languageService: LanguageService,
private mediaService: MediaService,
private toolState: ToolState) {}
private toolState: ToolState,
private datePipe: DatePipe) {}

ngOnDestroy(): void {
if (this.storageChange$$) {
Expand All @@ -72,7 +62,7 @@ export class EditionActionsService implements OnDestroy {
workspace: EditionWorkspace,
rowsInMapExtentCheckCondition$: BehaviorSubject<boolean>,
selectOnlyCheckCondition$: BehaviorSubject<boolean>
): Action[] {
): Action[] {
this.zoomAuto$.next(this.zoomAuto);
this.storageChange$$ = this.storageService.storageChange$
.pipe(skipWhile((storageChange: StorageServiceEvent) =>
Expand All @@ -81,108 +71,17 @@ export class EditionActionsService implements OnDestroy {
this.zoomAuto$.next(this.zoomAuto);
handleZoomAuto(workspace, this.storageService);
});
const actions = [
{
id: 'zoomAuto',
checkbox: true,
title: 'igo.integration.workspace.zoomAuto.title',
tooltip: 'igo.integration.workspace.zoomAuto.tooltip',
checkCondition: this.zoomAuto$,
handler: () => {
handleZoomAuto(workspace, this.storageService);
this.storageService.set('zoomAuto', !this.storageService.get('zoomAuto') as boolean);
}
},
{
id: 'filterInMapExtent',
checkbox: true,
title: 'igo.integration.workspace.inMapExtent.title',
tooltip: mapExtentStrategyActiveToolTip(workspace),
checkCondition: rowsInMapExtentCheckCondition$,
handler: () => rowsInMapExtentCheckCondition$.next(!rowsInMapExtentCheckCondition$.value)
},
{
id: 'selectedOnly',
checkbox: true,
title: 'igo.integration.workspace.selected.title',
tooltip: 'igo.integration.workspace.selected.title',
checkCondition: selectOnlyCheckCondition$,
handler: () => selectOnlyCheckCondition$.next(!selectOnlyCheckCondition$.value)
},
{
id: 'clearselection',
icon: 'select-off',
title: 'igo.integration.workspace.clearSelection.title',
tooltip: 'igo.integration.workspace.clearSelection.tooltip',
handler: (ws: EditionWorkspace) => {
ws.entityStore.state.updateMany(ws.entityStore.view.all(), { selected: false });
},
args: [workspace],
availability: (ws: EditionWorkspace) => noElementSelected(ws)
},
{
id: 'wfsDownload',
icon: 'file-export',
title: 'igo.integration.workspace.download.title',
tooltip: 'igo.integration.workspace.download.tooltip',
handler: (ws: EditionWorkspace) => {
const filterStrategy = ws.entityStore.getStrategyOfType(EntityStoreFilterCustomFuncStrategy);
const filterSelectionStrategy = ws.entityStore.getStrategyOfType(EntityStoreFilterSelectionStrategy);
const layersWithSelection = filterSelectionStrategy.active ? [ws.layer.id] : [];
this.toolState.toolToActivateFromOptions({
tool: 'importExport',
options: { layers: [ws.layer.id], featureInMapExtent: filterStrategy.active, layersWithSelection } as ExportOptions
});
},
args: [workspace]
},
{
id: 'ogcFilter',
icon: 'filter',
title: 'igo.integration.workspace.ogcFilter.title',
tooltip: 'igo.integration.workspace.ogcFilter.tooltip',
handler: (widget: Widget, ws: EditionWorkspace) => {
ws.activateWidget(widget, {
map: ws.map,
layer: ws.layer
});
},
args: [this.ogcFilterWidget, workspace]
},
{
id: 'maximize',
title: this.languageService.translate.instant('igo.integration.workspace.maximize'),
tooltip: this.languageService.translate.instant(
'igo.integration.workspace.maximizeTooltip'
),
icon: 'resize',
display: () => {
return this.maximize$.pipe(map((v) => !v && !this.mediaService.isMobile()));
},
handler: () => {
if (!this.mediaService.isMobile()) {
this.maximize$.next(true);
}
},
},
{
id: 'standardExtent',
title: this.languageService.translate.instant(
'igo.integration.workspace.standardExtent'
),
tooltip: this.languageService.translate.instant(
'igo.integration.workspace.standardExtentTooltip'
),
icon: 'resize',
display: () => {
return this.maximize$.pipe(map((v) => v && !this.mediaService.isMobile()));
},
handler: () => {
this.maximize$.next(false);
}
}
];
return (workspace.layer.dataSource as OgcFilterableDataSource).options.ogcFilters?.enabled ?
actions : actions.filter(action => action.id !== 'ogcFilter');
return getWorkspaceActions(
workspace,
rowsInMapExtentCheckCondition$,
selectOnlyCheckCondition$,
this.ogcFilterWidget,
this.zoomAuto$,
this.maximize$,
this.storageService,
this.languageService,
this.mediaService,
this.toolState,
this.datePipe);
}
}
Loading

0 comments on commit 1b62cd4

Please sign in to comment.