Skip to content

Commit

Permalink
fix tag updates when copying Feature Services
Browse files Browse the repository at this point in the history
The parsing method was trying to analyze the stringified JSON instead of
the parsed JSON.
  • Loading branch information
ecaldwell committed Dec 15, 2016
1 parent 856f2a3 commit d1199de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,10 +1077,10 @@ require([

// Update the new item's tags to make it easier to trace its origins.
var newTags = description.tags;
newTags.push("source-" + description.id);
destinationPortal.updateDescription(destinationPortal.username, service.itemId, folder, JSON.stringify({
tags: newTags
}));
newTags.push("sourceId-" + description.id);
newTags.push("copied with ago-assistant");
destinationPortal.updateDescription(destinationPortal.username, service.itemId, folder, JSON.stringify({tags: newTags}));

portal.serviceLayers(description.url)
.then(function(definition) {
var layerCount = definition.layers.length;
Expand Down
9 changes: 5 additions & 4 deletions src/js/portal/content/updateDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export function updateDescription(username, id, folder, description) {
* This is necessary because some of the item descriptions (e.g. tags and extent)
* are returned as arrays, but the POST operation expects comma separated strings.
*/
for (let [key, value] of description) {
let payload = JSON.parse(description);
for (let key of Object.keys(payload)) {
let value = payload[key];
if (value === null) {
description[key] = "";
payload[key] = "";
} else if (value instanceof Array) {
description[key] = value.toString();
payload[key] = value.toString();
}
}
let payload = JSON.parse(description);
payload.token = portal.token;
payload.f = "json";
let options = {
Expand Down

0 comments on commit d1199de

Please sign in to comment.