Skip to content

Commit

Permalink
Crowdsource Reporter AGOL 5.4 Enhancements (Sprint 2/2)
Browse files Browse the repository at this point in the history
Resolved following github tickets :
• Esri#226 : add basemap widget
• Esri#229 : add legend widget
• Esri#310 : App doesn't display features symbolized using an Arcade
expression
• Esri#326 : CSS issue when report has no title
  • Loading branch information
CTLocalGovTeam committed Nov 3, 2017
1 parent 792fe41 commit e19ff31
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 41 deletions.
2 changes: 2 additions & 0 deletions config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ define({
"locationField": "LONG_TEXT",
"showMapFirst":"list",
"showHelpOnLoad": false,
"showBaseMapGallery": false,
"showLegend": false,
"basemapGroup":"",

//Sort report configuration
Expand Down
111 changes: 77 additions & 34 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ define([

//Force the proxy for specified prefixes
if (this.config.proxyThesePrefixes && this.config.proxyThesePrefixes.length > 0 &&
this.config.proxyurl) {
this.config.proxyurl) {
array.forEach(this.config.proxyThesePrefixes, function (prefix) {
urlUtils.addProxyRule({
urlPrefix: prefix,
Expand Down Expand Up @@ -694,7 +694,7 @@ define([
var updatedFeatureTitle;
updatedFeatureTitle = this._issueWallWidget.itemsList.getItemTitle(updatedFeature);
domAttr.set(this._itemDetails.itemTitleDiv, "innerHTML", updatedFeatureTitle);
//If the updated issue is present in my issues list then update it accrodingly
//If the updated issue is present in my issues list then update it accordingly
if (this._myIssuesWidget && this._myIssuesWidget.itemsList && this.config.logInDetails && updatedFeature.attributes[this.config.reportedByField] && updatedFeature.attributes[this.config.reportedByField] === this.config.logInDetails.processedUserName) {
this._myIssuesWidget.updateIssueList(this._selectedMapDetails, updatedFeature);
}
Expand Down Expand Up @@ -1702,6 +1702,7 @@ define([
}
esriQuery = new Query();
esriQuery.objectIds = [parseInt(objectId, 10)];
esriQuery.outFields = ["*"];
esriQuery.where = currentDateTime + "=" + currentDateTime;
esriQuery.returnGeometry = true;
esriQuery.outSpatialReference = this.map.spatialReference;
Expand Down Expand Up @@ -1748,7 +1749,8 @@ define([
* @param{object} details of selected layer
*/
_getPointSymbol: function (graphic, layer) {
var symbol, isSymbolFound, graphics, point, graphicInfoValue, layerInfoValue, i, itemFromLayer, symbolShape;
var symbol, isSymbolFound, graphics, point, graphicInfoValue, layerInfoValue, i, itemFromLayer, symbolShape,
symbolDetails, sizeInfo, arcSymbolSize;
isSymbolFound = false;
symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, null, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 255, 255, 1]), 3));
symbol.setColor(null);
Expand Down Expand Up @@ -1783,27 +1785,41 @@ define([
}
}
layer = this.mapInstance.getLayer(layer.id);
if (!isSymbolFound && layer && layer.graphics && layer.graphics.length > 0) {
if (layer && layer.graphics && layer.graphics.length > 0) {
array.some(layer.graphics, function (item) {
if (item.attributes[graphic._layer.objectIdField] === graphic.attributes[graphic._layer.objectIdField]) {
if (item.attributes[layer.objectIdField] === graphic.attributes[layer.objectIdField]) {
itemFromLayer = item;
return item;
}
});
if (itemFromLayer.getShape) {
if (this.selectedLayer._getSymbol(itemFromLayer)) {
symbolShape = itemFromLayer.getShape();
if (symbolShape && symbolShape.shape) {
if (symbolShape.shape.hasOwnProperty("r")) {
isSymbolFound = true;
symbol.size = (symbolShape.shape.r * 2) + 10;
} else if (symbolShape.shape.hasOwnProperty("width")) {
isSymbolFound = true;
//get offsets in case of smartmapping symbols from the renderer info if available
//get offsets in case of smart mapping symbols from the renderer info if available
if (layer.renderer && layer.renderer.infos && layer.renderer.infos.length > 0) {
symbol = this._updatePointSymbolProperties(symbol, layer.renderer.infos[0].symbol);
}
symbol.size = symbolShape.shape.width + 10;
}
//handle arcade expressions, take max size of symbol
} else if (layer.renderer.visualVariables) {
symbolDetails = layer._getRenderer(itemFromLayer);
sizeInfo = this._getSizeInfo();
if (sizeInfo) {
arcSymbolSize = symbolDetails.getSize(itemFromLayer, {
sizeInfo: sizeInfo,
shape: this.selectedLayer._getSymbol(itemFromLayer),
resolution: layer && layer.getResolutionInMeters && layer.getResolutionInMeters()
});
if (arcSymbolSize !== null) {
symbol.size = arcSymbolSize + 10;
}
}
}
}
}
Expand All @@ -1814,6 +1830,24 @@ define([
return graphics;
},

/**
* This function is used to get symbol size
*/
_getSizeInfo: function () {
var draw;
if (this.selectedLayer.renderer.visualVariables) {
array.forEach(this.selectedLayer.renderer.visualVariables, lang.hitch(this, function (drawInfo) {
if (drawInfo.type === "sizeInfo") {
draw = drawInfo;
}
}));
} else {
draw = null;
}
return draw;
},


/**
* This function is used to get different data of symbol from infos properties of renderer object.
* @param{object} symbol that needs to be assigned to selected/activated feature
Expand Down Expand Up @@ -2122,6 +2156,8 @@ define([
//Set minimum and maximum scale to layer if exist
this.displaygraphicsLayer.setMaxScale(maxScale);
this.displaygraphicsLayer.setMinScale(minScale);
this.displaygraphicsLayer._layer = this.selectedLayer;
this.displaygraphicsLayer.fields = this.selectedLayer.fields;
this.map.addLayer(this.displaygraphicsLayer, this._existingLayerIndex);
this._getFeatureLayerCount(details, selectedOperationalLayer);
this._reorderAllLayers();
Expand Down Expand Up @@ -2530,34 +2566,37 @@ define([
//Create basemap widget on every layer/webmap change
this.legend = null;
this.basemapGallery = null;
if (!this.basemapGallery) {
basemapG = this._createOnScreenWidgetPanel("Basemap");
basemapGalleryButtonDiv = domConstruct.create("div", {
"class": "esriCTMapNavigationButton esriCTBasemapGalleryButton"
if (this.config.showBaseMapGallery) {
if (!this.basemapGallery) {
basemapG = this._createOnScreenWidgetPanel("Basemap");
basemapGalleryButtonDiv = domConstruct.create("div", {
"class": "esriCTMapNavigationButton esriCTBasemapGalleryButton"
});
on(basemapGalleryButtonDiv, "click", lang.hitch(this, function (event) {
event.stopPropagation();
if (!this.basemapGallery) {
this._fetchBasemapGalleryGroup().then(lang.hitch(this, function (id) {
this._createBasemapGallery(basemapG, id);
}));
}
this._showPanel("Basemap");
}));
}
}

if (this.config.showLegend) {
legendButtonDiv = domConstruct.create("div", {
"class": "esriCTMapNavigationButton esriCTLegendButton"
});
on(basemapGalleryButtonDiv, "click", lang.hitch(this, function (event) {
legend = this._createOnScreenWidgetPanel("Legend");
on(legendButtonDiv, "click", lang.hitch(this, function (event) {
event.stopPropagation();
if (!this.basemapGallery) {
this._fetchBasemapGalleryGroup().then(lang.hitch(this, function (id) {
this._createBasemapGallery(basemapG, id);
}));
if (!this.legend) {
this._createLegend(legend);
}
this._showPanel("Basemap");
this._showPanel("Legend");
}));
}

legendButtonDiv = domConstruct.create("div", {
"class": "esriCTMapNavigationButton esriCTLegendButton"
});
legend = this._createOnScreenWidgetPanel("Legend");
on(legendButtonDiv, "click", lang.hitch(this, function (event) {
event.stopPropagation();
if (!this.legend) {
this._createLegend(legend);
}
this._showPanel("Legend");
}));

incrementButton = query(".esriSimpleSliderIncrementButton", dom.byId("mapDiv"));
domConstruct.empty(incrementButton[0]);
domClass.add(incrementButton[0], "esriCTIncrementButton esriCTPointerCursor");
Expand All @@ -2566,11 +2605,15 @@ define([
domClass.add(decrementButton[0], "esriCTDecrementButton esriCTPointerCursor");
domConstruct.place(homeButtonDiv, query(".esriSimpleSliderIncrementButton", dom.byId("mapDiv"))[0], "after");
domConstruct.place(geoLocationButtonDiv, query(".esriSimpleSliderDecrementButton", dom.byId("mapDiv"))[0], "after");
domConstruct.place(basemapGalleryButtonDiv, geoLocationButtonDiv, "after");
this.appUtils.createBasemapGalleryButton(basemapGalleryButtonDiv);
domConstruct.place(legendButtonDiv, geoLocationButtonDiv, "after");
if (basemapGalleryButtonDiv) {
domConstruct.place(basemapGalleryButtonDiv, geoLocationButtonDiv, "after");
this.appUtils.createBasemapGalleryButton(basemapGalleryButtonDiv);
}
if (legendButtonDiv) {
domConstruct.place(legendButtonDiv, geoLocationButtonDiv, "after");
this.appUtils.createLegendButton(legendButtonDiv);
}
this.appUtils.createGeoLocationButton(details.itemInfo.itemData.baseMap.baseMapLayers, this._selectedMapDetails.map, geoLocationButtonDiv, false);
this.appUtils.createLegendButton(legendButtonDiv);
this.appUtils.createHomeButton(this._selectedMapDetails.map, homeButtonDiv);
this.mapSearch.createSearchButton(this.response, this.response.map, dom.byId("mapDiv"), false, details);
this.basemapExtent = this.appUtils.getBasemapExtent(details.itemInfo.itemData.baseMap.baseMapLayers);
Expand Down
2 changes: 1 addition & 1 deletion js/widgets/item-list/item-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ define([
titleNode = dojoQuery(".esriCTItemTitle", currentNode[0])[0];
}
if (titleNode) {
titleNode.innerHTML = this.getItemTitle(item);
titleNode.innerHTML = this.getItemTitle(item) || " ";
}
}
},
Expand Down
32 changes: 26 additions & 6 deletions resources/configuration-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"webMapInfoAvgRating": false,
"showNonEditableLayers": false,
"showPopupForNonEditableLayers": false,
"showBaseMapGallery": false,
"showLegend": false,
"submitMessage": "Thank you. Your report has been submitted.",
"likeField": "NUMVOTES",
"commentField": "COMMENTS",
Expand Down Expand Up @@ -84,11 +86,6 @@
"label": "Select a group",
"tooltip": "Group displayed in the application",
"type": "group"
}, {
"label": "Select basemap group",
"tooltip": "Group displayed in the base map gallery",
"type": "basemapgroup",
"fieldName": "basemapGroup"
}, {
"label": "Application title",
"tooltip": "Title should be shorter than approximately 34 characters to fit on mobile devices.",
Expand All @@ -106,11 +103,34 @@
"type": "string",
"fieldName": "noWebmapInGroupText"
}, {
"type": "subcategory",
"label": "Basemap and Legend settings"
}, {
"type": "paragraph",
"value": "User can enable/disable basemap gallery and legend."
}, {
"label": "Show basemap gallery",
"tooltip": "When disabled, basemap gallery button will not be displayed in map navigation buttons",
"type": "conditional",
"condition": false,
"fieldName": "showBaseMapGallery",
"items" : [{
"label": "Select basemap group",
"tooltip": "Group displayed in the base map gallery",
"type": "basemapgroup",
"fieldName": "basemapGroup"
}]
}, {
"label": "Show Legend",
"tooltip": "When disabled, legend button will not be displayed in map navigation buttons",
"type": "boolean",
"fieldName": "showLegend"
},{
"type": "subcategory",
"label": "Help"
}, {
"type": "paragraph",
"value": "A help window can be accessed from a link on the spash page and from an icon within the app. Configure this dialog to display instructions for using the app, or any other information that may be useful to your users."
"value": "A help window can be accessed from a link on the splash page and from an icon within the app. Configure this dialog to display instructions for using the app, or any other information that may be useful to your users."
}, {
"label": "Enable the help window",
"tooltip": "When disabled, the help window will not be accessible.",
Expand Down

0 comments on commit e19ff31

Please sign in to comment.