Skip to content

Commit

Permalink
Merge branch 'develop' into r-01-reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhauck authored Nov 9, 2023
2 parents e6acb46 + de1ecf1 commit dbcb571
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 37 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

## [0.7.0] - Nov 9th 2023
* Start work for R01 2024 release

## [0.6.46] - Nov 1st 2023

## [0.6.45] - Oct 31st 2023
Expand Down Expand Up @@ -320,4 +323,5 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
[0.6.44]: https://github.com/Esri/solution.js/compare/v0.6.43...v0.6.44 "v0.6.44"
[0.6.45]: https://github.com/Esri/solution.js/compare/v0.6.44...v0.6.45 "v0.6.45"
[0.6.46]: https://github.com/Esri/solution.js/compare/v0.6.45...v0.6.46 "v0.6.46"
[Unreleased]: https://github.com/Esri/solution.js/compare/v0.6.46...HEAD "Unreleased Changes"
[0.7.0]: https://github.com/Esri/solution.js/compare/v0.6.46...v0.7.0 "v0.7.0"
[Unreleased]: https://github.com/Esri/solution.js/compare/v0.7.0...HEAD "Unreleased Changes"
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@esri/solutions-components",
"version": "0.6.46",
"version": "0.7.0",
"description": "Web Components for Esri's Solutions Applications",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
Expand Down
24 changes: 12 additions & 12 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ export namespace Components {
* string: The text that will display at the top of the landing page
*/
"loginTitle": string;
/**
* esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
*/
"mapView": __esri.MapView;
/**
* string: The word(s) to display in the reports submit button
*/
Expand All @@ -231,6 +227,10 @@ export namespace Components {
* boolean: When true the comments from all users will be visible
*/
"showComments": boolean;
/**
* esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
*/
"mapView": __esri.MapView;
}
interface DeductCalculator {
}
Expand Down Expand Up @@ -337,15 +337,15 @@ export namespace Components {
/**
* string: Global ID of the feature to select
*/
"defaultGlobalId": string;
"defaultGlobalId": string[];
/**
* string: when provided this layer ID will be used when the app loads
*/
"defaultLayerId": string;
/**
* number: when provided this will be used to select a feature in the table by default
*/
"defaultOid": number;
"defaultOid": number[];
/**
* boolean: when true the layer table will auto refresh the data
*/
Expand Down Expand Up @@ -1858,10 +1858,6 @@ declare namespace LocalJSX {
* string: The text that will display at the top of the landing page
*/
"loginTitle"?: string;
/**
* esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
*/
"mapView"?: __esri.MapView;
/**
* string: The word(s) to display in the reports submit button
*/
Expand All @@ -1882,6 +1878,10 @@ declare namespace LocalJSX {
* boolean: When true the comments from all users will be visible
*/
"showComments"?: boolean;
/**
* esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html
*/
"mapView"?: __esri.MapView;
}
interface DeductCalculator {
/**
Expand Down Expand Up @@ -1979,15 +1979,15 @@ declare namespace LocalJSX {
/**
* string: Global ID of the feature to select
*/
"defaultGlobalId"?: string;
"defaultGlobalId"?: string[];
/**
* string: when provided this layer ID will be used when the app loads
*/
"defaultLayerId"?: string;
/**
* number: when provided this will be used to select a feature in the table by default
*/
"defaultOid"?: number;
"defaultOid"?: number[];
/**
* boolean: when true the layer table will auto refresh the data
*/
Expand Down
32 changes: 30 additions & 2 deletions src/components/crowdsource-manager/crowdsource-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ export class CrowdsourceManager {
//
//--------------------------------------------------------------------------

/**
* string[]: List of global ids that should be selected by default
*/
protected _defaultGlobalId: string[];

/**
* number[]: List of ids that should be selected by default
*/
protected _defaultOid: number[];

/**
* IMapChange: The current map change details
*/
Expand All @@ -213,6 +223,24 @@ export class CrowdsourceManager {
//
//--------------------------------------------------------------------------

/**
* Watch for globalid url param to be set
*/
@Watch("defaultGlobalId")
defaultGlobalIdWatchHandler(): void {
this._defaultGlobalId = !this.defaultGlobalId ? undefined :
this.defaultGlobalId.indexOf(",") > -1 ? this.defaultGlobalId.split(",") : [this.defaultGlobalId];
}

/**
* Watch for oid url param to be set
*/
@Watch("defaultOid")
defaultOidWatchHandler(): void {
this._defaultOid = !this.defaultOid ? undefined :
this.defaultOid.indexOf(",") > -1 ? this.defaultOid.split(",").map(o => parseInt(o, 10)) : [parseInt(this.defaultOid, 10)];
}

/**
* When true the map zoom tools will be available
*/
Expand Down Expand Up @@ -631,9 +659,9 @@ export class CrowdsourceManager {
</calcite-action-bar>
<div class="width-full height-full position-relative">
<layer-table
defaultGlobalId={hasMapAndLayer ? this.defaultGlobalId : ""}
defaultGlobalId={hasMapAndLayer ? this._defaultGlobalId : undefined}
defaultLayerId={hasMapAndLayer ? this.defaultLayer : ""}
defaultOid={hasMapAndLayer && !this.defaultGlobalId ? parseInt(this.defaultOid, 10) : undefined}
defaultOid={hasMapAndLayer && !this.defaultGlobalId ? this._defaultOid : undefined}
enableAutoRefresh={this.enableAutoRefresh}
enableCSV={this.enableCSV}
enableInlineEdit={this.enableInlineEdit}
Expand Down
1 change: 0 additions & 1 deletion src/components/crowdsource-reporter/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
| `searchConfiguration` | -- | ISearchConfiguration: Configuration details for the Search widget | `ISearchConfiguration` | `undefined` |
| `showComments` | `show-comments` | boolean: When true the comments from all users will be visible | `boolean` | `undefined` |


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
28 changes: 15 additions & 13 deletions src/components/layer-table/layer-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export class LayerTable {
/**
* string: Global ID of the feature to select
*/
@Prop() defaultGlobalId: string;
@Prop() defaultGlobalId: string[];

/**
* number: when provided this will be used to select a feature in the table by default
*/
@Prop() defaultOid: number;
@Prop() defaultOid: number[];

/**
* boolean: when true the layer table will auto refresh the data
Expand Down Expand Up @@ -1118,15 +1118,17 @@ export class LayerTable {
this._table.highlightIds.removeAll();
this._table.clearSelectionFilter();

if (!this._defaultOidHonored && this.defaultOid > -1) {
if (!this._defaultOidHonored && this.defaultOid?.length > 0 && this.defaultOid[0] > -1) {
this._selectDefaultFeature(this.defaultOid);
this._defaultOidHonored = true
}

if (!this._defaultGlobalIdHonored && this.defaultGlobalId) {
if (!this._defaultGlobalIdHonored && this.defaultGlobalId?.length > 0) {
const features = await queryFeaturesByGlobalID(this.defaultGlobalId, this._layer);
const oid = features?.length > 0 ? features[0].getObjectId() : -1;
this._selectDefaultFeature(oid);
const oids = features?.length > 0 ? features.map(f => f.getObjectId()) : undefined;
if (oids) {
this._selectDefaultFeature(oids);
}
this._defaultGlobalIdHonored = true;
}
});
Expand All @@ -1142,14 +1144,14 @@ export class LayerTable {
* @returns void
*/
protected _selectDefaultFeature(
oid: number
oids: number[]
): void {
if (oid > -1) {
this._table.highlightIds.add(oid);
setTimeout(() => {
const i = this._table.viewModel.getObjectIdIndex(oid);
this._table.scrollToIndex(i);
}, 500);
if (oids.length > 0) {
this._table.highlightIds.addMany(oids);
void this._table.when(() => {
const i = this._table.viewModel.getObjectIdIndex(oids[0]);
this._table.viewModel.scrollToIndex(i);
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/layer-table/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

| Property | Attribute | Description | Type | Default |
| ------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------- | ----------- |
| `defaultGlobalId` | `default-global-id` | string: Global ID of the feature to select | `string` | `undefined` |
| `defaultGlobalId` | -- | string: Global ID of the feature to select | `string[]` | `undefined` |
| `defaultLayerId` | `default-layer-id` | string: when provided this layer ID will be used when the app loads | `string` | `undefined` |
| `defaultOid` | `default-oid` | number: when provided this will be used to select a feature in the table by default | `number` | `undefined` |
| `defaultOid` | -- | number: when provided this will be used to select a feature in the table by default | `number[]` | `undefined` |
| `enableAutoRefresh` | `enable-auto-refresh` | boolean: when true the layer table will auto refresh the data | `boolean` | `undefined` |
| `enableCSV` | `enable-c-s-v` | boolean: when true the export to csv button will be available | `boolean` | `undefined` |
| `enableInlineEdit` | `enable-inline-edit` | boolean: when true edits can be applied directly within the table | `boolean` | `undefined` |
Expand Down
6 changes: 3 additions & 3 deletions src/utils/queryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export async function queryFeaturesByID(
* @returns Promise with the featureSet from the layer that match the provided globalId
*/
export async function queryFeaturesByGlobalID(
globalId: string,
globalIds: string[],
layer: __esri.FeatureLayer
): Promise<__esri.Graphic[]> {
const globalIdField = (layer as any).globalIdField;
Expand All @@ -173,8 +173,8 @@ export async function queryFeaturesByGlobalID(

const q = layer.createQuery();
q.returnGeometry = false;
q.outFields = [layer.objectIdField]
q.where = `${globalIdField} = '${globalId}'`
q.outFields = [layer.objectIdField];
q.where = globalIds.map(g => `${globalIdField} = '${g}'`).join(" or ");

const result = await layer.queryFeatures(q);
return result.features;
Expand Down

0 comments on commit dbcb571

Please sign in to comment.