in dashboardv2/public/js/views/search/SearchResultLayoutView.js [470:664]
getFixedDslColumn: function() {
var that = this,
nameCheck = 0,
col = {};
col['Check'] = {
name: "selected",
label: "Select",
cell: "select-row",
resizeable: false,
orderable: false,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'selected') : true),
headerCell: "select-all"
};
col['name'] = {
label: "Name",
cell: "html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: true,
className: "searchTableName",
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON(),
nameHtml = "",
name = Utils.getName(obj);
if (obj.guid) {
nameHtml = '<a title="' + name + '" href="#!/detailPage/' + obj.guid + '">' + name + '</a>';
} else {
nameHtml = '<a title="' + name + '">' + name + '</a>';
}
if (obj.status && Enums.entityStateReadOnly[obj.status]) {
nameHtml += '<button type="button" title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i></button>';
return '<div class="readOnly readOnlyLink">' + nameHtml + '</div>';
} else {
if (Globals.entityUpdate) {
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
nameHtml += '<button title="Edit" data-id="editEntityButton" data-giud= "' + obj.guid + '" class="btn btn-atlasAction btn-atlas editBtn"><i class="fa fa-pencil"></i></button>'
} else {
if (_.contains(Globals.entityTypeConfList, obj.typeName)) {
nameHtml += '<button title="Edit" data-id="editEntityButton" data-giud= "' + obj.guid + '" class="btn btn-atlasAction btn-atlas editBtn"><i class="fa fa-pencil"></i></button>'
}
}
}
return nameHtml;
}
}
})
};
col['description'] = {
label: "Description",
cell: "String",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.description) {
return obj.attributes.description;
}
}
})
};
col['typeName'] = {
label: "Type",
cell: "Html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'typeName') : true),
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.typeName) {
return '<a title="Search ' + obj.typeName + '" href="#!/search/searchResult?query=' + obj.typeName + ' &searchType=dsl&dslChecked=true">' + obj.typeName + '</a>';
}
}
})
};
col['owner'] = {
label: "Owner",
cell: "String",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.owner) {
return obj.attributes.owner;
}
}
})
};
col['tag'] = {
label: "Tags",
cell: "Html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'tag') : true),
className: 'searchTag',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj.status && Enums.entityStateReadOnly[obj.status]) {
return '<div class="readOnly">' + CommonViewFunction.tagForTable(obj); + '</div>';
} else {
return CommonViewFunction.tagForTable(obj);
}
}
})
};
if (Globals.taxonomy) {
col['terms'] = {
label: "Terms",
cell: "Html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'terms') : true),
className: 'searchTerm',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
var returnObject = CommonViewFunction.termTableBreadcrumbMaker(obj);
if (returnObject.object) {
that.bradCrumbList.push(returnObject.object);
}
if (obj.status && Enums.entityStateReadOnly[obj.status]) {
return '<div class="readOnly">' + returnObject.html + '</div>';
} else {
return returnObject.html;
}
}
})
};
}
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 });
_.each(attrObj, function(obj, key) {
var key = obj.name,
isRenderable = _.contains(that.columnToShow, key)
if (key == "name" || key == "description" || key == "owner") {
if (that.columnToShow && that.columnToShow.length) {
col[key].renderable = isRenderable;
}
return;
}
col[obj.name] = {
label: obj.name.capitalize(),
cell: "Html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: isRenderable,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var modelObj = model.toJSON();
if (modelObj && modelObj.attributes && !_.isUndefined(modelObj.attributes[key])) {
var tempObj = {
'scope': that,
'attributeDefs': [obj],
'valueObject': {},
'isTable': false
}
tempObj.valueObject[key] = modelObj.attributes[key]
Utils.findAndMergeRefEntity(tempObj.valueObject, that.searchCollection.referredEntities);
return CommonViewFunction.propertyTable(tempObj);
}
}
})
};
});
}
}
return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
},