Commit f7c765f2d06af4bcd82c628aad3fdc53f64bed9d

Authored by Heitor
1 parent 96d582a3

Fix branches not being fetched after page load on repository form

Signed-off-by: Daniel Miranda <danielkza2@gmail.com>
Showing 1 changed file with 10 additions and 3 deletions   Show diff stats
app/views/repositories/_form.html.erb
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <div class="form-row"> 43 <div class="form-row">
44 <div class="field-container"> 44 <div class="field-container">
45 <%= f.label :scm_type, class: 'control-label' %> 45 <%= f.label :scm_type, class: 'control-label' %>
46 - <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches(this);" ) %> 46 + <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches();" ) %>
47 </div> 47 </div>
48 <div class="help-container"> 48 <div class="help-container">
49 <p> 49 <p>
@@ -111,7 +111,8 @@ @@ -111,7 +111,8 @@
111 111
112 112
113 <script> 113 <script>
114 - function show_branches (scm_type_field) { 114 + function show_branches () {
  115 + var scm_type_field = document.getElementById("repository_scm_type");
115 var index = scm_type_field.selectedIndex; 116 var index = scm_type_field.selectedIndex;
116 var option = scm_type_field.options[index]; 117 var option = scm_type_field.options[index];
117 118
@@ -125,6 +126,12 @@ @@ -125,6 +126,12 @@
125 </script> 126 </script>
126 127
127 <script> 128 <script>
  129 + $(document).on('page:load ready', function() {
  130 + show_branches();
  131 + });
  132 +</script>
  133 +
  134 +<script>
128 var branches = {}; 135 var branches = {};
129 var request = null; 136 var request = null;
130 function fetch_branches (address_field) { 137 function fetch_branches (address_field) {
@@ -135,7 +142,7 @@ @@ -135,7 +142,7 @@
135 el.empty(); // remove old options 142 el.empty(); // remove old options
136 143
137 console.log(address); 144 console.log(address);
138 - if(branches[address] != undefined) { 145 + if(branches[address] != null) {
139 fill_options(branches[address], el); 146 fill_options(branches[address], el);
140 return; 147 return;
141 } 148 }