Skip to content

Commit

Permalink
Workspace fixes (#1290)
Browse files Browse the repository at this point in the history
* Insert accent hashtag (#1258)

* premier_test_ajout_hastags

* insert_accent_to_the_keywords_in_order_to_use_hashtag_and(-)

---------

Co-authored-by: karengeo <[email protected]>
(cherry picked from commit cf74db7)

* Corriger le parseInt qui ajuste normalement les attributs en integer (#1257)

* Corriger le parseInt qui ajuste normalement les attributs en integer

* Make condition a function

(cherry picked from commit 1d807d6)

* fix(draw): drawing circle crash whole drawing component. (#1273)

(cherry picked from commit 3998dcc)

* chore(Package): run the build once

* 1.15.3

* refactor(workspaces): move common method to workspace utils

* feat(workspaces): sourcefields with types add a cellClassFunc to the table template

* refactor(entity-table): typo

* fix(workspace): table scroll/overflow was not accessible

* lint

* lint

* wip

---------

Co-authored-by: MSPKarengeo <[email protected]>
Co-authored-by: Michael Lane <[email protected]>
Co-authored-by: Alexandre Caron <[email protected]>
  • Loading branch information
4 people authored Jun 14, 2023
1 parent 7a4f2cb commit bc40e5c
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ table button {
padding-right: 35px !important;
}

.class_sting,
.class_string,
.class_text,
.class_number_edition {
text-align: left;
Expand Down
13 changes: 2 additions & 11 deletions packages/geo/src/lib/workspace/shared/edition-workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { MatDialog } from '@angular/material/dialog';

import {
ActionStore,
EntityRecord,
EntityStoreFilterCustomFuncStrategy,
EntityStoreFilterSelectionStrategy,
EntityStoreStrategyFuncOptions,
EntityTableColumnRenderer,
EntityTableTemplate,
EntityTableButton} from '@igo2/common';
Expand Down Expand Up @@ -40,6 +37,7 @@ import olFeature from 'ol/Feature';
import olSourceImageWMS from 'ol/source/ImageWMS';
import type { default as OlGeometry } from 'ol/geom/Geometry';
import { BehaviorSubject, Observable, throwError } from 'rxjs';
import { createFilterInMapExtentOrResolutionStrategy } from './workspace.utils';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -233,7 +231,7 @@ export class EditionWorkspaceService {
store.addStrategy(inMapResolutionStrategy, true);
store.addStrategy(selectionStrategy, true);
store.addStrategy(selectedRecordStrategy, false);
store.addStrategy(this.createFilterInMapExtentOrResolutionStrategy(), true);
store.addStrategy(createFilterInMapExtentOrResolutionStrategy(), true);
return store;
}

Expand Down Expand Up @@ -378,13 +376,6 @@ export class EditionWorkspaceService {
};
}

private createFilterInMapExtentOrResolutionStrategy(): EntityStoreFilterCustomFuncStrategy {
const filterClauseFunc = (record: EntityRecord<object>) => {
return record.state.inMapExtent === true && record.state.inMapResolution === true;
};
return new EntityStoreFilterCustomFuncStrategy({filterClauseFunc} as EntityStoreStrategyFuncOptions);
}

public saveFeature(feature, workspace: EditionWorkspace) {
if (!this.validateFeature(feature, workspace)){
return false;
Expand Down
96 changes: 5 additions & 91 deletions packages/geo/src/lib/workspace/shared/feature-workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@ import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import {
ActionStore,
EntityTableTemplate,
EntityStoreFilterCustomFuncStrategy,
EntityRecord,
EntityStoreStrategyFuncOptions,
EntityStoreFilterSelectionStrategy,
EntityTableColumnRenderer
EntityStoreFilterSelectionStrategy
} from '@igo2/common';

import {
FeatureStore,
FeatureStoreLoadingLayerStrategy,
FeatureStoreSelectionStrategy,
FeatureStoreInMapExtentStrategy,
Feature,
FeatureMotion,
FeatureStoreInMapResolutionStrategy,
FeatureStoreSearchIndexStrategy,
Expand All @@ -24,16 +18,13 @@ import {
import { LayerService, VectorLayer } from '../../layer';
import { GeoWorkspaceOptions } from '../../layer/shared/layers/layer.interface';
import { IgoMap } from '../../map';
import { SourceFieldsOptionsParams, FeatureDataSource, RelationOptions, CapabilitiesService } from '../../datasource';
import { FeatureDataSource, CapabilitiesService } from '../../datasource';
import { getCommonVectorSelectedStyle } from '../../style/shared/vector/commonVectorStyle';

import { FeatureWorkspace } from './feature-workspace';
import { skipWhile, take } from 'rxjs/operators';
import { ConfigService, StorageService } from '@igo2/core';

import olFeature from 'ol/Feature';
import type { default as OlGeometry } from 'ol/geom/Geometry';
import { getGeoServiceAction } from './workspace.utils';
import { createFilterInMapExtentOrResolutionStrategy, createTableTemplate } from './workspace.utils';
import { PropertyTypeDetectorService } from '../../utils/propertyTypeDetector/propertyTypeDetector.service';

@Injectable({
Expand Down Expand Up @@ -79,7 +70,7 @@ export class FeatureWorkspaceService {
tableTemplate: undefined
}
});
this.createTableTemplate(wks, layer);
createTableTemplate(wks, layer, this.layerService, this.ws$);
return wks;

}
Expand Down Expand Up @@ -125,84 +116,7 @@ export class FeatureWorkspaceService {
store.addStrategy(inMapResolutionStrategy, true);
store.addStrategy(selectionStrategy, true);
store.addStrategy(selectedRecordStrategy, false);
store.addStrategy(this.createFilterInMapExtentOrResolutionStrategy(), true);
store.addStrategy(createFilterInMapExtentOrResolutionStrategy(), true);
return store;
}

private createTableTemplate(workspace: FeatureWorkspace, layer: VectorLayer): EntityTableTemplate {
const geoServiceAction = getGeoServiceAction(workspace, this.layerService);
const fields = layer.dataSource.options.sourceFields || [];

const relations = layer.dataSource.options.relations || [];

if (fields.length === 0) {
workspace.entityStore.entities$.pipe(
skipWhile(val => val.length === 0),
take(1)
).subscribe(entities => {
const ol = (entities[0] as Feature).ol as olFeature<OlGeometry>;
const columnsFromFeatures = ol.getKeys()
.filter(
col => !col.startsWith('_') &&
col !== 'geometry' &&
col !== ol.getGeometryName() &&
!col.match(/boundedby/gi))
.map(key => {
return {
name: `properties.${key}`,
title: key,
renderer: EntityTableColumnRenderer.UnsanitizedHTML
};
});
columnsFromFeatures.unshift(...geoServiceAction);
workspace.meta.tableTemplate = {
selection: true,
sort: true,
columns: columnsFromFeatures
};
});
return;
}
const columns = fields.map((field: SourceFieldsOptionsParams) => {
return {
name: `properties.${field.name}`,
title: field.alias ? field.alias : field.name,
renderer: EntityTableColumnRenderer.UnsanitizedHTML,
tooltip: field.tooltip
};
});

const relationsColumn = relations.map((relation: RelationOptions) => {
return {
name: `properties.${relation.name}`,
title: relation.alias ? relation.alias : relation.name,
renderer: EntityTableColumnRenderer.Icon,
icon: relation.icon,
parent: relation.parent,
type: 'relation',
tooltip: relation.tooltip,
onClick: () => {
this.ws$.next(relation.title);
},
cellClassFunc: () => {
return { 'class_icon': true };
}
};
});

columns.push(...relationsColumn);
columns.unshift(...geoServiceAction);
workspace.meta.tableTemplate = {
selection: true,
sort: true,
columns
};
}

private createFilterInMapExtentOrResolutionStrategy(): EntityStoreFilterCustomFuncStrategy {
const filterClauseFunc = (record: EntityRecord<object>) => {
return record.state.inMapExtent === true && record.state.inMapResolution === true;
};
return new EntityStoreFilterCustomFuncStrategy({filterClauseFunc} as EntityStoreStrategyFuncOptions);
}
}
95 changes: 5 additions & 90 deletions packages/geo/src/lib/workspace/shared/wfs-workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,28 @@ import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import {
ActionStore,
EntityTableTemplate,
EntityStoreFilterCustomFuncStrategy,
EntityRecord,
EntityStoreStrategyFuncOptions,
EntityStoreFilterSelectionStrategy,
EntityTableColumnRenderer
EntityStoreFilterSelectionStrategy
} from '@igo2/common';

import {
FeatureStore,
FeatureStoreLoadingLayerStrategy,
FeatureStoreSelectionStrategy,
FeatureStoreInMapExtentStrategy,
Feature,
FeatureMotion,
FeatureStoreInMapResolutionStrategy,
GeoPropertiesStrategy
} from '../../feature';
import { LayerService, VectorLayer } from '../../layer';
import { GeoWorkspaceOptions } from '../../layer/shared/layers/layer.interface';
import { IgoMap } from '../../map';
import { SourceFieldsOptionsParams, FeatureDataSource, RelationOptions, CapabilitiesService } from '../../datasource';
import { FeatureDataSource, CapabilitiesService } from '../../datasource';
import { PropertyTypeDetectorService} from '../../utils';
import { getCommonVectorSelectedStyle } from '../../style/shared/vector/commonVectorStyle';

import { WfsWorkspace } from './wfs-workspace';
import { skipWhile, take } from 'rxjs/operators';
import { StorageService, ConfigService } from '@igo2/core';
import olFeature from 'ol/Feature';
import type { default as OlGeometry } from 'ol/geom/Geometry';
import { getGeoServiceAction } from './workspace.utils';
import { createFilterInMapExtentOrResolutionStrategy, createTableTemplate } from './workspace.utils';
@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -74,7 +65,7 @@ export class WfsWorkspaceService {
tableTemplate: undefined
}
});
this.createTableTemplate(wks, layer);
createTableTemplate(wks, layer, this.layerService, this.ws$);
return wks;
}

Expand Down Expand Up @@ -112,83 +103,7 @@ export class WfsWorkspaceService {
store.addStrategy(inMapResolutionStrategy, true);
store.addStrategy(selectionStrategy, true);
store.addStrategy(selectedRecordStrategy, false);
store.addStrategy(this.createFilterInMapExtentOrResolutionStrategy(), true);
store.addStrategy(createFilterInMapExtentOrResolutionStrategy(), true);
return store;
}

private createTableTemplate(workspace: WfsWorkspace, layer: VectorLayer): EntityTableTemplate {
const geoServiceAction = getGeoServiceAction(workspace, this.layerService);
const fields = layer.dataSource.options.sourceFields || [];

const relations = layer.dataSource.options.relations || [];

if (fields.length === 0) {
workspace.entityStore.entities$.pipe(
skipWhile(val => val.length === 0),
take(1)
).subscribe(entities => {
const ol = (entities[0] as Feature).ol as olFeature<OlGeometry>;
const columnsFromFeatures = ol.getKeys()
.filter(
col => !col.startsWith('_') &&
col !== 'geometry' &&
col !== ol.getGeometryName() &&
!col.match(/boundedby/gi))
.map(key => {
return {
name: `properties.${key}`,
title: key,
renderer: EntityTableColumnRenderer.UnsanitizedHTML
};
});
columnsFromFeatures.unshift(...geoServiceAction);
workspace.meta.tableTemplate = {
selection: true,
sort: true,
columns: columnsFromFeatures
};
});
return;
}
const columns = fields.map((field: SourceFieldsOptionsParams) => {
return {
name: `properties.${field.name}`,
title: field.alias ? field.alias : field.name,
renderer: EntityTableColumnRenderer.UnsanitizedHTML,
tooltip: field.tooltip
};
});

const relationsColumn = relations.map((relation: RelationOptions) => {
return {
name: `properties.${relation.name}`,
title: relation.alias ? relation.alias : relation.name,
renderer: EntityTableColumnRenderer.Icon,
icon: relation.icon,
parent: relation.parent,
type: 'relation',
tooltip: relation.tooltip,
onClick: () => {
this.ws$.next(relation.title);
},
cellClassFunc: () => {
return { 'class_icon': true };
}
};
});

columns.push(...relationsColumn);
columns.unshift(...geoServiceAction);
workspace.meta.tableTemplate = {
selection: true,
sort: true,
columns
};
}
private createFilterInMapExtentOrResolutionStrategy(): EntityStoreFilterCustomFuncStrategy {
const filterClauseFunc = (record: EntityRecord<object>) => {
return record.state.inMapExtent === true && record.state.inMapResolution === true;
};
return new EntityStoreFilterCustomFuncStrategy({filterClauseFunc} as EntityStoreStrategyFuncOptions);
}
}
Loading

0 comments on commit bc40e5c

Please sign in to comment.