ATLAS-1487 : Create Entity in UI : types list doesn't list fs_permissions (struct type) hence no entity could be created for it.
This commit is contained in:
parent
4ed4ba15ad
commit
fa0d6dbef0
|
|
@ -0,0 +1,21 @@
|
|||
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.
|
||||
3
LICENSE
3
LICENSE
|
|
@ -250,4 +250,7 @@ MIT License. For details, see 3party-licenses/es5-shim-LICENSE
|
|||
|
||||
This product bundles Respond, which is available under
|
||||
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
|
||||
=======================================================================
|
||||
|
|
@ -161,18 +161,22 @@ require(['App',
|
|||
'utils/Globals',
|
||||
'utils/UrlLinks',
|
||||
'collection/VEntityList',
|
||||
'collection/VTagList',
|
||||
'utils/Overrides',
|
||||
'bootstrap',
|
||||
'd3',
|
||||
'select2'
|
||||
], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList) {
|
||||
], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
|
||||
var that = this;
|
||||
this.asyncFetchCounter = 2;
|
||||
this.asyncFetchCounter = 3;
|
||||
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({
|
||||
entityDefCollection: this.entityDefCollection
|
||||
entityDefCollection: this.entityDefCollection,
|
||||
typeHeaders: this.typeHeaders
|
||||
});
|
||||
|
||||
var startApp = function() {
|
||||
|
|
@ -210,7 +214,15 @@ require(['App',
|
|||
startApp();
|
||||
}
|
||||
});
|
||||
that.entityDefCollection.fetch({
|
||||
this.entityDefCollection.fetch({
|
||||
skipDefaultError: true,
|
||||
complete: function() {
|
||||
--that.asyncFetchCounter;
|
||||
startApp();
|
||||
}
|
||||
});
|
||||
this.typeHeaders.fetch({
|
||||
skipDefaultError: true,
|
||||
complete: function() {
|
||||
--that.asyncFetchCounter;
|
||||
startApp();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ define([
|
|||
'*actions': 'defaultAction'
|
||||
},
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders'));
|
||||
this.showRegions();
|
||||
this.bindCommonEvents();
|
||||
this.listenTo(this, 'route', this.postRouteExecute, this);
|
||||
|
|
@ -111,7 +111,7 @@ define([
|
|||
this.collection.url = url;
|
||||
App.rNHeader.show(new BusinessCatalogHeader({ 'url': url, 'collection': this.collection }));
|
||||
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 {
|
||||
App.rSideNav.currentView.RBusinessCatalogLayoutView.currentView.manualRender("/" + url);
|
||||
App.rSideNav.currentView.selectTab();
|
||||
|
|
@ -138,7 +138,7 @@ define([
|
|||
this.entityCollection = new VEntityList([], {});
|
||||
App.rNHeader.show(new Header());
|
||||
if (!App.rSideNav.currentView) {
|
||||
App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection }));
|
||||
App.rSideNav.show(new SideNavLayoutView({ 'collection': that.tagCollection, 'typeHeaders': that.typeHeaders }));
|
||||
} else {
|
||||
App.rSideNav.currentView.selectTab();
|
||||
}
|
||||
|
|
@ -146,6 +146,7 @@ define([
|
|||
'collection': this.entityCollection,
|
||||
'id': id,
|
||||
'entityDefCollection': that.entityDefCollection,
|
||||
'typeHeaders': that.typeHeaders
|
||||
}));
|
||||
this.entityCollection.url = UrlLinks.entitiesApiUrl(id);
|
||||
this.entityCollection.fetch({ reset: true });
|
||||
|
|
@ -164,6 +165,7 @@ define([
|
|||
if (!App.rSideNav.currentView) {
|
||||
App.rSideNav.show(new SideNavLayoutView({
|
||||
'tag': tagName,
|
||||
'typeHeaders': that.typeHeaders,
|
||||
'collection': that.tagCollection
|
||||
}));
|
||||
} else {
|
||||
|
|
@ -175,7 +177,8 @@ define([
|
|||
App.rNContent.show(new TagDetailLayoutView({
|
||||
'tag': tagName,
|
||||
'entityDefCollection': that.entityDefCollection,
|
||||
'collection': that.tagCollection
|
||||
'collection': that.tagCollection,
|
||||
'typeHeaders': that.typeHeaders
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
|
@ -192,7 +195,8 @@ define([
|
|||
App.rNHeader.show(new Header());
|
||||
if (!App.rSideNav.currentView) {
|
||||
App.rSideNav.show(new SideNavLayoutView({
|
||||
'collection': that.tagCollection
|
||||
'collection': that.tagCollection,
|
||||
'typeHeaders': that.typeHeaders
|
||||
}));
|
||||
} else {
|
||||
App.rSideNav.currentView.selectTab();
|
||||
|
|
@ -206,7 +210,8 @@ define([
|
|||
App.rNContent.show(new SearchDetailLayoutView({
|
||||
'value': paramObj,
|
||||
'entityDefCollection': that.entityDefCollection,
|
||||
'initialView': true
|
||||
'initialView': true,
|
||||
'typeHeaders': that.typeHeaders
|
||||
}))
|
||||
} else {
|
||||
App.rNContent.$el.html("");
|
||||
|
|
@ -227,7 +232,8 @@ define([
|
|||
if (!App.rSideNav.currentView) {
|
||||
App.rSideNav.show(new SideNavLayoutView({
|
||||
'value': paramObj,
|
||||
'collection': that.tagCollection
|
||||
'collection': that.tagCollection,
|
||||
'typeHeaders': that.typeHeaders
|
||||
}));
|
||||
} else {
|
||||
App.rSideNav.currentView.RSearchLayoutView.currentView.manualRender(paramObj);
|
||||
|
|
@ -236,6 +242,7 @@ define([
|
|||
App.rNContent.show(new SearchDetailLayoutView({
|
||||
'value': paramObj,
|
||||
'entityDefCollection': that.entityDefCollection,
|
||||
'typeHeaders': that.typeHeaders,
|
||||
'initialView': paramObj.query.trim().length === 0
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,15 +100,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
|
|||
var value = "",
|
||||
deleteButton = "",
|
||||
data = serverData.entity;
|
||||
if (data && data.attributes) {
|
||||
if (data.attributes.name) {
|
||||
value = data.attributes.name;
|
||||
} else if (data.attributes.qualifiedName) {
|
||||
value = data.attributes.qualifiedName;
|
||||
} else if (data.typeName) {
|
||||
value = data.typeName;
|
||||
}
|
||||
}
|
||||
value = Utils.getName(data);
|
||||
var id = "";
|
||||
if (data.guid) {
|
||||
if (Enums.entityStateReadOnly[data.status]) {
|
||||
|
|
@ -117,7 +109,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
|
|||
id = data.guid;
|
||||
}
|
||||
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 {
|
||||
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
|
|||
}
|
||||
|
||||
if (id && inputOutputField) {
|
||||
if (inputOutputField.attributes) {
|
||||
if (inputOutputField.attributes.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 name = Utils.getName(inputOutputField);
|
||||
if (name === "-") {
|
||||
var fetch = true;
|
||||
var fetchId = (_.isObject(id) ? id.id : id);
|
||||
fetchInputOutputValue(fetchId);
|
||||
tempLink += '<div data-id="' + fetchId + '"></div>';
|
||||
} else {
|
||||
tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>'
|
||||
}
|
||||
}
|
||||
if (readOnly) {
|
||||
|
|
@ -316,7 +297,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
|
|||
html = "",
|
||||
id = obj.guid,
|
||||
terms = [],
|
||||
entityName = (_.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || _.escape(obj.displayText) || obj.guid);
|
||||
entityName = Utils.getName(obj);
|
||||
if (traits) {
|
||||
traits.map(function(term) {
|
||||
if (term.split(".").length > 1) {
|
||||
|
|
@ -334,7 +315,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
|
|||
className += "showHideDiv hide";
|
||||
}
|
||||
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) {
|
||||
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
|
|||
addTag = "",
|
||||
popTag = "",
|
||||
count = 0,
|
||||
entityName = (_.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || _.escape(obj.displayText) || obj.guid);
|
||||
entityName = Utils.getName(obj);
|
||||
if (traits) {
|
||||
traits.map(function(tag) {
|
||||
if (tag.split(".").length === 1) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
loaderEl.css({
|
||||
'display': 'block',
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ define(['require',
|
|||
return events;
|
||||
},
|
||||
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) {
|
||||
this.tabClass = "tab col-sm-4";
|
||||
} else {
|
||||
|
|
@ -105,7 +105,8 @@ define(['require',
|
|||
var that = this;
|
||||
require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
|
||||
that.RSearchLayoutView.show(new SearchLayoutView({
|
||||
value: that.value
|
||||
value: that.value,
|
||||
typeHeaders: that.typeHeaders
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'collection', 'id', 'entityDefCollection', 'typeHeaders'));
|
||||
this.bindEvents();
|
||||
},
|
||||
bindEvents: function() {
|
||||
|
|
@ -122,18 +122,18 @@ define(['require',
|
|||
this.$el.removeClass('readOnly');
|
||||
}
|
||||
if (collectionJSON) {
|
||||
this.name = Utils.getName(collectionJSON);
|
||||
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) {
|
||||
this.name = this.name + ' (' + collectionJSON.typeName + ')';
|
||||
this.name = this.name + ' (' + _.escape(collectionJSON.typeName) + ')';
|
||||
}
|
||||
if (!this.name && collectionJSON.typeName) {
|
||||
this.name = collectionJSON.typeName;
|
||||
this.name = _.escape(collectionJSON.typeName);
|
||||
}
|
||||
this.description = collectionJSON.attributes.description;
|
||||
if (this.name) {
|
||||
this.ui.title.show();
|
||||
var titleName = '<span>' + _.escape(this.name) + '</span>';
|
||||
var titleName = '<span>' + this.name + '</span>';
|
||||
if (this.readOnly) {
|
||||
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',
|
|||
var view = new CreateEntityLayoutView({
|
||||
guid: that.id,
|
||||
entityDefCollection: that.entityDefCollection,
|
||||
typeHeaders: that.typeHeaders,
|
||||
callback: function() {
|
||||
that.fetchCollection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'guid', 'callback', 'showLoader', 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'guid', 'callback', 'showLoader', 'entityDefCollection', 'typeHeaders'));
|
||||
var that = this,
|
||||
entityTitle, okLabel;
|
||||
this.searchCollection = new VSearchList();
|
||||
|
|
@ -150,16 +150,22 @@ define(['require',
|
|||
}, this);
|
||||
this.ui.entityInputData.on("keyup", "textarea", function() {
|
||||
var value = this.value;
|
||||
try {
|
||||
if (value && value.length) {
|
||||
JSON.parse(value);
|
||||
$(this).removeClass('errorClass');
|
||||
that.modal.$el.find('button.ok').prop("disabled", false);
|
||||
if (!value.length && $(this).hasClass('false')) {
|
||||
$(this).removeClass('errorClass');
|
||||
that.modal.$el.find('button.ok').prop("disabled", false);
|
||||
} else {
|
||||
try {
|
||||
if (value && value.length) {
|
||||
JSON.parse(value);
|
||||
$(this).removeClass('errorClass');
|
||||
that.modal.$el.find('button.ok').prop("disabled", false);
|
||||
}
|
||||
} catch (err) {
|
||||
$(this).addClass('errorClass');
|
||||
that.modal.$el.find('button.ok').prop("disabled", true);
|
||||
}
|
||||
} catch (err) {
|
||||
$(this).addClass('errorClass');
|
||||
that.modal.$el.find('button.ok').prop("disabled", true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (this.guid) {
|
||||
|
|
@ -195,7 +201,7 @@ define(['require',
|
|||
},
|
||||
bindNonRequiredField: function() {
|
||||
var that = this;
|
||||
this.ui.entityInputData.off('keyup change dp.change', 'input.false,select.false').on('keyup change dp.change', 'input.false,select.false', function(e) {
|
||||
this.ui.entityInputData.off('keyup change', 'input.false,select.false').on('keyup change', 'input.false,select.false', function(e) {
|
||||
if (that.modal.$el.find('button.ok').prop('disabled') && that.ui.entityInputData.find('.errorClass').length === 0) {
|
||||
that.modal.$el.find('button.ok').prop("disabled", false);
|
||||
}
|
||||
|
|
@ -221,7 +227,7 @@ define(['require',
|
|||
value;
|
||||
if (this.guid) {
|
||||
this.collection.each(function(val) {
|
||||
name += _.escape(val.get("entity").attributes.name) || _.escape(val.get("entity").attributes.qualifiedName) || _.escape(val.get("entity").attributes.id);
|
||||
name += Utils.getName(val.get("entity"));
|
||||
that.entityData = val;
|
||||
});
|
||||
this.ui.assetName.html(name);
|
||||
|
|
@ -232,12 +238,13 @@ define(['require',
|
|||
return model.get('name');
|
||||
}
|
||||
this.entityDefCollection.fullCollection.sort().each(function(val) {
|
||||
var name = Utils.getName(val.toJSON());
|
||||
if (Globals.entityTypeConfList) {
|
||||
if (_.isEmptyArray(Globals.entityTypeConfList)) {
|
||||
str += '<option>' + _.escape(val.get("name")) + '</option>';
|
||||
str += '<option>' + name + '</option>';
|
||||
} else {
|
||||
if (_.contains(Globals.entityTypeConfList, val.get("name"))) {
|
||||
str += '<option>' + _.escape(val.get("name")) + '</option>';
|
||||
str += '<option>' + name + '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -321,7 +328,7 @@ define(['require',
|
|||
var that = this;
|
||||
this.collection.url = UrlLinks.entitiesDefApiUrl(entityName);
|
||||
this.collection.modelAttrName = 'attributeDefs';
|
||||
this.asyncFetchCounter++;
|
||||
++this.asyncFetchCounter;
|
||||
this.collection.fetch({
|
||||
success: function(model, data) {
|
||||
that.subAttributeData(data);
|
||||
|
|
@ -339,7 +346,8 @@ define(['require',
|
|||
this.$('input[data-type="date"]').each(function() {
|
||||
if (!$(this).data('datepicker')) {
|
||||
$(this).datetimepicker({
|
||||
format: 'DD MMMM YYYY'
|
||||
format: 'DD MMMM YYYY',
|
||||
keepInvalid: true
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -411,7 +419,7 @@ define(['require',
|
|||
getSelect: function(value, entityValue) {
|
||||
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">' +
|
||||
'<option disabled="disabled">--Select true or false--</option><option value="true">true</option>' +
|
||||
'<option value="">--Select true or false--</option><option value="true">true</option>' +
|
||||
'<option value="false">false</option></select>';
|
||||
} else {
|
||||
var splitTypeName = value.typeName.split("<");
|
||||
|
|
@ -481,7 +489,12 @@ define(['require',
|
|||
} else if (typeName.indexOf("map") > -1) {
|
||||
return this.getTextArea(value, entityValue);
|
||||
} else {
|
||||
return this.getInput(value, entityValue);
|
||||
var typeNameCategory = this.typeHeaders.fullCollection.findWhere({ name: typeName });
|
||||
if (typeNameCategory && typeNameCategory.get('category') === 'STRUCT') {
|
||||
return this.getTextArea(value, entityValue);
|
||||
} else {
|
||||
return this.getInput(value, entityValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
okButton: function() {
|
||||
|
|
@ -546,7 +559,7 @@ define(['require',
|
|||
if ($(this).hasClass("true")) {
|
||||
if (value == "" || value == undefined) {
|
||||
if ($(this).data('select2')) {
|
||||
$(this).data('select2').$container.addClass("errorClass")
|
||||
$(this).data('select2').$container.find('.select2-selection').addClass("errorClass")
|
||||
} else {
|
||||
$(this).addClass('errorClass');
|
||||
}
|
||||
|
|
@ -557,6 +570,7 @@ define(['require',
|
|||
}
|
||||
var dataTypeEnitity = $(this).data('type');
|
||||
var datakeyEntity = $(this).data('key');
|
||||
var typeNameCategory = that.typeHeaders.fullCollection.findWhere({ name: dataTypeEnitity });
|
||||
|
||||
// Extract Data
|
||||
if (dataTypeEnitity && datakeyEntity) {
|
||||
|
|
@ -564,7 +578,7 @@ define(['require',
|
|||
entity[datakeyEntity] = extractValue(value);
|
||||
} else if (typeof dataTypeEnitity === 'string' && datakeyEntity.indexOf("Time") > -1) {
|
||||
entity[datakeyEntity] = Date.parse(value);
|
||||
} else if (dataTypeEnitity.indexOf("map") > -1) {
|
||||
} else if (dataTypeEnitity.indexOf("map") > -1 || (typeNameCategory && typeNameCategory.get('category') === 'STRUCT')) {
|
||||
try {
|
||||
if (value && value.length) {
|
||||
parseData = JSON.parse(value);
|
||||
|
|
@ -587,7 +601,6 @@ define(['require',
|
|||
} else {
|
||||
entity[datakeyEntity] = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -644,45 +657,53 @@ define(['require',
|
|||
hideLoader: function() {
|
||||
this.$('.entityLoader').hide();
|
||||
this.$('.entityInputData').show();
|
||||
// To enable scroll after selecting value from select2.
|
||||
this.ui.entityList.select2('open');
|
||||
this.ui.entityList.select2('close');
|
||||
},
|
||||
addJsonSearchData: function() {
|
||||
if (this.asyncFetchLOVCounter === 0) {
|
||||
var that = this,
|
||||
queryText,
|
||||
str = '';
|
||||
// Add oprions in select
|
||||
if (this.selectStoreCollection.length) {
|
||||
var appendOption = function(optionValue) {
|
||||
str = '',
|
||||
appendOption = function(optionValue) {
|
||||
var obj = optionValue.toJSON(),
|
||||
labelName = (_.escape(obj.displayText) || _.escape(obj.attributes && obj.attributes.name ? obj.attributes.name : null) || obj.guid);
|
||||
labelName = Utils.getName(obj, 'displayText');
|
||||
if (obj && obj.queryText) {
|
||||
optionValue.set('labelName', labelName);
|
||||
if (labelName) {
|
||||
var str = '<option>' + _.escape(labelName) + '</option>';
|
||||
var str = '<option>' + labelName + '</option>';
|
||||
}
|
||||
// appending value to all same droupdown
|
||||
that.$('select[data-queryData="' + obj.queryText + '"]').append(str);
|
||||
}
|
||||
}
|
||||
_.each(this.selectStoreCollection.models, function(value) {
|
||||
var obj = value.toJSON();
|
||||
if (obj.status) {
|
||||
if (!Enums.entityStateReadOnly[obj.status]) {
|
||||
appendOption(value);
|
||||
}
|
||||
} else {
|
||||
appendOption(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$('select[data-id="entitySelectData"]').each(function(value, key) {
|
||||
this.$('select[data-id="entitySelectData"]').each(function(value, key) {
|
||||
var $this = $(this),
|
||||
keyData = $(this).data("key"),
|
||||
typeData = $(this).data("type"),
|
||||
queryData = $(this).data("querydata"),
|
||||
placeholderName = "Select a " + typeData + " from the dropdown list";
|
||||
|
||||
//add options.
|
||||
if (that.selectStoreCollection.length && !this.options.length) {
|
||||
that.selectStoreCollection.where({ queryText: queryData }).forEach(function(model) {
|
||||
var obj = model.toJSON();
|
||||
if (obj.status) {
|
||||
if (!Enums.entityStateReadOnly[obj.status]) {
|
||||
appendOption(model);
|
||||
}
|
||||
} else {
|
||||
appendOption(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true));
|
||||
|
||||
// Select Value.
|
||||
if (that.guid) {
|
||||
var dataValue = that.entityData.get("entity").attributes[keyData];
|
||||
var selectedValue = [];
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders'));
|
||||
},
|
||||
bindEvents: function() {},
|
||||
onRender: function() {
|
||||
|
|
@ -65,7 +65,8 @@ define(['require',
|
|||
value: value,
|
||||
tag: that.tag,
|
||||
initialView: that.initialView,
|
||||
entityDefCollection: that.entityDefCollection
|
||||
entityDefCollection: that.entityDefCollection,
|
||||
typeHeaders: that.typeHeaders
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@
|
|||
define(['require',
|
||||
'backbone',
|
||||
'hbs!tmpl/search/SearchLayoutView_tmpl',
|
||||
'collection/VTagList',
|
||||
'utils/Utils',
|
||||
'utils/UrlLinks',
|
||||
'utils/Globals',
|
||||
], function(require, Backbone, SearchLayoutViewTmpl, VTagList, Utils, UrlLinks, Globals) {
|
||||
], function(require, Backbone, SearchLayoutViewTmpl, Utils, UrlLinks, Globals) {
|
||||
'use strict';
|
||||
|
||||
var SearchLayoutView = Backbone.Marionette.LayoutView.extend(
|
||||
|
|
@ -72,9 +71,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'value'));
|
||||
this.typecollection = new VTagList([], {});
|
||||
this.typecollection.url = UrlLinks.typesApiUrl();
|
||||
_.extend(this, _.pick(options, 'value', 'typeHeaders'));
|
||||
this.type = "fulltext";
|
||||
var param = Utils.getUrlState.getQueryParams();
|
||||
this.query = {
|
||||
|
|
@ -89,10 +86,9 @@ define(['require',
|
|||
if (param && param.query && param.searchType) {
|
||||
this.query[param.searchType].query = param.query;
|
||||
}
|
||||
this.bindEvents();
|
||||
},
|
||||
bindEvents: function(param) {
|
||||
this.listenTo(this.typecollection, "reset", function(value) {
|
||||
this.listenTo(this.typeHeaders, "reset", function(value) {
|
||||
this.renderTypeList();
|
||||
this.setValues();
|
||||
this.ui.typeLov.select2({
|
||||
|
|
@ -104,11 +100,17 @@ define(['require',
|
|||
onRender: function() {
|
||||
// array of tags which is coming from url
|
||||
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.bindEvents();
|
||||
},
|
||||
fetchCollection: function(value) {
|
||||
this.typecollection.fetch({ reset: true });
|
||||
this.typeHeaders.fetch({ reset: true });
|
||||
},
|
||||
onRefreshButton: function() {
|
||||
this.fetchCollection();
|
||||
|
|
@ -120,12 +122,12 @@ define(['require',
|
|||
var that = this;
|
||||
this.ui.typeLov.empty();
|
||||
var str = '<option></option>';
|
||||
this.typecollection.fullCollection.comparator = function(model) {
|
||||
return model.get('name').toLowerCase();
|
||||
this.typeHeaders.fullCollection.comparator = function(model) {
|
||||
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') {
|
||||
str += '<option>' + _.escape(model.get("name")) + '</option>';
|
||||
str += '<option>' + (Utils.getName(model.toJSON(), 'name')) + '</option>';
|
||||
}
|
||||
});
|
||||
that.ui.typeLov.html(str);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders'));
|
||||
var pagination = "";
|
||||
this.entityModel = new VEntity();
|
||||
this.searchCollection = new VSearchList();
|
||||
|
|
@ -355,7 +355,8 @@ define(['require',
|
|||
var obj = model.get('entity');
|
||||
}
|
||||
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) {
|
||||
nameHtml = '<a title="' + name + '" href="#!/detailPage/' + obj.guid + '">' + name + '</a>';
|
||||
} else {
|
||||
|
|
@ -651,6 +652,7 @@ define(['require',
|
|||
var view = new CreateEntityLayoutView({
|
||||
guid: guid,
|
||||
entityDefCollection: that.entityDefCollection,
|
||||
typeHeaders: that.typeHeaders,
|
||||
callback: function() {
|
||||
that.fetchCollection();
|
||||
}
|
||||
|
|
@ -665,6 +667,7 @@ define(['require',
|
|||
], function(CreateEntityLayoutView) {
|
||||
var view = new CreateEntityLayoutView({
|
||||
entityDefCollection: that.entityDefCollection,
|
||||
typeHeaders: that.typeHeaders,
|
||||
callback: function() {
|
||||
that.fetchCollection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ define(['require',
|
|||
that = this;
|
||||
this.ui.parentTag.empty();
|
||||
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);
|
||||
// IE9 support
|
||||
|
|
|
|||
|
|
@ -101,9 +101,8 @@ define(['require',
|
|||
renderTagDetail: function() {
|
||||
var attributeData = "",
|
||||
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")) {
|
||||
this.ui.description.text(this.model.get("description"));
|
||||
}
|
||||
|
|
@ -112,7 +111,7 @@ define(['require',
|
|||
attributeDefs = [attributeDefs];
|
||||
}
|
||||
_.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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ define(['require',
|
|||
* @constructs
|
||||
*/
|
||||
initialize: function(options) {
|
||||
_.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection'));
|
||||
_.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders'));
|
||||
},
|
||||
bindEvents: function() {},
|
||||
onRender: function() {
|
||||
|
|
@ -61,7 +61,8 @@ define(['require',
|
|||
that.RSearchResultLayoutView.show(new SearchResultLayoutView({
|
||||
value: value,
|
||||
entityDefCollection: that.entityDefCollection,
|
||||
tag: that.tag
|
||||
tag: that.tag,
|
||||
typeHeaders: that.typeHeaders
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -140,10 +140,10 @@ define(['require',
|
|||
var that = this,
|
||||
str = '';
|
||||
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) {
|
||||
var name = _.escape(model.get('name'));
|
||||
var name = Utils.getName(model.toJSON(), 'name');
|
||||
if (name.indexOf(".") > -1) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ define(['require',
|
|||
}
|
||||
if (that.multiple) {
|
||||
_.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]) {
|
||||
obj.deletedEntity.push(name);
|
||||
} else {
|
||||
|
|
@ -187,13 +187,15 @@ define(['require',
|
|||
tagsCollection: function() {
|
||||
var that = this;
|
||||
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>';
|
||||
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) {
|
||||
str += '<option>' + _.escape(obj.get('name')) + '</option>';
|
||||
str += '<option>' + name + '</option>';
|
||||
}
|
||||
});
|
||||
this.ui.addTagOptions.html(str);
|
||||
|
|
@ -233,8 +235,9 @@ define(['require',
|
|||
if (this.commonCollection.models[0]) {
|
||||
if (this.commonCollection.models[0].get('attributeDefs')) {
|
||||
_.each(this.commonCollection.models[0].get('attributeDefs'), function(obj) {
|
||||
that.ui.tagAttribute.append('<div class="form-group"><label>' + _.escape(obj.name) + '</label>' +
|
||||
'<input type="text" class="form-control attributeInputVal attrName" data-key="' + obj.name + '" ></input></div>');
|
||||
var name = Utils.getName(obj, 'name');
|
||||
that.ui.tagAttribute.append('<div class="form-group"><label>' + name + '</label>' +
|
||||
'<input type="text" class="form-control attributeInputVal attrName" data-key="' + name + '" ></input></div>');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue