Skip to content

Commit

Permalink
update id parameter when copying hosted apps
Browse files Browse the repository at this point in the history
Important step to ensure hosted apps continue to be editable in the
destination. Fixes Esri#60 and Esri#91.
  • Loading branch information
ecaldwell committed Aug 14, 2015
1 parent cf1c3fa commit 3adb7b7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/js/main.js
Expand Up @@ -817,7 +817,18 @@ require([
destinationPortal.addItem(destinationPortal.username, folder, description, data, thumbnailUrl).done(function (response) {
var html;
if (response.success === true) {
jquery("#" + id + "_clone").addClass("btn-success");
// Update the id parameter to reflect the new item's id.
if (description.url.indexOf("id=") > -1) {
var newUrl = description.url.substring(description.url.indexOf("/apps/"));
newUrl = newUrl.replace("id=" + description.id, "id=" + response.id);
var folder = response.folder || "";
destinationPortal.updateUrl(destinationPortal.username, folder, response.id, newUrl)
.done(function (status) {
jquery("#" + id + "_clone").addClass("btn-success");
});
} else {
jquery("#" + id + "_clone").addClass("btn-success");
}
} else if (response.error) {
jquery("#" + id + "_clone").addClass("btn-danger");
html = mustache.to_html(jquery("#contentCopyErrorTemplate").html(), {
Expand Down

0 comments on commit 3adb7b7

Please sign in to comment.