Skip to content

Commit

Permalink
Make wall maker fill in the manage wall screen with the return value …
Browse files Browse the repository at this point in the history
…from create wall
  • Loading branch information
birtles committed Mar 19, 2013
1 parent 9e70d22 commit 469f89a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
13 changes: 10 additions & 3 deletions wall/public/wall-maker/js/create-wall.js
Expand Up @@ -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) {
Expand Down
60 changes: 34 additions & 26 deletions wall/public/wall-maker/js/manage-wall.js
Expand Up @@ -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");
Expand Down Expand Up @@ -135,29 +132,49 @@ 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 =
this.form.querySelectorAll("input[type=radio][name=design]");
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
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down

0 comments on commit 469f89a

Please sign in to comment.