From ea9aff161e18f7d7443e8b712b7728ee3d4192cc Mon Sep 17 00:00:00 2001 From: Rafael Reggiani Manzo Date: Wed, 10 Jun 2015 16:29:54 -0300 Subject: [PATCH] Extracted show_branches into toggle method from Repository.Branch --- app/assets/javascripts/repository/branch.js.coffee | 11 +++++++++++ app/views/repositories/_form.html.erb | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/repository/branch.js.coffee diff --git a/app/assets/javascripts/repository/branch.js.coffee b/app/assets/javascripts/repository/branch.js.coffee new file mode 100644 index 0000000..49fcfcf --- /dev/null +++ b/app/assets/javascripts/repository/branch.js.coffee @@ -0,0 +1,11 @@ +class Repository.Branch + @toggle: -> + scm_type_field = document.getElementById("repository_scm_type") + index = scm_type_field.selectedIndex + option = scm_type_field.options[index] + + if option.value != "SVN" + $("#branches").show() + fetch_branches (document.getElementById("repository_address")) + else + $("#branches").hide() \ No newline at end of file diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb index c8b2b1c..111b194 100644 --- a/app/views/repositories/_form.html.erb +++ b/app/views/repositories/_form.html.erb @@ -43,7 +43,7 @@
<%= f.label :scm_type, class: 'control-label' %> - <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches();" ) %> + <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "Repository.Branch.toggle();" ) %>

@@ -127,7 +127,7 @@ -- libgit2 0.21.2