AdministratorLayoutView.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. define([ "require", "backbone", "hbs!tmpl/administrator/AdministratorLayoutView_tmpl", "collection/VEntityList", "models/VSearch", "utils/Utils", "utils/Enums", "utils/UrlLinks", "utils/CommonViewFunction" ], function(require, Backbone, AdministratorLayoutView_tmpl, VEntityList, VSearch, Utils, Enums, UrlLinks, CommonViewFunction) {
  2. "use strict";
  3. var AdministratorLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "AdministratorLayoutView",
  5. template: AdministratorLayoutView_tmpl,
  6. regions: {
  7. RBusinessMetadataTableLayoutView: "#r_businessMetadataTableLayoutView",
  8. REnumTableLayoutView: "#r_enumTableLayoutView",
  9. RAdminTableLayoutView: "#r_adminTableLayoutView",
  10. RTypeSystemTreeLayoutView: "#r_typeSystemTreeLayoutView"
  11. },
  12. ui: {
  13. tablist: '[data-id="tab-list"] li'
  14. },
  15. events: function() {
  16. var events = {};
  17. return events["click " + this.ui.tablist] = function(e) {
  18. var tabValue = $(e.currentTarget).attr("role");
  19. Utils.setUrl({
  20. url: Utils.getUrlState.getQueryUrl().queyParams[0],
  21. urlParams: {
  22. tabActive: tabValue || "properties"
  23. },
  24. mergeBrowserUrl: !1,
  25. trigger: !1,
  26. updateTabState: !0
  27. });
  28. }, events;
  29. },
  30. initialize: function(options) {
  31. _.extend(this, _.pick(options, "value", "entityDefCollection", "businessMetadataDefCollection", "enumDefCollection", "searchTableFilters"));
  32. },
  33. onShow: function() {
  34. this.value && this.value.tabActive && (this.$(".nav.nav-tabs").find('[role="' + this.value.tabActive + '"]').addClass("active").siblings().removeClass("active"),
  35. this.$(".tab-content").find('[role="' + this.value.tabActive + '"]').addClass("active").siblings().removeClass("active"),
  36. $("html, body").animate({
  37. scrollTop: this.$(".tab-content").offset().top + 1200
  38. }, 1e3));
  39. },
  40. bindEvents: function() {
  41. this.renderEnumLayoutView(), this.renderAdminLayoutView(), this.renderTypeSystemTreeLayoutView();
  42. },
  43. onRender: function() {
  44. this.renderBusinessMetadataLayoutView(), this.bindEvents();
  45. },
  46. renderBusinessMetadataLayoutView: function(obj) {
  47. var that = this;
  48. require([ "views/business_metadata/BusinessMetadataTableLayoutView" ], function(BusinessMetadataTableLayoutView) {
  49. that.RBusinessMetadataTableLayoutView.show(new BusinessMetadataTableLayoutView({
  50. businessMetadataDefCollection: that.businessMetadataDefCollection,
  51. entityDefCollection: that.entityDefCollection
  52. }));
  53. });
  54. },
  55. renderEnumLayoutView: function(obj) {
  56. var that = this;
  57. require([ "views/business_metadata/EnumCreateUpdateItemView" ], function(EnumCreateUpdateItemView) {
  58. var view = new EnumCreateUpdateItemView({
  59. enumDefCollection: that.enumDefCollection,
  60. businessMetadataDefCollection: that.businessMetadataDefCollection
  61. });
  62. that.REnumTableLayoutView.show(view);
  63. });
  64. },
  65. renderAdminLayoutView: function(obj) {
  66. var that = this;
  67. require([ "views/audit/AdminAuditTableLayoutView" ], function(AdminAuditTableLayoutView) {
  68. var view = new AdminAuditTableLayoutView({
  69. searchTableFilters: that.searchTableFilters,
  70. entityDefCollection: that.entityDefCollection,
  71. enumDefCollection: that.enumDefCollection
  72. });
  73. that.RAdminTableLayoutView.show(view);
  74. });
  75. },
  76. renderTypeSystemTreeLayoutView: function(obj) {
  77. var that = this;
  78. require([ "views/graph/TypeSystemTreeView" ], function(TypeSystemTreeView) {
  79. var view = new TypeSystemTreeView({
  80. entityDefCollection: that.entityDefCollection
  81. });
  82. that.RTypeSystemTreeLayoutView.show(view);
  83. });
  84. }
  85. });
  86. return AdministratorLayoutView;
  87. });