I have uploaded my recent version of my application on github: csergent45/streetSigns at 8b5b613676474eebed160981cb654b41107da459 · GitHub I also republished the application at Street Signs - If you try it, don't allow location as it will not show you the map because the data is for Decatur, Illinois.
Before I had an issue with my updates not being applied because I was not converting an ObjectId to a number, but I do that with both forms and neither will now update. Any ideas what I am doing wrong? :
The sign layer information on click:
var installed, signId, facing, visibility, condition, supportId, text, color1, delineator, illum, offset;
var mountht, backing, width, height, txtSize, numSize, comments, twoSided, attachType, attachNum, attachLoc, siteObs, signShape, color2, mutcd;
var objectId;
objectId = evt.graphic.attributes.OBJECTID;
mutcd = evt.graphic.attributes.MUTCD;
installed = evt.graphic.attributes.INSTALLED;
signId = evt.graphic.attributes.SIGNID;
facing = evt.graphic.attributes.FACING;
visibility = evt.graphic.attributes.VISIBILITY;
condition = evt.graphic.attributes.CONDITION_;
supportId = evt.graphic.attributes.SUPPORTID;
text = evt.graphic.attributes.TEXT;
color1 = evt.graphic.attributes.COLOR1;
delineator = evt.graphic.attributes.DELINEATOR;
illum = evt.graphic.attributes.ILLUM;
offset = evt.graphic.attributes.OFFSET;
mountht = evt.graphic.attributes.MOUNTHT;
backing = evt.graphic.attributes.BACKING;
width = evt.graphic.attributes.WIDTH;
height = evt.graphic.attributes.HEIGHT;
txtSize = evt.graphic.attributes.TXTSIZE;
numSize = evt.graphic.attributes.NUMSIZE;
comments = evt.graphic.attributes.COMMENTS;
twoSided = evt.graphic.attributes.TWOSIDED;
attachType = evt.graphic.attributes.ATTACHTYPE;
attachNum = evt.graphic.attributes.ATTACHNUM;
attachLoc = evt.graphic.attributes.ATTACHLOC;
siteObs = evt.graphic.attributes.SITEOBS;
signShape = evt.graphic.attributes.SIGNSHAPE;
color2 = evt.graphic.attributes.COLOR2;
// Clear form of values before connecting current values
document.getElementById("signForm").reset();
/* Enter your domain item and then the element to populate */
populateSelect("MUTCD", "mutcd", "sign");
populateSelect("VISIBILITY", "visibility", "sign");
populateSelect("CONDITION_", "condition", "sign");
populateSelect("COLOR1", "color1", "sign");
populateSelect("DELINEATOR", "delineator", "sign");
populateSelect("ILLUM", "illum", "sign");
populateSelect("BACKING", "backing", "sign");
populateSelect("ATTACHTYPE", "attachType", "sign");
populateSelect("ATTACHLOC", "attachLoc", "sign");
populateSelect("SITEOBS", "siteObs", "sign");
populateSelect("SIGNSHAPE", "signShape", "sign");
populateSelect("COLOR2", "color2", "sign");
/* Populate form with data */
document.getElementById("signObjectId").value = objectId;
document.getElementById("mutcd").value = mutcd;
document.getElementById("installed").value = installed;
document.getElementById("signId").value = signId;
document.getElementById("facing").value = facing;
document.getElementById("visibility").value = visibility;
document.getElementById("condition").value = condition;
document.getElementById("supportId").value = supportId;
document.getElementById("text").value = text;
document.getElementById("color1").value = color1;
document.getElementById("delineator").value = delineator;
document.getElementById("illum").value = illum;
document.getElementById("offset").value = offset;
document.getElementById("mountht").value = mountht;
document.getElementById("backing").value = backing;
document.getElementById("width").value = width;
document.getElementById("height").value = height;
document.getElementById("txtSize").value = txtSize;
document.getElementById("numSize").value = numSize;
document.getElementById("comments").value = comments;
document.getElementById("twoSided").value = twoSided;
document.getElementById("attachType").value = attachType;
document.getElementById("attachNum").value = attachNum;
document.getElementById("attachLoc").value = attachLoc;
document.getElementById("siteObs").value = siteObs;
document.getElementById("signShape").value = signShape;
document.getElementById("color2").value = color2;
document.getElementById("btnSignUpdate").style.visibility = "visible";
// Show signs form for updating
app.attributesSignModal.modal("show"); });
/* Update Sign Layer End */
The sign layer update:
// get sign attributes from form and submit
var updateSigns = function () {
// alert(domClass.contains("attributesSignModal", "in"));
var attributes = {
// TODO: not sure if this is needed
//requestreceived: null
};
var currentDate = new Date(); // current date is defined but never used.
var graphic;
graphic = new Graphic(app.currentGeometry);
query("#attributesSignModal input, #attributesSignModal select, #attributesSignModal textarea").forEach(function (formInput) {
attributes[formInput.name] = formInput.value;
});
// Form validation - ensures that the values for the data are here if left blank
if ((attributes.installed === undefined) || (attributes.installed === "")) {
attributes.installed = null;
}
if ((attributes.signId === undefined) || (attributes.signId === "")) {
attributes.signId = null;
}
if ((attributes.supportId === undefined) || (attributes.supportId === "")) {
attributes.supportId = null;
}
attributes.signObjectId = parseInt(attributes.signObjectId, 10);
graphic.setAttributes(attributes);
stopCaptureRequest();
console.log(attributes);
app.signLayer.applyEdits(null, [graphic], null).then(function (response) {
console.log(response);
});
app.signLayer.refresh();
};And here is the information for the support layer that was working before:
Support layer onClick:
/* Update Support Layer Begin */
app.supportLayer.on("click", function (evt) {
/* Get support information on click */
var objectId, supportId, type, address, size, material, base, rating, dateInv, inspector, comments, addrCode;
// declare rest endpoint values
objectId = evt.graphic.attributes.OBJECTID;
supportId = evt.graphic.attributes.SUPPORTID;
type = evt.graphic.attributes.TYPE;
address = evt.graphic.attributes.ADDRESS;
size = evt.graphic.attributes.SIZE_;
material = evt.graphic.attributes.MATERIAL;
base = evt.graphic.attributes.BASE;
rating = evt.graphic.attributes.RATING;
dateInv = evt.graphic.attributes.DATEINV;
inspector = evt.graphic.attributes.INSPECTOR;
comments = evt.graphic.attributes.COMMENTS;
addrCode = evt.graphic.attributes.ADDRCODE;
// Clear form of values before connecting current values
document.getElementById("supportForm").reset();
/* Enter your domain item and then the element to populate */
populateSelect("TYPE", "type", "support");
populateSelect("SIZE_", "size", "support");
populateSelect("MATERIAL", "material", "support");
populateSelect("BASE", "base", "support");
populateSelect("RATING", "rating", "support");
/* Populate form with data */
document.getElementById("objectId").value = objectId;
document.getElementById("address").value = address;
document.getElementById("supportId").value = supportId;
document.getElementById("type").value = type;
document.getElementById("size").value = size;
document.getElementById("material").value = material;
document.getElementById("base").value = base;
document.getElementById("rating").value = rating;
document.getElementById("dateInv").value = dateInv;
document.getElementById("inspector").value = inspector;
document.getElementById("comments").value = comments;
document.getElementById("addrCode").value = addrCode;
// Show supports form for updating
document.getElementById("btnSupportUpdate").style.visibility = "visible";
app.attributesModal.modal("show");
});
/* Update Support Layer End */Support layer update:
// get attributes from form and submit
var updateSupports = function () {
//alert(domClass.contains("attributesModal", "in"));
var attributes = {
// TODO: not sure if this is needed
//requestreceived: null
};
var currentDate = new Date(); // current date is defined but never used.
var graphic;
graphic = new Graphic(app.currentGeometry);
query("#attributesModal input, #attributesModal select, #attributesModal textarea").forEach(function (formInput) {
attributes[formInput.name] = formInput.value;
});
// Form Validation - ensures that the values for the database are here if left blank
if ((attributes.supportId === undefined) || (attributes.supportId === "")) {
attributes.supportId = null;
}
if ((attributes.dateInv === undefined) || (attributes.dateInv === "")) {
attributes.dateInv = null;
}
if ((attributes.addrCode === undefined) || (attributes.addrCode === "")) {
attributes.addrCode = null;
}
attributes.objectId = parseInt(attributes.objectId, 10);
graphic.setAttributes(attributes);
stopCaptureRequest();
//console.log(attributes);
app.supportLayer.applyEdits(null, [graphic], null).then(function (response) {
console.log(response);
});
app.supportLayer.refresh();
};