|
9 | 9 | %p
|
10 | 10 | %label{ for: "repository_protected_branche[user_list]" }= l(:label_user_list) + ' :'
|
11 | 11 |
|
12 |
| - %ul{ id: 'user_list' } |
| 12 | + = tag_it_list 'repository_protected_branche_user_list', |
| 13 | + { name: 'repository_protected_branche[user_list][]' }, |
| 14 | + { source: 'user_list', placeholder: '+ add user' } do |
13 | 15 | - if @protected_branch.user_list.any?
|
14 | 16 | - @protected_branch.user_list.each do |item|
|
15 | 17 | %li= item
|
16 | 18 |
|
17 | 19 | :javascript
|
18 | 20 | var user_list = #{raw @protected_branch.available_users.to_json};
|
19 |
| - |
20 |
| - function loadTagIt(target){ |
21 |
| - |
22 |
| - $('#' + target).gtagit({ |
23 |
| - autocomplete: {source: function(request, resolve) { |
24 |
| - // fetch new values with request.resolve |
25 |
| - resolve(user_list); |
26 |
| - } |
27 |
| - }, |
28 |
| - afterTagAdded: function(event, ui) { |
29 |
| - var value = ui.tag.children('input:hidden').val(); |
30 |
| - user_list = user_list.filter(function(v) { return v != value;}); |
31 |
| - $(".ui-dialog-content").dialog("option", "position", ['center', 'center']).animate('slow'); |
32 |
| - }, |
33 |
| - afterTagRemoved: function(event, ui) { |
34 |
| - var value = ui.tag.children('input:hidden').val(); |
35 |
| - user_list.push(value); |
36 |
| - $(".ui-dialog-content").dialog("option", "position", ['center', 'center']).animate('slow'); |
37 |
| - }, |
38 |
| - showAutocompleteOnFocus: true, |
39 |
| - placeholderText: '+ add user', |
40 |
| - allowDuplicates: false, |
41 |
| - caseSensitive: false, |
42 |
| - fieldName: 'repository_protected_branche[' + target + '][]', |
43 |
| - }); |
44 |
| - |
45 |
| - } |
46 |
| - |
47 |
| - $(document).ready(function() { |
48 |
| - loadTagIt('user_list'); |
49 |
| - }); |
| 21 | + $(document).ready(function(){ setTagIt(); }); |
0 commit comments