Skip to content

Instantly share code, notes, and snippets.

@kerbyfc
Last active August 31, 2015 15:58
Show Gist options
  • Save kerbyfc/c12edbab6edc9fbf9294 to your computer and use it in GitHub Desktop.
Save kerbyfc/c12edbab6edc9fbf9294 to your computer and use it in GitHub Desktop.
Выполнение "кастомной" бизнес-логики при рендеринге/обновлении построителя запросов
diff --git a/web/front/app/scripts/views/events/query_builder/advanced_conditions_query.coffee b/web/front/app/scripts/views/events/query_builder/advanced_conditions_query.coffee
index 768919a..b19c0fd 100644
--- a/web/front/app/scripts/views/events/query_builder/advanced_conditions_query.coffee
+++ b/web/front/app/scripts/views/events/query_builder/advanced_conditions_query.coffee
@@ -44,6 +44,7 @@ class FilterView extends App.Helpers.virtual_class(
return {
link_operator : @model.get 'link_operator'
isCommonPeriodUsed : @options.isCommonPeriodUsed
+ callbacks : @options.callbacks
formats : @formats
}
diff --git a/web/front/app/scripts/views/events/query_builder/query_builder_base.coffee b/web/front/app/scripts/views/events/query_builder/query_builder_base.coffee
index 6d59350..ab43362 100644
--- a/web/front/app/scripts/views/events/query_builder/query_builder_base.coffee
+++ b/web/front/app/scripts/views/events/query_builder/query_builder_base.coffee
@@ -4,6 +4,10 @@ module.exports = class QueryBuilderBase
onDomRefresh: ->
if @data
+
+ if _.isFunction @callback
+ @callback @
+
if @data.capture_date?.interval is 'period'
@$el.find('.period_range').show()
@@ -116,6 +120,9 @@ module.exports = class QueryBuilderBase
if query
for item in query
if item.category? and item.value
+
+ @callback = @options.callbacks?[item.category]
+
switch item.category
when 'object_id'
data[item.category] = {}
diff --git a/web/front/app/scripts/views/reports/dialogs/widget.coffee b/web/front/app/scripts/views/reports/dialogs/widget.coffee
index 796b638..f5bfe1c 100644
--- a/web/front/app/scripts/views/reports/dialogs/widget.coffee
+++ b/web/front/app/scripts/views/reports/dialogs/widget.coffee
@@ -303,6 +303,11 @@ module.exports = class ReportWidgetView extends Marionette.LayoutView
isCommonPeriodUsed : isCommonPeriodUsed
exclude : ['object_id', 'general']
+ callbacks:
+ capture_date: (view) ->
+ view.$el.append "span"
+ # do things
+
+
if @mode is "lite"
view.on "form:change", @_updateQuery
else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment