SearchQueryView.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define([ "require", "backbone", "modules/Modal", "utils/Utils", "hbs!tmpl/search/SearchQuery_tmpl", "utils/Globals" ], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl, Globals) {
  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", "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. this.$(".fontLoader").show();
  42. var obj = {
  43. value: this.value,
  44. searchVent: this.searchVent,
  45. entityDefCollection: this.entityDefCollection,
  46. enumDefCollection: this.enumDefCollection,
  47. classificationDefCollection: this.classificationDefCollection,
  48. searchTableFilters: this.searchTableFilters
  49. };
  50. this.tag ? (obj.tag = !0, obj.attrObj = this.classificationDefCollection.fullCollection.find({
  51. name: this.value.tag
  52. }), obj.attrObj && (obj.attrObj = Utils.getNestedSuperTypeObj({
  53. data: obj.attrObj.toJSON(),
  54. collection: this.classificationDefCollection,
  55. attrMerge: !0
  56. })), Globals[this.value.tag] && (obj.attrObj = Globals[this.value.tag].attributeDefs)) : (obj.type = !0,
  57. obj.attrObj = this.entityDefCollection.fullCollection.find({
  58. name: this.value.type
  59. }), obj.attrObj && (obj.attrObj = Utils.getNestedSuperTypeObj({
  60. data: obj.attrObj.toJSON(),
  61. collection: this.entityDefCollection,
  62. attrMerge: !0
  63. })), Globals[this.value.type] && (obj.attrObj = Globals[this.value.type].attributeDefs)),
  64. this.renderQueryBuilder(obj);
  65. },
  66. bindEvents: function() {},
  67. renderQueryBuilder: function(obj) {
  68. var that = this;
  69. require([ "views/search/QueryBuilderView" ], function(QueryBuilderView) {
  70. that.RQueryBuilder.show(new QueryBuilderView(obj));
  71. });
  72. }
  73. });
  74. return SearchQueryView;
  75. });