aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorXinhui2017-05-19 16:47:48 +0200
committerXinhui2017-05-19 16:51:37 +0200
commit96f12acb6a122c8549e00f04c953e51f5212a6cf (patch)
treee54fe64ec467c2c5930db4aafe6917a14cbcbf4e /app/assets/javascripts
parent4c1a2a33fde5b29f3b4c4024281ad80277a967d5 (diff)
downloadchouette-core-96f12acb6a122c8549e00f04c953e51f5212a6cf.tar.bz2
Templating select2 time_table_combination + refactoring
Refs #3406
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/select2.coffee4
-rw-r--r--app/assets/javascripts/time_table_combinations.coffee8
2 files changed, 10 insertions, 2 deletions
diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee
index 510e6fe9b..6771a7d05 100644
--- a/app/assets/javascripts/select2.coffee
+++ b/app/assets/javascripts/select2.coffee
@@ -29,12 +29,12 @@ bind_select2_ajax = (el, cfg = {}) ->
select2_time_table = (item) ->
return item.text if item.loading
wrap = $('<div>', "class":'select2-result clearfix')
- wrap.html(["<h5>Time table : #{item.comment}</h5>"].join("\n"))
+ wrap.html(["<h5>#{item.comment}</h5>"].join("\n"))
select2_calendar = (item) ->
return item.text if item.loading
wrap = $('<div>', "class":'select2-result clearfix')
- wrap.html(["<h5>Calendar : #{item.name}</h5>"].join("\n"))
+ wrap.html(["<h5>#{item.name}</h5>"].join("\n"))
@select_2 = ->
diff --git a/app/assets/javascripts/time_table_combinations.coffee b/app/assets/javascripts/time_table_combinations.coffee
new file mode 100644
index 000000000..8fd9dadb1
--- /dev/null
+++ b/app/assets/javascripts/time_table_combinations.coffee
@@ -0,0 +1,8 @@
+$(document).on("change", '#time_table_combination_combined_type', (e) ->
+ el = $("#time_table_combination_#{$(this).val()}_id")
+ other = $(".tt_combination_target:not(##{el.attr('id')})")
+
+ if el.length
+ el.prop('disabled', false).parents('.form-group').removeClass('hidden').show()
+ other.prop('disabled', true).parents('.form-group').hide()
+)