diff --git a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js
index 2aa6f9e66..bdb5d5fdc 100644
--- a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js
+++ b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js
@@ -183,7 +183,6 @@ ExtendReconciledDataPreviewDialog.prototype._update = function() {
columnName: this._column.name
};
- console.log(this._extension);
$.post(
"command/core/preview-extend-data?" + $.param(params),
{
@@ -253,17 +252,17 @@ ExtendReconciledDataPreviewDialog.prototype._renderPreview = function(data) {
$(' ').appendTo(th);
$(' ')
- .text($.i18n("core-views")["remove-prop"])
+ .text($.i18n._("core-views")["remove-prop"])
.addClass("action")
- .attr("title", $.i18n("core-views")["remove-col"])
+ .attr("title", $.i18n._("core-views")["remove-col"])
.click(function() {
self._removeProperty(column.id);
}).appendTo(th);
$(' ')
- .text($.i18n("core-views")["configure-prop"])
+ .text($.i18n._("core-views")["configure-prop"])
.addClass("action")
- .attr("title", $.i18n("core-views")["configure-col"])
+ .attr("title", $.i18n._("core-views")["configure-col"])
.click(function() {
self._constrainProperty(column.id);
}).appendTo(th);
@@ -325,19 +324,9 @@ ExtendReconciledDataPreviewDialog.prototype._constrainProperty = function(id) {
var body = $('
').addClass("dialog-body").appendTo(frame);
var footer = $('
').addClass("dialog-footer").appendTo(frame);
- // by default we display an area where the user can input JSON
- var form = (
- '' +
- 'Enter query settings as JSON' +
- ' ' +
- '' +
- '' +
- ' ');
-
- // If the service metadata specifies fields, we build a proper form to make it more user-friendly
var fields = self._serviceMetadata.extend.property_settings;
+ var table = $('');
if (fields != null) {
- form = '';
for(var i = 0; i < fields.length; i++) {
var field = fields[i];
var fieldHTML = '';
@@ -345,57 +334,60 @@ ExtendReconciledDataPreviewDialog.prototype._constrainProperty = function(id) {
if (property.settings != null && property.settings[field.name] != null) {
currentValue = property.settings[field.name];
}
+ var tr = $(' ');
+ var td = $(' ').attr('title', field.help_text).appendTo(tr);
if (field.type == 'select') {
- fieldHTML += ''+field.label+': ';
+ var fieldLabel = $(' ').text(field.label+':').appendTo(td);
+ td.append($(' '));
for(var j = 0; j < field.choices.length; j++) {
var choice = field.choices[j];
- fieldHTML += '';
- fieldHTML += ' '+choice.name+' ';
- }
- } else if (field.type == 'checkbox') {
- fieldHTML += ' '+field.label+' '
- } else if (field.type == 'number') {
- fieldHTML += ''+field.label+': ';
- }
- if(fieldHTML != '') {
- form += ''+fieldHTML+' ';
- form += ' ';
- }
- }
+ var labelElem = $(' ').attr('for', field.name+'_'+choice.value).appendTo(td);
+ var inputElem = $(' ').attr(
+ 'id', field.name+'_'+choice.value).attr(
+ 'value', choice.value).attr(
+ 'name', field.name).appendTo(labelElem);
- if (form == '') {
- form = ''+$.i18n('core-views')['no-settings']+' '
- }
+ if (choice.value == currentValue) {
+ inputElem.attr('checked', 'checked');
+ }
+ labelElem.append(' '+choice.name);
+ td.append(' ');
+ }
+ td.append(fieldHTML);
+ } else if (field.type == 'checkbox') {
+ var label = $(' ').attr('for', field.name).appendTo(td);
+ var input = $(' ').attr('name', field.name).appendTo(label);
+ if (currentValue == 'on') {
+ input.attr('checked','checked');
+ }
+ label.append(' '+field.label);
+ } else if (field.type == 'number' || field.type == 'text') {
+ var label = $(' ').attr('for', field.name).appendTo(td);
+ label.append(field.label+': ');
+ var input = $(' ').attr(
+ 'name', field.name).attr(
+ 'type', field.type).attr(
+ 'value', currentValue).appendTo(label);
+ }
+ if (tr.children().length > 0) {
+ table.append(tr);
+ }
+ }
}
- body.html(
- ''
- );
+ if (table.children().length == 0) {
+ var tr = $(' ').appendTo(table);
+ $(' ').text($.i18n._('core-views')['no-settings']).appendTo(tr);
+ }
+
+ var form = $('').append(table);
+ var gridLayout = $('
').append(form);
+ body.append(gridLayout);
var bodyElmts = DOM.bind(body);
- if (fields == null) {
- if ("settings" in property) {
- bodyElmts.textarea[0].value = JSON.stringify(property.settings, null, 2);
- } else {
- bodyElmts.textarea[0].value = JSON.stringify({ "limit" : 10 }, null, 2);
- }
- }
-
footer.html(
- ''+$.i18n('core-buttons')['ok']+' ' +
- ''+$.i18n('core-buttons')['cancel']+' '
+ ''+$.i18n._('core-buttons')['ok']+' ' +
+ ''+$.i18n._('core-buttons')['cancel']+' '
);
var footerElmts = DOM.bind(footer);
@@ -407,32 +399,14 @@ ExtendReconciledDataPreviewDialog.prototype._constrainProperty = function(id) {
footerElmts.cancelButton.click(dismiss);
footerElmts.okButton.click(function() {
try {
- if (fields == null) {
- var o = JSON.parse(bodyElmts.textarea[0].value);
- if (o === undefined) {
- alert("Please ensure that the JSON you enter is valid.");
- return;
- }
-
- if ($.isArray(o) && o.length == 1) {
- o = o[0];
- }
- if (!$.isPlainObject(o)) {
- alert("The JSON you enter must be an object, that is, it is of this form { ... }.");
- return;
- }
-
- property.settings = o;
- } else {
+ if (fields != null) {
var elem = $(bodyElmts.form[0]);
var ar = elem.serializeArray();
var settings = {};
for(var i = 0; i < ar.length; i++) {
settings[ar[i].name] = ar[i].value;
}
- console.log(ar);
property.settings = settings;
- console.log(settings);
}
dismiss();