Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make wall maker fill in the manage wall screen with the return value …

…from create wall
  • Loading branch information...
commit 469f89aeab6f5fa5e8e247a7eb927e1e168257dc 1 parent 9e70d22
@birtles birtles authored
View
13 wall/public/wall-maker/js/create-wall.js
@@ -48,11 +48,18 @@ var CreateWallController =
if (typeof response.wallId !== "number") {
console.debug("Got non-numerical wall id: " + response.wallId);
}
- var id = response.wallId;
+
+ // Clear create wall form
this.clearAll();
+
+ // Trigger update to wall summary screen
UserData.updateWalls();
- sessionStorage.setItem("messageKey", "create-wall-success");
- Navigation.goToScreen("wall/" + id + "#event");
+
+ // Fill in fields of manage wall form using response
+ ManageWallController.updateWallInfo(response);
+
+ // Update the screen
+ Navigation.goToScreen("wall/" + response.wallId + "#event");
},
createError: function(key, detail) {
View
60 wall/public/wall-maker/js/manage-wall.js
@@ -38,9 +38,6 @@ var ManageWallController =
return;
}
- // Load the wall
- this.wallId = wallId;
-
// Show loading screen
$("wall-info").setAttribute("aria-hidden", "true");
$("wall-loading").setAttribute("aria-hidden", "false");
@@ -135,21 +132,41 @@ var ManageWallController =
},
loadSuccess: function(response, tabName) {
+ // Update form fields
+ this.updateWallInfo(response);
+
+ // Switch to appropriate tab
+ if (tabName) {
+ this.selectTab(tabName);
+ }
+
+ // Hide loading and show page
+ $("wall-loading").setAttribute("aria-hidden", "true");
+ $("wall-info").setAttribute("aria-hidden", "false");
+ },
+
+ updateWallInfo: function(wall) {
+ // It doesn't make sense to show errors when we change wall
+ this.clearError();
+
+ // Set the ID
+ this.wallId = wall.wallId;
+
// Basic data
- $("manage-eventName").value = response.name;
+ $("manage-eventName").value = wall.name;
// Make up links
- this.updateShortenableLink($('manage-wallUrl'), response.wallUrl,
- response.wallUrlShort);
- this.updateShortenableLink($('manage-editorUrl'), response.editorUrl,
- response.editorUrlShort);
+ this.updateShortenableLink($('manage-wallUrl'), wall.wallUrl,
+ wall.wallUrlShort);
+ this.updateShortenableLink($('manage-editorUrl'), wall.editorUrl,
+ wall.editorUrlShort);
// Event data
- $("manage-eventLocation").value = response.eventLocation;
- $("manage-eventDescr").value = response.eventDescr;
+ $("manage-eventLocation").value = wall.eventLocation;
+ $("manage-eventDescr").value = wall.eventDescr;
// Sessions
- this.updateSessionInfo(response.latestSession);
+ this.updateSessionInfo(wall.latestSession);
// Design
var designRadios =
@@ -157,7 +174,7 @@ var ManageWallController =
for (var i = 0; i < designRadios.length; i++) {
var radio = designRadios[i];
var origValue = radio.checked;
- radio.checked = (radio.value == response.designId);
+ radio.checked = (radio.value == wall.designId);
if (radio.checked != origValue) {
// Unfortunately, just changing checked does not trigger a change event
// in most browsers so we trigger an event specifically fire the event
@@ -166,19 +183,19 @@ var ManageWallController =
radio.dispatchEvent(evt);
}
}
- $("manage-duration").value = response.duration == null
+ $("manage-duration").value = wall.duration == null
? ""
- : response.duration/1000;
- $("manage-defaultDuration").textContent = response.defaultDuration/1000;
+ : wall.duration/1000;
+ $("manage-defaultDuration").textContent = wall.defaultDuration/1000;
// Privacy
var dummypasscode = "";
- for (var i = 0; i < response.passcode; i++) {
+ for (var i = 0; i < wall.passcodeLen; i++) {
dummypasscode += "x";
}
$("manage-passcode").value = dummypasscode;
var radios = document.getElementsByName("manage-galleryDisplay");
- if (response.galleryDisplay == 0) {
+ if (wall.galleryDisplay == 0) {
radios[0].checked = false;
radios[1].checked = true;
} else {
@@ -188,15 +205,6 @@ var ManageWallController =
// Collaboration
// Characters
-
- // Switch to appropriate tab
- if (tabName) {
- this.selectTab(tabName);
- }
-
- // Hide loading and show page
- $("wall-loading").setAttribute("aria-hidden", "true");
- $("wall-info").setAttribute("aria-hidden", "false");
},
updateShortenableLink: function(linkContainer, url, shortUrl) {
Please sign in to comment.
Something went wrong with that request. Please try again.