Commit c7900f25 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1592: updated UI to display struct values without type header details

parent 69c4806a
...@@ -149,7 +149,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -149,7 +149,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
valueOfArray.push('<span>' + _.escape(inputOutputField) + '</span>'); valueOfArray.push('<span>' + _.escape(inputOutputField) + '</span>');
} }
} else if (_.isObject(inputOutputField) && !id) { } else if (_.isObject(inputOutputField) && !id) {
_.each(inputOutputField, function(objValue, objKey) { var attributesList = inputOutputField;
if (scope.typeHeaders && inputOutputField.typeName) {
var typeNameCategory = scope.typeHeaders.fullCollection.findWhere({ name: inputOutputField.typeName });
if (attributesList.attributes && typeNameCategory && typeNameCategory.get('category') === 'STRUCT') {
attributesList = attributesList.attributes;
}
}
_.each(attributesList, function(objValue, objKey) {
var value = objValue; var value = objValue;
if (objKey.indexOf("$") == -1) { if (objKey.indexOf("$") == -1) {
if (_.isObject(value)) { if (_.isObject(value)) {
...@@ -162,7 +169,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -162,7 +169,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (id && inputOutputField) { if (id && inputOutputField) {
var name = Utils.getName(inputOutputField); var name = Utils.getName(inputOutputField);
if (name === "-") { if (name === "-" || name === id) {
var fetch = true; var fetch = true;
var fetchId = (_.isObject(id) ? id.id : id); var fetchId = (_.isObject(id) ? id.id : id);
fetchInputOutputValue(fetchId); fetchInputOutputValue(fetchId);
......
...@@ -167,6 +167,7 @@ define(['require', ...@@ -167,6 +167,7 @@ define(['require',
referredEntities: this.entityObject.referredEntities, referredEntities: this.entityObject.referredEntities,
guid: this.id, guid: this.id,
entityName: this.name, entityName: this.name,
typeHeaders: this.typeHeaders,
entityDefCollection: this.entityDefCollection, entityDefCollection: this.entityDefCollection,
fetchCollection: this.fetchCollection.bind(that) fetchCollection: this.fetchCollection.bind(that)
} }
......
...@@ -148,7 +148,7 @@ define(['require', ...@@ -148,7 +148,7 @@ define(['require',
this.decrementCounter('asyncFetchLOVCounter'); this.decrementCounter('asyncFetchLOVCounter');
this.addJsonSearchData(); this.addJsonSearchData();
}, this); }, this);
this.ui.entityInputData.on("keyup", "textarea", function() { this.ui.entityInputData.on("keyup change", "textarea", function(e) {
var value = this.value; var value = this.value;
if (!value.length && $(this).hasClass('false')) { if (!value.length && $(this).hasClass('false')) {
$(this).removeClass('errorClass'); $(this).removeClass('errorClass');
...@@ -165,7 +165,6 @@ define(['require', ...@@ -165,7 +165,6 @@ define(['require',
that.modal.$el.find('button.ok').prop("disabled", true); that.modal.$el.find('button.ok').prop("disabled", true);
} }
} }
}); });
if (this.guid) { if (this.guid) {
...@@ -433,12 +432,23 @@ define(['require', ...@@ -433,12 +432,23 @@ define(['require',
} }
}, },
getTextArea: function(value, entityValue) { getTextArea: function(value, entityValue, structType) {
var setValue = entityValue
try {
if (structType && entityValue && entityValue.length) {
var parseValue = JSON.parse(entityValue);
if (_.isObject(parseValue) && !_.isArray(parseValue) && parseValue.attributes) {
setValue = JSON.stringify(parseValue.attributes);
}
}
} catch (err) {}
return '<textarea class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' + return '<textarea class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
' data-type="' + value.typeName + '"' + ' data-type="' + value.typeName + '"' +
' data-key="' + value.name + '"' + ' data-key="' + value.name + '"' +
' placeholder="' + value.name + '"' + ' placeholder="' + value.name + '"' +
' data-id="entityInput">' + entityValue + '</textarea>'; ' data-id="entityInput">' + setValue + '</textarea>';
}, },
getInput: function(value, entityValue) { getInput: function(value, entityValue) {
return '<input class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' + return '<input class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
...@@ -491,7 +501,7 @@ define(['require', ...@@ -491,7 +501,7 @@ define(['require',
} else { } else {
var typeNameCategory = this.typeHeaders.fullCollection.findWhere({ name: typeName }); var typeNameCategory = this.typeHeaders.fullCollection.findWhere({ name: typeName });
if (typeNameCategory && typeNameCategory.get('category') === 'STRUCT') { if (typeNameCategory && typeNameCategory.get('category') === 'STRUCT') {
return this.getTextArea(value, entityValue); return this.getTextArea(value, entityValue, true);
} else { } else {
return this.getInput(value, entityValue); return this.getInput(value, entityValue);
} }
......
...@@ -48,7 +48,7 @@ define(['require', ...@@ -48,7 +48,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'entity', 'referredEntities')); _.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders'));
this.entityModel = new VEntity({}); this.entityModel = new VEntity({});
}, },
bindEvents: function() {}, bindEvents: function() {},
......
...@@ -242,8 +242,6 @@ define(['require', ...@@ -242,8 +242,6 @@ define(['require',
classificationDefs: [{ classificationDefs: [{
'name': this.name.trim(), 'name': this.name.trim(),
'description': this.description.trim(), 'description': this.description.trim(),
"typeVersion": "2",
"version": "2",
'superTypes': superTypes.length ? superTypes : [], 'superTypes': superTypes.length ? superTypes : [],
"attributeDefs": attributeObj "attributeDefs": attributeObj
}], }],
......
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