Commit fa0d6dbe by kevalbhatt

ATLAS-1487 : Create Entity in UI : types list doesn't list fs_permissions…

ATLAS-1487 : Create Entity in UI : types list doesn't list fs_permissions (struct type) hence no entity could be created for it.
parent 4ed4ba15
The MIT License (MIT)
Copyright (c) 2015 Jonathan Peterson (@Eonasdan)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
...@@ -250,4 +250,7 @@ MIT License. For details, see 3party-licenses/es5-shim-LICENSE ...@@ -250,4 +250,7 @@ MIT License. For details, see 3party-licenses/es5-shim-LICENSE
This product bundles Respond, which is available under This product bundles Respond, which is available under
MIT License. For details, see 3party-licenses/Respond-LICENSE MIT License. For details, see 3party-licenses/Respond-LICENSE
This product bundles bootstrap-datepicker 4.14.30, which is available under
MIT License. For details, see 3party-licenses/bootstrap-datepicker-LICENSE
======================================================================= =======================================================================
\ No newline at end of file
...@@ -161,18 +161,22 @@ require(['App', ...@@ -161,18 +161,22 @@ require(['App',
'utils/Globals', 'utils/Globals',
'utils/UrlLinks', 'utils/UrlLinks',
'collection/VEntityList', 'collection/VEntityList',
'collection/VTagList',
'utils/Overrides', 'utils/Overrides',
'bootstrap', 'bootstrap',
'd3', 'd3',
'select2' 'select2'
], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList) { ], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
var that = this; var that = this;
this.asyncFetchCounter = 2; this.asyncFetchCounter = 3;
this.entityDefCollection = new VEntityList(); this.entityDefCollection = new VEntityList();
that.entityDefCollection.url = UrlLinks.entitiesDefApiUrl(); this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList();
this.typeHeaders.url = UrlLinks.typesApiUrl();
App.appRouter = new Router({ App.appRouter = new Router({
entityDefCollection: this.entityDefCollection entityDefCollection: this.entityDefCollection,
typeHeaders: this.typeHeaders
}); });
var startApp = function() { var startApp = function() {
...@@ -210,7 +214,15 @@ require(['App', ...@@ -210,7 +214,15 @@ require(['App',
startApp(); startApp();
} }
}); });
that.entityDefCollection.fetch({ this.entityDefCollection.fetch({
skipDefaultError: true,
complete: function() {
--that.asyncFetchCounter;
startApp();
}
});
this.typeHeaders.fetch({
skipDefaultError: true,
complete: function() { complete: function() {
--that.asyncFetchCounter; --that.asyncFetchCounter;
startApp(); startApp();
......
...@@ -42,7 +42,7 @@ define([ ...@@ -42,7 +42,7 @@ define([
'*actions': 'defaultAction' '*actions': 'defaultAction'
}, },
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'entityDefCollection')); _.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders'));
this.showRegions(); this.showRegions();
this.bindCommonEvents(); this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this); this.listenTo(this, 'route', this.postRouteExecute, this);
...@@ -111,7 +111,7 @@ define([ ...@@ -111,7 +111,7 @@ define([
this.collection.url = url; this.collection.url = url;
App.rNHeader.show(new BusinessCatalogHeader({ '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({ 'url': url, 'collection': that.tagCollection })); App.rSideNav.show(new SideNavLayoutView({ 'url': url, 'collection': that.tagCollection, 'typeHeaders': that.typeHeaders }));
} else { } else {
App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url); App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url);
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
...@@ -138,7 +138,7 @@ define([ ...@@ -138,7 +138,7 @@ define([
this.entityCollection = new VEntityList([], {}); this.entityCollection = new VEntityList([], {});
App.rNHeader.show(new Header()); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection })); App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection, 'typeHeaders': that.typeHeaders }));
} else { } else {
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
} }
...@@ -146,6 +146,7 @@ define([ ...@@ -146,6 +146,7 @@ define([
'collection': this.entityCollection, 'collection': this.entityCollection,
'id': id, 'id': id,
'entityDefCollection': that.entityDefCollection, 'entityDefCollection': that.entityDefCollection,
'typeHeaders': that.typeHeaders
})); }));
this.entityCollection.url = UrlLinks.entitiesApiUrl(id); this.entityCollection.url = UrlLinks.entitiesApiUrl(id);
this.entityCollection.fetch({ reset: true }); this.entityCollection.fetch({ reset: true });
...@@ -164,6 +165,7 @@ define([ ...@@ -164,6 +165,7 @@ define([
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'tag': tagName, 'tag': tagName,
'typeHeaders': that.typeHeaders,
'collection': that.tagCollection 'collection': that.tagCollection
})); }));
} else { } else {
...@@ -175,7 +177,8 @@ define([ ...@@ -175,7 +177,8 @@ define([
App.rNContent.show(new TagDetailLayoutView({ App.rNContent.show(new TagDetailLayoutView({
'tag': tagName, 'tag': tagName,
'entityDefCollection': that.entityDefCollection, 'entityDefCollection': that.entityDefCollection,
'collection': that.tagCollection 'collection': that.tagCollection,
'typeHeaders': that.typeHeaders
})); }));
} }
}); });
...@@ -192,7 +195,8 @@ define([ ...@@ -192,7 +195,8 @@ define([
App.rNHeader.show(new Header()); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'collection': that.tagCollection 'collection': that.tagCollection,
'typeHeaders': that.typeHeaders
})); }));
} else { } else {
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
...@@ -206,7 +210,8 @@ define([ ...@@ -206,7 +210,8 @@ define([
App.rNContent.show(new SearchDetailLayoutView({ App.rNContent.show(new SearchDetailLayoutView({
'value': paramObj, 'value': paramObj,
'entityDefCollection': that.entityDefCollection, 'entityDefCollection': that.entityDefCollection,
'initialView': true 'initialView': true,
'typeHeaders': that.typeHeaders
})) }))
} else { } else {
App.rNContent.$el.html(""); App.rNContent.$el.html("");
...@@ -227,7 +232,8 @@ define([ ...@@ -227,7 +232,8 @@ define([
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView({ App.rSideNav.show(new SideNavLayoutView({
'value': paramObj, 'value': paramObj,
'collection': that.tagCollection 'collection': that.tagCollection,
'typeHeaders': that.typeHeaders
})); }));
} else { } else {
App.rSideNav.currentView.RSearchLayoutView.currentView.manualRender(paramObj); App.rSideNav.currentView.RSearchLayoutView.currentView.manualRender(paramObj);
...@@ -236,6 +242,7 @@ define([ ...@@ -236,6 +242,7 @@ define([
App.rNContent.show(new SearchDetailLayoutView({ App.rNContent.show(new SearchDetailLayoutView({
'value': paramObj, 'value': paramObj,
'entityDefCollection': that.entityDefCollection, 'entityDefCollection': that.entityDefCollection,
'typeHeaders': that.typeHeaders,
'initialView': paramObj.query.trim().length === 0 'initialView': paramObj.query.trim().length === 0
})); }));
}); });
......
...@@ -100,15 +100,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -100,15 +100,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
var value = "", var value = "",
deleteButton = "", deleteButton = "",
data = serverData.entity; data = serverData.entity;
if (data && data.attributes) { value = Utils.getName(data);
if (data.attributes.name) {
value = data.attributes.name;
} else if (data.attributes.qualifiedName) {
value = data.attributes.qualifiedName;
} else if (data.typeName) {
value = data.typeName;
}
}
var id = ""; var id = "";
if (data.guid) { if (data.guid) {
if (Enums.entityStateReadOnly[data.status]) { if (Enums.entityStateReadOnly[data.status]) {
...@@ -117,7 +109,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -117,7 +109,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
id = data.guid; id = data.guid;
} }
if (value.length > 1) { if (value.length > 1) {
scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(value) + '</a>'); scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + value + '</a>');
} else { } else {
scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + '</a>'); scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + '</a>');
} }
...@@ -169,25 +161,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -169,25 +161,14 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
if (id && inputOutputField) { if (id && inputOutputField) {
if (inputOutputField.attributes) { var name = Utils.getName(inputOutputField);
if (inputOutputField.attributes.name) { if (name === "-") {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(inputOutputField.attributes.name) + '</a>'
} else if (inputOutputField.attributes.qualifiedName) {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(inputOutputField.attributes.qualifiedName) + '</a>'
} else if (inputOutputField.typeName) {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(inputOutputField.typeName) + '</a>'
} else {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(id) + '</a>'
}
} else if (inputOutputField.name) {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(inputOutputField.name) + '</a>';
} else if (inputOutputField.qualifiedName) {
tempLink += '<a href="#!/detailPage/' + id + '">' + _.escape(inputOutputField.qualifiedName) + '</a>'
} else {
var fetch = true; var fetch = true;
var fetchId = (_.isObject(id) ? id.id : id); var fetchId = (_.isObject(id) ? id.id : id);
fetchInputOutputValue(fetchId); fetchInputOutputValue(fetchId);
tempLink += '<div data-id="' + fetchId + '"></div>'; tempLink += '<div data-id="' + fetchId + '"></div>';
} else {
tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>'
} }
} }
if (readOnly) { if (readOnly) {
...@@ -316,7 +297,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -316,7 +297,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
html = "", html = "",
id = obj.guid, id = obj.guid,
terms = [], terms = [],
entityName = (_.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || _.escape(obj.displayText) || obj.guid); entityName = Utils.getName(obj);
if (traits) { if (traits) {
traits.map(function(term) { traits.map(function(term) {
if (term.split(".").length > 1) { if (term.split(".").length > 1) {
...@@ -334,7 +315,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -334,7 +315,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
className += "showHideDiv hide"; className += "showHideDiv hide";
} }
obj['valueUrl'] = CommonViewFunction.breadcrumbUrlMaker(obj.url); obj['valueUrl'] = CommonViewFunction.breadcrumbUrlMaker(obj.url);
html += '<div class="' + className + '" dataterm-name="' + _.escape(obj.name) + '"><div class="liContent"></div>' + obj.deleteHtml + '</div>'; html += '<div class="' + className + '" dataterm-name="' + entityName + '"><div class="liContent"></div>' + obj.deleteHtml + '</div>';
}) })
if (terms.length > 1) { if (terms.length > 1) {
html += '<div><a href="javascript:void(0)" data-id="showMoreLessTerm" class="inputTag inputTagGreen"><span>Show More </span><i class="fa fa-angle-right"></i></a></div>' html += '<div><a href="javascript:void(0)" data-id="showMoreLessTerm" class="inputTag inputTagGreen"><span>Show More </span><i class="fa fa-angle-right"></i></a></div>'
...@@ -358,7 +339,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -358,7 +339,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
addTag = "", addTag = "",
popTag = "", popTag = "",
count = 0, count = 0,
entityName = (_.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || _.escape(obj.displayText) || obj.guid); entityName = Utils.getName(obj);
if (traits) { if (traits) {
traits.map(function(tag) { traits.map(function(tag) {
if (tag.split(".").length === 1) { if (tag.split(".").length === 1) {
......
...@@ -330,7 +330,43 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button ...@@ -330,7 +330,43 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
} }
} }
} }
Utils.getName = function(collectionJSON, priorityAttribute) {
if (collectionJSON) {
if (collectionJSON.attributes && collectionJSON.attributes[priorityAttribute]) {
return _.escape(collectionJSON.attributes[priorityAttribute]);
}
if (collectionJSON[priorityAttribute]) {
return _.escape(collectionJSON[priorityAttribute]);
}
if (collectionJSON.attributes) {
if (collectionJSON.attributes.name) {
return _.escape(collectionJSON.attributes.name);
}
if (collectionJSON.attributes.qualifiedName) {
return _.escape(collectionJSON.attributes.qualifiedName);
}
if (collectionJSON.attributes.id) {
return _.escape(collectionJSON.attributes.id);
}
}
if (collectionJSON.name) {
return _.escape(collectionJSON.name);
}
if (collectionJSON.qualifiedName) {
return _.escape(collectionJSON.qualifiedName);
}
if (collectionJSON.displayText) {
return _.escape(collectionJSON.displayText);
}
if (collectionJSON.guid) {
return _.escape(collectionJSON.guid);
}
if (collectionJSON.id) {
return _.escape(collectionJSON.id);
}
}
return "-";
}
Utils.showTitleLoader = function(loaderEl, titleBoxEl) { Utils.showTitleLoader = function(loaderEl, titleBoxEl) {
loaderEl.css({ loaderEl.css({
'display': 'block', 'display': 'block',
......
...@@ -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, 'url', 'value', 'tag', 'selectFirst', 'collection')); _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'collection', 'typeHeaders'));
if (Globals.taxonomy) { if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4"; this.tabClass = "tab col-sm-4";
} else { } else {
...@@ -105,7 +105,8 @@ define(['require', ...@@ -105,7 +105,8 @@ 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({
value: that.value value: that.value,
typeHeaders: that.typeHeaders
})); }));
}); });
}, },
......
...@@ -102,7 +102,7 @@ define(['require', ...@@ -102,7 +102,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection')); _.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection', 'typeHeaders'));
this.bindEvents(); this.bindEvents();
}, },
bindEvents: function() { bindEvents: function() {
...@@ -122,18 +122,18 @@ define(['require', ...@@ -122,18 +122,18 @@ define(['require',
this.$el.removeClass('readOnly'); this.$el.removeClass('readOnly');
} }
if (collectionJSON) { if (collectionJSON) {
this.name = Utils.getName(collectionJSON);
if (collectionJSON.attributes) { if (collectionJSON.attributes) {
this.name = (_.escape(collectionJSON.attributes && collectionJSON.attributes.name ? collectionJSON.attributes.name : null) || _.escape(collectionJSON.displayText) || collectionJSON.guid);
if (this.name && collectionJSON.typeName) { if (this.name && collectionJSON.typeName) {
this.name = this.name + ' (' + collectionJSON.typeName + ')'; this.name = this.name + ' (' + _.escape(collectionJSON.typeName) + ')';
} }
if (!this.name && collectionJSON.typeName) { if (!this.name && collectionJSON.typeName) {
this.name = collectionJSON.typeName; this.name = _.escape(collectionJSON.typeName);
} }
this.description = collectionJSON.attributes.description; this.description = collectionJSON.attributes.description;
if (this.name) { if (this.name) {
this.ui.title.show(); this.ui.title.show();
var titleName = '<span>' + _.escape(this.name) + '</span>'; var titleName = '<span>' + this.name + '</span>';
if (this.readOnly) { if (this.readOnly) {
titleName += '<button title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i> Deleted</button>'; titleName += '<button title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i> Deleted</button>';
} }
...@@ -348,6 +348,7 @@ define(['require', ...@@ -348,6 +348,7 @@ define(['require',
var view = new CreateEntityLayoutView({ var view = new CreateEntityLayoutView({
guid: that.id, guid: that.id,
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
callback: function() { callback: function() {
that.fetchCollection(); that.fetchCollection();
} }
......
...@@ -43,7 +43,7 @@ define(['require', ...@@ -43,7 +43,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection')); _.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -65,7 +65,8 @@ define(['require', ...@@ -65,7 +65,8 @@ define(['require',
value: value, value: value,
tag: that.tag, tag: that.tag,
initialView: that.initialView, initialView: that.initialView,
entityDefCollection: that.entityDefCollection entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders
})); }));
} }
}); });
......
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
define(['require', define(['require',
'backbone', 'backbone',
'hbs!tmpl/search/SearchLayoutView_tmpl', 'hbs!tmpl/search/SearchLayoutView_tmpl',
'collection/VTagList',
'utils/Utils', 'utils/Utils',
'utils/UrlLinks', 'utils/UrlLinks',
'utils/Globals', 'utils/Globals',
], function(require, Backbone, SearchLayoutViewTmpl, VTagList, Utils, UrlLinks, Globals) { ], function(require, Backbone, SearchLayoutViewTmpl, Utils, UrlLinks, Globals) {
'use strict'; 'use strict';
var SearchLayoutView = Backbone.Marionette.LayoutView.extend( var SearchLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -72,9 +71,7 @@ define(['require', ...@@ -72,9 +71,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value')); _.extend(this, _.pick(options, 'value', 'typeHeaders'));
this.typecollection = new VTagList([], {});
this.typecollection.url = UrlLinks.typesApiUrl();
this.type = "fulltext"; this.type = "fulltext";
var param = Utils.getUrlState.getQueryParams(); var param = Utils.getUrlState.getQueryParams();
this.query = { this.query = {
...@@ -89,10 +86,9 @@ define(['require', ...@@ -89,10 +86,9 @@ define(['require',
if (param && param.query && param.searchType) { if (param && param.query && param.searchType) {
this.query[param.searchType].query = param.query; this.query[param.searchType].query = param.query;
} }
this.bindEvents();
}, },
bindEvents: function(param) { bindEvents: function(param) {
this.listenTo(this.typecollection, "reset", function(value) { this.listenTo(this.typeHeaders, "reset", function(value) {
this.renderTypeList(); this.renderTypeList();
this.setValues(); this.setValues();
this.ui.typeLov.select2({ this.ui.typeLov.select2({
...@@ -104,11 +100,17 @@ define(['require', ...@@ -104,11 +100,17 @@ define(['require',
onRender: function() { onRender: function() {
// array of tags which is coming from url // array of tags which is coming from url
this.$('.typeLOV').hide(); this.$('.typeLOV').hide();
this.fetchCollection(); this.renderTypeList();
this.setValues();
this.ui.typeLov.select2({
placeholder: "Search For",
allowClear: true
});
this.ui.searchBtn.attr("disabled", "true"); this.ui.searchBtn.attr("disabled", "true");
this.bindEvents();
}, },
fetchCollection: function(value) { fetchCollection: function(value) {
this.typecollection.fetch({ reset: true }); this.typeHeaders.fetch({ reset: true });
}, },
onRefreshButton: function() { onRefreshButton: function() {
this.fetchCollection(); this.fetchCollection();
...@@ -120,12 +122,12 @@ define(['require', ...@@ -120,12 +122,12 @@ define(['require',
var that = this; var that = this;
this.ui.typeLov.empty(); this.ui.typeLov.empty();
var str = '<option></option>'; var str = '<option></option>';
this.typecollection.fullCollection.comparator = function(model) { this.typeHeaders.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase(); return Utils.getName(model.toJSON(), 'name').toLowerCase();
} }
this.typecollection.fullCollection.sort().each(function(model) { this.typeHeaders.fullCollection.sort().each(function(model) {
if (model.get('category') == 'ENTITY') { if (model.get('category') == 'ENTITY') {
str += '<option>' + _.escape(model.get("name")) + '</option>'; str += '<option>' + (Utils.getName(model.toJSON(), 'name')) + '</option>';
} }
}); });
that.ui.typeLov.html(str); that.ui.typeLov.html(str);
......
...@@ -122,7 +122,7 @@ define(['require', ...@@ -122,7 +122,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection')); _.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders'));
var pagination = ""; var pagination = "";
this.entityModel = new VEntity(); this.entityModel = new VEntity();
this.searchCollection = new VSearchList(); this.searchCollection = new VSearchList();
...@@ -355,7 +355,8 @@ define(['require', ...@@ -355,7 +355,8 @@ define(['require',
var obj = model.get('entity'); var obj = model.get('entity');
} }
var nameHtml = ""; var nameHtml = "";
var name = (_.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || _.escape(obj.displayText) || obj.guid)
var name = Utils.getName(obj);
if (obj.guid) { if (obj.guid) {
nameHtml = '<a title="' + name + '" href="#!/detailPage/' + obj.guid + '">' + name + '</a>'; nameHtml = '<a title="' + name + '" href="#!/detailPage/' + obj.guid + '">' + name + '</a>';
} else { } else {
...@@ -651,6 +652,7 @@ define(['require', ...@@ -651,6 +652,7 @@ define(['require',
var view = new CreateEntityLayoutView({ var view = new CreateEntityLayoutView({
guid: guid, guid: guid,
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
callback: function() { callback: function() {
that.fetchCollection(); that.fetchCollection();
} }
...@@ -665,6 +667,7 @@ define(['require', ...@@ -665,6 +667,7 @@ define(['require',
], function(CreateEntityLayoutView) { ], function(CreateEntityLayoutView) {
var view = new CreateEntityLayoutView({ var view = new CreateEntityLayoutView({
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
callback: function() { callback: function() {
that.fetchCollection(); that.fetchCollection();
} }
......
...@@ -98,7 +98,7 @@ define(['require', ...@@ -98,7 +98,7 @@ define(['require',
that = this; that = this;
this.ui.parentTag.empty(); this.ui.parentTag.empty();
this.tagCollection.fullCollection.each(function(val) { this.tagCollection.fullCollection.each(function(val) {
str += '<option>' + _.escape(val.get("name")) + '</option>'; str += '<option>' + (Utils.getName(val.toJSON())) + '</option>';
}); });
that.ui.parentTag.html(str); that.ui.parentTag.html(str);
// IE9 support // IE9 support
......
...@@ -101,9 +101,8 @@ define(['require', ...@@ -101,9 +101,8 @@ define(['require',
renderTagDetail: function() { renderTagDetail: function() {
var attributeData = "", var attributeData = "",
attributeDefs = this.model.get("attributeDefs"); attributeDefs = this.model.get("attributeDefs");
if (this.model.get("name")) {
this.ui.title.html('<span>' + _.escape(this.model.get("name")) + '</span>'); this.ui.title.html('<span>' + (Utils.getName(this.model.toJSON())) + '</span>');
}
if (this.model.get("description")) { if (this.model.get("description")) {
this.ui.description.text(this.model.get("description")); this.ui.description.text(this.model.get("description"));
} }
...@@ -112,7 +111,7 @@ define(['require', ...@@ -112,7 +111,7 @@ define(['require',
attributeDefs = [attributeDefs]; attributeDefs = [attributeDefs];
} }
_.each(attributeDefs, function(value, key) { _.each(attributeDefs, function(value, key) {
attributeData += '<span class="inputAttribute">' + _.escape(value.name) + '</span>'; attributeData += '<span class="inputAttribute">' + (Utils.getName(value)) + '</span>';
}); });
this.ui.showAttribute.html(attributeData); this.ui.showAttribute.html(attributeData);
} }
......
...@@ -44,7 +44,7 @@ define(['require', ...@@ -44,7 +44,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection')); _.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -61,7 +61,8 @@ define(['require', ...@@ -61,7 +61,8 @@ define(['require',
that.RSearchResultLayoutView.show(new SearchResultLayoutView({ that.RSearchResultLayoutView.show(new SearchResultLayoutView({
value: value, value: value,
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
tag: that.tag tag: that.tag,
typeHeaders: that.typeHeaders
})); }));
}); });
}, },
......
...@@ -140,10 +140,10 @@ define(['require', ...@@ -140,10 +140,10 @@ define(['require',
var that = this, var that = this,
str = ''; str = '';
that.collection.fullCollection.comparator = function(model) { that.collection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase(); return Utils.getName(model.toJSON(), 'name').toLowerCase();
}; };
that.collection.fullCollection.sort().each(function(model) { that.collection.fullCollection.sort().each(function(model) {
var name = _.escape(model.get('name')); var name = Utils.getName(model.toJSON(), 'name');
if (name.indexOf(".") > -1) { if (name.indexOf(".") > -1) {
return; return;
} }
......
...@@ -77,7 +77,7 @@ define(['require', ...@@ -77,7 +77,7 @@ define(['require',
} }
if (that.multiple) { if (that.multiple) {
_.each(that.multiple, function(entity, i) { _.each(that.multiple, function(entity, i) {
var name = (_.escape(entity.model.attributes && entity.model.attributes.name ? entity.model.attributes.name : null) || _.escape(entity.model.displayText) || entity.model.guid) var name = Utils.getName(entity.model);
if (Enums.entityStateReadOnly[entity.model.status]) { if (Enums.entityStateReadOnly[entity.model.status]) {
obj.deletedEntity.push(name); obj.deletedEntity.push(name);
} else { } else {
...@@ -187,13 +187,15 @@ define(['require', ...@@ -187,13 +187,15 @@ define(['require',
tagsCollection: function() { tagsCollection: function() {
var that = this; var that = this;
this.collection.fullCollection.comparator = function(model) { this.collection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase(); return Utils.getName(model.toJSON(), 'name').toLowerCase();
} }
var str = '<option selected="selected" disabled="disabled">-- Select a tag from the dropdown list --</option>'; var str = '<option selected="selected" disabled="disabled">-- Select a tag from the dropdown list --</option>';
this.collection.fullCollection.sort().each(function(obj, key) { this.collection.fullCollection.sort().each(function(obj, key) {
var name = Utils.getName(obj.toJSON(), 'name');
// using obj.get('name') insted of name variable because if html is presen in name then escaped name will not found in tagList.
if (_.indexOf(that.tagList, obj.get('name')) === -1) { if (_.indexOf(that.tagList, obj.get('name')) === -1) {
str += '<option>' + _.escape(obj.get('name')) + '</option>'; str += '<option>' + name + '</option>';
} }
}); });
this.ui.addTagOptions.html(str); this.ui.addTagOptions.html(str);
...@@ -233,8 +235,9 @@ define(['require', ...@@ -233,8 +235,9 @@ define(['require',
if (this.commonCollection.models[0]) { if (this.commonCollection.models[0]) {
if (this.commonCollection.models[0].get('attributeDefs')) { if (this.commonCollection.models[0].get('attributeDefs')) {
_.each(this.commonCollection.models[0].get('attributeDefs'), function(obj) { _.each(this.commonCollection.models[0].get('attributeDefs'), function(obj) {
that.ui.tagAttribute.append('<div class="form-group"><label>' + _.escape(obj.name) + '</label>' + var name = Utils.getName(obj, 'name');
'<input type="text" class="form-control attributeInputVal attrName" data-key="' + obj.name + '" ></input></div>'); that.ui.tagAttribute.append('<div class="form-group"><label>' + name + '</label>' +
'<input type="text" class="form-control attributeInputVal attrName" data-key="' + name + '" ></input></div>');
}); });
} }
......
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