').addClass("dialog-header").text("Constrain " + id).appendTo(frame);
+ var header = $('').addClass("dialog-header").text("Settings for " + id).appendTo(frame);
var body = $('').addClass("dialog-body").appendTo(frame);
var footer = $('').addClass("dialog-footer").appendTo(frame);
- body.html(
- '
' +
+ // by default we display an area where the user can input JSON
+ var form = (
'
' +
- 'Enter MQL query constraints as JSON' +
+ '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;
+ if (fields != null) {
+ form = '';
+ for(var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var fieldHTML = '';
+ var currentValue = field.default;
+ if (property.settings != null && property.settings[field.name] != null) {
+ currentValue = property.settings[field.name];
+ }
+ if (field.type == 'select') {
+ fieldHTML += ''+field.label+': ';
+ for(var j = 0; j < field.choices.length; j++) {
+ var choice = field.choices[j];
+ fieldHTML += ' ';
+ }
+ } else if (field.type == 'checkbox') {
+ fieldHTML += ''
+ } else if (field.type == 'number') {
+ fieldHTML += '';
+ }
+ if(fieldHTML != '') {
+ form += '
'+fieldHTML+'
';
+ form += '
';
+ }
+ }
+ }
+
+ body.html(
+ ''
);
var bodyElmts = DOM.bind(body);
- if ("constraints" in property) {
- bodyElmts.textarea[0].value = JSON.stringify(property.constraints, null, 2);
- } else {
- bodyElmts.textarea[0].value = JSON.stringify({ "limit" : 10 }, null, 2);
+ 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(
@@ -356,21 +403,33 @@ ExtendReconciledDataPreviewDialog.prototype._constrainProperty = function(id) {
footerElmts.cancelButton.click(dismiss);
footerElmts.okButton.click(function() {
try {
- var o = JSON.parse(bodyElmts.textarea[0].value);
- if (o === undefined) {
- alert("Please ensure that the JSON you enter is valid.");
- return;
- }
+ 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;
- }
+ 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.constraints = o;
+ property.settings = o;
+ } else {
+ 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();
@@ -380,6 +439,6 @@ ExtendReconciledDataPreviewDialog.prototype._constrainProperty = function(id) {
}
});
- bodyElmts.textarea.focus();
+ //bodyElmts.textarea.focus();
};
diff --git a/main/webapp/modules/core/styles/reconciliation/extend-data-preview-dialog.less b/main/webapp/modules/core/styles/reconciliation/extend-data-preview-dialog.less
index 220a4610a..069a70628 100644
--- a/main/webapp/modules/core/styles/reconciliation/extend-data-preview-dialog.less
+++ b/main/webapp/modules/core/styles/reconciliation/extend-data-preview-dialog.less
@@ -78,3 +78,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
padding: 45%;
display: inline-block;
}
+
+.data-extension-property-config td {
+ padding: 5px;
+}