diff --git a/src/components.d.ts b/src/components.d.ts index 2341ea0f9..a066aaf63 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -241,6 +241,10 @@ export namespace Components { * boolean: when true the zoom widget will be available */ "enableZoom": boolean; + /** + * boolean: When true the application will be in mobile mode, controls the mobile or desktop view + */ + "isMobile": boolean; /** * string[]: list of layer ids */ @@ -253,6 +257,10 @@ export namespace Components { * IMapInfo[]: array of map infos (name and id) */ "mapInfos": IMapInfo[]; + /** + * 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 */ @@ -2206,6 +2214,10 @@ declare namespace LocalJSX { * boolean: when true the zoom widget will be available */ "enableZoom"?: boolean; + /** + * boolean: When true the application will be in mobile mode, controls the mobile or desktop view + */ + "isMobile"?: boolean; /** * string[]: list of layer ids */ @@ -2218,6 +2230,10 @@ declare namespace LocalJSX { * IMapInfo[]: array of map infos (name and id) */ "mapInfos"?: IMapInfo[]; + /** + * 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 */ diff --git a/src/components/crowdsource-reporter/crowdsource-reporter.css b/src/components/crowdsource-reporter/crowdsource-reporter.css index 72e3a2463..bce60a699 100644 --- a/src/components/crowdsource-reporter/crowdsource-reporter.css +++ b/src/components/crowdsource-reporter/crowdsource-reporter.css @@ -21,7 +21,7 @@ } .width-full { - width: 100%; + width: 100% !important; } .width-0 { @@ -29,7 +29,7 @@ } .height-full { - height: 100%; + height: 100% !important; } .height-0 { @@ -64,29 +64,7 @@ padding: 10px; } -@media screen and (max-width: 600px) { - .map-container { - left: 0; - height: 50%; - width: 100%; - } - - .map-container-mobile { - height: calc(100% - 100px); - } - - .side-panel { - padding: 2px; - width: 100%; - height: 50%; - position: absolute; - top: 50%; - left: 0; - z-index: 60; - } - - .collapsed-side-panel { - top: calc(100% - 100px); - height: 100px; - } +.collapsed-side-panel { + top: calc(100% - 55px); + height: 54px; } diff --git a/src/components/crowdsource-reporter/crowdsource-reporter.tsx b/src/components/crowdsource-reporter/crowdsource-reporter.tsx index 03d242032..eff4b6d78 100644 --- a/src/components/crowdsource-reporter/crowdsource-reporter.tsx +++ b/src/components/crowdsource-reporter/crowdsource-reporter.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component, Element, Host, h, Prop, VNode, State, Listen } from "@stencil/core"; +import { Component, Element, Host, h, Prop, VNode, State, Watch } from "@stencil/core"; import { IMapChange, IMapInfo, ISearchConfiguration, theme } from "../../utils/interfaces"; import { getLocaleComponentStrings } from "../../utils/locale"; import CrowdsourceReporter_T9n from "../../assets/t9n/crowdsource-reporter/resources.json"; @@ -44,6 +44,11 @@ export class CrowdsourceReporter { */ @Prop() description: string; + /** + * boolean: When true the application will be in mobile mode, controls the mobile or desktop view + */ + @Prop() isMobile: boolean; + /** * boolean: When true the anonymous users will be allowed to submit reports and comments */ @@ -79,6 +84,11 @@ export class CrowdsourceReporter { */ @Prop() loginTitle: string; + /** + * esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html + */ + @Prop() mapView: __esri.MapView; + /** * string: The word(s) to display in the reports submit button */ @@ -145,16 +155,6 @@ export class CrowdsourceReporter { */ @State() _mapInfo: IMapInfo; - /** - * __esri.MapView: Stores the current map view - */ - @State() _mapView: __esri.MapView; - - /** - * boolean: When true the application will be in mobile mode, controls the mobile or desktop view - */ - @State() _isMobile = false; - /** * string[]: Reporter flow items list */ @@ -217,6 +217,26 @@ export class CrowdsourceReporter { // //-------------------------------------------------------------------------- + /** + * Called each time the mapView prop is changed. + */ + @Watch("isMobile") + async isMobileWatchHandler(): Promise { + if (this.isMobile) { + this._sidePanelCollapsed = false; + } + } + + /** + * Called each time the mapView prop is changed. + */ + @Watch("mapView") + async mapViewWatchHandler(): Promise { + await this.mapView.when(async () => { + await this.setMapView(); + }); + } + //-------------------------------------------------------------------------- // // Methods (public) @@ -229,18 +249,6 @@ export class CrowdsourceReporter { // //-------------------------------------------------------------------------- - /** - * Listen for mapChanged event to be fired then store the new mapView so components will be updated - */ - @Listen("mapChanged", { target: "window" }) - async mapChanged( - evt: CustomEvent - ): Promise { - this._mapChange = evt.detail; - await this._mapChange.mapView.when(async () => { - await this.setMapView(); - }); - } //-------------------------------------------------------------------------- // // Functions (lifecycle) @@ -254,39 +262,18 @@ export class CrowdsourceReporter { */ async componentWillLoad(): Promise { await this._getTranslations(); - const mediaQueryList = window.matchMedia("screen and (max-width: 600px)"); - this._isMobile = mediaQueryList.matches; - //on change update the state for is mobile and the sidePanelCollapsed - mediaQueryList.onchange = (e) => { - this._isMobile = e.matches; - this._sidePanelCollapsed = false; - } } /** * Renders the component. */ render() { - let validConfiguration = true; - //Check if webMap id is configured - if(!this.mapInfos || this.mapInfos.length<=0 || (this.mapInfos?.length>0 && !this.mapInfos[0]?.id)){ - validConfiguration = false - } return (
- {validConfiguration && - - {this._getReporter()} - {this._getMapNode()} - - } - {!validConfiguration && - -
{this._translations.error}
-
{ this._translations.invalidConfigurationErrorMsg}
-
- } + + {this._getReporter()} +
); @@ -315,18 +302,18 @@ export class CrowdsourceReporter { case "feature-details": renderLists.push(this.getFeatureDetailsFlowItem()); break; - + } }); let sidePanelClass = "side-panel"; //in case of mobile handle for collapsed styles of the panel - if (this._isMobile && this._sidePanelCollapsed) { + if (this.isMobile && this._sidePanelCollapsed) { sidePanelClass += " collapsed-side-panel"; } const themeClass = this.theme === "dark" ? "calcite-mode-dark" : "calcite-mode-light"; return ( - - {this._mapView + + {this.mapView ? {renderLists?.length > 0 && renderLists} @@ -342,19 +329,19 @@ export class CrowdsourceReporter { */ protected getLayerListFlowItem(): Node { return ( - - {this._hasValidLayers && } - {this._hasValidLayers && } - {this._isMobile && this.getActionToExpandCollapsePanel()} + + {this._hasValidLayers && } + {this._hasValidLayers && } + {this.isMobile && this.getActionToExpandCollapsePanel()} {this._hasValidLayers && this.enableNewReports && {this.reportButtonText} } @@ -417,19 +404,19 @@ export class CrowdsourceReporter { */ protected getFeatureListFlowItem(layerId: string, layerName: string): Node { return ( - - - - {this._isMobile && this.getActionToExpandCollapsePanel()} + + + + {this.isMobile && this.getActionToExpandCollapsePanel()} {this.enableNewReports && {this.reportButtonText} } { - {this._isMobile && this.getActionToExpandCollapsePanel()} + + {this.isMobile && this.getActionToExpandCollapsePanel()} @@ -472,76 +459,14 @@ export class CrowdsourceReporter { ); } - /** - * Get the map node based for the current layout options - * @returns the map node - * @protected - */ - protected _getMapNode(): VNode { - let mapContainerClass = "overflow-hidden map-container"; - if (this._isMobile) { - if (this._sidePanelCollapsed) { - mapContainerClass += " map-container-mobile"; - } - } else { - mapContainerClass += " height-full"; - } - - return ( -
-
); - } - - /** - * Get the current map info (configuration details) when maps change - * @param id Id of the map to be returned - * @returns IMapInfo for the provided id - * @protected - */ - protected getMapInfo(id: string): IMapInfo { - let mapInfo: IMapInfo; - this.mapInfos.some(mi => { - if (mi.id === id) { - mapInfo = mi; - return true; - } - }) - return { ...mapInfo }; - } - /** * Set the current map info when maps change * @protected */ protected async setMapView(): Promise { - this._mapInfo = this.getMapInfo(this._mapChange.id); - this._mapView = this._mapChange.mapView; - this.initMapZoom(); - this._mapView.popupEnabled = false; + this.mapView.popupEnabled = false; if (this._defaultCenter && this._defaultLevel) { - await this._mapView.goTo({ + await this.mapView.goTo({ center: this._defaultCenter, zoom: this._defaultLevel }); @@ -550,22 +475,6 @@ export class CrowdsourceReporter { } } - /** - * Add/remove zoom tools based on enableZoom prop - * @protected - */ - protected initMapZoom(): void { - if (!this.enableZoom) { - this._mapView.ui.remove("zoom"); - } else if (this.enableZoom) { - this._mapView.ui.add({ - component: "zoom", - position: "top-left", - index: 0 - }); - } - } - /** * Fetches the component's translations * @returns Promise when complete diff --git a/src/components/crowdsource-reporter/readme.md b/src/components/crowdsource-reporter/readme.md index ad50893ce..2964d784f 100644 --- a/src/components/crowdsource-reporter/readme.md +++ b/src/components/crowdsource-reporter/readme.md @@ -7,27 +7,29 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ------------------------- | --------------------------- | ------------------------------------------------------------------------------------- | ---------------------- | ----------- | -| `defaultWebmap` | `default-webmap` | string: Item ID of the web map that should be selected by default | `string` | `""` | -| `description` | `description` | string: The text that will display under the title on the landing page | `string` | `undefined` | -| `enableAnonymousAccess` | `enable-anonymous-access` | boolean: When true the anonymous users will be allowed to submit reports and comments | `boolean` | `undefined` | -| `enableAnonymousComments` | `enable-anonymous-comments` | boolean: When true the anonymous users will be allowed to submit comments | `boolean` | `undefined` | -| `enableComments` | `enable-comments` | boolean: When true the user will be allowed to submit comments | `boolean` | `undefined` | -| `enableHome` | `enable-home` | boolean: when true the home widget will be available | `boolean` | `true` | -| `enableLogin` | `enable-login` | boolean: When true the user will be provided a login page | `boolean` | `undefined` | -| `enableNewReports` | `enable-new-reports` | boolean: When true the user will be allowed to submit new reports | `boolean` | `undefined` | -| `enableSearch` | `enable-search` | boolean: when true the search widget will be available | `boolean` | `true` | -| `enableZoom` | `enable-zoom` | boolean: when true the zoom widget will be available | `boolean` | `true` | -| `layers` | -- | string[]: list of layer ids | `string[]` | `undefined` | -| `loginTitle` | `login-title` | string: The text that will display at the top of the landing page | `string` | `undefined` | -| `mapInfos` | -- | IMapInfo[]: array of map infos (name and id) | `IMapInfo[]` | `[]` | -| `reportButtonText` | `report-button-text` | string: The word(s) to display in the reports submit button | `string` | `undefined` | -| `reportSubmittedMessage` | `report-submitted-message` | string: The message to display when the report has been submitted | `string` | `undefined` | -| `reportsHeader` | `reports-header` | string: The word(s) to display in the reports header | `string` | `undefined` | -| `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` | -| `theme` | `theme` | theme: "light" \| "dark" theme to be used | `"dark" \| "light"` | `"light"` | +| Property | Attribute | Description | Type | Default | +| ------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------- | ----------- | +| `defaultWebmap` | `default-webmap` | string: Item ID of the web map that should be selected by default | `string` | `""` | +| `description` | `description` | string: The text that will display under the title on the landing page | `string` | `undefined` | +| `enableAnonymousAccess` | `enable-anonymous-access` | boolean: When true the anonymous users will be allowed to submit reports and comments | `boolean` | `undefined` | +| `enableAnonymousComments` | `enable-anonymous-comments` | boolean: When true the anonymous users will be allowed to submit comments | `boolean` | `undefined` | +| `enableComments` | `enable-comments` | boolean: When true the user will be allowed to submit comments | `boolean` | `undefined` | +| `enableHome` | `enable-home` | boolean: when true the home widget will be available | `boolean` | `true` | +| `enableLogin` | `enable-login` | boolean: When true the user will be provided a login page | `boolean` | `undefined` | +| `enableNewReports` | `enable-new-reports` | boolean: When true the user will be allowed to submit new reports | `boolean` | `undefined` | +| `enableSearch` | `enable-search` | boolean: when true the search widget will be available | `boolean` | `true` | +| `enableZoom` | `enable-zoom` | boolean: when true the zoom widget will be available | `boolean` | `true` | +| `isMobile` | `is-mobile` | boolean: When true the application will be in mobile mode, controls the mobile or desktop view | `boolean` | `undefined` | +| `layers` | -- | string[]: list of layer ids | `string[]` | `undefined` | +| `loginTitle` | `login-title` | string: The text that will display at the top of the landing page | `string` | `undefined` | +| `mapInfos` | -- | IMapInfo[]: array of map infos (name and id) | `IMapInfo[]` | `[]` | +| `mapView` | -- | esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html | `MapView` | `undefined` | +| `reportButtonText` | `report-button-text` | string: The word(s) to display in the reports submit button | `string` | `undefined` | +| `reportSubmittedMessage` | `report-submitted-message` | string: The message to display when the report has been submitted | `string` | `undefined` | +| `reportsHeader` | `reports-header` | string: The word(s) to display in the reports header | `string` | `undefined` | +| `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` | +| `theme` | `theme` | theme: "light" \| "dark" theme to be used | `"dark" \| "light"` | `"light"` | ## Dependencies @@ -35,7 +37,6 @@ ### Depends on - calcite-shell -- calcite-notice - calcite-panel - calcite-flow - calcite-loader @@ -45,13 +46,11 @@ - [layer-list](../layer-list) - [feature-list](../feature-list) - [info-card](../info-card) -- [map-card](../map-card) ### Graph ```mermaid graph TD; crowdsource-reporter --> calcite-shell - crowdsource-reporter --> calcite-notice crowdsource-reporter --> calcite-panel crowdsource-reporter --> calcite-flow crowdsource-reporter --> calcite-loader @@ -61,8 +60,6 @@ graph TD; crowdsource-reporter --> layer-list crowdsource-reporter --> feature-list crowdsource-reporter --> info-card - crowdsource-reporter --> map-card - calcite-notice --> calcite-icon calcite-panel --> calcite-action calcite-panel --> calcite-action-menu calcite-panel --> calcite-scrim @@ -82,6 +79,7 @@ graph TD; layer-list --> calcite-list layer-list --> calcite-list-item layer-list --> calcite-icon + calcite-notice --> calcite-icon calcite-list --> calcite-scrim calcite-list --> calcite-stack calcite-list --> calcite-filter @@ -119,24 +117,6 @@ graph TD; calcite-alert --> calcite-icon calcite-alert --> calcite-chip calcite-chip --> calcite-icon - map-card --> map-picker - map-card --> map-tools - map-picker --> calcite-button - map-picker --> calcite-tooltip - map-picker --> calcite-action-bar - map-picker --> calcite-list - map-picker --> calcite-list-item - calcite-action-bar --> calcite-action-group - calcite-action-group --> calcite-action-menu - calcite-action-group --> calcite-action - map-tools --> basemap-gallery - map-tools --> map-search - map-tools --> map-legend - map-tools --> map-fullscreen - map-tools --> floor-filter - map-tools --> calcite-action - map-tools --> calcite-icon - map-tools --> calcite-tooltip style crowdsource-reporter fill:#f9f,stroke:#333,stroke-width:4px ``` diff --git a/src/components/map-card/readme.md b/src/components/map-card/readme.md index 97fda650d..02af7cb89 100644 --- a/src/components/map-card/readme.md +++ b/src/components/map-card/readme.md @@ -45,7 +45,6 @@ ### Used by - [crowdsource-manager](../crowdsource-manager) - - [crowdsource-reporter](../crowdsource-reporter) ### Depends on @@ -93,7 +92,6 @@ graph TD; map-tools --> calcite-icon map-tools --> calcite-tooltip crowdsource-manager --> map-card - crowdsource-reporter --> map-card style map-card fill:#f9f,stroke:#333,stroke-width:4px ``` diff --git a/src/demos/crowdsource-reporter.html b/src/demos/crowdsource-reporter.html index 1afa7d54c..c2eb4fc8c 100644 --- a/src/demos/crowdsource-reporter.html +++ b/src/demos/crowdsource-reporter.html @@ -22,9 +22,34 @@ | limitations under the License. --> @@ -37,64 +62,90 @@ - - + +
+