Commit 293f1ad672ac516b85fc4894a56f692bfadc0e09
Committed by
Heitor
1 parent
ea9aff16
Exists in
colab
and in
4 other branches
branches and request vars for Repository form js extracted to Branch class
New attributes names and request. Signed off by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
12 additions
and
10 deletions
Show diff stats
app/assets/javascripts/repository/branch.js.coffee
app/views/repositories/_form.html.erb
| ... | ... | @@ -132,8 +132,7 @@ |
| 132 | 132 | </script> |
| 133 | 133 | |
| 134 | 134 | <script> |
| 135 | - var branches = {}; | |
| 136 | - var request = null; | |
| 135 | + var repository_branch = new Repository.Branch; | |
| 137 | 136 | function fetch_branches (address_field) { |
| 138 | 137 | cancel_previous_request(); |
| 139 | 138 | var address = address_field.value; |
| ... | ... | @@ -141,15 +140,14 @@ |
| 141 | 140 | var el = $("#repository_branch"); |
| 142 | 141 | el.empty(); // remove old options |
| 143 | 142 | |
| 144 | - console.log(address); | |
| 145 | - if(branches[address] != null) { | |
| 146 | - fill_options(branches[address], el); | |
| 143 | + if(repository_branch.names[address] != null) { | |
| 144 | + fill_options(repository_branch.names[address], el); | |
| 147 | 145 | return; |
| 148 | 146 | } |
| 149 | 147 | |
| 150 | 148 | var scm_type = $("#repository_scm_type option:selected").text(); |
| 151 | 149 | |
| 152 | - request = ($.ajax({ | |
| 150 | + repository_branch.request = ($.ajax({ | |
| 153 | 151 | url: "<%= repository_branches_path() %>", |
| 154 | 152 | data: {'url': address, 'scm_type': scm_type}, |
| 155 | 153 | type: 'GET', |
| ... | ... | @@ -157,16 +155,16 @@ |
| 157 | 155 | success: function (data){ |
| 158 | 156 | options = data["branches"]; |
| 159 | 157 | if (options != null) { |
| 160 | - branches[address] = options; | |
| 158 | + repository_branch.names[address] = options; | |
| 161 | 159 | fill_options(options, el); |
| 162 | 160 | } |
| 163 | 161 | } |
| 164 | 162 | })); |
| 165 | 163 | |
| 166 | 164 | function cancel_previous_request() { |
| 167 | - if (request != null) { | |
| 168 | - request.abort(); | |
| 169 | - request = null; | |
| 165 | + if (repository_branch.request != null) { | |
| 166 | + repository_branch.request.abort(); | |
| 167 | + repository_branch.request = null; | |
| 170 | 168 | } |
| 171 | 169 | } |
| 172 | 170 | } | ... | ... |