Commit 23d91567 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Some slicing and dicing to get rid of some the cruft that was left over

from the original embedded modal version of the code, still needs a total
cleanup. But this along with a few other changes allows David's profile to
work; a parameterized profile that starts out single site, but can be
multisite after configuration.
parent bb1044ca
......@@ -60,10 +60,7 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
{uuid : selected_uuid,
registered : registered,
isadmin : isadmin,
amlist : amlist,
amdefault : amdefault,
callback : ConfigureDone,
button_label : "Accept",
rspec :
(!window.SKIPSTEPS ? null :
$('#pp_rspec_textarea').val()),
......@@ -486,20 +483,12 @@ function (_, Constraints, sup, ppstart, JacksEditor, aboutaptString, aboutcloudS
/*
* Callback from the PP configurator. Stash rspec into the form.
*/
function ConfigureDone(newRspec, where) {
function ConfigureDone(newRspec) {
// If not a registered user, we do not get an rspec back, since
// the user is not allowed to change the configuration.
if (newRspec) {
$('#pp_rspec_textarea').val(newRspec);
}
// Need to change the form before submit.
if (where && $('#profile_where').length) {
// Deselect current option.
$('#profile_where option').prop("selected", false);
// Find and select new option.
$('#profile_where option')
.filter('[value="'+ where + '"]')
.prop('selected', true);
CreateAggregateSelectors(newRspec);
}
// Enable the create button.
$('#instantiate_submit').attr('disabled', false);
......
......@@ -16,13 +16,10 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
var editorLarge = null;
var defaults = null;
var uuid = "";
var amlist = null;
var amdefault = null;
var registered = true;
var isadmin = 0;
var callback_done = null;
var button_label = "Instantiate";
var RSPEC = null;
var configuredone_callback = null;
//
// Moved into a separate function since we want to regen the form
......@@ -116,9 +113,7 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
*/
if (!registered) {
sup.HideModal('#ppmodal');
if (callback_done) {
callback_done(null);
}
configuredone_callback(null);
return;
}
......@@ -127,62 +122,21 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
SubmitForm(1, callback);
}
// Instantiate the new rspec on the chosen aggregate.
function Instantiate(where)
{
if (callback_done) {
callback_done(RSPEC, where);
return;
}
var callback = function(json) {
sup.HideModal("#waitwait-modal");
if (json.code) {
sup.SpitOops("oops", json.value);
return;
}
window.location.replace(json.value);
}
sup.ShowModal("#waitwait-modal");
var xmlthing = sup.CallServerMethod(null, "instantiate",
"Instantiate",
{"rspec" : RSPEC,
"where" : where,
"uuid" : uuid});
xmlthing.done(callback);
}
//
// Editor callback, returning the new rspec.
// Configuration is done, we have the new rspec.
//
function EditorDone(newRspec)
function ConfigureDone()
{
if (!amlist || amlist.length == 1) {
Instantiate(amdefault);
}
var html = chooseTemplate({
amlist : amlist,
amdefault : amdefault,
});
$('#instantiate_div').html(html);
configuredone_callback(RSPEC);
// Handler for instantiate submit button, which is in
// the modal.
$('#stepsContainer .actions a[href="#finish"]').click(function (event) {
// Handler for instantiate submit button, which is in the page.
$('#stepsContainer .actions a[href="#finish"]')
.click(function (event) {
event.preventDefault();
Instantiate($('.aggregate_selector #profile_where option:selected').val());
$('#instantiate_submit').click();
});
}
//
// Editor canceled; put back the configure modal.
//
function EditorCancel()
{
sup.ShowModal('#ppmodal');
}
//
// Submit the form. If no errors, we get back the rspec. Throw that
// up in a Jack editor window.
......@@ -212,11 +166,12 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
SubmitForm(0, steps_callback);
}
else {
RSPEC = json.value.rspec;
ConfigureDone();
// Must be after the callback, so that any changes to
// the aggregate selector is reflected in the final tab
steps_callback(true);
if (_.has(json.value, "amdefault")) {
amdefault = json.value.amdefault;
}
ShowEditor(json.value.rspec);
ShowEditor();
}
}
// Convert form data into formfields array, like all our
......@@ -244,8 +199,6 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
function StartPP(args) {
uuid = args.uuid;
registered = args.registered;
amlist = args.amlist;
amdefault = args.amdefault;
isadmin = args.isadmin;
if (bodyTemplate) {
......@@ -256,14 +209,7 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
// Caller might already have an editor instance.
editor = new JacksEditor($('#inline_jacks'), true, true,
true, true, !isadmin);
// Callback; instead of instantiate, send rspec to callback.
if (_.has(args, "callback")) {
callback_done = args.callback;
}
// Allow caller to change the Jacks accept button label.
if (_.has(args, "button_label")) {
button_label = args.button_label;
}
configuredone_callback = args.callback;
/*
* Need to ask for the profile parameter form fragment and
......@@ -291,7 +237,9 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
GenerateModalBody(defaults, null);
//sup.ShowModal('#ppmodal');
if (args.rspec) {
ShowEditor(args.rspec);
RSPEC = args.rspec;
ConfigureDone();
ShowEditor();
}
}
var xmlthing = sup.CallServerMethod(null, "instantiate",
......@@ -302,12 +250,10 @@ function(_, sup, JacksEditor, ppmodalString, ppbodyString, chooserString)
function ChangeJacksRoot(root, selectionPane) {
editor = new JacksEditor(root, true, true, selectionPane, true);
editor.show(RSPEC, EditorDone, EditorCancel, button_label);
editor.show(RSPEC);
}
function ShowEditor(rspec) {
RSPEC = rspec;
editor.show(RSPEC, EditorDone, EditorCancel, button_label);
EditorDone(RSPEC);
function ShowEditor() {
editor.show(RSPEC);
}
return {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment