in dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js [110:198]
bindEvents: function() {
var that = this;
this.listenTo(this.collection, 'reset', function() {
this.entityObject = this.collection.first().toJSON();
var collectionJSON = this.entityObject.entity;
if (collectionJSON && collectionJSON.guid) {
var tagGuid = collectionJSON.guid;
this.readOnly = Enums.entityStateReadOnly[collectionJSON.status];
} else {
var tagGuid = this.id;
}
if (this.readOnly) {
this.$el.addClass('readOnly');
} else {
this.$el.removeClass('readOnly');
}
if (collectionJSON) {
this.name = Utils.getName(collectionJSON);
if (collectionJSON.attributes) {
if (this.name && collectionJSON.typeName) {
this.name = this.name + ' (' + _.escape(collectionJSON.typeName) + ')';
}
if (!this.name && collectionJSON.typeName) {
this.name = _.escape(collectionJSON.typeName);
}
this.description = collectionJSON.attributes.description;
if (this.name) {
this.ui.title.show();
var titleName = '<span>' + this.name + '</span>';
if (this.readOnly) {
titleName += '<button title="Deleted" class="btn btn-atlasAction btn-atlas deleteBtn"><i class="fa fa-trash"></i> Deleted</button>';
}
this.ui.title.html(titleName);
} else {
this.ui.title.hide();
}
if (this.description) {
this.ui.description.show();
this.ui.description.html('<span>' + _.escape(this.description) + '</span>');
} else {
this.ui.description.hide();
}
}
if (collectionJSON.classifications) {
this.addTagToTerms(collectionJSON.classifications);
} else {
this.addTagToTerms([]);
}
if (Globals.entityTypeConfList && _.isEmptyArray(Globals.entityTypeConfList)) {
this.ui.editButton.show();
} else {
if (_.contains(Globals.entityTypeConfList, collectionJSON.typeName)) {
this.ui.editButton.show();
}
}
}
this.hideLoader();
var obj = {
entity: collectionJSON,
referredEntities: this.entityObject.referredEntities,
guid: this.id,
entityName: this.name,
typeHeaders: this.typeHeaders,
entityDefCollection: this.entityDefCollection,
fetchCollection: this.fetchCollection.bind(that),
enumDefCollection: this.enumDefCollection,
classificationDefCollection: this.classificationDefCollection
}
this.getEntityDef(obj);
this.renderTagTableLayoutView(obj);
this.renderTermTableLayoutView(_.extend({}, obj, { term: true }));
// To render Schema check attribute "schemaElementsAttribute"
var schemaOptions = this.entityDefCollection.fullCollection.find({ name: collectionJSON.typeName }).get('options');
if (schemaOptions && schemaOptions.hasOwnProperty('schemaElementsAttribute') && schemaOptions.schemaElementsAttribute !== "") {
this.$('.schemaTable').show();
this.renderSchemaLayoutView(_.extend({}, obj, {
attribute: collectionJSON.attributes[schemaOptions.schemaElementsAttribute]
}));
}
}, this);
this.listenTo(this.collection, 'error', function(model, response) {
this.$('.fontLoader').hide();
if (response.responseJSON) {
Utils.notifyError({
content: response.responseJSON.errorMessage || response.responseJSON.error
});
}
}, this);
},