Commit 1decc731 by Kalyani Committed by nixonrodrigues

ATLAS-1759 : UI - Add checkbox to exclude deleted entities in schema table.

parent 96d9a0ec
......@@ -16,9 +16,14 @@
-->
<div>
<div class="tableOverlay"></div>
<div style="margin-left: 20px" data-id="checkDeletedEntity">
<label class="checkbox">
<input type="checkbox" class="input" name="queryType" value="text" name="check" value="1" />Include historical entities</label>
</div>
<div class="clearfix">
<a href="javascript:void(0)" class="inputAssignTag multiSelectTerm btnAssign" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i> Assign Term</a>
<a href="javascript:void(0)" class="inputAssignTag multiSelectTag assignTag btnAssign" style="display:none" data-id="addAssignTag"><i class="fa fa-plus"></i> Assign Tag</a>
</div>
<div id="r_schemaTableLayoutView"></div>
<div id="r_schemaTableLayoutView">
</div>
</div>
......@@ -47,7 +47,9 @@ define(['require',
addTerm: '[data-id="addTerm"]',
showMoreLess: '[data-id="showMoreLess"]',
showMoreLessTerm: '[data-id="showMoreLessTerm"]',
addAssignTag: "[data-id='addAssignTag']"
addAssignTag: "[data-id='addAssignTag']",
checkDeletedEntity: "[data-id='checkDeletedEntity']",
},
/** ui events hash */
events: function() {
......@@ -84,6 +86,8 @@ define(['require',
$(e.currentTarget).find('span').text('Show less');
}
};
events["click " + this.ui.checkDeletedEntity] = 'onCheckDeletedEntity';
return events;
},
/**
......@@ -142,20 +146,36 @@ define(['require',
});
},
onRender: function() {
var that = this;
_.each(this.attribute, function(obj) {
var defObj = that.entityDefCollection.fullCollection.find({ name: obj.typeName });
this.generateTableData();
},
generateTableData: function(checkedDelete) {
var that = this,
newModel;
this.activeObj = [];
this.deleteObj = [];
this.schemaTableAttribute = null;
if (this.attribute && this.attribute[0]) {
var firstColumn = this.attribute[0],
defObj = that.entityDefCollection.fullCollection.find({ name: firstColumn.typeName });
if (defObj && defObj.get('options') && defObj.get('options').schemaAttributes) {
try {
var mapObj = JSON.parse(defObj.get('options').schemaAttributes);
var newModel = that.referredEntities[obj.guid];
newModel.schemaTableAttribute = _.pick(newModel.attributes, mapObj);
if (newModel.attributes['position']) {
newModel['position'] = newModel.attributes['position'];
}
that.schemaCollection.push(newModel);
} catch (e) {}
if (firstColumn) {
try {
var mapObj = JSON.parse(defObj.get('options').schemaAttributes);
that.schemaTableAttribute = _.pick(firstColumn.attributes, mapObj);
} catch (e) {}
}
}
}
_.each(this.attribute, function(obj) {
newModel = that.referredEntities[obj.guid];
if (newModel.attributes['position']) {
newModel['position'] = newModel.attributes['position'];
}
if (!Enums.entityStateReadOnly[newModel.status]) {
that.activeObj.push(newModel);
that.schemaCollection.push(newModel);
} else if (Enums.entityStateReadOnly[newModel.status]) {
that.deleteObj.push(newModel);
}
});
$('body').click(function(e) {
......@@ -167,6 +187,13 @@ define(['require',
that.$('.popover.popoverTag').hide();
}
});
if (this.schemaCollection.length === 0 && this.deleteObj.length) {
this.ui.checkDeletedEntity.find("input").prop('checked', true);
this.schemaCollection.reset(this.deleteObj, { silent: true });
}
if (this.activeObj.length === 0 && this.deleteObj.length === 0) {
this.ui.checkDeletedEntity.hide();
}
this.renderTableLayoutView();
},
showLoader: function() {
......@@ -177,7 +204,7 @@ define(['require',
this.$('.fontLoader').hide();
this.$('.tableOverlay').hide();
},
renderTableLayoutView: function() {
renderTableLayoutView: function(deleteEnity) {
var that = this;
require(['utils/TableLayout'], function(TableLayout) {
var columnCollection = Backgrid.Columns.extend({
......@@ -222,7 +249,6 @@ define(['require',
},
getSchemaTableColumns: function() {
var that = this,
schemaFirstmodel = this.schemaCollection.first(),
col = {
Check: {
name: "selected",
......@@ -231,8 +257,8 @@ define(['require',
headerCell: "select-all"
}
}
if (schemaFirstmodel) {
_.each(_.keys(schemaFirstmodel.get('schemaTableAttribute')), function(key) {
if (this.schemaTableAttribute) {
_.each(_.keys(this.schemaTableAttribute), function(key) {
if (key !== "position") {
col[key] = {
label: key,
......@@ -242,7 +268,7 @@ define(['require',
className: "searchTableName",
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var value = model.get('schemaTableAttribute')[key];
var value = model.get('attributes')[key];
if (key === "name" && model.get('guid')) {
var nameHtml = '<a href="#!/detailPage/' + model.get('guid') + '">' + value + '</a>';
if (model.get('status') && Enums.entityStateReadOnly[model.get('status')]) {
......@@ -410,6 +436,15 @@ define(['require',
that.fetchCollection();
}
});
},
onCheckDeletedEntity: function(e) {
if (e.target.checked) {
if (this.deleteObj.length) {
this.schemaCollection.reset(this.activeObj.concat(this.deleteObj));
}
} else {
this.schemaCollection.reset(this.activeObj);
}
}
});
return SchemaTableLayoutView;
......
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