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',
'utils/UrlLinks',
'collection/VEntityList',
'collection/VTagList',
'utils/Enums',
'utils/Overrides',
'bootstrap',
'd3',
'select2'
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList, Enums) {
var that = this;
this.asyncFetchCounter = 6;
this.asyncFetchCounter = 6 + (Enums.addOnEntities.length + 1);
this.entityDefCollection = new VEntityList();
this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList();
......@@ -308,4 +309,24 @@ require(['App',
startApp();
}
});
});
\ No newline at end of file
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 @@
* 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';
var CommonViewFunction = {};
......@@ -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>';
}
CommonViewFunction.generateQueryOfFilter = function(value) {
value = Utils.getUrlState.getQueryParams();
var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }),
tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }),
queryArray = [];
......@@ -456,22 +457,32 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
val = val.join(',');
} else if (k == "tagFilters") {
if (classificationDefCollection) {
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification })
attributeDefs = Utils.getNestedSuperTypeObj({
collection: classificationDefCollection,
attrMerge: true,
data: classificationDef.toJSON()
});
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }), attributeDefs = [];
if (classificationDef) {
Utils.getNestedSuperTypeObj({
collection: classificationDefCollection,
attrMerge: true,
data: classificationDef.toJSON()
});
}
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (k == "entityFilters") {
if (entityDefCollection) {
var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }),
attributeDefs = Utils.getNestedSuperTypeObj({
collection: entityDefCollection,
attrMerge: true,
data: entityDef.toJSON()
});
var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value[skey].typeName }), attributeDefs = [];
if (entityDef) {
Utils.getNestedSuperTypeObj({
collection: entityDefCollection,
attrMerge: true,
data: entityDef.toJSON()
});
}
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
......@@ -940,5 +951,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
});
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;
});
\ No newline at end of file
});
......@@ -136,7 +136,8 @@ define(['require'], function(require) {
validValues: getTermRelationAttributes(),
validValuesFor: getTermRelationAttributes()
}
Enums.addOnClassification = ["_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnClassification = ["_ALL_CLASSIFICATION_TYPES", "_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnEntities = ["_ALL_ENTITY_TYPES"];
Enums.stats = {
generalData: {
......
......@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
metricsApiUrl: function(){
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) {
var defApiUrl = this.typedefsUrl(), defUrl;
if (name) {
......
......@@ -53,8 +53,9 @@ define(['require',
* @constructs
*/
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.systemAttrArr = _.sortBy(this.systemAttrArr, 'name');
this.filterType = this.tag ? 'tagFilters' : 'entityFilters';
},
bindEvents: function() {},
......@@ -82,12 +83,15 @@ define(['require',
}
return false;
},
getObjDef: function(attrObj, rules) {
getObjDef: function(attrObj, rules, isGroup, groupType) {
var obj = {
id: attrObj.name,
label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"),
type: _.escape(attrObj.typeName)
};
if (isGroup) {
obj.optgroup = groupType;
}
if (obj.type === "date") {
obj['plugin'] = 'daterangepicker';
obj['plugin_config'] = {
......@@ -141,12 +145,29 @@ define(['require',
},
onRender: function() {
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) {
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) {
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) {
filters.push(returnObj);
}
......@@ -156,7 +177,7 @@ define(['require',
this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'],
filters: filters,
select_placeholder: '--Select Attribute--',
select_placeholder: placeHolder,
allow_empty: true,
conditions: ['AND', 'OR'],
allow_groups: true,
......@@ -195,4 +216,4 @@ define(['require',
}
});
return QueryBuilderView;
});
\ No newline at end of file
});
......@@ -124,6 +124,11 @@ define(['require',
this.type = param.searchType;
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();
},
renderSaveSearch: function() {
......@@ -206,6 +211,9 @@ define(['require',
this.setValues();
this.checkForButtonVisiblity();
this.renderSaveSearch();
if (this.setInitialEntityVal) {
this.setInitialEntityVal = false;
}
},
makeFilterButtonActive: function(filtertypeParam) {
var filtertype = ['entityFilters', 'tagFilters'],
......@@ -231,7 +239,8 @@ define(['require',
}
}
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);
if (filterObj && filterObj.length) {
that.ui.tagAttrFilter.addClass('active');
......@@ -461,8 +470,11 @@ define(['require',
}
},
manualRender: function(paramObj) {
if (paramObj) {
this.value = paramObj;
}
this.updateQueryObject(paramObj);
this.renderTypeTagList(paramObj);
this.renderTypeTagList();
this.setValues(paramObj);
},
getFilterBox: function() {
......@@ -488,11 +500,7 @@ define(['require',
this.ui.typeLov.empty();
var typeStr = '<option></option>',
tagStr = typeStr,
foundNewClassification = false,
optionsValue = this.options.value;
if (options && options.tag) {
optionsValue = options;
}
foundNewClassification = false;
this.typeHeaders.fullCollection.each(function(model) {
var name = Utils.getName(model.toJSON(), 'name');
if (model.get('category') == 'ENTITY' && (serviceTypeToBefiltered && serviceTypeToBefiltered.length ? _.contains(serviceTypeToBefiltered, model.get('serviceType')) : true)) {
......@@ -501,8 +509,8 @@ define(['require',
}
if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') {
var tagEntityCount = that.entityCountObj.tag.tagEntities[name];
if (optionsValue) { // to check if wildcard classification is present in our data
if (name === optionsValue.tag) {
if (that.value && that.value.tag) { // to check if wildcard classification is present in our data
if (name === that.value.tag) {
foundNewClassification = true;
}
}
......@@ -510,17 +518,26 @@ define(['require',
}
});
if (!foundNewClassification && optionsValue) {
if (optionsValue.tag) {
var classificationValue = decodeURIComponent(optionsValue.tag);
if (this.type !== "dsl") {
_.each(Enums.addOnEntities, function(entity) {
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>';
}
}
if (_.isUndefined(isTypeOnly)) {
//to insert extra classification list
_.each(Enums.addOnClassification, function(classificationName) {
tagStr += '<option value="' + (classificationName) + '" data-name="' + (classificationName) + '">' + classificationName + '</option>';
});
if (that.value) {
_.each(Enums.addOnClassification, function(classificationName) {
if (classificationName !== that.value.tag) {
tagStr += '<option value="' + (classificationName) + '" data-name="' + (classificationName) + '">' + classificationName + '</option>';
}
});
}
that.ui.tagLov.html(tagStr);
this.ui.tagLov.select2({
placeholder: "Select Classification",
......@@ -554,6 +571,11 @@ define(['require',
if (typeLovSelect2 && serviceTypeToBefiltered) {
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() {
var getTypeAheadData = function(data, params) {
......
......@@ -21,7 +21,9 @@ define(['require',
'modules/Modal',
'utils/Utils',
'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(
/** @lends SearchQueryView */
......@@ -100,6 +102,9 @@ define(['require',
attrMerge: true,
});
}
if (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]) {
obj['systemAttrArr'] = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs;
}
} else {
obj['type'] = true;
obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type });
......@@ -110,6 +115,9 @@ define(['require',
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.showHideFilter(this.value);
......@@ -123,4 +131,4 @@ define(['require',
}
});
return SearchQueryView;
});
\ No newline at end of file
});
......@@ -573,6 +573,9 @@ define(['require',
if (!that.REntityTableLayoutView) {
return;
}
if (!that.value) {
that.value = that.options.value;
}
that.REntityTableLayoutView.show(table);
if (that.value.searchType !== "dsl") {
that.ui.containerCheckBox.show();
......@@ -637,6 +640,7 @@ define(['require',
nameCheck = 0,
columnToShow = null,
col = {};
this.value = Utils.getUrlState.getQueryParams();
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];
}
......@@ -786,9 +790,21 @@ define(['require',
}
if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
if (def) {
var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true });
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }), systemAttr = [];
if (def || Globals[this.value.type] || (
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) {
var key = obj.name,
isRenderable = _.contains(columnToShow, key),
......@@ -1202,4 +1218,4 @@ define(['require',
}
});
return SearchResultLayoutView;
});
\ No newline at end of file
});
......@@ -24,8 +24,9 @@ define(['require',
'collection/VTagList',
'models/VTag',
'utils/Messages',
'utils/UrlLinks'
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks) {
'utils/UrlLinks',
'utils/Globals'
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks, Globals) {
'use strict';
var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -92,6 +93,9 @@ define(['require',
onRender: function() {
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail'));
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.renderTagDetail();
}
......@@ -312,4 +316,4 @@ define(['require',
}
});
return TagAttributeDetailLayoutView;
});
\ No newline at end of file
});
......@@ -195,13 +195,14 @@ require(['App',
'utils/UrlLinks',
'collection/VEntityList',
'collection/VTagList',
'utils/Enums',
'utils/Overrides',
'bootstrap',
'd3',
'select2'
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
], function(App, Router, Helper, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList, Enums) {
var that = this;
this.asyncFetchCounter = 6;
this.asyncFetchCounter = 6 + (Enums.addOnEntities.length + 1);
this.entityDefCollection = new VEntityList();
this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList();
......@@ -308,4 +309,24 @@ require(['App',
startApp();
}
});
});
\ No newline at end of file
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 @@
* 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';
var CommonViewFunction = {};
......@@ -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>';
}
CommonViewFunction.generateQueryOfFilter = function(value, isCapsuleView) {
value = Utils.getUrlState.getQueryParams();
var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }),
tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }),
queryArray = [];
......@@ -476,22 +477,32 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
val = val.join(',');
} else if (k == "tagFilters") {
if (classificationDefCollection) {
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification })
attributeDefs = Utils.getNestedSuperTypeObj({
collection: classificationDefCollection,
attrMerge: true,
data: classificationDef.toJSON()
});
var classificationDef = classificationDefCollection.fullCollection.findWhere({ 'name': value[skey].classification }), attributeDefs = []
if (classificationDef) {
Utils.getNestedSuperTypeObj({
collection: classificationDefCollection,
attrMerge: true,
data: classificationDef.toJSON()
});
}
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (k == "entityFilters") {
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({
collection: entityDefCollection,
attrMerge: true,
data: entityDef.toJSON()
});
}
if (Globals[value[skey].typeName]) {
attributeDefs = Globals[value[skey].typeName].attributeDefs;
}
}
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val, "attributeDefs": attributeDefs });
} else if (_.contains(["includeDE", "excludeST", "excludeSC"], k)) {
......@@ -960,5 +971,45 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
});
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;
});
\ No newline at end of file
});
......@@ -136,7 +136,8 @@ define(['require'], function(require) {
validValues: getTermRelationAttributes(),
validValuesFor: getTermRelationAttributes()
}
Enums.addOnClassification = ["_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnClassification = ["_ALL_CLASSIFICATION_TYPES", "_CLASSIFIED", "_NOT_CLASSIFIED"];
Enums.addOnEntities = ["_ALL_ENTITY_TYPES"];
Enums.stats = {
generalData: {
......
......@@ -43,6 +43,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
metricsApiUrl: function() {
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) {
var defApiUrl = this.typedefsUrl(),
defUrl;
......
......@@ -53,8 +53,9 @@ define(['require',
* @constructs
*/
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.systemAttrArr = _.sortBy(this.systemAttrArr, 'name');
this.filterType = this.tag ? 'tagFilters' : 'entityFilters';
},
bindEvents: function() {},
......@@ -82,12 +83,15 @@ define(['require',
}
return false;
},
getObjDef: function(attrObj, rules) {
getObjDef: function(attrObj, rules, isGroup, groupType) {
var obj = {
id: attrObj.name,
label: _.escape(attrObj.name.capitalize() + " (" + attrObj.typeName + ")"),
type: _.escape(attrObj.typeName)
};
if (isGroup) {
obj.optgroup = groupType;
}
if (obj.type === "date") {
obj['plugin'] = 'daterangepicker';
obj['plugin_config'] = {
......@@ -141,12 +145,28 @@ define(['require',
},
onRender: function() {
var that = this,
filters = [];
if (this.value) {
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) {
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) {
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) {
filters.push(returnObj);
}
......@@ -156,7 +176,7 @@ define(['require',
this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'],
filters: filters,
select_placeholder: '--Select Attribute--',
select_placeholder: placeHolder,
allow_empty: true,
conditions: ['AND', 'OR'],
allow_groups: true,
......@@ -195,4 +215,4 @@ define(['require',
}
});
return QueryBuilderView;
});
\ No newline at end of file
});
......@@ -16,7 +16,7 @@
* 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";
var SearchDefaultlLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -252,6 +252,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
});
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, {
tag: true,
type: false,
......@@ -270,6 +274,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
});
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, {
tag: false,
type: true,
......@@ -430,4 +438,4 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
}
);
return SearchDefaultlLayoutView;
});
\ No newline at end of file
});
......@@ -36,14 +36,13 @@ define([
RClassificationTreeRender: '[data-id="r_classificationTreeRender"]',
REntityTreeRender: '[data-id="r_entityTreeRender"]',
RCustomFilterTreeRender: '[data-id="r_customFilterTreeRender"]',
},
ui: {
//search
searchNode: '[data-id="searchNode"]',
sliderBar: '[data-id="sliderBar"]',
menuItems: '.menu-items'
menuItems: ".menu-items"
},
templateHelpers: function() {
return {
......@@ -95,7 +94,7 @@ define([
events["click " + this.ui.menuItems] = function(e) {
e.stopPropagation();
//this.$('.menu-items').removeClass('open');
}
};
return events;
},
bindEvents: function() {},
......@@ -119,26 +118,30 @@ define([
this.bindEvents();
},
onRender: function() {
this.renderEntityTree();
this.renderClassificationTree();
this.renderGlossaryTree();
var opt = opt = Utils.getUrlState.getQueryParams();
this.renderEntityTree(opt);
this.renderClassificationTree(opt);
this.renderGlossaryTree(opt);
this.renderCustomFilterTree();
this.showHideGlobalFilter();
this.showDefaultPage();
},
showDefaultPage: function() {
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({
url: '!/search',
url: "!/search",
mergeBrowserUrl: false,
trigger: true,
updateTabState: true
});
}
}
},
onShow: function() {
var that = this;
......@@ -206,30 +209,30 @@ define([
}
}
},
renderEntityTree: function() {
renderEntityTree: function(opt) {
var that = this;
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;
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;
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() {
var that = this;
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)));
});
}
});
return SearchFilterBrowseLayoutViewNew;
});
\ No newline at end of file
});
......@@ -21,7 +21,8 @@ define(['require',
'modules/Modal',
'utils/Utils',
'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(
/** @lends SearchQueryView */
......@@ -100,6 +101,9 @@ define(['require',
attrMerge: true,
});
}
if (Globals[this.value.tag]) {
obj['attrObj'] = Globals[this.value.tag].attributeDefs;
}
} else {
obj['type'] = true;
obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type });
......@@ -110,6 +114,9 @@ define(['require',
attrMerge: true
});
}
if (Globals[this.value.type]) {
obj['attrObj'] = Globals[this.value.type].attributeDefs;
}
}
this.renderQueryBuilder(obj);
// this.showHideFilter(this.value);
......@@ -123,4 +130,4 @@ define(['require',
}
});
return SearchQueryView;
});
\ No newline at end of file
});
......@@ -584,6 +584,9 @@ define(['require',
if (!that.REntityTableLayoutView) {
return;
}
if (!that.value) {
that.value = that.options.value;
}
that.REntityTableLayoutView.show(table);
if (that.value.searchType !== "dsl") {
that.ui.containerCheckBox.show();
......@@ -648,6 +651,7 @@ define(['require',
nameCheck = 0,
columnToShow = null,
col = {};
this.value = Utils.getUrlState.getQueryParams();
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];
}
......@@ -798,9 +802,21 @@ define(['require',
}
if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
if (def) {
var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true });
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type }), systemAttr = [];
if (def || Globals[this.value.type] || (
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) {
var key = obj.name,
isRenderable = _.contains(columnToShow, key),
......@@ -1222,4 +1238,4 @@ define(['require',
}
});
return SearchResultLayoutView;
});
\ No newline at end of file
});
......@@ -25,8 +25,9 @@ define([
"utils/CommonViewFunction",
"collection/VSearchList",
"collection/VGlossaryList",
"utils/Enums",
"jstree"
], function(require, ClassificationTreeLayoutViewTmpl, Utils, Messages, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList) {
], function(require, ClassificationTreeLayoutViewTmpl, Utils, Messages, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList, Enums) {
"use strict";
var ClassificationTreeLayoutView = Marionette.LayoutView.extend({
......@@ -264,6 +265,11 @@ define([
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) {
......@@ -489,9 +495,31 @@ define([
});
var classificationTreeData = that.isEmptyClassification ? listWithEmptyParents : listOfParents;
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;
},
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) {
var $el = options && options.$el,
type = options && options.type,
......@@ -783,4 +811,4 @@ define([
});
return ClassificationTreeLayoutView;
});
\ No newline at end of file
});
......@@ -24,8 +24,9 @@ define([
"utils/CommonViewFunction",
"collection/VSearchList",
"collection/VGlossaryList",
'utils/Enums',
"jstree"
], function(require, EntityLayoutViewTmpl, Utils, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList) {
], function(require, EntityLayoutViewTmpl, Utils, Globals, UrlLinks, CommonViewFunction, VSearchList, VGlossaryList, Enums) {
"use strict";
var EntityTreeLayoutview = Marionette.LayoutView.extend({
......@@ -184,6 +185,11 @@ define([
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) {
......@@ -318,10 +324,39 @@ define([
var serviceTypeData = that.isEmptyServicetype ? serviceTypeWithEmptyEntity : serviceTypeArr;
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 {
return serviceTypeData;
data.push(rootEntityNode);
}
return data;
},
getParentsData = function(data) {
var parents = Object.keys(data),
......@@ -438,7 +473,7 @@ define([
).on("open_node.jstree", function(e, data) {
that.isTreeOpen = true;
}).on("select_node.jstree", function(e, data) {
if (that.fromManualRender !== true) {
if (!that.fromManualRender) {
that.onNodeSelect(data);
} else {
that.fromManualRender = false;
......@@ -508,4 +543,4 @@ define([
}
});
return EntityTreeLayoutview;
});
\ No newline at end of file
});
......@@ -24,8 +24,9 @@ define(['require',
'collection/VTagList',
'models/VTag',
'utils/Messages',
'utils/UrlLinks'
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks) {
'utils/UrlLinks',
"utils/Globals",
], function(require, Backbone, TagAttributeDetailLayoutViewTmpl, Utils, AddTagAttributeView, VTagList, VTag, Messages, UrlLinks, Globals) {
'use strict';
var TagAttributeDetailLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -96,6 +97,9 @@ define(['require',
onRender: function() {
Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.$('.tagDetail'));
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.renderTagDetail();
}
......@@ -316,4 +320,4 @@ define(['require',
}
});
return TagAttributeDetailLayoutView;
});
\ No newline at end of file
});
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