Commit f20f8bae by kevalbhatt

ATLAS-3366:UI: Quick Search dropdown entry icon does not match the fallback icon for that entry

parent 23aea76f
......@@ -37,6 +37,7 @@ define(["require"], function(require) {
status: false,
response: {}
};
Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
return Globals;
......
......@@ -189,7 +189,14 @@ define(['require',
titleName += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i> Deleted</button>';
}
this.ui.title.html(titleName);
var entityData = _.extend({ "serviceType": this.activeEntityDef && this.activeEntityDef.get('serviceType'), "isProcess": isProcess }, collectionJSON);
if (collectionJSON.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined && this.activeEntityDef) {
Globals.serviceTypeMap[collectionJSON.typeName] = this.activeEntityDef.get('serviceType');
}
} else if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined) {
Globals.serviceTypeMap[collectionJSON.typeName] = collectionJSON.attributes.serviceType;
}
var entityData = _.extend({ "serviceType": Globals.serviceTypeMap[collectionJSON.typeName], "isProcess": isProcess }, collectionJSON);
if (this.readOnly) {
this.ui.entityIcon.addClass('disabled');
} else {
......
......@@ -667,6 +667,17 @@ define(['require',
var obj = model.toJSON(),
nameHtml = "",
name = Utils.getName(obj);
if (obj.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[obj.typeName] === undefined && that.entityDefCollection) {
var defObj = that.entityDefCollection.fullCollection.find({ name: obj.typeName });
if (defObj) {
Globals.serviceTypeMap[obj.typeName] = defObj.get('serviceType');
}
}
} else if (Globals.serviceTypeMap[obj.typeName] === undefined) {
Globals.serviceTypeMap[obj.typeName] = obj.attributes.serviceType;
}
obj.serviceType = Globals.serviceTypeMap[obj.typeName];
if (obj.guid) {
if (obj.guid == "-1") {
nameHtml = '<span title="' + name + '">' + name + '</span>';
......
......@@ -133,12 +133,14 @@ define(['require',
var that = this,
request = options.request,
response = options.response,
inputEl = options.inputEl,
term = request.term,
data = {},
sendResponse = function() {
var query = data.query,
suggestions = data.suggestions;
if (query !== undefined && suggestions !== undefined) {
inputEl.siblings('span.fa-refresh').removeClass("fa-refresh fa-spin-custom").addClass("fa-search");
response(data);
}
};
......@@ -195,12 +197,6 @@ define(['require',
search: function() {
$(this).siblings('span.fa-search').removeClass("fa-search").addClass("fa-refresh fa-spin-custom");
},
focus: function(event, ui) {
return false;
},
open: function() {
$(this).siblings('span.fa-refresh').removeClass("fa-refresh fa-spin-custom").addClass("fa-search");
},
select: function(event, ui) {
var item = ui && ui.item;
event.preventDefault();
......@@ -223,7 +219,8 @@ define(['require',
source: function(request, response) {
that.fetchSearchData({
request: request,
response: response
response: response,
inputEl: this.element
});
}
}).focus(function() {
......@@ -242,7 +239,6 @@ define(['require',
}
}
}).atlasAutoComplete("instance")._renderItem = function(ul, searchItem) {
if (searchItem) {
var data = searchItem.data,
searchTerm = this.term,
......@@ -268,6 +264,17 @@ define(['require',
item.itemText = Utils.getName(item) + " (" + item.typeName + ")";
var options = {},
table = '';
if (item.serviceType === undefined) {
if (Globals.serviceTypeMap[item.typeName] === undefined && that.entityDefCollection) {
var defObj = that.entityDefCollection.fullCollection.find({ name: item.typeName });
if (defObj) {
Globals.serviceTypeMap[item.typeName] = defObj.get("serviceType");
}
}
} else if (Globals.serviceTypeMap[item.typeName] === undefined) {
Globals.serviceTypeMap[item.typeName] = item.serviceType;
}
item.serviceType = Globals.serviceTypeMap[item.typeName];
options.entityData = item;
var imgEl = $('<img src="' + Utils.getEntityIconPath(options) + '">').on("error", function(error, s) {
this.src = Utils.getEntityIconPath(_.extend(options, { errorUrl: this.src }));
......
......@@ -37,6 +37,7 @@ define(["require"], function(require) {
status: false,
response: {}
};
Globals.serviceTypeMap = {};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
return Globals;
......
......@@ -193,7 +193,14 @@ define(['require',
titleName += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i> Deleted</button>';
}
this.ui.title.html(titleName);
var entityData = _.extend({ "serviceType": this.activeEntityDef && this.activeEntityDef.get('serviceType'), "isProcess": isProcess }, collectionJSON);
if (collectionJSON.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined && this.activeEntityDef) {
Globals.serviceTypeMap[collectionJSON.typeName] = this.activeEntityDef.get('serviceType');
}
} else if (Globals.serviceTypeMap[collectionJSON.typeName] === undefined) {
Globals.serviceTypeMap[collectionJSON.typeName] = collectionJSON.attributes.serviceType;
}
var entityData = _.extend({ "serviceType": Globals.serviceTypeMap[collectionJSON.typeName], "isProcess": isProcess }, collectionJSON);
if (this.readOnly) {
this.ui.entityIcon.addClass('disabled');
} else {
......
......@@ -21,8 +21,9 @@ define(["require",
"hbs!tmpl/search/GlobalSearchLayoutView_tmpl",
"utils/Utils",
"utils/UrlLinks",
'utils/Globals',
"jquery-ui"
], function(require, Backbone, GlobalSearchLayoutViewTmpl, Utils, UrlLinks) {
], function(require, Backbone, GlobalSearchLayoutViewTmpl, Utils, UrlLinks, Globals) {
"use strict";
var GlobalSearchLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -292,6 +293,17 @@ define(["require",
item.itemText = Utils.getName(item) + " (" + item.typeName + ")";
var options = {},
table = "";
if (item.serviceType === undefined) {
if (Globals.serviceTypeMap[item.typeName] === undefined && that.entityDefCollection) {
var defObj = that.entityDefCollection.fullCollection.find({ name: item.typeName });
if (defObj) {
Globals.serviceTypeMap[item.typeName] = defObj.get("serviceType");
}
}
} else if (Globals.serviceTypeMap[item.typeName] === undefined) {
Globals.serviceTypeMap[item.typeName] = item.serviceType;
}
item.serviceType = Globals.serviceTypeMap[item.typeName];
options.entityData = item;
var imgEl = $('<img src="' + Utils.getEntityIconPath(options) + '">').on("error", function(error, s) {
this.src = Utils.getEntityIconPath(_.extend(options, { errorUrl: this.src }));
......
......@@ -680,6 +680,17 @@ define(['require',
var obj = model.toJSON(),
nameHtml = "",
name = Utils.getName(obj);
if (obj.attributes.serviceType === undefined) {
if (Globals.serviceTypeMap[obj.typeName] === undefined && that.entityDefCollection) {
var defObj = that.entityDefCollection.fullCollection.find({ name: obj.typeName });
if (defObj) {
Globals.serviceTypeMap[obj.typeName] = defObj.get('serviceType');
}
}
} else if (Globals.serviceTypeMap[obj.typeName] === undefined) {
Globals.serviceTypeMap[obj.typeName] = obj.attributes.serviceType;
}
obj.serviceType = Globals.serviceTypeMap[obj.typeName];
if (obj.guid) {
if (obj.guid == "-1") {
nameHtml = '<span title="' + name + '">' + name + '</span>';
......
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