diff --git a/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee b/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee
index f0321ac92..9e4a0764a 100644
--- a/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee
+++ b/app/assets/javascripts/app/controllers/_ui_element/time_range.coffee
@@ -10,8 +10,28 @@ class App.UiElement.time_range
for key, value of ranges
ranges[key] = App.i18n.translateInline(value)
- values = {}
- for count in [0..31]
- values[count.toString()] = count.toString()
+ range = 'minute'
+ if attribute.value && attribute.value.range
+ range = attribute.value.range
+ values =
+ minute: [1..120]
+ hour: [1..48]
+ day: [1..31]
+ month: [1..12]
+ year: [1..20]
- $( App.view('generic/time_range')( attribute: attribute, ranges: ranges, values: values ) )
+ element = $( App.view('generic/time_range')(attribute: attribute, ranges: ranges))
+ @localRenderPulldown(element.filter('.js-valueRangeSelector'), values[range], attribute)
+ element.find('select.form-control.js-range').on('change', (e) =>
+ range = $(e.currentTarget).val()
+ @localRenderPulldown($(e.currentTarget).closest('.js-filterElement').find('.js-valueRangeSelector'), values[range], attribute)
+ )
+ element
+
+ @localRenderPulldown: (el, range, attribute) ->
+ return if !range
+ values = {}
+ for count in range
+ values[count.toString()] = count.toString()
+ select = App.view('generic/time_range_value_selector')(attribute: attribute, values: values)
+ el.html(select)
diff --git a/app/assets/javascripts/app/views/generic/time_range.jst.eco b/app/assets/javascripts/app/views/generic/time_range.jst.eco
index 16587f36e..d933027a0 100644
--- a/app/assets/javascripts/app/views/generic/time_range.jst.eco
+++ b/app/assets/javascripts/app/views/generic/time_range.jst.eco
@@ -1,11 +1,4 @@
-
-
- <%- @Icon('arrow-down', 'dropdown-arrow') %>
-
+