in dashboardv2/public/js/views/search/SearchLayoutView.js [580:670]
renderTypeTagList: function(options) {
var that = this;
var serviceTypeToBefiltered = (options && options.filterList);
var isTypeOnly = options && options.isTypeOnly;
if (this.selectedFilter[this.type].length) {
serviceTypeToBefiltered = this.selectedFilter[this.type];
}
this.ui.typeLov.empty();
var typeStr = '<option></option>',
tagStr = typeStr,
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)) {
var entityCount = (that.entityCountObj.entity.entityActive[name] || 0) + (that.entityCountObj.entity.entityDeleted[name] || 0);
typeStr += '<option value="' + (name) + '" data-name="' + (name) + '">' + (name) + ' ' + (entityCount ? "(" + _.numberFormatWithComma(entityCount) + ")" : '') + '</option>';
}
if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') {
var tagEntityCount = that.entityCountObj.tag.tagEntities[name];
if (that.value && that.value.tag) { // to check if wildcard classification is present in our data
if (name === that.value.tag) {
foundNewClassification = true;
}
}
tagStr += '<option value="' + (name) + '" data-name="' + (name) + '">' + (name) + ' ' + (tagEntityCount ? "(" + _.numberFormatWithComma(tagEntityCount) + ")" : '') + '</option>';
}
});
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
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",
allowClear: true,
tags: true,
createTag: function(tag) {
if (tag.term.indexOf('*') != -1) {
return {
id: tag.term,
text: tag.term,
isNew: true
};
}
}
});
}
that.ui.typeLov.html(typeStr);
var typeLovSelect2 = this.ui.typeLov.select2({
placeholder: "Select Type",
dropdownAdapter: $.fn.select2.amd.require("ServiceTypeFilterDropdownAdapter"),
allowClear: true,
getFilterBox: this.getFilterBox.bind(this),
onFilterSubmit: function(options) {
that.selectedFilter[that.type] = options.filterVal;
that.filterTypeSelected = that.selectedFilter[that.type];
that.renderTypeTagList({ "filterList": options.filterVal, isTypeOnly: true });
that.checkForButtonVisiblity();
}
});
if (this.value.filterTypeSelected === "undefined") {
typeLovSelect2.on("select2:close", function() {
typeLovSelect2.trigger("hideFilter");
});
if (typeLovSelect2 && isTypeOnly) {
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);
}
},