Skip to content

Commit

Permalink
Item12952: improve reporting of changes coming back from wizards
Browse files Browse the repository at this point in the history
  • Loading branch information
crawford committed Aug 30, 2014
1 parent 8fb0afb commit 8e62225
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 46 deletions.
7 changes: 6 additions & 1 deletion pub/System/ConfigurePlugin/configure.uncompressed.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,9 @@ div.information {
#auth_prompt {
height: 300px;
width: 350px;
}
}

textarea.report {
width: 100%;
height: 40%;
}
19 changes: 12 additions & 7 deletions pub/System/ConfigurePlugin/configure.uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var $TRUE = 1;
$('body').css('cursor','auto');
}

// Create a popup with reports
// Create a popup with reports, and apply changes
function wizard_reports(results) {
$('body').css('cursor','wait');
// Generate reports
Expand All @@ -170,14 +170,19 @@ var $TRUE = 1;
$whine.addClass(rep.level);
$div.append($whine);
});
// Reflect changed values back to the input elements
// Reflect changed values back to the input elements and
// run the checker on them
$.each(results.changes, function(keys, value) {
// Get the input for the keys, if it's there
var $input = $('#' + _id_ify(keys));
$input.each(function() {
$(this).attr('value', value);
update_modified_default($(this).closest('div.node'));
})
$('#' + _id_ify(keys))
.closest('.node')
.each(function() {
var $node = $(this);
var handler = $node.data('value_handler');
handler.useVal(value);
// Fire off checker
check_current_value($node);
})
});
$div.dialog({
width: '60%',
Expand Down
76 changes: 38 additions & 38 deletions pub/System/ConfigurePlugin/types.uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Types.BaseType = Class.extend({
var cols = m[1];
var rows = m[2];
var value = val == undefined ? '' : val;
this.ui = $('<textarea id="' + _id_ify(this.spec.keys)
this.$ui = $('<textarea id="' + _id_ify(this.spec.keys)
+ '" rows="' + rows
+ '" cols="' + cols
+ '" class="foswikiTextArea">' + value + '</textarea>');
Expand All @@ -44,26 +44,26 @@ Types.BaseType = Class.extend({
&& (m = this.spec.SIZE.match(/^\s*(\d+)(\s|$)/))) {
size = m[1];
}
this.ui = $('<input id="' + _id_ify(this.spec.keys)
this.$ui = $('<input id="' + _id_ify(this.spec.keys)
+ '" size="' + size + '"/>');
this.ui.attr('value', val);
this.$ui.val(val);
}
if (this.spec.SPELLCHECK) {
this.ui.attr('spellcheck', "true");
this.$ui.attr('spellcheck', 'true');
}
if (change_handler != undefined)
this.ui.change(change_handler);
return this.ui;
this.$ui.change(change_handler);
return this.$ui;
},

useVal: function(val) {
this.ui.val(val);
this.$ui.val(val);
},

currentValue: function() {
if (this.null_if != null && this.null_if())
return null;
return this.ui.val();
return this.$ui.val();
},

commitVal: function() {
Expand Down Expand Up @@ -96,23 +96,23 @@ Types.BaseType = Class.extend({

Types.BOOLEAN = Types.BaseType.extend({
createUI: function(change_handler) {
this.ui = $('<input type="checkbox" id="' + _id_ify(this.spec.keys)
this.$ui = $('<input type="checkbox" id="' + _id_ify(this.spec.keys)
+ '" />');
if (change_handler != undefined)
this.ui.change(change_handler);
this.$ui.change(change_handler);
if (typeof(this.spec.current_value) == 'undefined')
this.spec.current_value = 0;
if (this.spec.current_value != 0) {
this.ui.attr('checked', 'checked');
this.$ui.attr('checked', 'checked');
}
if (this.spec.extraClass) {
this.ui.addClass(this.spec.extraClass);
this.$ui.addClass(this.spec.extraClass);
}
return this.ui;
return this.$ui;
},

currentValue: function() {
return this.ui[0].checked ? 1 : 0;
return this.$ui[0].checked ? 1 : 0;
},

isModified: function() {
Expand All @@ -128,7 +128,7 @@ Types.BOOLEAN = Types.BaseType.extend({
},

useVal: function(val) {
this.ui[0].attr(checked, val ? 'checked' : '');
this.$ui.attr('checked', val ? 'checked' : '');
}
});

Expand All @@ -140,16 +140,16 @@ Types.BOOLGROUP = Types.BaseType.extend({
for (var i = 0; i < values.length; i++) {
sets[values[i]] = true;
}
this.ui = $('<div class="checkbox_group"></div>');
this.$ui = $('<div class="checkbox_group"></div>');
for (var i = 0; i < options.length; i++) {
var cb = $('<input type="checkbox" name="' + options[i]
+ ' id="' + _id_ify(this.spec.keys) + '"/>');
if (sets[options[i]])
cb.attr('checked', 'checked');
cb.change(change_handler);
this.ui.append(cb);
this.$ui.append(cb);
}
return this.ui;
return this.$ui;
},

currentValue: function() {
Expand All @@ -168,7 +168,7 @@ Types.BOOLGROUP = Types.BaseType.extend({
sets[values[i]] = true;
}
var i = 0;
this.ui.find('input[type="checkbox"]').each(function() {
this.$ui.find('input[type="checkbox"]').each(function() {
if (sets[options[i++]])
cb.attr('checked', 'checked');
});
Expand All @@ -178,9 +178,9 @@ Types.BOOLGROUP = Types.BaseType.extend({
Types.PASSWORD = Types.BaseType.extend({
createUI: function(change_handler) {
this._super(change_handler);
this.ui.attr('type', 'password');
this.ui.attr('autocomplete', 'off');
return this.ui;
this.$ui.attr('type', 'password');
this.$ui.attr('autocomplete', 'off');
return this.$ui;
}
});

Expand Down Expand Up @@ -214,16 +214,16 @@ Types.OCTAL = Types.BaseType.extend({
},

currentValue: function() {
var newval = this.ui.val();
var newval = this.$ui.val();
return newval.toString(8);
}
});

Types.PATHINFO = Types.BaseType.extend({
createUI: function(change_handler) {
this._super(change_handler);
this.ui.attr('readonly', 'readonly');
return this.ui;
this.$ui.attr('readonly', 'readonly');
return this.$ui;
}
});

Expand All @@ -233,19 +233,19 @@ Types.PATHINFO = Types.BaseType.extend({
Types.NULL = Types.BaseType.extend({
createUI: function(change_handler) {
this._super(change_handler);
this.ui.attr('readonly', 'readonly');
this.ui.attr('disabled', 'disabled');
this.ui.attr('size', '1');
return this.ui;
this.$ui.attr('readonly', 'readonly');
this.$ui.attr('disabled', 'disabled');
this.$ui.attr('size', '1');
return this.$ui;
}
});

Types.BUTTON = Types.BaseType.extend({
createUI: function() {
this.ui = $('<a href="' + this.spec.uri + '">'
this.$ui = $('<a href="' + this.spec.uri + '">'
+ this.spec.title + '</a>');
this.ui.button();
return this.ui;
this.$ui.button();
return this.$ui;
},

useVal: function() {
Expand Down Expand Up @@ -277,12 +277,12 @@ Types.SELECT = Types.BaseType.extend({
if (this.spec.SIZE && (m = this.spec.SIZE.match(/\b(\d+)\b/)))
size = m[0];

this.ui = $('<select id="' + _id_ify(this.spec.keys) + '" size="' + size
this.$ui = $('<select id="' + _id_ify(this.spec.keys) + '" size="' + size
+ '" class="foswikiSelect" />');
if (change_handler != undefined)
this.ui.change(change_handler);
this.$ui.change(change_handler);
if (this.spec.MULTIPLE) {
this.ui.attr('multiple', 'multiple');
this.$ui.attr('multiple', 'multiple');
}

if (this.spec.select_from != undefined) {
Expand All @@ -293,18 +293,18 @@ Types.SELECT = Types.BaseType.extend({
if (sel[opt]) {
option.attr('selected', 'selected');
}
this.ui.append(option);
this.$ui.append(option);
}
}
return this.ui;
return this.$ui;
},

useVal: function(val) {
var sel = this._getSel(val);
var sf = this.spec.select_from;
if (sf != undefined) {
var i = 0;
this.ui.find('option').each(function() {
this.$ui.find('option').each(function() {
var opt = sf[i++];
if (sel[opt])
$(this).attr('selected', 'selected');
Expand Down

0 comments on commit 8e62225

Please sign in to comment.