Commit 39b059e0 by kevalbhatt Committed by Sarath Subramanian

ATLAS-3128: UI: Create entity is not working after new relationship attribute introduce

parent 1a5009ea
......@@ -23,10 +23,12 @@
.control-label-sm {
padding-top: 3px;
}
.control-label-sm-pl {
@extend .control-label-sm;
padding-left: 10px;
}
.control-label-sm-pr {
@extend .control-label-sm;
padding-right: 10px;
......@@ -44,6 +46,7 @@
&.text-left {
text-align: left;
}
&.text-right {
text-align: right;
}
......@@ -53,6 +56,7 @@
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
background-color: $color_mystic_approx;
border: 1px $color_mystic_approx solid;
&:focus {
border-color: $color_bali_hai_approx;
outline: 0; //Instead of the line below you could use @include box-shadow($shadow-1, $shadow-2, $shadow-3, $shadow-4, $shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9, $shadow-10)
......@@ -62,6 +66,7 @@
}
.form-color {
.form-group span[class^="select2-selection select2-selection--"],
.form-control {
background-color: #e8e8e8 !important;
......@@ -70,6 +75,7 @@
.sidebar-wrapper {
z-index: 9 !important;
.form-control {
background-color: $white;
border: 1px $white solid;
......@@ -83,6 +89,7 @@
textarea {
resize: none;
&:focus {
outline: none !important;
}
......@@ -99,6 +106,7 @@ button:focus {
.btn {
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
border-radius: 4px;
&:hover {
text-decoration: none;
}
......@@ -106,6 +114,7 @@ button:focus {
[class^="col-md-"],
[class^="col-sm-"] {
.btn.checkbox-inline,
.btn.radio-inline {
padding-left: 19px;
......@@ -116,6 +125,7 @@ button:focus {
color: $white;
background-color: $color_blue_bayoux_approx;
border-color: $color_blue_bayoux_approx;
&:hover {
color: $white;
background-color: $color_pickled_bluewood_approx;
......@@ -127,11 +137,13 @@ button:focus {
color: $white;
background-color: $color_jungle_green_approx;
border-color: $color_jungle_green_approx;
&:hover {
color: $white;
background-color: $color_jungle_green_approx;
border-color: $color_jungle_green_approx;
}
&:focus {
color: $white;
background-color: $color_jungle_green_approx;
......@@ -143,11 +155,13 @@ button:focus {
color: $white;
background-color: $color_picton_blue_approx;
border-color: $color_picton_blue_approx;
&:hover {
color: $white;
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
}
&:focus {
color: $white;
background-color: $color_curious_blue_approx;
......@@ -159,11 +173,13 @@ button:focus {
color: $white;
background-color: $color_yellow_sea_approx;
border-color: $color_yellow_sea_approx;
&:hover {
color: $white;
background-color: $color_gamboge_approx;
border-color: $color_gamboge_approx;
}
&:focus {
color: $white;
background-color: $color_gamboge_approx;
......@@ -175,11 +191,13 @@ button:focus {
color: $white;
background-color: $color_trinidad_approx;
border-color: $color_trinidad_approx;
&:hover {
color: $white;
background-color: $color_grenadier_approx;
border-color: $color_grenadier_approx;
}
&:focus {
color: $white;
background-color: $color_grenadier_approx;
......@@ -196,17 +214,21 @@ button:focus {
border-radius: 4px; //Instead of the line below you could use @include transition($transition-1, $transition-2, $transition-3, $transition-4, $transition-5, $transition-6, $transition-7, $transition-8, $transition-9, $transition-10)
transition: all .3s ease;
margin: 2px;
&:hover {
@include btn-action-effect('default');
background-color: $transparent;
}
&:focus {
@include btn-action-effect('default');
background-color: $transparent;
}
&.btn-sm {
padding: 2px 6px;
}
&.btn-md {
padding: 6px 10px;
}
......@@ -222,17 +244,20 @@ button:focus {
.btn-fixed-width {
.btn-icon {
min-width: 100px;
&.propagte-classification {
>span {
width: 98px;
}
}
>span {
@include ellipsis();
float: left;
width: 76px;
padding: 2px 5px !important;
}
>i {
float: right;
line-height: 15px;
......@@ -246,6 +271,7 @@ button:focus {
border-radius: 4px;
font-size: 14px;
background-color: $transparent;
&.active {
@include btn-action-hover-effect('default');
}
......@@ -262,33 +288,41 @@ button:focus {
&.btn-sm {
padding: 2px 6px;
}
&.btn-md {
padding: 5px 10px;
}
&.btn-blue {
@include btn-action-effect('blue');
&.active {
@include btn-action-hover-effect('blue');
}
&:hover {
@include btn-action-hover-effect('blue');
}
&:focus {
@include btn-action-effect('blue');
}
&.btn-icon {
@include btn-action-effect('blue');
color: $tag_color !important;
&:hover {
color: $color_havelock_blue_approx;
background-color: $transparent;
}
>span {
&:hover {
@include btn-action-hover-effect('blue');
}
}
i.fa {
&:hover {
@include btn-action-hover-effect('blue');
......@@ -301,10 +335,12 @@ button:focus {
border: 1px $action_gray solid;
color: $action_gray;
cursor: default;
i.fa {
position: relative;
right: -5px;
}
&:hover {
color: $white;
background-color: $action_gray;
......@@ -315,25 +351,31 @@ button:focus {
padding: 0px;
overflow: hidden;
background-color: $transparent;
&:hover {
color: $color_keppel_approx;
background-color: $transparent;
}
>span {
padding: 5px;
&:hover {
@include btn-action-hover-effect('default');
}
}
i.fa {
position: relative;
padding: 5px;
cursor: pointer;
&:hover {
@include btn-action-hover-effect('default');
}
}
}
&.btn-icon-pd {
i.fa {
padding: 5px;
......@@ -343,6 +385,7 @@ button:focus {
}
.btn-group {
.btn-atlas,
.btn-action {
margin: 0px;
......@@ -353,10 +396,12 @@ button:focus {
>a {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
&:focus {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
}
&:hover {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
......@@ -366,10 +411,12 @@ button:focus {
>span {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
&:focus {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
}
&:hover {
background-color: $color_curious_blue_approx;
border-color: $color_curious_blue_approx;
......@@ -382,6 +429,7 @@ button:focus {
color: $color_mountain_mist_approx;
cursor: default;
margin: 5px 10px;
&:hover {
border-color: $color_mountain_mist_approx;
color: $color_mountain_mist_approx !important;
......@@ -402,3 +450,42 @@ button:focus {
.list-style-disc {
list-style: disc;
}
.create-entity-form {
&.all {
.attribute-dash-box {
&.alloptional {
display: block;
}
}
}
.attribute-dash-box {
border-style: dashed;
border-width: 2px;
border-spacing: 8px;
border-radius: 12px;
border-color: #cbcbcb;
position: relative;
padding: 0px 10px;
margin-top: 25px;
span.required:after {
content: "*";
padding-left: 1%;
color: $red
}
&.alloptional {
display: none;
}
.attribute-type-label {
background: $white;
padding: 5px 10px;
position: absolute;
top: -16px;
}
}
}
\ No newline at end of file
......@@ -50,7 +50,7 @@
.modal-body {
position: relative;
padding: 15px;
max-height: 72vh;
max-height: calc(100vh - 200px);
min-height: 70px;
overflow: auto;
......
......@@ -112,7 +112,9 @@ header {
h1 {
&.title {
word-break: break-all;
} // margin-top: 50px;
}
// margin-top: 50px;
margin-bottom: 10px;
font-weight: 600;
@include ellipsis();
......@@ -286,15 +288,18 @@ hr[size="10"] {
.panel-title {
display: inline-block;
}
i.ec-icon:before {
content: "\f078"
}
&.collapsed,
&[aria-expanded="false"] {
i.ec-icon:before {
content: "\f078"
}
}
&[aria-expanded="true"] {
i.ec-icon:before {
content: "\f077"
......@@ -388,10 +393,6 @@ hr[size="10"] {
box-shadow: none !important;
}
fieldset.fieldset-child-pd>div {
padding-left: 12px;
}
.inline-content {
>.inline {
display: inline-block;
......
......@@ -37,7 +37,7 @@
</div>
</div>
</div>
<div class="col-sm-12 entityInputData" data-id="entityInputData"></div>
<div class="col-sm-12 entityInputData create-entity-form" data-id="entityInputData"></div>
</div>
</form>
<div class="fontLoader-relative entityLoader" style="display:none">
......
......@@ -32,6 +32,9 @@ define(['require',
return false;
}
},
toArrayifObject: function(val) {
return _.isObject(val) ? [val] : val;
},
startsWith: function(str, matchStr) {
if (str && matchStr && _.isString(str) && _.isString(matchStr)) {
return str.lastIndexOf(matchStr, 0) === 0
......
......@@ -599,27 +599,56 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
return _.uniq(superTypes);
}
Utils.getNestedSuperTypeObj = function(options) {
var flag = 0,
data = options.data,
collection = options.collection;
if (options.attrMerge) {
var attributeDefs = [];
} else {
var mainData = options.data,
collection = options.collection,
attrMerge = options.attrMerge,
mergeRelationAttributes = options.mergeRelationAttributes || false,
seperateRelatioshipAttr = options.seperateRelatioshipAttr || false;
if (mergeRelationAttributes && seperateRelatioshipAttr) {
throw "Both mergeRelationAttributes & seperateRelatioshipAttr cannot be true!"
}
var attributeDefs = {};
if (attrMerge && !seperateRelatioshipAttr) {
attributeDefs = [];
} else if (options.attrMerge && seperateRelatioshipAttr) {
attributeDefs = {
attributeDefs: [],
relationshipAttributeDefs: []
}
}
var getRelationshipAttributeDef = function(data) {
return _.filter(
data.relationshipAttributeDefs,
function(obj, key) {
return obj;
})
}
var getData = function(data, collection) {
if (options.attrMerge) {
if (seperateRelatioshipAttr) {
attributeDefs.attributeDefs = attributeDefs.attributeDefs.concat(data.attributeDefs);
attributeDefs.relationshipAttributeDefs = attributeDefs.relationshipAttributeDefs.concat(getRelationshipAttributeDef(data));
} else {
attributeDefs = attributeDefs.concat(data.attributeDefs);
if (mergeRelationAttributes) {
attributeDefs = attributeDefs.concat(getRelationshipAttributeDef(data));
}
}
} else {
if (attributeDefs[data.name]) {
if (_.isArray(attributeDefs[data.name])) {
attributeDefs[data.name] = attributeDefs[data.name].concat(data.attributeDefs);
attributeDefs[data.name] = _.toArrayifObject(attributeDefs[data.name]).concat(data.attributeDefs);
} else {
_.extend(attributeDefs[data.name], data.attributeDefs);
}
if (seperateRelatioshipAttr) {
attributeDefs[data.name] = {
attributeDefs: data.attributeDefs,
relationshipAttributeDefs: data.relationshipAttributeDefs
};
} else {
attributeDefs[data.name] = data.attributeDefs;
if (mergeRelationAttributes) {
attributeDefs[data.name] = _.toArrayifObject(attributeDefs[data.name]).concat(getRelationshipAttributeDef(data));
}
}
}
}
if (data.superTypes && data.superTypes.length) {
......@@ -638,7 +667,27 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
});
}
}
getData(data, collection);
getData(mainData, collection);
if (attrMerge) {
if (seperateRelatioshipAttr) {
attributeDefs = {
attributeDefs: _.uniq(_.sortBy(attributeDefs.attributeDefs, 'name'), true, function(obj) {
return obj.name
}),
relationshipAttributeDefs: _.uniq(_.sortBy(attributeDefs.relationshipAttributeDefs, 'name'), true, function(obj) {
return (obj.name + obj.relationshipTypeName)
})
}
} else {
attributeDefs = _.uniq(_.sortBy(attributeDefs, 'name'), true, function(obj) {
if (obj.relationshipTypeName) {
(obj.name + obj.relationshipTypeName)
} else {
(obj.name)
}
});
}
}
return attributeDefs;
}
......
......@@ -236,7 +236,7 @@ define(['require',
var str = '<option disabled="disabled" selected>--Select entity-type--</option>';
this.entityDefCollection.fullCollection.each(function(val) {
var name = Utils.getName(val.toJSON());
if (Globals.entityTypeConfList) {
if (Globals.entityTypeConfList && name.indexOf("__") !== 0) {
if (_.isEmptyArray(Globals.entityTypeConfList)) {
str += '<option>' + name + '</option>';
} else {
......@@ -256,11 +256,13 @@ define(['require',
},
requiredAllToggle: function(checked) {
if (checked) {
this.ui.entityInputData.addClass('all').removeClass('required');
this.ui.entityInputData.find('div.true').show();
this.ui.entityInputData.find('fieldset div.true').show();
this.ui.entityInputData.find('fieldset').show();
this.required = false;
} else {
this.ui.entityInputData.addClass('required').removeClass('all');
this.ui.entityInputData.find('fieldset').each(function() {
if (!$(this).find('div').hasClass('false')) {
$(this).hide();
......@@ -296,26 +298,111 @@ define(['require',
silent: true
});
},
renderAttribute: function(object) {
var that = this,
visitedAttr = {},
attributeObj = object.attributeDefs,
isAllAttributeOptinal = true,
isAllRelationshipAttributeOptinal = true,
attributeDefList = attributeObj.attributeDefs,
relationshipAttributeDefsList = attributeObj.relationshipAttributeDefs,
attributeHtml = "",
relationShipAttributeHtml = "",
fieldElemetHtml = '',
commonInput = function(object) {
var value = object.value,
containerHtml = '';
containerHtml += that.getContainer(object);
return containerHtml;
};
if (attributeDefList.length || relationshipAttributeDefsList.length) {
_.each(attributeDefList, function(value) {
if (value.isOptional === false) {
isAllAttributeOptinal = false;
}
attributeHtml += commonInput({
"value": value,
"duplicateValue": false,
"isAttribute": true
});
});
_.each(relationshipAttributeDefsList, function(value) {
if (value.isOptional === false) {
isAllRelationshipAttributeOptinal = false;
}
if (visitedAttr[value.name] === null) {
// on second visited set it to true;and now onwords ignore if same value come.
var duplicateRelationship = _.where(relationshipAttributeDefsList, { name: value.name });
var str = '<option value="">--Select a Relationship Type--</option>';
_.each(duplicateRelationship, function(val, index, list) {
str += '<option>' + _.escape(val.relationshipTypeName) + '</option>';
});
var isOptional = value.isOptional;
visitedAttr[value.name] = '<div class="form-group"><select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") + '" data-for-key= "' + value.name + '"> ' + str + '</select></div>';
} else {
relationShipAttributeHtml += commonInput({
"value": value,
"duplicateValue": true,
"isRelation": true
});
// once visited set it to null;
visitedAttr[value.name] = null;
}
});
if (attributeHtml.length) {
fieldElemetHtml += that.getFieldElementContainer({
"htmlField": attributeHtml,
"attributeType": true,
"alloptional": isAllAttributeOptinal
});
}
if (relationShipAttributeHtml.length) {
fieldElemetHtml += that.getFieldElementContainer({
"htmlField": relationShipAttributeHtml,
"relationshipType": true,
"alloptional": isAllRelationshipAttributeOptinal
});
}
if (fieldElemetHtml.length) {
that.ui.entityInputData.append(fieldElemetHtml);
_.each(_.keys(visitedAttr), function(key) {
if (visitedAttr[key] === null) {
return;
}
var elFound = that.ui.entityInputData.find('[data-key="' + key + '"]');
elFound.parent().prepend(visitedAttr[key]);
});
} else {
fieldElemetHtml = "<h4 class='text-center'>Defination not found</h4>";
that.ui.entityInputData.append(fieldElemetHtml);
}
}
that.ui.entityInputData.find("select[data-for-key]").select2({})
return false;
},
subAttributeData: function(data) {
var that = this,
attributeInput = "",
alloptional = false,
attributeDefs = Utils.getNestedSuperTypeObj({ data: data, collection: this.entityDefCollection });
_.each(_.sortBy(_.keys(attributeDefs)), function(key) {
if (attributeDefs[key].length) {
attributeInput = "";
_.each(_.sortBy(attributeDefs[key], 'name'), function(value) {
if (value.isOptional == true) {
alloptional = true;
}
attributeInput += that.getContainer(value);
attributeDefs = Utils.getNestedSuperTypeObj({
seperateRelatioshipAttr: true,
attrMerge: true,
data: data,
collection: this.entityDefCollection
});
if (attributeInput !== "") {
entityTitle = that.getFieldSet(key, alloptional, attributeInput);
that.ui.entityInputData.append(entityTitle);
if (attributeDefs && attributeDefs.relationshipAttributeDefs.length) {
attributeDefs.attributeDefs = _.filter(attributeDefs.attributeDefs, function(obj) {
if (_.find(attributeDefs.relationshipAttributeDefs, { name: obj.name }) === undefined) {
return true;
}
})
}
//make a function call.
this.renderAttribute({
attributeDefs: attributeDefs
});
if (this.required) {
this.ui.entityInputData.find('fieldset div.true').hide()
this.ui.entityInputData.find('div.true').hide();
......@@ -395,19 +482,35 @@ define(['require',
}
});
},
getContainer: function(value) {
var entityLabel = this.capitalize(value.name);
return '<div class="row form-group ' + value.isOptional + '"><span class="col-sm-3">' +
getContainer: function(object) {
var value = object.value,
entityLabel = this.capitalize(value.name);
return '<div class=" row ' + value.isOptional + '"><span class="col-sm-3">' +
'<label><span class="' + (value.isOptional ? 'true' : 'false required') + '">' + entityLabel + '</span><span class="center-block ellipsis text-gray" title="Data Type : ' + value.typeName + '">' + '(' + Utils.escapeHtml(value.typeName) + ')' + '</span></label></span>' +
'<span class="col-sm-9">' + (this.getElement(value)) +
'<span class="col-sm-9">' + (this.getElement(object)) +
'</input></span></div>';
},
getFieldSet: function(name, alloptional, attributeInput) {
return '<fieldset class="form-group fieldset-child-pd ' + (alloptional ? "alloptional" : "") + '"><legend class="legend-sm">' + name + '</legend>' + attributeInput + '</fieldset>';
},
getSelect: function(value, entityValue) {
getFieldElementContainer: function(object) {
var htmlField = object.htmlField,
attributeType = object.attributeType ? object.attributeType : false,
relationshipType = object.relationshipType ? object.relationshipType : false,
alloptional = object.alloptional,
typeOfDefination = (relationshipType ? "Relationships" : "Attributes");
return '<div class="attribute-dash-box ' + (alloptional ? "alloptional" : "") + ' "><span class="attribute-type-label">' + (typeOfDefination) + '</span>' + htmlField + '</div>';
},
getSelect: function(object) {
var value = object.value,
entityValue = object.entityValue,
isAttribute = object.isAttribute,
isRelation = object.isRelation;
if (value.typeName === "boolean") {
return '<select class="form-control row-margin-bottom ' + (value.isOptional === true ? "false" : "true") + '" data-type="' + value.typeName + '" data-key="' + value.name + '" data-id="entityInput">' +
return '<select class="form-control row-margin-bottom ' + (value.isOptional === true ? "false" : "true") +
'" data-type="' + value.typeName +
'" data-attribute="' + isAttribute +
'" data-relation="' + isRelation +
'" data-key="' + value.name +
'" data-id="entityInput">' +
'<option value="">--Select true or false--</option><option value="true">true</option>' +
'<option value="false">false</option></select>';
} else {
......@@ -417,13 +520,21 @@ define(['require',
} else {
splitTypeName = value.typeName;
}
return '<select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") + '" data-type="' + value.typeName +
'" data-key="' + value.name + '" data-id="entitySelectData" data-queryData="' + splitTypeName + '">' + (this.guid ? entityValue : "") + '</select>';
return '<select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") +
'" data-type="' + value.typeName +
'" data-attribute="' + isAttribute +
'" data-relation="' + isRelation +
'" data-key="' + value.name +
'" data-id="entitySelectData" data-queryData="' + splitTypeName + '">' + (this.guid ? entityValue : "") + '</select>';
}
},
getTextArea: function(value, entityValue, structType) {
var setValue = entityValue
getTextArea: function(object) {
var value = object.value,
setValue = object.entityValue,
isAttribute = object.isAttribute,
isRelation = object.isRelation,
structType = object.structType;
try {
if (structType && entityValue && entityValue.length) {
var parseValue = JSON.parse(entityValue);
......@@ -436,20 +547,31 @@ define(['require',
return '<textarea class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
' data-type="' + value.typeName + '"' +
' data-key="' + value.name + '"' +
' data-attribute="' + isAttribute + '"' +
' data-relation="' + isRelation + '"' +
' placeholder="' + value.name + '"' +
' data-id="entityInput">' + setValue + '</textarea>';
},
getInput: function(value, entityValue) {
getInput: function(object) {
var value = object.value,
entityValue = object.entityValue,
isAttribute = object.isAttribute,
isRelation = object.isRelation;
return '<input class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
' data-type="' + value.typeName + '"' +
' value="' + entityValue + '"' +
' data-key="' + value.name + '"' +
' data-attribute="' + isAttribute + '"' +
' data-relation="' + isRelation + '"' +
' placeholder="' + value.name + '"' +
' data-id="entityInput">';
},
getElement: function(value) {
var typeName = value.typeName,
getElement: function(object) {
var value = object.value,
isAttribute = object.isAttribute,
isRelation = object.isRelation,
typeName = value.typeName,
entityValue = "";
if (this.guid) {
var dataValue = this.entityData.get("entity").attributes[value.name];
......@@ -469,15 +591,38 @@ define(['require',
}
}
if ((typeName && this.entityDefCollection.fullCollection.find({ name: typeName })) || typeName === "boolean" || typeName.indexOf("array") > -1) {
return this.getSelect(value, entityValue);
return this.getSelect({
"value": value,
"entityValue": entityValue,
"isAttribute": isAttribute,
"isRelation": isRelation
});
} else if (typeName.indexOf("map") > -1) {
return this.getTextArea(value, entityValue);
return this.getTextArea({
"value": value,
"entityValue": entityValue,
"isAttribute": isAttribute,
"isRelation": isRelation,
"structType": false
});
} else {
var typeNameCategory = this.typeHeaders.fullCollection.findWhere({ name: typeName });
if (typeNameCategory && typeNameCategory.get('category') === 'STRUCT') {
return this.getTextArea(value, entityValue, true);
return this.getTextArea({
"value": value,
"entityValue": entityValue,
"isAttribute": isAttribute,
"isRelation": isRelation,
"structType": true
});
} else {
return this.getInput(value, entityValue);
return this.getInput({
"value": value,
"entityValue": entityValue,
"isAttribute": isAttribute,
"isRelation": isRelation,
});
}
}
},
......@@ -485,8 +630,9 @@ define(['require',
var that = this;
this.showLoader();
this.parentEntity = this.ui.entityList.val();
var entity = {};
var referredEntities = {};
var entityAttribute = {},
referredEntities = {},
relationshipAttribute = {};
var extractValue = function(value, typeName) {
if (!value) {
return value;
......@@ -503,7 +649,8 @@ define(['require',
}
try {
this.ui.entityInputData.find("input,select,textarea").each(function() {
var value = $(this).val();
var value = $(this).val(),
el = this;
if ($(this).val() && $(this).val().trim) {
value = $(this).val().trim();
}
......@@ -534,19 +681,21 @@ define(['require',
var dataTypeEnitity = $(this).data('type'),
datakeyEntity = $(this).data('key'),
typeName = $(this).data('querydata'),
typeNameCategory = that.typeHeaders.fullCollection.findWhere({ name: dataTypeEnitity });
attribute = $(this).data('attribute') == 'undefined' ? false : true,
relation = $(this).data('relation') == 'undefined' ? false : true,
typeNameCategory = that.typeHeaders.fullCollection.findWhere({ name: dataTypeEnitity }),
val = null;
// Extract Data
if (dataTypeEnitity && datakeyEntity) {
if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) {
entity[datakeyEntity] = extractValue(value, typeName);
val = extractValue(value, typeName);
} else if (dataTypeEnitity === 'date' || dataTypeEnitity === 'time') {
entity[datakeyEntity] = Date.parse(value);
val = Date.parse(value);
} else if (dataTypeEnitity.indexOf("map") > -1 || (typeNameCategory && typeNameCategory.get('category') === 'STRUCT')) {
try {
if (value && value.length) {
parseData = JSON.parse(value);
entity[datakeyEntity] = parseData;
val = parseData;
}
} catch (err) {
$(this).addClass('errorClass');
......@@ -554,24 +703,44 @@ define(['require',
return;
}
} else if (dataTypeEnitity.indexOf("array") > -1 && dataTypeEnitity.indexOf("string") === -1) {
entity[datakeyEntity] = extractValue(value, typeName);
val = extractValue(value, typeName);
} else {
if (_.isString(value)) {
if (value.length) {
entity[datakeyEntity] = value;
val = value;
} else {
entity[datakeyEntity] = null;
val = null;
}
} else {
entity[datakeyEntity] = value;
val = value;
}
}
if (attribute) {
entityAttribute[datakeyEntity] = val;
} else if (relation) {
relationshipAttribute[datakeyEntity] = val;
}
} else {
var dataRelEntity = $(this).data('forKey');
if (dataRelEntity && relationshipAttribute[dataRelEntity]) {
if (_.isArray(relationshipAttribute[dataRelEntity])) {
_.each(relationshipAttribute[dataRelEntity], function(obj) {
if (obj) {
obj["relationshipType"] = $(el).val();
}
});
} else {
relationshipAttribute[dataRelEntity]["relationshipType"] = $(this).val();
}
}
}
});
var entityJson = {
"entity": {
"typeName": (this.guid ? this.entityData.get("entity").typeName : this.parentEntity),
"attributes": entity,
"attributes": entityAttribute,
"relationshipAttributes": relationshipAttribute,
"guid": (this.guid ? this.guid : -1)
},
"referredEntities": referredEntities
......@@ -628,17 +797,16 @@ define(['require',
queryData = $(this).data("querydata"),
skip = $(this).data('skip'),
placeholderName = "Select a " + typeData + " from the dropdown list";
$this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true));
// Select Value.
if (that.guid) {
var dataValue = that.entityData.get("entity").attributes[keyData],
entities = that.entityData.get("entity").attributes,
relationshipType = that.entityData.get("entity").relationshipAttributes[keyData],
referredEntities = that.entityData.get("referredEntities"),
selectedValue = [],
select2Options = [];
if (dataValue) {
if (_.isObject(dataValue) && !_.isArray(dataValue)) {
dataValue = [dataValue];
......@@ -653,6 +821,12 @@ define(['require',
}
}
});
if (!_.isUndefined(relationshipType)) {
if (relationshipType && relationshipType.relationshipAttributes && relationshipType.relationshipAttributes.typeName) {
that.$("select[data-for-key=" + keyData + "]").val(relationshipType.relationshipAttributes.typeName).trigger("change");
}
}
}
// Array of string.
......
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