SearchQueryView.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. define([ "require", "backbone", "modules/Modal", "utils/Utils", "hbs!tmpl/search/SearchQuery_tmpl", "utils/Globals", "utils/Enums" ], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl, Globals, Enums) {
  2. var SearchQueryView = Backbone.Marionette.LayoutView.extend({
  3. _viewName: "SearchQueryView",
  4. template: SearchQuery_Tmpl,
  5. regions: {
  6. RQueryBuilder: "#r_queryBuilder"
  7. },
  8. ui: {},
  9. events: function() {
  10. var events = {};
  11. return events;
  12. },
  13. initialize: function(options) {
  14. _.extend(this, _.pick(options, "value", "entityDefCollection", "typeHeaders", "searchVent", "enumDefCollection", "classificationDefCollection", "businessMetadataDefCollection", "tag", "searchTableFilters")),
  15. this.bindEvents();
  16. var that = this;
  17. this.modal = new Modal({
  18. title: "Attribute Filter",
  19. content: this,
  20. allowCancel: !0,
  21. mainClass: "modal-lg",
  22. okCloses: !1,
  23. buttons: [ {
  24. text: "Cancel",
  25. btnClass: "cancel btn-action",
  26. title: "Cancel"
  27. }, {
  28. text: "Apply",
  29. btnClass: "ok btn-atlas",
  30. title: "Apply the filters and close popup (won't perform search)"
  31. }, {
  32. text: "Search",
  33. btnClass: "ok search btn-atlas",
  34. title: "Apply the filters and do search"
  35. } ]
  36. }).open(), this.modal.on("closeModal", function() {
  37. that.modal.trigger("cancel");
  38. });
  39. },
  40. onRender: function() {
  41. var obj = {
  42. value: this.value,
  43. searchVent: this.searchVent,
  44. entityDefCollection: this.entityDefCollection,
  45. enumDefCollection: this.enumDefCollection,
  46. classificationDefCollection: this.classificationDefCollection,
  47. businessMetadataDefCollection: this.businessMetadataDefCollection,
  48. searchTableFilters: this.searchTableFilters,
  49. typeHeaders: this.typeHeaders
  50. };
  51. this.tag ? (obj.tag = !0, obj.attrObj = this.classificationDefCollection.fullCollection.find({
  52. name: this.value.tag
  53. }), obj.attrObj && (obj.attrObj = Utils.getNestedSuperTypeObj({
  54. data: obj.attrObj.toJSON(),
  55. collection: this.classificationDefCollection,
  56. attrMerge: !0
  57. })), (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]) && (obj.systemAttrArr = (Globals[this.value.tag] || Globals[Enums.addOnClassification[0]]).attributeDefs)) : (obj.type = !0,
  58. obj.attrObj = this.entityDefCollection.fullCollection.find({
  59. name: this.value.type
  60. }), obj.attrObj && (obj.attrObj = Utils.getNestedSuperTypeObj({
  61. data: obj.attrObj.toJSON(),
  62. collection: this.entityDefCollection,
  63. attrMerge: !0
  64. })), (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]) && (obj.systemAttrArr = (Globals[this.value.type] || Globals[Enums.addOnEntities[0]]).attributeDefs)),
  65. this.renderQueryBuilder(obj);
  66. },
  67. bindEvents: function() {},
  68. renderQueryBuilder: function(obj) {
  69. var that = this;
  70. require([ "views/search/QueryBuilderView" ], function(QueryBuilderView) {
  71. that.RQueryBuilder.show(new QueryBuilderView(obj));
  72. });
  73. }
  74. });
  75. return SearchQueryView;
  76. });