Commit dd744765 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1521 : Update UI to eliminate REST calls to obtain schema data

parent 808eb1d1
...@@ -39,22 +39,33 @@ define(['require', ...@@ -39,22 +39,33 @@ define(['require',
// if (!this.modelAttrName) { // if (!this.modelAttrName) {
// throw new Error("this.modelAttrName not defined for " + this); // throw new Error("this.modelAttrName not defined for " + this);
// } // }
if (this.modelAttrName && this.modelAttrName === "createEntity") { if (resp.entity && resp.referredEntities) {
var arr = []; var obj = {
arr.push({ entity: resp.entity,
attributes: resp.attributes, referredEntities: resp.referredEntities
classifications: resp.classifications, }
guid: resp.guid, return obj;
typeName: resp.typeName } else if (resp[this.modelAttrName]) {
});
return arr;
} else {
if (resp[this.modelAttrName]) {
return resp[this.modelAttrName]; return resp[this.modelAttrName];
} else { } else {
return resp return resp
} }
} // if (this.modelAttrName && this.modelAttrName === "createEntity") {
// var arr = [];
// arr.push({
// attributes: resp.attributes,
// classifications: resp.classifications,
// guid: resp.guid,
// typeName: resp.typeName
// });
// return arr;
// } else {
// if (resp[this.modelAttrName]) {
// return resp[this.modelAttrName];
// } else {
// return resp
// }
// }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -160,12 +160,27 @@ require(['App', ...@@ -160,12 +160,27 @@ require(['App',
'utils/CommonViewFunction', 'utils/CommonViewFunction',
'utils/Globals', 'utils/Globals',
'utils/UrlLinks', 'utils/UrlLinks',
'collection/VEntityList',
'utils/Overrides', 'utils/Overrides',
'bootstrap', 'bootstrap',
'd3', 'd3',
'select2' 'select2'
], function(App, Router, CommonViewFunction, Globals, UrlLinks) { ], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList) {
App.appRouter = new Router(); var that = this;
this.asyncFetchCounter = 2;
this.entityDefCollection = new VEntityList();
that.entityDefCollection.url = UrlLinks.entitiesDefApiUrl()
that.entityDefCollection.modelAttrName = 'list';
App.appRouter = new Router({
entityDefCollection: this.entityDefCollection
});
var startApp = function() {
if (that.asyncFetchCounter === 0) {
App.start();
}
};
CommonViewFunction.userDataFetch({ CommonViewFunction.userDataFetch({
url: UrlLinks.sessionApiUrl(), url: UrlLinks.sessionApiUrl(),
callback: function(response) { callback: function(response) {
...@@ -192,7 +207,14 @@ require(['App', ...@@ -192,7 +207,14 @@ require(['App',
} }
} }
} }
App.start(); --that.asyncFetchCounter;
startApp();
}
});
that.entityDefCollection.fetch({
complete: function() {
--that.asyncFetchCounter;
startApp();
} }
}); });
}); });
...@@ -82,6 +82,7 @@ define(function(require) { ...@@ -82,6 +82,7 @@ define(function(require) {
okCloses: true, okCloses: true,
cancelText: 'Cancel', cancelText: 'Cancel',
allowCancel: false, allowCancel: false,
allowBackdrop: true,
showFooter: true, showFooter: true,
escape: true, escape: true,
animate: true, animate: true,
...@@ -145,7 +146,7 @@ define(function(require) { ...@@ -145,7 +146,7 @@ define(function(require) {
//Create it //Create it
$el.modal(_.extend({ $el.modal(_.extend({
keyboard: this.options.allowCancel, keyboard: this.options.allowCancel,
backdrop: this.options.allowCancel ? true : 'static' backdrop: this.options.allowBackdrop ? 'static' : true
}, this.options.modalOptions)); }, this.options.modalOptions));
//Focus OK button //Focus OK button
......
...@@ -41,13 +41,11 @@ define([ ...@@ -41,13 +41,11 @@ define([
// Default // Default
'*actions': 'defaultAction' '*actions': 'defaultAction'
}, },
initialize: function() { initialize: function(options) {
_.extend(this, _.pick(options, 'entityDefCollection'));
this.showRegions(); this.showRegions();
this.bindCommonEvents(); this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this); this.listenTo(this, 'route', this.postRouteExecute, this);
this.globalVent = new Backbone.Wreqr.EventAggregator();
this.catalogVent = new Backbone.Wreqr.EventAggregator();
this.tagVent = new Backbone.Wreqr.EventAggregator();
this.tagCollection = new VTagList(); this.tagCollection = new VTagList();
}, },
bindCommonEvents: function() { bindCommonEvents: function() {
...@@ -111,15 +109,14 @@ define([ ...@@ -111,15 +109,14 @@ define([
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
this.collection = new VCatalogList(); this.collection = new VCatalogList();
this.collection.url = url; this.collection.url = url;
App.rNHeader.show(new BusinessCatalogHeader({ 'globalVent': that.globalVent, 'url': url, 'collection': this.collection })); App.rNHeader.show(new BusinessCatalogHeader({ 'url': url, 'collection': this.collection }));
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ 'globalVent': that.globalVent, 'url': url, 'collection': that.tagCollection })); App.rSideNav.show(new SideNavLayoutView({ 'url': url, 'collection': that.tagCollection }));
} else { } else {
App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url); App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url);
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
} }
App.rNContent.show(new BusinessCatalogDetailLayoutView({ App.rNContent.show(new BusinessCatalogDetailLayoutView({
'globalVent': that.globalVent,
'url': url, 'url': url,
'collection': this.collection 'collection': this.collection
})); }));
...@@ -139,16 +136,16 @@ define([ ...@@ -139,16 +136,16 @@ define([
'collection/VEntityList' 'collection/VEntityList'
], function(Header, DetailPageLayoutView, SideNavLayoutView, VEntityList) { ], function(Header, DetailPageLayoutView, SideNavLayoutView, VEntityList) {
this.entityCollection = new VEntityList([], {}); this.entityCollection = new VEntityList([], {});
App.rNHeader.show(new Header({ 'globalVent': that.globalVent })); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ 'globalVent': that.globalVent, 'collection': that.tagCollection })); App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection }));
} else { } else {
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
} }
App.rNContent.show(new DetailPageLayoutView({ App.rNContent.show(new DetailPageLayoutView({
'globalVent': that.globalVent,
'collection': this.entityCollection, 'collection': this.entityCollection,
'id': id, 'id': id,
'entityDefCollection': that.entityDefCollection,
})); }));
this.entityCollection.url = UrlLinks.entitiesApiUrl(id); this.entityCollection.url = UrlLinks.entitiesApiUrl(id);
this.entityCollection.fetch({ reset: true }); this.entityCollection.fetch({ reset: true });
...@@ -163,10 +160,9 @@ define([ ...@@ -163,10 +160,9 @@ define([
'views/business_catalog/SideNavLayoutView', 'views/business_catalog/SideNavLayoutView',
'views/tag/TagDetailLayoutView', 'views/tag/TagDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) { ], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) {
App.rNHeader.show(new Header({ 'globalVent': that.globalVent, 'vent': that.catalogVent })); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'globalVent': that.globalVent,
'tag': tagName, 'tag': tagName,
'collection': that.tagCollection 'collection': that.tagCollection
})); }));
...@@ -177,7 +173,6 @@ define([ ...@@ -177,7 +173,6 @@ define([
if (tagName) { if (tagName) {
App.rNContent.show(new TagDetailLayoutView({ App.rNContent.show(new TagDetailLayoutView({
'globalVent': that.globalVent,
'tag': tagName, 'tag': tagName,
'collection': that.tagCollection 'collection': that.tagCollection
})); }));
...@@ -193,10 +188,9 @@ define([ ...@@ -193,10 +188,9 @@ define([
'views/search/SearchDetailLayoutView', 'views/search/SearchDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) { ], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header({ 'globalVent': that.globalVent })); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'globalVent': that.globalVent,
'collection': that.tagCollection 'collection': that.tagCollection
})); }));
} else { } else {
...@@ -209,8 +203,8 @@ define([ ...@@ -209,8 +203,8 @@ define([
} }
if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) { if (Globals.entityCreate && Utils.getUrlState.isSearchTab()) {
App.rNContent.show(new SearchDetailLayoutView({ App.rNContent.show(new SearchDetailLayoutView({
'globalVent': that.globalVent,
'value': paramObj, 'value': paramObj,
'entityDefCollection': that.entityDefCollection,
'initialView': true 'initialView': true
})) }))
} else { } else {
...@@ -228,10 +222,9 @@ define([ ...@@ -228,10 +222,9 @@ define([
'views/search/SearchDetailLayoutView' 'views/search/SearchDetailLayoutView'
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) { ], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(); var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header({ 'globalVent': that.globalVent, 'vent': that.catalogVent })); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'globalVent': that.globalVent,
'value': paramObj, 'value': paramObj,
'collection': that.tagCollection 'collection': that.tagCollection
})); }));
...@@ -240,8 +233,8 @@ define([ ...@@ -240,8 +233,8 @@ define([
} }
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
App.rNContent.show(new SearchDetailLayoutView({ App.rNContent.show(new SearchDetailLayoutView({
'globalVent': that.globalVent,
'value': paramObj, 'value': paramObj,
'entityDefCollection': that.entityDefCollection,
'initialView': paramObj.query.trim().length === 0 'initialView': paramObj.query.trim().length === 0
})); }));
}); });
......
...@@ -36,6 +36,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -36,6 +36,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
require(['models/VTag'], function(VTag) { require(['models/VTag'], function(VTag) {
var tagModel = new VTag(); var tagModel = new VTag();
if (options && options.guid && options.tagName) { if (options && options.guid && options.tagName) {
if (options.showLoader) {
options.showLoader();
}
tagModel.deleteTag(options.guid, options.tagName, { tagModel.deleteTag(options.guid, options.tagName, {
skipDefaultError: true, skipDefaultError: true,
success: function(data) { success: function(data) {
...@@ -61,6 +64,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -61,6 +64,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (response && response.responseJSON) { if (response && response.responseJSON) {
message = response.responseJSON.errorMessage; message = response.responseJSON.errorMessage;
} }
if (options.hideLoader) {
options.hideLoader();
}
Utils.notifyError({ Utils.notifyError({
content: message content: message
}); });
...@@ -69,6 +75,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -69,6 +75,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
}); });
}; };
CommonViewFunction.findAndmergeRefEntity = function(attributeObject, referredEntities) {
_.each(attributeObject, function(obj, key) {
if (_.isObject(obj)) {
if (_.isArray(obj)) {
_.each(obj, function(value) {
_.extend(value, referredEntities[value.guid]);
});
} else {
_.extend(obj, referredEntities[obj.guid]);
}
}
});
}
CommonViewFunction.propertyTable = function(valueObject, scope, searchTable) { CommonViewFunction.propertyTable = function(valueObject, scope, searchTable) {
var table = "", var table = "",
fetchInputOutputValue = function(id) { fetchInputOutputValue = function(id) {
...@@ -77,9 +96,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -77,9 +96,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
++scope.fetchList ++scope.fetchList
} }
scope.entityModel.getEntity(id, { scope.entityModel.getEntity(id, {
success: function(data) { success: function(serverData) {
var value = "", var value = "",
deleteButton = ""; deleteButton = "",
data = serverData.entity;
if (data && data.attributes) { if (data && data.attributes) {
if (data.attributes.name) { if (data.attributes.name) {
value = data.attributes.name; value = data.attributes.name;
...@@ -118,18 +138,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -118,18 +138,19 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
key = _.escape(key) key = _.escape(key)
var keyValue = valueObject[key], var keyValue = valueObject[key],
valueOfArray = []; valueOfArray = [];
if (_.isArray(keyValue) || _.isObject(keyValue)) { if (_.isObject(keyValue)) {
if (!_.isArray(keyValue) && _.isObject(keyValue)) { if (!_.isArray(keyValue) && _.isObject(keyValue)) {
keyValue = [keyValue]; keyValue = [keyValue];
} }
var subLink = ""; var subLink = "";
for (var i = 0; i < keyValue.length; i++) { for (var i = 0; i < keyValue.length; i++) {
var inputOutputField = keyValue[i], var inputOutputField = keyValue[i],
id = inputOutputField.guid || inputOutputField.id, id = inputOutputField.guid || (_.isObject(inputOutputField.id) ? inputOutputField.id.id : inputOutputField.id),
tempLink = "", tempLink = "",
readOnly = false; status = inputOutputField.status || (_.isObject(inputOutputField.id) ? inputOutputField.id.state : inputOutputField.state),
if (Enums.entityStateReadOnly[inputOutputField.status]) { readOnly = Enums.entityStateReadOnly[status];
readOnly = inputOutputField.status if (!inputOutputField.attributes && inputOutputField.values) {
inputOutputField['attributes'] = inputOutputField.values;
} }
if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) { if (_.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) {
if (inputOutputField.indexOf("$") == -1) { if (inputOutputField.indexOf("$") == -1) {
...@@ -289,7 +310,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -289,7 +310,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (!obj) { if (!obj) {
return ""; return "";
} }
var traits = obj.classificationNames, var traits = obj.classificationNames || _.pluck(obj.classifications, 'typeName'),
url = "", url = "",
deleteHtml = "", deleteHtml = "",
html = "", html = "",
...@@ -332,7 +353,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -332,7 +353,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
CommonViewFunction.tagForTable = function(obj) { CommonViewFunction.tagForTable = function(obj) {
var traits = obj.classificationNames, var traits = obj.classificationNames || _.pluck(obj.classifications, 'typeName'),
atags = "", atags = "",
addTag = "", addTag = "",
popTag = "", popTag = "",
......
...@@ -57,7 +57,7 @@ define(['require', ...@@ -57,7 +57,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'guid', 'vent', 'entityObject')); _.extend(this, _.pick(options, 'guid', 'entity'));
this.entityCollection = new VEntityList(); this.entityCollection = new VEntityList();
this.count = 26; this.count = 26;
this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid); this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid);
...@@ -78,7 +78,6 @@ define(['require', ...@@ -78,7 +78,6 @@ define(['require',
paginatorOpts: {} paginatorOpts: {}
}; };
this.currPage = 1; this.currPage = 1;
this.bindEvents();
}, },
onRender: function() { onRender: function() {
$.extend(this.entityCollection.queryParams, { count: this.count }); $.extend(this.entityCollection.queryParams, { count: this.count });
...@@ -89,17 +88,7 @@ define(['require', ...@@ -89,17 +88,7 @@ define(['require',
}); });
this.renderTableLayoutView(); this.renderTableLayoutView();
}, },
bindEvents: function() { bindEvents: function() {},
var that = this;
this.listenTo(this.vent, "reset:collection", function() {
this.fetchCollection({
next: this.ui.nextAuditData,
nextClick: false,
previous: this.ui.previousAuditData
});
}, this);
},
getToOffset: function() { getToOffset: function() {
var toOffset = 0; var toOffset = 0;
if (this.entityCollection.models.length < this.count) { if (this.entityCollection.models.length < this.count) {
...@@ -169,7 +158,6 @@ define(['require', ...@@ -169,7 +158,6 @@ define(['require',
require(['utils/TableLayout'], function(TableLayout) { require(['utils/TableLayout'], function(TableLayout) {
var cols = new Backgrid.Columns(that.getAuditTableColumns()); var cols = new Backgrid.Columns(that.getAuditTableColumns());
that.RAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, { that.RAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
globalVent: that.globalVent,
columns: cols columns: cols
}))); })));
if (!(that.entityCollection.models.length < that.count)) { if (!(that.entityCollection.models.length < that.count)) {
...@@ -236,7 +224,7 @@ define(['require', ...@@ -236,7 +224,7 @@ define(['require',
that.action = $(e.target).data("action"); that.action = $(e.target).data("action");
var eventModel = that.entityCollection.findWhere({ 'eventKey': $(e.currentTarget).data('modalid') }).toJSON(), var eventModel = that.entityCollection.findWhere({ 'eventKey': $(e.currentTarget).data('modalid') }).toJSON(),
collectionModel = new that.entityCollection.model(eventModel), collectionModel = new that.entityCollection.model(eventModel),
view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entityObject: that.entityObject }); view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entity: that.entity });
var modal = new Modal({ var modal = new Modal({
title: that.action, title: that.action,
content: view, content: view,
......
...@@ -54,7 +54,7 @@ define(['require', ...@@ -54,7 +54,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'guid', 'entityModel', 'action', 'entityObject')); _.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -63,24 +63,27 @@ define(['require', ...@@ -63,24 +63,27 @@ define(['require',
auditTableGenerate: function() { auditTableGenerate: function() {
var that = this, var that = this,
table = ""; table = "";
if (this.entityModel.get('details').search('{') >= 0) { var detailObj = this.entityModel.get('details');
var appendedString = "{" + this.entityModel.get('details') + "}"; if (detailObj && detailObj.search(':') >= 0) {
var parseDetailsObject = detailObj;
var appendedString = "{" + detailObj + "}";
var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1]; var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1];
try { try {
var detailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData]; parseDetailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
var name = _.escape(parseDetailsObject.typeName);
} catch (err) { } catch (err) {
Utils.serverErrorHandler(); if (parseDetailsObject.search(':') >= 0) {
var name = parseDetailsObject.split(":")[1];
} }
//Append string for JSON parse
if (detailsObject) {
var valueObject = detailsObject.values;
} }
if ((this.action == Enums.auditAction.TAG_ADD || Enums.auditAction.ENTITY_CREATE) && detailsObject) { var values = parseDetailsObject.values;
this.ui.auditHeaderValue.html('<th>' + (this.action === Enums.auditAction.ENTITY_CREATE ? Enums.auditAction.ENTITY_CREATE : Enums.auditAction.TAG_ADD) + '</th>'); if (this.action && (Enums.auditAction.ENTITY_CREATE !== this.action && Enums.auditAction.ENTITY_UPDATE !== this.action) && name) {
this.ui.auditValue.html("<tr><td>" + _.escape(detailsObject.typeName) + "</td></tr>"); this.ui.auditHeaderValue.html('<th>' + this.action + '</th>');
} else { this.ui.auditValue.html("<tr><td>" + name + "</td></tr>");
} else if (parseDetailsObject && parseDetailsObject.values) {
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>'); this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>');
table = CommonViewFunction.propertyTable(valueObject, this); //CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities);
table = CommonViewFunction.propertyTable(values, this);
if (table.length) { if (table.length) {
this.ui.noData.hide(); this.ui.noData.hide();
this.ui.tableAudit.show(); this.ui.tableAudit.show();
...@@ -90,9 +93,6 @@ define(['require', ...@@ -90,9 +93,6 @@ define(['require',
this.ui.tableAudit.hide(); this.ui.tableAudit.hide();
} }
} }
} else if (this.action == Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE) {
this.ui.auditHeaderValue.html('<th>' + Enums.auditAction.TAG_DELETE || Enums.auditAction.ENTITY_DELETE + '</th>');
this.ui.auditValue.html("<tr><td>" + (this.entityObject.name || this.entityObject.qualifiedName) + "</td></tr>");
} }
}, },
......
...@@ -55,7 +55,7 @@ define(['require', ...@@ -55,7 +55,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'url', 'collection')); _.extend(this, _.pick(options, 'url', 'collection'));
this.bindEvents(); this.bindEvents();
}, },
bindEvents: function() { bindEvents: function() {
......
...@@ -29,7 +29,7 @@ define(['require', ...@@ -29,7 +29,7 @@ define(['require',
regions: {}, regions: {},
events: {}, events: {},
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'url', 'collection')); _.extend(this, _.pick(options, 'url', 'collection'));
this.value = []; this.value = [];
}, },
/** /**
......
...@@ -66,7 +66,7 @@ define(['require', ...@@ -66,7 +66,7 @@ define(['require',
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'url', 'value', 'tag', 'selectFirst','collection')); _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'collection'));
if (Globals.taxonomy) { if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4"; this.tabClass = "tab col-sm-4";
} else { } else {
...@@ -88,7 +88,6 @@ define(['require', ...@@ -88,7 +88,6 @@ define(['require',
var that = this; var that = this;
require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) { require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) {
that.RBusinessCatalogLayoutView.show(new BusinessCatalogLayoutView({ that.RBusinessCatalogLayoutView.show(new BusinessCatalogLayoutView({
globalVent: that.globalVent,
url: that.url url: that.url
})); }));
}); });
...@@ -97,7 +96,6 @@ define(['require', ...@@ -97,7 +96,6 @@ define(['require',
var that = this; var that = this;
require(['views/tag/TagLayoutView'], function(TagLayoutView) { require(['views/tag/TagLayoutView'], function(TagLayoutView) {
that.RTagLayoutView.show(new TagLayoutView({ that.RTagLayoutView.show(new TagLayoutView({
globalVent: that.globalVent,
collection: that.collection, collection: that.collection,
tag: that.tag tag: that.tag
})); }));
...@@ -107,8 +105,6 @@ define(['require', ...@@ -107,8 +105,6 @@ define(['require',
var that = this; var that = this;
require(['views/search/SearchLayoutView'], function(SearchLayoutView) { require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
that.RSearchLayoutView.show(new SearchLayoutView({ that.RSearchLayoutView.show(new SearchLayoutView({
globalVent: that.globalVent,
vent: that.vent,
value: that.value value: that.value
})); }));
}); });
......
...@@ -92,7 +92,7 @@ define(['require', ...@@ -92,7 +92,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'url', 'viewBased')); _.extend(this, _.pick(options, 'url', 'viewBased'));
this.parentCollection = new VCatalogList(); this.parentCollection = new VCatalogList();
this.childCollection = new VCatalogList(); this.childCollection = new VCatalogList();
this.taxanomy = new VCatalogList(); this.taxanomy = new VCatalogList();
......
...@@ -41,7 +41,7 @@ define(['require', ...@@ -41,7 +41,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent')); _.extend(this, options);
}, },
bindEvents: function() { bindEvents: function() {
......
...@@ -102,14 +102,14 @@ define(['require', ...@@ -102,14 +102,14 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'collection', 'vent', 'id')); _.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection'));
this.bindEvents(); this.bindEvents();
this.auditVent = new Backbone.Wreqr.EventAggregator();
}, },
bindEvents: function() { bindEvents: function() {
var that = this; var that = this;
this.listenTo(this.collection, 'reset', function() { this.listenTo(this.collection, 'reset', function() {
var collectionJSON = this.collection.first().toJSON(); var entityObject = this.collection.first().toJSON();
var collectionJSON = entityObject.entity;
if (collectionJSON && collectionJSON.guid) { if (collectionJSON && collectionJSON.guid) {
var tagGuid = collectionJSON.guid; var tagGuid = collectionJSON.guid;
this.readOnly = Enums.entityStateReadOnly[collectionJSON.status]; this.readOnly = Enums.entityStateReadOnly[collectionJSON.status];
...@@ -123,24 +123,13 @@ define(['require', ...@@ -123,24 +123,13 @@ define(['require',
} }
if (collectionJSON) { if (collectionJSON) {
if (collectionJSON.attributes) { if (collectionJSON.attributes) {
if (collectionJSON.attributes.name) { this.name = (_.escape(collectionJSON.attributes && collectionJSON.attributes.name ? collectionJSON.attributes.name : null) || _.escape(collectionJSON.displayText) || collectionJSON.guid);
this.name = collectionJSON.attributes.name
}
if (!this.name && collectionJSON.attributes.qualifiedName) {
this.name = collectionJSON.attributes.qualifiedName;
}
if (!this.name && collectionJSON.displayText) {
this.name = collectionJSON.displayText;
}
if (this.name && collectionJSON.typeName) { if (this.name && collectionJSON.typeName) {
this.name = this.name + ' (' + collectionJSON.typeName + ')'; this.name = this.name + ' (' + collectionJSON.typeName + ')';
} }
if (!this.name && collectionJSON.typeName) { if (!this.name && collectionJSON.typeName) {
this.name = collectionJSON.typeName; this.name = collectionJSON.typeName;
} }
if (!this.name && this.id) {
this.name = this.id;
}
this.description = collectionJSON.attributes.description; this.description = collectionJSON.attributes.description;
if (this.name) { if (this.name) {
this.ui.title.show(); this.ui.title.show();
...@@ -173,12 +162,27 @@ define(['require', ...@@ -173,12 +162,27 @@ define(['require',
} }
} }
this.hideLoader(); this.hideLoader();
this.renderEntityDetailTableLayoutView(); var obj = {
this.renderAuditTableLayoutView(this.id, collectionJSON.attributes); entity: collectionJSON,
this.renderTagTableLayoutView(tagGuid); referredEntities: entityObject.referredEntities,
this.renderTermTableLayoutView(tagGuid); guid: this.id,
this.renderLineageLayoutView(this.id); assetName: this.name,
this.renderSchemaLayoutView(this.id); entityDefCollection: this.entityDefCollection,
fetchCollection: this.fetchCollection.bind(that)
}
this.renderEntityDetailTableLayoutView(obj);
this.renderAuditTableLayoutView(obj);
this.renderTagTableLayoutView(obj);
this.renderTermTableLayoutView(_.extend({}, obj, { term: true }));
this.renderLineageLayoutView(obj);
// To render Schema check attribute "schemaElementsAttribute"
var schemaOptions = this.entityDefCollection.find({ name: collectionJSON.typeName }).get('options');
if (schemaOptions && schemaOptions.hasOwnProperty('schemaElementsAttribute') && schemaOptions.schemaElementsAttribute !== "") {
this.$('.schemaTable').show();
this.renderSchemaLayoutView(_.extend({}, obj, {
attribute: collectionJSON.attributes[schemaOptions.schemaElementsAttribute]
}));
}
}, this); }, this);
this.listenTo(this.collection, 'error', function(model, response) { this.listenTo(this.collection, 'error', function(model, response) {
this.$('.fontLoader').hide(); this.$('.fontLoader').hide();
...@@ -265,7 +269,6 @@ define(['require', ...@@ -265,7 +269,6 @@ define(['require',
var that = this; var that = this;
require(['views/tag/addTagModalView'], function(AddTagModalView) { require(['views/tag/addTagModalView'], function(AddTagModalView) {
var view = new AddTagModalView({ var view = new AddTagModalView({
vent: that.vent,
guid: that.id, guid: that.id,
tagList: _.map(that.collection.first().toJSON().classifications, function(obj) { tagList: _.map(that.collection.first().toJSON().classifications, function(obj) {
return obj.typeName; return obj.typeName;
...@@ -300,65 +303,40 @@ define(['require', ...@@ -300,65 +303,40 @@ define(['require',
}); });
}, },
renderEntityDetailTableLayoutView: function() { renderEntityDetailTableLayoutView: function(obj) {
var that = this; var that = this;
require(['views/entity/EntityDetailTableLayoutView'], function(EntityDetailTableLayoutView) { require(['views/entity/EntityDetailTableLayoutView'], function(EntityDetailTableLayoutView) {
that.REntityDetailTableLayoutView.show(new EntityDetailTableLayoutView({ that.REntityDetailTableLayoutView.show(new EntityDetailTableLayoutView(obj));
globalVent: that.globalVent,
collection: that.collection
}));
}); });
}, },
renderTagTableLayoutView: function(tagGuid) { renderTagTableLayoutView: function(obj) {
var that = this; var that = this;
require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) { require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) {
that.RTagTableLayoutView.show(new TagDetailTableLayoutView({ that.RTagTableLayoutView.show(new TagDetailTableLayoutView(obj));
globalVent: that.globalVent,
collection: that.collection,
guid: tagGuid,
assetName: that.name
}));
}); });
}, },
renderLineageLayoutView: function(tagGuid) { renderTermTableLayoutView: function(obj) {
var that = this; var that = this;
require(['views/graph/LineageLayoutView'], function(LineageLayoutView) { require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) {
that.RLineageLayoutView.show(new LineageLayoutView({ that.RTermTableLayoutView.show(new TagDetailTableLayoutView(obj));
globalVent: that.globalVent,
guid: tagGuid
}));
}); });
}, },
renderSchemaLayoutView: function(tagGuid) { renderLineageLayoutView: function(obj) {
var that = this; var that = this;
require(['views/schema/SchemaLayoutView'], function(SchemaLayoutView) { require(['views/graph/LineageLayoutView'], function(LineageLayoutView) {
that.RSchemaTableLayoutView.show(new SchemaLayoutView({ that.RLineageLayoutView.show(new LineageLayoutView(obj));
globalVent: that.globalVent,
guid: tagGuid
}));
}); });
}, },
renderAuditTableLayoutView: function(tagGuid, entityObject) { renderSchemaLayoutView: function(obj) {
var that = this; var that = this;
require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) { require(['views/schema/SchemaLayoutView'], function(SchemaLayoutView) {
that.RAuditTableLayoutView.show(new AuditTableLayoutView({ that.RSchemaTableLayoutView.show(new SchemaLayoutView(obj));
globalVent: that.globalVent,
guid: tagGuid,
vent: that.auditVent,
entityObject: entityObject
}));
}); });
}, },
renderTermTableLayoutView: function(tagGuid) { renderAuditTableLayoutView: function(obj) {
var that = this; var that = this;
require(['views/tag/TagDetailTableLayoutView'], function(TagDetailTableLayoutView) { require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) {
that.RTermTableLayoutView.show(new TagDetailTableLayoutView({ that.RAuditTableLayoutView.show(new AuditTableLayoutView(obj));
globalVent: that.globalVent,
collection: that.collection,
guid: tagGuid,
assetName: that.name,
term: true
}));
}); });
}, },
onClickEditEntity: function(e) { onClickEditEntity: function(e) {
......
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
define(['require', define(['require',
'backbone', 'backbone',
'hbs!tmpl/entity/EntityDetailTableLayoutView_tmpl', 'hbs!tmpl/entity/EntityDetailTableLayoutView_tmpl',
'utils/CommonViewFunction' 'utils/CommonViewFunction',
], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction) { 'models/VEntity',
], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction, VEntity) {
'use strict'; 'use strict';
var EntityDetailTableLayoutView = Backbone.Marionette.LayoutView.extend( var EntityDetailTableLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -47,9 +48,8 @@ define(['require', ...@@ -47,9 +48,8 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'collection')); _.extend(this, _.pick(options, 'entity', 'referredEntities'));
this.collectionObject = this.collection.toJSON(); this.entityModel = new VEntity({});
this.entityModel = new this.collection.model();
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -57,13 +57,14 @@ define(['require', ...@@ -57,13 +57,14 @@ define(['require',
}, },
entityTableGenerate: function() { entityTableGenerate: function() {
var that = this, var that = this,
attributeObject = this.collection.first().toJSON().attributes; attributeObject = this.entity.attributes;
if (attributeObject) { CommonViewFunction.findAndmergeRefEntity(attributeObject, that.referredEntities);
if (attributeObject && attributeObject.columns) {
var valueSorted = _.sortBy(attributeObject.columns, function(val) { var valueSorted = _.sortBy(attributeObject.columns, function(val) {
return val.attributes.position return val.attributes.position
}); });
}
attributeObject.columns = valueSorted; attributeObject.columns = valueSorted;
}
var table = CommonViewFunction.propertyTable(attributeObject, this); var table = CommonViewFunction.propertyTable(attributeObject, this);
that.ui.detailValue.append(table); that.ui.detailValue.append(table);
} }
......
...@@ -56,7 +56,7 @@ define(['require', ...@@ -56,7 +56,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'guid')); _.extend(this, _.pick(options, 'guid'));
this.entityModel = new VEntity(); this.entityModel = new VEntity();
this.collection = new VLineageList(); this.collection = new VLineageList();
this.typeMap = {}; this.typeMap = {};
......
...@@ -72,7 +72,7 @@ define(['require', ...@@ -72,7 +72,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'value')); _.extend(this, _.pick(options, 'value'));
this.typecollection = new VTagList([], {}); this.typecollection = new VTagList([], {});
this.typecollection.url = UrlLinks.typesApiUrl(); this.typecollection.url = UrlLinks.typesApiUrl();
this.type = "fulltext"; this.type = "fulltext";
......
...@@ -59,7 +59,7 @@ define(['require', ...@@ -59,7 +59,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'tag', 'collection')); _.extend(this, _.pick(options, 'tag', 'collection'));
}, },
bindEvents: function() { bindEvents: function() {
this.listenTo(this.collection, 'reset', function() { this.listenTo(this.collection, 'reset', function() {
......
...@@ -44,7 +44,7 @@ define(['require', ...@@ -44,7 +44,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'tag', 'collection')); _.extend(this, _.pick(options, 'tag', 'collection'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
......
...@@ -60,8 +60,8 @@ define(['require', ...@@ -60,8 +60,8 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'collection', 'guid', 'term', 'assetName')); _.extend(this, _.pick(options, 'entity', 'guid', 'term', 'assetName'));
this.collectionObject = this.collection.first().toJSON(); this.collectionObject = this.entity;
this.tagTermCollection = new VTagList(); this.tagTermCollection = new VTagList();
var tagorterm = _.toArray(this.collectionObject.classifications), var tagorterm = _.toArray(this.collectionObject.classifications),
tagTermList = [], tagTermList = [],
...@@ -102,7 +102,6 @@ define(['require', ...@@ -102,7 +102,6 @@ define(['require',
require(['utils/TableLayout'], function(TableLayout) { require(['utils/TableLayout'], function(TableLayout) {
var cols = new Backgrid.Columns(that.getSchemaTableColumns()); var cols = new Backgrid.Columns(that.getSchemaTableColumns());
that.RTagTermTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, { that.RTagTermTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
globalVent: that.globalVent,
columns: cols columns: cols
}))); })));
}); });
...@@ -164,7 +163,6 @@ define(['require', ...@@ -164,7 +163,6 @@ define(['require',
var that = this; var that = this;
require(['views/tag/addTagModalView'], function(AddTagModalView) { require(['views/tag/addTagModalView'], function(AddTagModalView) {
var view = new AddTagModalView({ var view = new AddTagModalView({
vent: that.vent,
guid: that.guid, guid: that.guid,
modalCollection: that.collection modalCollection: that.collection
}); });
......
...@@ -58,7 +58,7 @@ define(['require', ...@@ -58,7 +58,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'globalVent', 'tag', 'collection')); _.extend(this, _.pick(options, 'tag', 'collection'));
}, },
bindEvents: function() { bindEvents: function() {
var that = this; var that = this;
...@@ -143,7 +143,10 @@ define(['require', ...@@ -143,7 +143,10 @@ define(['require',
return model.get('name').toLowerCase(); return model.get('name').toLowerCase();
}; };
that.collection.fullCollection.sort().each(function(model) { that.collection.fullCollection.sort().each(function(model) {
var name = _.escape(model.get('name')) var name = _.escape(model.get('name'));
if (name.indexOf(".") > -1) {
return;
}
if (searchString) { if (searchString) {
if (name.search(new RegExp(searchString, "i")) != -1) { if (name.search(new RegExp(searchString, "i")) != -1) {
// data-name="<space>'<tagName>'" Space is required for DSL search Input // data-name="<space>'<tagName>'" Space is required for DSL search Input
...@@ -165,7 +168,7 @@ define(['require', ...@@ -165,7 +168,7 @@ define(['require',
}, },
onClickCreateTag: function(e) { onClickCreateTag: function(e) {
var that = this; var that = this;
$(e.currentTarget).blur(); $(e.currentTarget).attr("disabled", "true");
require([ require([
'views/tag/CreateTagLayoutView', 'views/tag/CreateTagLayoutView',
'modules/Modal' 'modules/Modal'
...@@ -184,7 +187,7 @@ define(['require', ...@@ -184,7 +187,7 @@ define(['require',
modal.$el.find('button.ok').removeAttr("disabled"); modal.$el.find('button.ok').removeAttr("disabled");
}); });
view.ui.tagName.on('keyup', function(e) { view.ui.tagName.on('keyup', function(e) {
if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value == "") { if ((e.keyCode == 8 || e.keyCode == 32 || e.keyCode == 46) && e.currentTarget.value.trim() == "") {
modal.$el.find('button.ok').attr("disabled", "true"); modal.$el.find('button.ok').attr("disabled", "true");
} }
}); });
...@@ -196,10 +199,12 @@ define(['require', ...@@ -196,10 +199,12 @@ define(['require',
}); });
}); });
modal.on('ok', function() { modal.on('ok', function() {
modal.$el.find('button.ok').attr("disabled", "true");
that.onCreateButton(view, modal); that.onCreateButton(view, modal);
}); });
modal.on('closeModal', function() { modal.on('closeModal', function() {
modal.trigger('cancel'); modal.trigger('cancel');
that.ui.createTag.removeAttr("disabled");
}); });
}); });
}, },
...@@ -243,6 +248,7 @@ define(['require', ...@@ -243,6 +248,7 @@ define(['require',
}; };
new this.collection.model().set(this.json).save(null, { new this.collection.model().set(this.json).save(null, {
success: function(model, response) { success: function(model, response) {
that.ui.createTag.removeAttr("disabled");
that.createTag = true; that.createTag = true;
that.fetchCollections(); that.fetchCollections();
that.collection.add(model) that.collection.add(model)
......
...@@ -48,7 +48,7 @@ define(['require', ...@@ -48,7 +48,7 @@ define(['require',
*/ */
initialize: function(options) { initialize: function(options) {
var that = this; var that = this;
_.extend(this, _.pick(options, 'vent', 'modalCollection', 'guid', 'callback', 'multiple', 'showLoader', 'hideLoader', 'tagList')); _.extend(this, _.pick(options, 'modalCollection', 'guid', 'callback', 'multiple', 'showLoader', 'hideLoader', 'tagList'));
this.collection = new VTagList(); this.collection = new VTagList();
this.commonCollection = new VTagList(); this.commonCollection = new VTagList();
this.asyncAttrFetchCounter = 0; this.asyncAttrFetchCounter = 0;
...@@ -81,7 +81,7 @@ define(['require', ...@@ -81,7 +81,7 @@ define(['require',
if (Enums.entityStateReadOnly[entity.model.status]) { if (Enums.entityStateReadOnly[entity.model.status]) {
obj.deletedEntity.push(name); obj.deletedEntity.push(name);
} else { } else {
if (_.indexOf(entity.model.classificationNames, tagName) === -1) { if (_.indexOf((entity.model.classificationNames || _.pluck(entity.model.classifications, 'typeName')), tagName) === -1) {
obj.guid.push(entity.model.guid) obj.guid.push(entity.model.guid)
} else { } else {
obj.skipEntity.push(name); obj.skipEntity.push(name);
......
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