EntityDetailTableLayoutView.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. define([ "require", "backbone", "hbs!tmpl/entity/EntityDetailTableLayoutView_tmpl", "utils/CommonViewFunction", "models/VEntity", "utils/Utils" ], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction, VEntity, Utils) {
  2. "use strict";
  3. var EntityDetailTableLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "EntityDetailTableLayoutView",
  5. template: EntityDetailTableLayoutView_tmpl,
  6. templateHelpers: function() {
  7. return {
  8. editEntity: this.editEntity
  9. };
  10. },
  11. regions: {},
  12. ui: {
  13. detailValue: "[data-id='detailValue']",
  14. noValueToggle: "[data-id='noValueToggle']",
  15. editButton: '[data-id="editButton"]'
  16. },
  17. events: function() {
  18. var events = {};
  19. return events["click " + this.ui.noValueToggle] = function() {
  20. this.showAllProperties = !this.showAllProperties, this.ui.noValueToggle.attr("data-original-title", (this.showAllProperties ? "Hide" : "Show") + " empty values"),
  21. Utils.togglePropertyRelationshipTableEmptyValues({
  22. inputType: this.ui.noValueToggle,
  23. tableEl: this.ui.detailValue
  24. });
  25. }, events["click " + this.ui.editButton] = "onClickEditEntity", events;
  26. },
  27. initialize: function(options) {
  28. _.extend(this, _.pick(options, "entity", "typeHeaders", "attributeDefs", "attributes", "editEntity", "guid", "entityDefCollection", "searchVent", "fetchCollection")),
  29. this.entityModel = new VEntity({}), this.showAllProperties = !1;
  30. },
  31. bindEvents: function() {},
  32. onRender: function() {
  33. this.entityTableGenerate();
  34. },
  35. entityTableGenerate: function() {
  36. var that = this, highlightString = $(".atlas-header .global-search-container input.global-search").val(), table = CommonViewFunction.propertyTable({
  37. scope: this,
  38. valueObject: _.extend({
  39. isIncomplete: this.entity.isIncomplete
  40. }, this.entity.attributes),
  41. attributeDefs: this.attributeDefs,
  42. highlightString: highlightString
  43. });
  44. this.ui.detailValue.append(table), Utils.togglePropertyRelationshipTableEmptyValues({
  45. inputType: this.ui.noValueToggle,
  46. tableEl: this.ui.detailValue
  47. }), setTimeout(function() {
  48. that.$el.find(".searched-term-highlight").addClass("bold");
  49. }, 5e3);
  50. },
  51. onClickEditEntity: function(e) {
  52. var that = this;
  53. $(e.currentTarget).blur(), require([ "views/entity/CreateEntityLayoutView" ], function(CreateEntityLayoutView) {
  54. new CreateEntityLayoutView({
  55. guid: that.guid,
  56. searchVent: that.searchVent,
  57. entityDefCollection: that.entityDefCollection,
  58. typeHeaders: that.typeHeaders,
  59. callback: function() {
  60. that.fetchCollection();
  61. }
  62. });
  63. });
  64. }
  65. });
  66. return EntityDetailTableLayoutView;
  67. });