Commit ea9aff161e18f7d7443e8b712b7728ee3d4192cc
Committed by
Heitor
1 parent
8138fe24
Exists in
colab
and in
4 other branches
Extracted show_branches into toggle method from Repository.Branch
Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
13 additions
and
2 deletions
Show diff stats
... | ... | @@ -0,0 +1,11 @@ |
1 | +class Repository.Branch | |
2 | + @toggle: -> | |
3 | + scm_type_field = document.getElementById("repository_scm_type") | |
4 | + index = scm_type_field.selectedIndex | |
5 | + option = scm_type_field.options[index] | |
6 | + | |
7 | + if option.value != "SVN" | |
8 | + $("#branches").show() | |
9 | + fetch_branches (document.getElementById("repository_address")) | |
10 | + else | |
11 | + $("#branches").hide() | |
0 | 12 | \ No newline at end of file | ... | ... |
app/views/repositories/_form.html.erb
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | <div class="form-row"> |
44 | 44 | <div class="field-container"> |
45 | 45 | <%= f.label :scm_type, class: 'control-label' %> |
46 | - <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches();" ) %> | |
46 | + <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "Repository.Branch.toggle();" ) %> | |
47 | 47 | </div> |
48 | 48 | <div class="help-container"> |
49 | 49 | <p> |
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 | |
128 | 128 | <script> |
129 | 129 | $(document).on('page:load ready', function() { |
130 | - show_branches(); | |
130 | + Repository.Branch.toggle(); | |
131 | 131 | }); |
132 | 132 | </script> |
133 | 133 | ... | ... |