Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
driskull committed Sep 9, 2016
2 parents 76587c7 + 78f448a commit 9dc8df0
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 94 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The GeoForm template can be accessed via the ArcGIS template gallery or item det
3. Change the sharing host, found in defaults.js inside the config folder for the application, to the sharing URL for ArcGIS Online or Portal. For ArcGIS Online users, keep the default value of www.arcgis.com or specify the name of your organization.
- ArcGIS Online Example: `"sharinghost": location.protocol + "//" + “<your organization name>.maps.arcgis.com`
- Portal Example where `arcgis` is the name of the Web Adaptor: `"sharinghost": location.protocol + "//" + "webadaptor.domain.com/arcgis"`
4. If you are using Portal or a local install of the ArcGIS API for JavaScript, change all references to the ArcGIS API for JavaScript in index.html to refer to your local copy of the API. Search for the references containing `"//js.arcgis.com/3.17"` and replace this portion of the reference with the url to your local install.
4. If you are using Portal or a local install of the ArcGIS API for JavaScript, change all references to the ArcGIS API for JavaScript in index.html to refer to your local copy of the API. Search for the references containing `"//js.arcgis.com/3.18"` and replace this portion of the reference with the url to your local install.
- For example: `"//webadaptor.domain.com/arcgis/jsapi/jsapi"` where `arcgis` is the name of your Web Adaptor.
5. Copy a map or group ID from Portal/ArcGIS Online and replace the default web map ID in the application’s defaults.js file. You can now run the application on your web server or customize the application further.

Expand Down
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" type="text/css" href="js/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="js/vendor/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="//js.arcgis.com/3.17/esri/css/esri.css">
<link rel="stylesheet" type="text/css" href="//js.arcgis.com/3.17/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="//js.arcgis.com/3.18/esri/css/esri.css">
<link rel="stylesheet" type="text/css" href="//js.arcgis.com/3.18/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="js/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link id="rtlCSS" rel="stylesheet" />
<link href="js/vendor/select2/select2.min.css" rel="stylesheet" />
<link href="js/vendor/touch-spinner/jquery.bootstrap-touchspin.min.css" rel="stylesheet" type="text/css" />
<script src="js/vendor/jquery.min.js"></script>
<script src="js/vendor/moment-with-langs.min.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="js/vendor/html5shiv.min.js"></script>
Expand Down Expand Up @@ -72,7 +74,7 @@
dojoConfig.locale = RegExp.$1;
}
</script>
<script type="text/javascript" src="//js.arcgis.com/3.17"></script>
<script type="text/javascript" src="//js.arcgis.com/3.18"></script>
<script type="text/javascript" src="js/vendor/offline/offline.min.js"></script>
<script type="text/javascript" src="js/vendor/IndexedDBShim.min.js"></script>
<script type="text/javascript">
Expand Down
62 changes: 40 additions & 22 deletions js/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ define([
locationSearchOption: null,

constructor: function (config, response) {
this._layerIds = [];
this.config = config;
this.response = response;
this.onDemandResources = [
Expand Down Expand Up @@ -275,12 +276,13 @@ define([
//support for all layers in webmap
if (evt.currentTarget.value === "all") {
domStyle.set(dom.byId("layerSelectPane"), 'display', 'block');
array.forEach(dom.byId("layerSelect").options, lang.hitch(this, function (opt) {
this._populateFields(opt.value);
this._updateAppConfiguration("fields", opt.value);
this.previousValue = opt.value;
array.forEach(dom.byId("layerSelect").options, lang.hitch(this, function (opt, i) {
if(i === 0){
this._populateFields(opt.value);
this._updateAppConfiguration("fields", opt.value);
this.previousValue = opt.value;
}
}));
dom.byId("layerSelect")[dom.byId("layerSelect").options.length - 1].selected = true;
this.currentConfig.form_layer.id = "all";
$("#ShowHideLayerOption")[0].disabled = true;
} else if (evt.currentTarget.value !== "") {
Expand Down Expand Up @@ -312,9 +314,11 @@ define([
}));

on(dom.byId("layerSelect"), "change", lang.hitch(this, function (evt) {
this._updateAppConfiguration("fields", this.previousValue);
this._populateFields(evt.currentTarget.value);
this.previousValue = evt.currentTarget.value;
var value = evt.target.value;
this._updateAppConfiguration("fields", this._layerSelectValue);
this._populateFields(value);
this._layerSelectValue = value;
this.previousValue = value;
}));
on(dom.byId('selectAll'), "change", lang.hitch(this, function (evt) {
array.forEach(query(".fieldCheckbox"), lang.hitch(this, function (currentCheckBox) {
Expand Down Expand Up @@ -494,16 +498,17 @@ define([
} else {
if (isLoadRequired) {
if (dom.byId("selectLayer").options.length > 2) {
array.forEach(dom.byId("layerSelect").options, lang.hitch(this, function (opt) {
this._populateFields(opt.value);
this._updateAppConfiguration("fields", opt.value);
this.previousValue = opt.value;
array.forEach(dom.byId("layerSelect").options, lang.hitch(this, function (opt, i) {
if(i === 0){
this._populateFields(opt.value);
this._updateAppConfiguration("fields", opt.value);
this.previousValue = opt.value;
}
}));
dom.byId("selectLayer").options[dom.byId("selectLayer").length - 1].selected = true;
}
domAttr.set(dom.byId("selectLayer"), "disabled", false);
domStyle.set(dom.byId("layerSelectPane"), 'display', 'block');
dom.byId("layerSelect")[dom.byId("layerSelect").options.length - 1].selected = true;
this.currentConfig.form_layer.id = "all";
} else {
this.previousValue = this.currentConfig.form_layer.id;
Expand Down Expand Up @@ -1138,8 +1143,12 @@ define([
}));
if (this.currentConfig.form_layer.id == "all") {
domStyle.set(dom.byId("layerSelectPane"), "display", "block");
var counter = 0;
for (var key in this.fieldInfo) {
this._populateFields(key);
if( counter === 0){
this._populateFields(key);
counter++;
}
}
} else {
this._populateFields(this.currentConfig.form_layer.id);
Expand All @@ -1152,14 +1161,23 @@ define([
_validateFeatureServer: function (layer, canCreate, layerId) {
if (canCreate && layer.geometryType === 'esriGeometryPoint') {
var filteredLayer, fLayer;
filteredLayer = document.createElement("option");
fLayer = document.createElement("option");
filteredLayer.text = fLayer.text = layer.name;
filteredLayer.value = fLayer.value = layerId;
filteredLayer = domConstruct.create("option", {
textContent: layer.name,
value: layerId
});
fLayer = domConstruct.create("option", {
textContent: layer.name,
value: layerId
});
if(!this._layerSelectValue){
domAttr.set(filteredLayer, "selected", "selected");
domAttr.set(fLayer, "selected", "selected");
this._layerSelectValue = layerId;
}
this.previousValue = layerId;
dom.byId("selectLayer").appendChild(filteredLayer);
dom.byId("layerSelect").appendChild(fLayer);
fLayer.selected = true;
this.previousValue = layerId;
this._layerIds.push(layerId);
this.fieldInfo[layerId] = {};
this.fieldInfo[layerId].Fields = layer.fields;
this.fieldInfo[layerId].layerUrl = layer.url;
Expand Down Expand Up @@ -1276,7 +1294,7 @@ define([
this.currentConfig.viewSubmissionsText = dom.byId("viewSubmissionsText").value;
break;
case "fields":
if (layerObj !== "all") {
if(layerObj && layerObj !== "all") {
var innerObj = [];
var fieldName, fieldLabel, fieldDescription, visible, preventPast, preventFuture, setCurrentDate, hiddenDate;
this.currentSelectedLayer[layerObj] = dom.byId('geoFormFieldsTable');
Expand Down Expand Up @@ -1385,7 +1403,7 @@ define([
this._addProgressBar();
$("#myModal").modal('show');
arcgisUtils.getItem(this.currentConfig.appid).then(lang.hitch(this, function (response) {
var updateURL = this.userInfo.portal.url + "/sharing/rest/content/users/" + this.userInfo.username + (response.item.ownerFolder ? ("/" + response.item.ownerFolder) : "") + "/items/" + this.currentConfig.appid + "/update";
var updateURL = this.userInfo.portal.url + "/sharing/rest/content/users/" + response.item.owner + (response.item.ownerFolder ? ("/" + response.item.ownerFolder) : "") + "/items/" + this.currentConfig.appid + "/update";
esriRequest({
url: updateURL,
content: rqData,
Expand Down
6 changes: 4 additions & 2 deletions js/builder/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ define([

this._galleryTemplate = this._galleryTemplate ||
"<div class='itemGrid'>" +
"<img alt='' src='${thumbnailUrl:_formatThumbnail}'>" +
"<img alt='' src='${thumbnailUrl:_formatThumbnail}${token}'>" +
"<div class='truncate itemTitle'>${title:_formatTitle}</div>" +
"<span class='itemOwner'>${owner}</span>" +
"<p class='itemText snippet gridVisibility'>${snippet}</p>" +
"</div>";

this._detailsTemplate = this._detailsTemplate ||
"<div class='itemDetail'>" +
"<img alt='' src='${thumbnailUrl:_formatThumbnail}'>" +
"<img alt='' src='${thumbnailUrl:_formatThumbnail}${token}'>" +
"<p class='truncate itemTitle'>${title}</p>" +
"<span class='itemOwner'>${owner}</span>" +
"</p>" +
Expand All @@ -47,6 +47,7 @@ define([

this._renderers = lang.mixin(this._renderers || {}, {
gallery: lang.hitch(this, function (obj) {
obj.token = obj.thumbnailUrl && obj.thumbnailUrl.indexOf("?token") === -1 && this.query && this.query.token ? "?token=" + this.query.token : "";
obj.snippet = obj.snippet || "";
var div = put("div"),
node = new(declare([WidgetBase, TemplatedMixin, WidgetsInTemplateMixin], {
Expand All @@ -56,6 +57,7 @@ define([
return div;
}),
details: lang.hitch(this, function (obj) {
obj.token = obj.thumbnailUrl && obj.thumbnailUrl.indexOf("?token") === -1 && this.query && this.query.token ? "?token=" + this.query.token : "";
obj.snippet = obj.snippet || "";
var div = put("div"),
node = new(declare([WidgetBase, TemplatedMixin, WidgetsInTemplateMixin], {
Expand Down
13 changes: 1 addition & 12 deletions js/builder/signInHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,8 @@ define([
return this._portal;
},

getPortalUser: function () {
var esriCookie = cookie('esri_auth');
if (!esriCookie)
return;
esriCookie = JSON.parse(esriCookie.replace('"ssl":undefined', '"ssl":""'));
// Cookie has to be set on the same organization
if (esriCookie.urlKey && esriCookie.customBaseUrl && (esriCookie.urlKey + '.' + esriCookie.customBaseUrl).toLowerCase() != document.location.hostname.toLowerCase())
return;
return esriCookie ? esriCookie : null;
},

userIsAppOwner: function (itemData, userInfo) {
return (userInfo && itemData.item.owner == userInfo.username);
return (userInfo && (itemData.item.owner == userInfo.username || userInfo.role === "org_admin"));
},

reportError: function (error) {
Expand Down
65 changes: 47 additions & 18 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,19 @@ define([
var utmResults = [];
usng.LLtoUTM(lat, lng, utmResults);
if (utmResults && utmResults.length === 3) {
dom.byId('utm_easting').value = parseInt(utmResults[0]);
dom.byId('utm_northing').value = parseInt(utmResults[1]);
dom.byId('utm_zone_number').value = utmResults[2];
var northing = parseFloat(utmResults[1]);
var easting = parseFloat(utmResults[0]);
var zone = parseInt(utmResults[2], 10);
if(northing < 0){
zone += "S";
northing = Math.abs(northing);
}
else{
zone += "N";
}
dom.byId('utm_easting').value = easting;
dom.byId('utm_northing').value = northing;
dom.byId('utm_zone_number').value = zone;
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -502,7 +512,8 @@ define([
}));
return;
}
array.forEach(this._formLayer.fields, lang.hitch(this, function (layerField) {
array.forEach(this._formLayer.fields, lang.hitch(this, function (field) {
var layerField = lang.clone(field);
matchingField = false;
array.forEach(fields, lang.hitch(this, function (currentField) {
if (layerField.name == currentField.name && currentField.visible) {
Expand Down Expand Up @@ -550,7 +561,8 @@ define([
array.forEach(this.sortedFields, lang.hitch(this, function (currentField, index) {
//code to set true/false value to property 'isTypeDependent' of the field.
currentField.isTypeDependent = false;
array.forEach(this._formLayer.types, function (currentType) {
array.forEach(this._formLayer.types, function (type) {
var currentType = lang.clone(type);
var hasDomainValue = null,
hasDefaultValue = null;
hasDomainValue = currentType.domains[currentField.name];
Expand Down Expand Up @@ -742,7 +754,8 @@ define([
this._addToFileList(query(".hideFileInputUI")[0], fileBtnSpan, formContent, evt.currentTarget);
},
//function to create elements of form.
_createFormElements: function (currentField, index, referenceNode) {
_createFormElements: function (field, index, referenceNode) {
var currentField = lang.clone(field);
var radioContainer, fieldname, radioContent, inputContent, labelContent, fieldLabelText, selectOptions, inputLabel, radioInput, formContent, requireField, userFormNode,
checkboxContainer, checkboxContent, checkBoxCounter = 0,
helpBlock, rangeHelpText, inputGroupContainer;
Expand Down Expand Up @@ -1255,8 +1268,9 @@ define([
return true;
}
array.some(this._formLayer.fields, function (layerField) {
if (layerField.name === currentInput.name) {
field = lang.clone(lang.mixin(layerField, currentInput));
var lyrField = lang.clone(layerField);
if (lyrField.name === currentInput.name) {
field = lang.clone(lang.mixin(lyrField, currentInput));
return true;
}
});
Expand Down Expand Up @@ -1968,7 +1982,23 @@ define([
this._clearSubmissionGraphic();
var northing = parseFloat(dom.byId('utm_northing').value);
var easting = parseFloat(dom.byId('utm_easting').value);
var zone = parseInt(dom.byId('utm_zone_number').value, 10);

var zoneNode = dom.byId('utm_zone_number');
var zoneString = zoneNode.value;

var zoneLastChar = zoneString.substr(zoneString.length-1);

var zone = parseInt(zoneString, 10);

if(isNaN(zoneLastChar)){
if(zoneLastChar.toLowerCase() === "s"){
northing = -Math.abs(northing);
}
}
else{
northing = Math.abs(northing);
}

var converted = {};
try {
usng.UTMtoLL(northing, easting, zone, converted);
Expand Down Expand Up @@ -2165,7 +2195,7 @@ define([
featureData.attributes = {};
// start with layer defaults
if (this._formLayer.templates[0] && this._formLayer.templates[0].prototype.attributes) {
featureData.attributes = this._formLayer.templates[0].prototype.attributes;
featureData.attributes = lang.clone(this._formLayer.templates[0].prototype.attributes);
}
//condition to filter out radio inputs
array.forEach(query(".geoFormQuestionare .form-control"), function (currentField) {
Expand Down Expand Up @@ -2751,16 +2781,15 @@ define([
}
for (var key in this.config.locationSearchOptions) {
if (this.config.locationSearchOptions.hasOwnProperty(key) && key !== "enableMyLocation") {
if (!this.config.locationSearchOptions[key] && key !== "enableSearch") {
domStyle.set(locationTabs[count], 'display', 'none');
} else if (key === "enableSearch" && !this.config.locationSearchOptions[key] && !this.config.locationSearchOptions.enableMyLocation) {
domStyle.set(locationTabs[count], 'display', 'none');
} else {
//resize the map to set the correct info-window anchor
on(locationTabs[count], a11yclick, lang.hitch(this, this._resizeMap));
for(var i = 0; i < locationTabs.length; i++){
var tab = locationTabs[i];
var tabId = domAttr.get(tab, "data-tab-id");
if(tabId === key){
domStyle.set(tab, 'display', this.config.locationSearchOptions[key] ? "block" : "none");
}
on(tab, a11yclick, lang.hitch(this, this._resizeMap));
total++;
}
count++;
}
}
if (!this.config.locationSearchOptions.enableMyLocation) {
Expand Down
Loading

0 comments on commit 9dc8df0

Please sign in to comment.