Commit e202e9e4 by sameer79 Committed by kevalbhatt

ATLAS-3482: UI: Support basic search to search with System attributes only for entity

parent 65a62b05
...@@ -195,13 +195,14 @@ require(['App', ...@@ -195,13 +195,14 @@ require(['App',
'utils/UrlLinks', 'utils/UrlLinks',
'collection/VEntityList', 'collection/VEntityList',
'collection/VTagList', 'collection/VTagList',
'utils/Enums',
'utils/Overrides', 'utils/Overrides',
'bootstrap', 'bootstrap',
'd3', 'd3',
'select2' 'select2'
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) { ], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList, Enums) {
var that = this; var that = this;
this.asyncFetchCounter = 6; this.asyncFetchCounter = 6 + (Enums.addOnEntities.length + 1);
this.entityDefCollection = new VEntityList(); this.entityDefCollection = new VEntityList();
this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl(); this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList(); this.typeHeaders = new VTagList();
...@@ -308,4 +309,24 @@ require(['App', ...@@ -308,4 +309,24 @@ require(['App',
startApp(); startApp();
} }
}); });
Enums.addOnEntities.forEach(function(addOnEntity) {
CommonViewFunction.fetchRootEntityAttributes({
url: UrlLinks.rootEntityDefUrl(addOnEntity),
entity: addOnEntity,
callback: function() {
--that.asyncFetchCounter;
startApp();
}
});
});
CommonViewFunction.fetchRootClassificationAttributes({
url: UrlLinks.rootClassificationDefUrl(Enums.addOnClassification[0]),
classification: Enums.addOnClassification[0],
callback: function() {
--that.asyncFetchCounter;
startApp();
}
});
}); });
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enums', 'moment'], function(require, Utils, Modal, Messages, Enums, moment) { define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enums', 'moment', 'utils/Globals'], function(require, Utils, Modal, Messages, Enums, moment, Globals) {
'use strict'; 'use strict';
var CommonViewFunction = {}; var CommonViewFunction = {};
...@@ -362,6 +362,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -362,6 +362,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
return '<div class="tagList btn-inline btn-fixed-width">' + termHtml + addTerm + '</div>'; return '<div class="tagList btn-inline btn-fixed-width">' + termHtml + addTerm + '</div>';
} }
CommonViewFunction.generateQueryOfFilter = function(value) { CommonViewFunction.generateQueryOfFilter = function(value) {
value = Utils.getUrlState.getQueryParams();
var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }), var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }),
tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }), tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }),
queryArray = []; queryArray = [];
...@@ -456,23 +457,33 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -456,23 +457,33 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
val = val.join(','); val = val.join(',');
} else if (k == "tagFilters") { } else if (k == "tagFilters") {
if (classificationDefCollection) { if (classificationDefCollection) {
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }) var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }), attributeDefs = [];
attributeDefs = Utils.getNestedSuperTypeObj({ if (classificationDef) {
Utils.getNestedSuperTypeObj({
collection: classificationDefCollection, collection: classificationDefCollection,
attrMerge: true, attrMerge: true,
data: classificationDef.toJSON() data: classificationDef.toJSON()
}); });
} }
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs }); val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (k == "entityFilters") { } else if (k == "entityFilters") {
if (entityDefCollection) { if (entityDefCollection) {
var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }), var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }), attributeDefs = [];
attributeDefs = Utils.getNestedSuperTypeObj({ if (entityDef) {
Utils.getNestedSuperTypeObj({
collection: entityDefCollection, collection: entityDefCollection,
attrMerge: true, attrMerge: true,
data: entityDef.toJSON() data: entityDef.toJSON()
}); });
} }
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs }); val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) { } else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
val = val ? false : true; val = val ? false : true;
...@@ -940,5 +951,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -940,5 +951,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}); });
return list.join(','); return list.join(',');
} }
CommonViewFunction.fetchRootEntityAttributes = function (options) {
$.ajax({
url: options.url,
methods: 'GET',
dataType: 'json',
delay: 250,
cache: true,
success: function(response) {
if (response) {
var entity = Object.assign(response, { name: options.entity });
Globals[options.entity] = entity;
}
},
complete: function(response) {
if (options.callback) {
options.callback(response);
}
}
});
},
CommonViewFunction.fetchRootClassificationAttributes = function (options) {
$.ajax({
url: options.url,
methods: 'GET',
dataType: 'json',
delay: 250,
cache: true,
success: function(response) {
if (response) {
var classification = Object.assign(response, { name: options.classification });
Globals[options.classification] = classification;
}
},
complete: function(response) {
if (options.callback) {
options.callback(response);
}
}
});
}
return CommonViewFunction; return CommonViewFunction;
}); });
...@@ -136,7 +136,8 @@ define(['require'], function(require) { ...@@ -136,7 +136,8 @@ define(['require'], function(require) {
validValues: getTermRelationAttributes(), validValues: getTermRelationAttributes(),
validValuesFor: getTermRelationAttributes() validValuesFor: getTermRelationAttributes()
} }
Enums.addOnClassification = ["_CLASSIFIED", "_NOT_CLASSIFIED"]; Enums.addOnClassification = ["_ALL_CLASSIFICATION_TYPES", "_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnEntities = ["_ALL_ENTITY_TYPES"];
Enums.stats = { Enums.stats = {
generalData: { generalData: {
......
...@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require ...@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
metricsApiUrl: function(){ metricsApiUrl: function(){
return this.baseUrl + '/admin/metrics' return this.baseUrl + '/admin/metrics'
}, },
rootEntityDefUrl: function(name) {
return this.baseUrlV2 + '/types/entitydef/name/' + name;
},
rootClassificationDefUrl: function(name) {
return this.baseUrlV2 + '/types/classificationdef/name/' + name;
},
getDefApiUrl: function(type, name) { getDefApiUrl: function(type, name) {
var defApiUrl = this.typedefsUrl(), defUrl; var defApiUrl = this.typedefsUrl(), defUrl;
if (name) { if (name) {
......
...@@ -53,8 +53,9 @@ define(['require', ...@@ -53,8 +53,9 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag', 'searchTableFilters')); _.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag', 'searchTableFilters', 'systemAttrArr'));
this.attrObj = _.sortBy(this.attrObj, 'name'); this.attrObj = _.sortBy(this.attrObj, 'name');
this.systemAttrArr = _.sortBy(this.systemAttrArr, 'name');
this.filterType = this.tag ? 'tagFilters' : 'entityFilters'; this.filterType = this.tag ? 'tagFilters' : 'entityFilters';
}, },
bindEvents: function() {}, bindEvents: function() {},
...@@ -82,12 +83,15 @@ define(['require', ...@@ -82,12 +83,15 @@ define(['require',
} }
return false; return false;
}, },
getObjDef: function(attrObj, rules) { getObjDef: function(attrObj, rules, isGroup, groupType) {
var obj = { var obj = {
id: attrObj.name, id: attrObj.name,
label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"), label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"),
type: _.escape(attrObj.typeName) type: _.escape(attrObj.typeName)
}; };
if (isGroup) {
obj.optgroup = groupType;
}
if (obj.type === "date") { if (obj.type === "date") {
obj['plugin'] = 'daterangepicker'; obj['plugin'] = 'daterangepicker';
obj['plugin_config'] = { obj['plugin_config'] = {
...@@ -141,12 +145,29 @@ define(['require', ...@@ -141,12 +145,29 @@ define(['require',
}, },
onRender: function() { onRender: function() {
var that = this, var that = this,
filters = []; filters = [],
isGroupView = false,
placeHolder = '--Select Attribute--';
if (this.attrObj.length > 0 && this.systemAttrArr.length > 0) {
isGroupView = true;
} else if (this.attrObj.length === 0 || this.systemAttrArr.length === 0) {
isGroupView = false;
}
if (this.attrObj.length === 0) {
placeHolder = '--Select System Attribute--';
}
if (this.value) { if (this.value) {
var rules_widgets = CommonViewFunction.attributeFilter.extractUrl({ "value": this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)], "formatDate": true }); var rules_widgets = CommonViewFunction.attributeFilter.extractUrl({ "value": this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)], "formatDate": true });
} }
_.each(this.attrObj, function(obj) { _.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets); var type = that.tag ? 'Classification' : 'Entity';
var returnObj = that.getObjDef(obj, rules_widgets, isGroupView, 'Select ' + type + ' Attribute');
if (returnObj) {
filters.push(returnObj);
}
});
_.each(this.systemAttrArr, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets, isGroupView, 'Select System Attribute');
if (returnObj) { if (returnObj) {
filters.push(returnObj); filters.push(returnObj);
} }
...@@ -156,7 +177,7 @@ define(['require', ...@@ -156,7 +177,7 @@ define(['require',
this.ui.builder.queryBuilder({ this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'], plugins: ['bt-tooltip-errors'],
filters: filters, filters: filters,
select_placeholder: '--Select Attribute--', select_placeholder: placeHolder,
allow_empty: true, allow_empty: true,
conditions: ['AND', 'OR'], conditions: ['AND', 'OR'],
allow_groups: true, allow_groups: true,
......
...@@ -124,6 +124,11 @@ define(['require', ...@@ -124,6 +124,11 @@ define(['require',
this.type = param.searchType; this.type = param.searchType;
this.updateQueryObject(param); this.updateQueryObject(param);
} }
if ((this.value && this.value.type) || (this.value && this.value.tag && this.value.searchType === "basic")) {
this.setInitialEntityVal = false;
} else {
this.setInitialEntityVal = true;
}
this.bindEvents(); this.bindEvents();
}, },
renderSaveSearch: function() { renderSaveSearch: function() {
...@@ -206,6 +211,9 @@ define(['require', ...@@ -206,6 +211,9 @@ define(['require',
this.setValues(); this.setValues();
this.checkForButtonVisiblity(); this.checkForButtonVisiblity();
this.renderSaveSearch(); this.renderSaveSearch();
if (this.setInitialEntityVal) {
this.setInitialEntityVal = false;
}
}, },
makeFilterButtonActive: function(filtertypeParam) { makeFilterButtonActive: function(filtertypeParam) {
var filtertype = ['entityFilters', 'tagFilters'], var filtertype = ['entityFilters', 'tagFilters'],
...@@ -231,7 +239,8 @@ define(['require', ...@@ -231,7 +239,8 @@ define(['require',
} }
} }
var tagCheck = function(filterObj, type) { var tagCheck = function(filterObj, type) {
if (that.value.tag && !_.contains(Enums.addOnClassification, that.value.tag)) { var filterAddOn = Enums.addOnClassification.filter(function(a) { a !== Enums.addOnClassification[0]});
if (that.value.tag && !_.contains(filterAddOn, that.value.tag)) {
that.ui.tagAttrFilter.prop('disabled', false); that.ui.tagAttrFilter.prop('disabled', false);
if (filterObj && filterObj.length) { if (filterObj && filterObj.length) {
that.ui.tagAttrFilter.addClass('active'); that.ui.tagAttrFilter.addClass('active');
...@@ -461,8 +470,11 @@ define(['require', ...@@ -461,8 +470,11 @@ define(['require',
} }
}, },
manualRender: function(paramObj) { manualRender: function(paramObj) {
if (paramObj) {
this.value = paramObj;
}
this.updateQueryObject(paramObj); this.updateQueryObject(paramObj);
this.renderTypeTagList(paramObj); this.renderTypeTagList();
this.setValues(paramObj); this.setValues(paramObj);
}, },
getFilterBox: function() { getFilterBox: function() {
...@@ -488,11 +500,7 @@ define(['require', ...@@ -488,11 +500,7 @@ define(['require',
this.ui.typeLov.empty(); this.ui.typeLov.empty();
var typeStr = '<option></option>', var typeStr = '<option></option>',
tagStr = typeStr, tagStr = typeStr,
foundNewClassification = false, foundNewClassification = false;
optionsValue = this.options.value;
if (options && options.tag) {
optionsValue = options;
}
this.typeHeaders.fullCollection.each(function(model) { this.typeHeaders.fullCollection.each(function(model) {
var name = Utils.getName(model.toJSON(), 'name'); var name = Utils.getName(model.toJSON(), 'name');
if (model.get('category') == 'ENTITY' && (serviceTypeToBefiltered && serviceTypeToBefiltered.length ? _.contains(serviceTypeToBefiltered, model.get('serviceType')) : true)) { if (model.get('category') == 'ENTITY' && (serviceTypeToBefiltered && serviceTypeToBefiltered.length ? _.contains(serviceTypeToBefiltered, model.get('serviceType')) : true)) {
...@@ -501,8 +509,8 @@ define(['require', ...@@ -501,8 +509,8 @@ define(['require',
} }
if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') { if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') {
var tagEntityCount = that.entityCountObj.tag.tagEntities[name]; var tagEntityCount = that.entityCountObj.tag.tagEntities[name];
if (optionsValue) { // to check if wildcard classification is present in our data if (that.value && that.value.tag) { // to check if wildcard classification is present in our data
if (name === optionsValue.tag) { if (name === that.value.tag) {
foundNewClassification = true; foundNewClassification = true;
} }
} }
...@@ -510,17 +518,26 @@ define(['require', ...@@ -510,17 +518,26 @@ define(['require',
} }
}); });
if (!foundNewClassification && optionsValue) { if (this.type !== "dsl") {
if (optionsValue.tag) { _.each(Enums.addOnEntities, function(entity) {
var classificationValue = decodeURIComponent(optionsValue.tag); typeStr += '<option value="' + (entity) + '" data-name="' + (entity) + '">' + entity + '</option>';
});
}
if (!foundNewClassification && that.value) {
if (that.value.tag) {
var classificationValue = decodeURIComponent(that.value.tag);
tagStr += '<option value="' + (classificationValue) + '" data-name="' + (classificationValue) + '">' + classificationValue + '</option>'; tagStr += '<option value="' + (classificationValue) + '" data-name="' + (classificationValue) + '">' + classificationValue + '</option>';
} }
} }
if (_.isUndefined(isTypeOnly)) { if (_.isUndefined(isTypeOnly)) {
//to insert extra classification list //to insert extra classification list
if (that.value) {
_.each(Enums.addOnClassification, function(classificationName) { _.each(Enums.addOnClassification, function(classificationName) {
if (classificationName !== that.value.tag) {
tagStr += '<option value="' + (classificationName) + '" data-name="' + (classificationName) + '">' + classificationName + '</option>'; tagStr += '<option value="' + (classificationName) + '" data-name="' + (classificationName) + '">' + classificationName + '</option>';
}
}); });
}
that.ui.tagLov.html(tagStr); that.ui.tagLov.html(tagStr);
this.ui.tagLov.select2({ this.ui.tagLov.select2({
placeholder: "Select Classification", placeholder: "Select Classification",
...@@ -554,6 +571,11 @@ define(['require', ...@@ -554,6 +571,11 @@ define(['require',
if (typeLovSelect2 && serviceTypeToBefiltered) { if (typeLovSelect2 && serviceTypeToBefiltered) {
typeLovSelect2.select2('open').trigger("change", { 'manual': true }); typeLovSelect2.select2('open').trigger("change", { 'manual': true });
} }
if (that.setInitialEntityVal) {
var defaultEntity = Enums.addOnEntities[0];
that.value.type = defaultEntity;
that.ui.typeLov.val(defaultEntity, null);
}
}, },
renderTermList: function() { renderTermList: function() {
var getTypeAheadData = function(data, params) { var getTypeAheadData = function(data, params) {
......
...@@ -21,7 +21,9 @@ define(['require', ...@@ -21,7 +21,9 @@ define(['require',
'modules/Modal', 'modules/Modal',
'utils/Utils', 'utils/Utils',
'hbs!tmpl/search/SearchQuery_tmpl', 'hbs!tmpl/search/SearchQuery_tmpl',
], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl) { 'utils/Globals',
'utils/Enums'
], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl, Globals, Enums) {
var SearchQueryView = Backbone.Marionette.LayoutView.extend( var SearchQueryView = Backbone.Marionette.LayoutView.extend(
/** @lends SearchQueryView */ /** @lends SearchQueryView */
...@@ -100,6 +102,9 @@ define(['require', ...@@ -100,6 +102,9 @@ define(['require',
attrMerge: true, attrMerge: true,
}); });
} }
if (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]) {
obj['systemAttrArr'] = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
}
} else { } else {
obj['type'] = true; obj['type'] = true;
obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type }); obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type });
...@@ -110,6 +115,9 @@ define(['require', ...@@ -110,6 +115,9 @@ define(['require',
attrMerge: true attrMerge: true
}); });
} }
if (Globals[this.value.type] ||Globals[Enums.addOnEntities[0]]) {
obj['systemAttrArr'] = (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs;
}
} }
this.renderQueryBuilder(obj); this.renderQueryBuilder(obj);
// this.showHideFilter(this.value); // this.showHideFilter(this.value);
......
...@@ -573,6 +573,9 @@ define(['require', ...@@ -573,6 +573,9 @@ define(['require',
if (!that.REntityTableLayoutView) { if (!that.REntityTableLayoutView) {
return; return;
} }
if (!that.value) {
that.value = that.options.value;
}
that.REntityTableLayoutView.show(table); that.REntityTableLayoutView.show(table);
if (that.value.searchType !== "dsl") { if (that.value.searchType !== "dsl") {
that.ui.containerCheckBox.show(); that.ui.containerCheckBox.show();
...@@ -637,6 +640,7 @@ define(['require', ...@@ -637,6 +640,7 @@ define(['require',
nameCheck = 0, nameCheck = 0,
columnToShow = null, columnToShow = null,
col = {}; col = {};
this.value = Utils.getUrlState.getQueryParams();
if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) { if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) {
columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type]; columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type];
} }
...@@ -786,9 +790,21 @@ define(['require', ...@@ -786,9 +790,21 @@ define(['require',
} }
if (this.value && this.value.searchType === "basic") { if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }); var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }), systemAttr = [];
if (def) { if (def || Globals[this.value.type] || (
var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true }); this.value.tag
? Globals[this.value.tag]
? Globals[this.value.tag]
: Globals[Enums.addOnClassification[0]]
: undefined)) {
var attrObj = def ? Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true }) : [];
if (this.value.type && ( Globals[this.value.type] || Globals[Enums.addOnEntities[0]])) {
systemAttr = (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs;
}
if (this.value.tag && ( Globals[this.value.tag] || Globals[Enums.addOnClassification[0]])) {
systemAttr = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
}
attrObj = attrObj.concat(systemAttr);
_.each(attrObj, function(obj, key) { _.each(attrObj, function(obj, key) {
var key = obj.name, var key = obj.name,
isRenderable = _.contains(columnToShow, key), isRenderable = _.contains(columnToShow, key),
......
...@@ -24,8 +24,9 @@ define(['require', ...@@ -24,8 +24,9 @@ define(['require',
'collection/VTagList', 'collection/VTagList',
'models/VTag', 'models/VTag',
'utils/Messages', 'utils/Messages',
'utils/UrlLinks' 'utils/UrlLinks',
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks) { 'utils/Globals'
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks, Globals) {
'use strict'; 'use strict';
var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend( var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -92,6 +93,9 @@ define(['require', ...@@ -92,6 +93,9 @@ define(['require',
onRender: function() { onRender: function() {
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail')); Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail'));
if (this.collection.models.length && !this.model) { if (this.collection.models.length && !this.model) {
if (Globals[this.tag]) {
this.collection.fullCollection.push(Globals[this.tag]);
}
this.model = this.collection.fullCollection.findWhere({ name: this.tag }); this.model = this.collection.fullCollection.findWhere({ name: this.tag });
this.renderTagDetail(); this.renderTagDetail();
} }
......
...@@ -195,13 +195,14 @@ require(['App', ...@@ -195,13 +195,14 @@ require(['App',
'utils/UrlLinks', 'utils/UrlLinks',
'collection/VEntityList', 'collection/VEntityList',
'collection/VTagList', 'collection/VTagList',
'utils/Enums',
'utils/Overrides', 'utils/Overrides',
'bootstrap', 'bootstrap',
'd3', 'd3',
'select2' 'select2'
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) { ], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList, Enums) {
var that = this; var that = this;
this.asyncFetchCounter = 6; this.asyncFetchCounter = 6 + (Enums.addOnEntities.length + 1);
this.entityDefCollection = new VEntityList(); this.entityDefCollection = new VEntityList();
this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl(); this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList(); this.typeHeaders = new VTagList();
...@@ -308,4 +309,24 @@ require(['App', ...@@ -308,4 +309,24 @@ require(['App',
startApp(); startApp();
} }
}); });
Enums.addOnEntities.forEach(function(addOnEntity) {
CommonViewFunction.fetchRootEntityAttributes({
url: UrlLinks.rootEntityDefUrl(addOnEntity),
entity: addOnEntity,
callback: function() {
--that.asyncFetchCounter;
startApp();
}
});
});
CommonViewFunction.fetchRootClassificationAttributes({
url: UrlLinks.rootClassificationDefUrl(Enums.addOnClassification[0]),
classification: Enums.addOnClassification[0],
callback: function() {
--that.asyncFetchCounter;
startApp();
}
});
}); });
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enums', 'moment'], function(require, Utils, Modal, Messages, Enums, moment) { define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enums', 'moment', 'utils/Globals'], function(require, Utils, Modal, Messages, Enums, moment, Globals) {
'use strict'; 'use strict';
var CommonViewFunction = {}; var CommonViewFunction = {};
...@@ -362,6 +362,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -362,6 +362,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
return '<div class="tagList btn-inline btn-fixed-width">' + termHtml + addTerm + '</div>'; return '<div class="tagList btn-inline btn-fixed-width">' + termHtml + addTerm + '</div>';
} }
CommonViewFunction.generateQueryOfFilter = function(value, isCapsuleView) { CommonViewFunction.generateQueryOfFilter = function(value, isCapsuleView) {
value = Utils.getUrlState.getQueryParams();
var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }), var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }),
tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }), tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }),
queryArray = []; queryArray = [];
...@@ -476,23 +477,33 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -476,23 +477,33 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
val = val.join(','); val = val.join(',');
} else if (k == "tagFilters") { } else if (k == "tagFilters") {
if (classificationDefCollection) { if (classificationDefCollection) {
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }) var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }), attributeDefs = []
attributeDefs = Utils.getNestedSuperTypeObj({ if (classificationDef) {
Utils.getNestedSuperTypeObj({
collection: classificationDefCollection, collection: classificationDefCollection,
attrMerge: true, attrMerge: true,
data: classificationDef.toJSON() data: classificationDef.toJSON()
}); });
} }
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs }); val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (k == "entityFilters") { } else if (k == "entityFilters") {
if (entityDefCollection) { if (entityDefCollection) {
var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }), var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }), attributeDefs = [];
if (entityDef) {
attributeDefs = Utils.getNestedSuperTypeObj({ attributeDefs = Utils.getNestedSuperTypeObj({
collection: entityDefCollection, collection: entityDefCollection,
attrMerge: true, attrMerge: true,
data: entityDef.toJSON() data: entityDef.toJSON()
}); });
} }
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs }); val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) { } else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
val = val ? false : true; val = val ? false : true;
...@@ -960,5 +971,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -960,5 +971,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}); });
return list.join(','); return list.join(',');
} }
CommonViewFunction.fetchRootEntityAttributes = function (options) {
$.ajax({
url: options.url,
methods: 'GET',
dataType: 'json',
delay: 250,
cache: true,
success: function(response) {
if (response) {
var entity = Object.assign(response, { name: options.entity , guid: options.entity });
Globals[options.entity] = entity;
}
},
complete: function(response) {
if (options.callback) {
options.callback(response);
}
}
});
},
CommonViewFunction.fetchRootClassificationAttributes = function (options) {
$.ajax({
url: options.url,
methods: 'GET',
dataType: 'json',
delay: 250,
cache: true,
success: function(response) {
if (response) {
var classification = Object.assign(response, { name: options.classification, guid: options.classification });
Globals[options.classification] = classification;
}
},
complete: function(response) {
if (options.callback) {
options.callback(response);
}
}
});
}
return CommonViewFunction; return CommonViewFunction;
}); });
...@@ -136,7 +136,8 @@ define(['require'], function(require) { ...@@ -136,7 +136,8 @@ define(['require'], function(require) {
validValues: getTermRelationAttributes(), validValues: getTermRelationAttributes(),
validValuesFor: getTermRelationAttributes() validValuesFor: getTermRelationAttributes()
} }
Enums.addOnClassification = ["_CLASSIFIED", "_NOT_CLASSIFIED"]; Enums.addOnClassification = ["_ALL_CLASSIFICATION_TYPES", "_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnEntities = ["_ALL_ENTITY_TYPES"];
Enums.stats = { Enums.stats = {
generalData: { generalData: {
......
...@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require ...@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
metricsApiUrl: function() { metricsApiUrl: function() {
return this.baseUrl + '/admin/metrics' return this.baseUrl + '/admin/metrics'
}, },
rootEntityDefUrl: function(name) {
return this.baseUrlV2 + '/types/entitydef/name/' + name;
},
rootClassificationDefUrl: function(name) {
return this.baseUrlV2 + '/types/classificationdef/name/' + name;
},
getDefApiUrl: function(type, name) { getDefApiUrl: function(type, name) {
var defApiUrl = this.typedefsUrl(), var defApiUrl = this.typedefsUrl(),
defUrl; defUrl;
......
...@@ -53,8 +53,9 @@ define(['require', ...@@ -53,8 +53,9 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag', 'searchTableFilters')); _.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag', 'searchTableFilters', 'systemAttrArr'));
this.attrObj = _.sortBy(this.attrObj, 'name'); this.attrObj = _.sortBy(this.attrObj, 'name');
this.systemAttrArr = _.sortBy(this.systemAttrArr, 'name');
this.filterType = this.tag ? 'tagFilters' : 'entityFilters'; this.filterType = this.tag ? 'tagFilters' : 'entityFilters';
}, },
bindEvents: function() {}, bindEvents: function() {},
...@@ -82,12 +83,15 @@ define(['require', ...@@ -82,12 +83,15 @@ define(['require',
} }
return false; return false;
}, },
getObjDef: function(attrObj, rules) { getObjDef: function(attrObj, rules, isGroup, groupType) {
var obj = { var obj = {
id: attrObj.name, id: attrObj.name,
label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"), label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"),
type: _.escape(attrObj.typeName) type: _.escape(attrObj.typeName)
}; };
if (isGroup) {
obj.optgroup = groupType;
}
if (obj.type === "date") { if (obj.type === "date") {
obj['plugin'] = 'daterangepicker'; obj['plugin'] = 'daterangepicker';
obj['plugin_config'] = { obj['plugin_config'] = {
...@@ -141,12 +145,28 @@ define(['require', ...@@ -141,12 +145,28 @@ define(['require',
}, },
onRender: function() { onRender: function() {
var that = this, var that = this,
filters = []; filters = [],
if (this.value) { isGroupView = false,
placeHolder = '--Select Attribute--';
if (this.attrObj.length > 0 && this.systemAttrArr.length > 0) {
isGroupView = true;
} else if (this.attrObj.length === 0 || this.systemAttrArr.length === 0) {
isGroupView = false;
}
if (this.attrObj.length === 0) {
placeHolder = '--Select System Attribute--';
} if (this.value) {
var rules_widgets = CommonViewFunction.attributeFilter.extractUrl({ "value": this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)], "formatDate": true }); var rules_widgets = CommonViewFunction.attributeFilter.extractUrl({ "value": this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)], "formatDate": true });
} }
_.each(this.attrObj, function(obj) { _.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets); var type = that.tag ? 'Classification' : 'Entity';
var returnObj = that.getObjDef(obj, rules_widgets, isGroupView, 'Select '+ type + ' Attribute');
if (returnObj) {
filters.push(returnObj);
}
});
_.each(this.systemAttrArr, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets, isGroupView, 'Select System Attribute');
if (returnObj) { if (returnObj) {
filters.push(returnObj); filters.push(returnObj);
} }
...@@ -156,7 +176,7 @@ define(['require', ...@@ -156,7 +176,7 @@ define(['require',
this.ui.builder.queryBuilder({ this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'], plugins: ['bt-tooltip-errors'],
filters: filters, filters: filters,
select_placeholder: '--Select Attribute--', select_placeholder: placeHolder,
allow_empty: true, allow_empty: true,
conditions: ['AND', 'OR'], conditions: ['AND', 'OR'],
allow_groups: true, allow_groups: true,
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLayoutView_tmpl", 'utils/Utils', 'utils/CommonViewFunction'], function(require, Backbone, Globals, SearchDefaultLayoutViewTmpl, Utils, CommonViewFunction) { define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLayoutView_tmpl", 'utils/Utils', 'utils/CommonViewFunction', 'utils/Enums'], function(require, Backbone, Globals, SearchDefaultLayoutViewTmpl, Utils, CommonViewFunction, Enums) {
"use strict"; "use strict";
var SearchDefaultlLayoutView = Backbone.Marionette.LayoutView.extend( var SearchDefaultlLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -252,6 +252,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa ...@@ -252,6 +252,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
}); });
this.tagAttributeLength = attrTagObj.length; this.tagAttributeLength = attrTagObj.length;
} }
if (Globals[that.options.value.tag] || Globals[Enums.addOnClassification[0]]) {
obj.systemAttrArr = (Globals[that.options.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
this.tagAttributeLength = obj.systemAttrArr.length;
}
this.renderQueryBuilder(_.extend({}, obj, { this.renderQueryBuilder(_.extend({}, obj, {
tag: true, tag: true,
type: false, type: false,
...@@ -270,6 +274,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa ...@@ -270,6 +274,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
}); });
this.entityAttributeLength = attrTypeObj.length; this.entityAttributeLength = attrTypeObj.length;
} }
if (Globals[that.options.value.type] || Globals[Enums.addOnEntities[0]]) {
obj.systemAttrArr = (Globals[that.options.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs;
this.entityAttributeLength = obj.systemAttrArr.length;
}
this.renderQueryBuilder(_.extend({}, obj, { this.renderQueryBuilder(_.extend({}, obj, {
tag: false, tag: false,
type: true, type: true,
......
...@@ -36,14 +36,13 @@ define([ ...@@ -36,14 +36,13 @@ define([
RClassificationTreeRender: '[data-id="r_classificationTreeRender"]', RClassificationTreeRender: '[data-id="r_classificationTreeRender"]',
REntityTreeRender: '[data-id="r_entityTreeRender"]', REntityTreeRender: '[data-id="r_entityTreeRender"]',
RCustomFilterTreeRender: '[data-id="r_customFilterTreeRender"]', RCustomFilterTreeRender: '[data-id="r_customFilterTreeRender"]',
}, },
ui: { ui: {
//search //search
searchNode: '[data-id="searchNode"]', searchNode: '[data-id="searchNode"]',
sliderBar: '[data-id="sliderBar"]', sliderBar: '[data-id="sliderBar"]',
menuItems: '.menu-items' menuItems: ".menu-items"
}, },
templateHelpers: function() { templateHelpers: function() {
return { return {
...@@ -95,7 +94,7 @@ define([ ...@@ -95,7 +94,7 @@ define([
events["click " + this.ui.menuItems] = function(e) { events["click " + this.ui.menuItems] = function(e) {
e.stopPropagation(); e.stopPropagation();
//this.$('.menu-items').removeClass('open'); //this.$('.menu-items').removeClass('open');
} };
return events; return events;
}, },
bindEvents: function() {}, bindEvents: function() {},
...@@ -119,26 +118,30 @@ define([ ...@@ -119,26 +118,30 @@ define([
this.bindEvents(); this.bindEvents();
}, },
onRender: function() { onRender: function() {
this.renderEntityTree(); var opt = opt = Utils.getUrlState.getQueryParams();
this.renderClassificationTree(); this.renderEntityTree(opt);
this.renderGlossaryTree(); this.renderClassificationTree(opt);
this.renderGlossaryTree(opt);
this.renderCustomFilterTree(); this.renderCustomFilterTree();
this.showHideGlobalFilter(); this.showHideGlobalFilter();
this.showDefaultPage(); this.showDefaultPage();
}, },
showDefaultPage: function() { showDefaultPage: function() {
if (this.options.value) { if (this.options.value) {
if (!this.options.value.type && !this.options.value.tag && !this.options.value.term && !this.options.value.gType) { if (
!this.options.value.type &&
!this.options.value.tag &&
!this.options.value.term &&
!this.options.value.gType
) {
Utils.setUrl({ Utils.setUrl({
url: '!/search', url: "!/search",
mergeBrowserUrl: false, mergeBrowserUrl: false,
trigger: true, trigger: true,
updateTabState: true updateTabState: true
}); });
} }
} }
}, },
onShow: function() { onShow: function() {
var that = this; var that = this;
...@@ -206,28 +209,28 @@ define([ ...@@ -206,28 +209,28 @@ define([
} }
} }
}, },
renderEntityTree: function() { renderEntityTree: function(opt) {
var that = this; var that = this;
require(["views/search/tree/EntityTreeLayoutView"], function(ClassificationTreeLayoutView) { require(["views/search/tree/EntityTreeLayoutView"], function(ClassificationTreeLayoutView) {
that.REntityTreeRender.show(new ClassificationTreeLayoutView(_.extend({ query: that.query }, that.options))) that.REntityTreeRender.show(new ClassificationTreeLayoutView(_.extend({ query: that.query }, that.options, {value: opt})));
}); });
}, },
renderClassificationTree: function() { renderClassificationTree: function(opt) {
var that = this; var that = this;
require(["views/search/tree/ClassificationTreeLayoutView"], function(ClassificationTreeLayoutView) { require(["views/search/tree/ClassificationTreeLayoutView"], function(ClassificationTreeLayoutView) {
that.RClassificationTreeRender.show(new ClassificationTreeLayoutView(_.extend({ query: that.query }, that.options))) that.RClassificationTreeRender.show(new ClassificationTreeLayoutView(_.extend({ query: that.query }, that.options, {value: opt})));
}); });
}, },
renderGlossaryTree: function() { renderGlossaryTree: function(opt) {
var that = this; var that = this;
require(["views/search/tree/GlossaryTreeLayoutView"], function(GlossaryTreeLayoutView) { require(["views/search/tree/GlossaryTreeLayoutView"], function(GlossaryTreeLayoutView) {
that.RGlossaryTreeRender.show(new GlossaryTreeLayoutView(_.extend({ query: that.query }, that.options))) that.RGlossaryTreeRender.show(new GlossaryTreeLayoutView(_.extend({ query: that.query }, that.options, {value: opt})));
}); });
}, },
renderCustomFilterTree: function() { renderCustomFilterTree: function() {
var that = this; var that = this;
require(["views/search/tree/CustomFilterTreeLayoutView"], function(CustomFilterTreeLayoutView) { require(["views/search/tree/CustomFilterTreeLayoutView"], function(CustomFilterTreeLayoutView) {
that.RCustomFilterTreeRender.show(new CustomFilterTreeLayoutView(_.extend({ query: that.query }, that.options))) that.RCustomFilterTreeRender.show(new CustomFilterTreeLayoutView(_.extend({ query: that.query }, that.options)));
}); });
} }
}); });
......
...@@ -21,7 +21,8 @@ define(['require', ...@@ -21,7 +21,8 @@ define(['require',
'modules/Modal', 'modules/Modal',
'utils/Utils', 'utils/Utils',
'hbs!tmpl/search/SearchQuery_tmpl', 'hbs!tmpl/search/SearchQuery_tmpl',
], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl) { 'utils/Globals'
], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl, Globals) {
var SearchQueryView = Backbone.Marionette.LayoutView.extend( var SearchQueryView = Backbone.Marionette.LayoutView.extend(
/** @lends SearchQueryView */ /** @lends SearchQueryView */
...@@ -100,6 +101,9 @@ define(['require', ...@@ -100,6 +101,9 @@ define(['require',
attrMerge: true, attrMerge: true,
}); });
} }
if (Globals[this.value.tag]) {
obj['attrObj'] = Globals[this.value.tag].attributeDefs;
}
} else { } else {
obj['type'] = true; obj['type'] = true;
obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type }); obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type });
...@@ -110,6 +114,9 @@ define(['require', ...@@ -110,6 +114,9 @@ define(['require',
attrMerge: true attrMerge: true
}); });
} }
if (Globals[this.value.type]) {
obj['attrObj'] = Globals[this.value.type].attributeDefs;
}
} }
this.renderQueryBuilder(obj); this.renderQueryBuilder(obj);
// this.showHideFilter(this.value); // this.showHideFilter(this.value);
......
...@@ -584,6 +584,9 @@ define(['require', ...@@ -584,6 +584,9 @@ define(['require',
if (!that.REntityTableLayoutView) { if (!that.REntityTableLayoutView) {
return; return;
} }
if (!that.value) {
that.value = that.options.value;
}
that.REntityTableLayoutView.show(table); that.REntityTableLayoutView.show(table);
if (that.value.searchType !== "dsl") { if (that.value.searchType !== "dsl") {
that.ui.containerCheckBox.show(); that.ui.containerCheckBox.show();
...@@ -648,6 +651,7 @@ define(['require', ...@@ -648,6 +651,7 @@ define(['require',
nameCheck = 0, nameCheck = 0,
columnToShow = null, columnToShow = null,
col = {}; col = {};
this.value = Utils.getUrlState.getQueryParams();
if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) { if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) {
columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type]; columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type];
} }
...@@ -798,9 +802,21 @@ define(['require', ...@@ -798,9 +802,21 @@ define(['require',
} }
if (this.value && this.value.searchType === "basic") { if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }); var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }), systemAttr = [];
if (def) { if (def || Globals[this.value.type] || (
var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true }); this.value.tag
? Globals[this.value.tag]
? Globals[this.value.tag]
: Globals[Enums.addOnClassification[0]]
: undefined)) {
var attrObj = def ? Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true }) : [];
if (this.value.type && ( Globals[this.value.type] || Globals[Enums.addOnEntities[0]])) {
systemAttr = (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs;
}
if (this.value.tag && ( Globals[this.value.tag] || Globals[Enums.addOnClassification[0]])) {
systemAttr = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
}
attrObj = attrObj.concat(systemAttr);
_.each(attrObj, function(obj, key) { _.each(attrObj, function(obj, key) {
var key = obj.name, var key = obj.name,
isRenderable = _.contains(columnToShow, key), isRenderable = _.contains(columnToShow, key),
......
...@@ -25,8 +25,9 @@ define([ ...@@ -25,8 +25,9 @@ define([
"utils/CommonViewFunction", "utils/CommonViewFunction",
"collection/VSearchList", "collection/VSearchList",
"collection/VGlossaryList", "collection/VGlossaryList",
"utils/Enums",
"jstree" "jstree"
], function(require, ClassificationTreeLayoutViewTmpl, Utils, Messages, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList) { ], function(require, ClassificationTreeLayoutViewTmpl, Utils, Messages, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList, Enums) {
"use strict"; "use strict";
var ClassificationTreeLayoutView = Marionette.LayoutView.extend({ var ClassificationTreeLayoutView = Marionette.LayoutView.extend({
...@@ -264,6 +265,11 @@ define([ ...@@ -264,6 +265,11 @@ define([
this.ui.classificationSearchTree.jstree(true).select_node(dataFound.get("guid")); this.ui.classificationSearchTree.jstree(true).select_node(dataFound.get("guid"));
} }
} }
if (!dataFound && Globals[that.options.value.tag]) {
this.fromManualRender = true;
this.typeId = Globals[that.options.value.tag].guid;
this.ui.classificationSearchTree.jstree(true).select_node(this.typeId);
}
} }
}, },
onNodeSelect: function(options) { onNodeSelect: function(options) {
...@@ -489,9 +495,31 @@ define([ ...@@ -489,9 +495,31 @@ define([
}); });
var classificationTreeData = that.isEmptyClassification ? listWithEmptyParents : listOfParents; var classificationTreeData = that.isEmptyClassification ? listWithEmptyParents : listOfParents;
var flatViewClassificaton = that.isEmptyClassification ? listWithEmptyParentsFlatView : flatViewList; var flatViewClassificaton = that.isEmptyClassification ? listWithEmptyParentsFlatView : flatViewList;
var classificationData = that.isGroupView ? classificationTreeData : flatViewClassificaton; var classificationData = that.isGroupView
? that.pushRootClassificationToJstree.call(that, classificationTreeData)
: that.pushRootClassificationToJstree.call(that, flatViewClassificaton);
return classificationData; return classificationData;
}, },
pushRootClassificationToJstree: function(data) {
var rootClassification = Globals[Enums.addOnClassification[0]];
var isSelected = this.options.value && this.options.value.tag ? this.options.value.tag == rootClassification.name : false;
var rootClassificationNode = {
text: _.escape(rootClassification.name),
name: rootClassification.name,
type: rootClassification.category,
gType: "Classification",
guid: "root-classification",
id: "root-classification",
model: rootClassification,
children: [],
icon: "fa fa-tag",
state: {
selected: isSelected
}
}
data.push(rootClassificationNode);
return data;
},
generateSearchTree: function(options) { generateSearchTree: function(options) {
var $el = options && options.$el, var $el = options && options.$el,
type = options && options.type, type = options && options.type,
......
...@@ -24,8 +24,9 @@ define([ ...@@ -24,8 +24,9 @@ define([
"utils/CommonViewFunction", "utils/CommonViewFunction",
"collection/VSearchList", "collection/VSearchList",
"collection/VGlossaryList", "collection/VGlossaryList",
'utils/Enums',
"jstree" "jstree"
], function(require, EntityLayoutViewTmpl, Utils, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList) { ], function(require, EntityLayoutViewTmpl, Utils, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList, Enums) {
"use strict"; "use strict";
var EntityTreeLayoutview = Marionette.LayoutView.extend({ var EntityTreeLayoutview = Marionette.LayoutView.extend({
...@@ -184,6 +185,11 @@ define([ ...@@ -184,6 +185,11 @@ define([
this.ui.entitySearchTree.jstree(true).select_node(dataFound.get("guid")); this.ui.entitySearchTree.jstree(true).select_node(dataFound.get("guid"));
} }
} }
if (!dataFound && Globals[that.options.value.type]) {
this.fromManualRender = true;
this.typeId = Globals[that.options.value.type].guid;
this.ui.entitySearchTree.jstree(true).select_node(this.typeId);
}
} }
}, },
onNodeSelect: function(options) { onNodeSelect: function(options) {
...@@ -318,10 +324,39 @@ define([ ...@@ -318,10 +324,39 @@ define([
var serviceTypeData = that.isEmptyServicetype ? serviceTypeWithEmptyEntity : serviceTypeArr; var serviceTypeData = that.isEmptyServicetype ? serviceTypeWithEmptyEntity : serviceTypeArr;
if (that.isGroupView) { if (that.isGroupView) {
return getParentsData.call(that, serviceTypeData); var serviceDataWithRootEntity = pushRootEntityToJstree.call(that,'group',serviceTypeData);
return getParentsData.call(that, serviceDataWithRootEntity);
} else {
return pushRootEntityToJstree.call(that, null,serviceTypeData);
}
},
pushRootEntityToJstree = function(type, data) {
var rootEntity = Globals[Enums.addOnEntities[0]];
var isSelected = this.options.value && this.options.value.type ? this.options.value.type == rootEntity.name : false;
var rootEntityNode = {
text: _.escape(rootEntity.name),
name: rootEntity.name,
type: rootEntity.category,
gType: "serviceType",
guid: rootEntity.guid,
id: rootEntity.guid,
model: rootEntity,
parent: "#",
icon: "fa fa-file-o",
state: {
// disabled: entityCount == 0 ? true : false,
selected: isSelected
},
};
if (type === 'group') {
if (data.other_types === undefined) {
data.other_types = { name : "other_types", children: []};
}
data.other_types.children.push(rootEntityNode);
} else { } else {
return serviceTypeData; data.push(rootEntityNode);
} }
return data;
}, },
getParentsData = function(data) { getParentsData = function(data) {
var parents = Object.keys(data), var parents = Object.keys(data),
...@@ -438,7 +473,7 @@ define([ ...@@ -438,7 +473,7 @@ define([
).on("open_node.jstree", function(e, data) { ).on("open_node.jstree", function(e, data) {
that.isTreeOpen = true; that.isTreeOpen = true;
}).on("select_node.jstree", function(e, data) { }).on("select_node.jstree", function(e, data) {
if (that.fromManualRender !== true) { if (!that.fromManualRender) {
that.onNodeSelect(data); that.onNodeSelect(data);
} else { } else {
that.fromManualRender = false; that.fromManualRender = false;
......
...@@ -24,8 +24,9 @@ define(['require', ...@@ -24,8 +24,9 @@ define(['require',
'collection/VTagList', 'collection/VTagList',
'models/VTag', 'models/VTag',
'utils/Messages', 'utils/Messages',
'utils/UrlLinks' 'utils/UrlLinks',
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks) { "utils/Globals",
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks, Globals) {
'use strict'; 'use strict';
var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend( var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -96,6 +97,9 @@ define(['require', ...@@ -96,6 +97,9 @@ define(['require',
onRender: function() { onRender: function() {
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail')); Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail'));
if (this.collection.models.length && !this.model) { if (this.collection.models.length && !this.model) {
if (Globals[this.tag]) {
this.collection.fullCollection.push(Globals[this.tag]);
}
this.model = this.collection.fullCollection.findWhere({ name: this.tag }); this.model = this.collection.fullCollection.findWhere({ name: this.tag });
this.renderTagDetail(); this.renderTagDetail();
} }
......
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