Show More
@@ -1,145 +1,147 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 |
|
3 | |||
4 | <div class="panel panel-default"> |
|
4 | <div class="panel panel-default"> | |
5 | <div class="panel-heading"> |
|
5 | <div class="panel-heading"> | |
6 | <h3 class="panel-title">${_('User groups administration')}</h3> |
|
6 | <h3 class="panel-title">${_('User groups administration')}</h3> | |
7 | </div> |
|
7 | </div> | |
8 | <div class="panel-body"> |
|
8 | <div class="panel-body"> | |
9 | <div class="field"> |
|
9 | <div class="fields"> | |
10 |
<div class=" |
|
10 | <div class="field"> | |
11 | <label for="users_group_active">${_('Add user to group')}:</label> |
|
11 | <div class="label label-checkbox"> | |
|
12 | <label for="users_group_active">${_('Add `%s` to user group') % c.user.username}:</label> | |||
|
13 | </div> | |||
|
14 | <div class="input"> | |||
|
15 | ${h.text('add_user_to_group', placeholder="user group name", class_="medium")} | |||
|
16 | </div> | |||
|
17 | ||||
12 | </div> |
|
18 | </div> | |
13 | <div class="input"> |
|
|||
14 | ${h.text('add_user_to_group', placeholder="user group name", class_="medium")} |
|
|||
15 | </div> |
|
|||
16 |
|
||||
17 | </div> |
|
19 | </div> | |
18 |
|
20 | |||
19 | <div class="groups_management"> |
|
21 | <div class="groups_management"> | |
20 | ${h.secure_form(h.route_path('edit_user_groups_management_updates', user_id=c.user.user_id), method='post')} |
|
22 | ${h.secure_form(h.route_path('edit_user_groups_management_updates', user_id=c.user.user_id), method='post')} | |
21 | <div id="repos_list_wrap"> |
|
23 | <div id="repos_list_wrap"> | |
22 | <table id="user_group_list_table" class="display"></table> |
|
24 | <table id="user_group_list_table" class="display"></table> | |
23 | </div> |
|
25 | </div> | |
24 | <div class="buttons"> |
|
26 | <div class="buttons"> | |
25 | ${h.submit('save',_('Save'),class_="btn")} |
|
27 | ${h.submit('save',_('Save'),class_="btn")} | |
26 | </div> |
|
28 | </div> | |
27 | ${h.end_form()} |
|
29 | ${h.end_form()} | |
28 | </div> |
|
30 | </div> | |
29 | </div> |
|
31 | </div> | |
30 | </div> |
|
32 | </div> | |
31 | <script> |
|
33 | <script> | |
32 | var api; |
|
34 | var api; | |
33 | $(document).ready(function() { |
|
35 | $(document).ready(function() { | |
34 |
|
36 | |||
35 | var get_datatable_count = function(){ |
|
37 | var get_datatable_count = function(){ | |
36 | $('#user_group_count').text(api.page.info().recordsDisplay); |
|
38 | $('#user_group_count').text(api.page.info().recordsDisplay); | |
37 | }; |
|
39 | }; | |
38 |
|
40 | |||
39 | $('#user_group_list_table').on('click', 'a.editor_remove', function (e) { |
|
41 | $('#user_group_list_table').on('click', 'a.editor_remove', function (e) { | |
40 | e.preventDefault(); |
|
42 | e.preventDefault(); | |
41 | var row = api.row($(this).closest('tr')); |
|
43 | var row = api.row($(this).closest('tr')); | |
42 | row.remove().draw(); |
|
44 | row.remove().draw(); | |
43 | } ); |
|
45 | } ); | |
44 |
|
46 | |||
45 | $('#user_group_list_table').DataTable({ |
|
47 | $('#user_group_list_table').DataTable({ | |
46 | data: ${c.groups|n}, |
|
48 | data: ${c.groups|n}, | |
47 | dom: 'rtp', |
|
49 | dom: 'rtp', | |
48 | pageLength: ${c.visual.admin_grid_items}, |
|
50 | pageLength: ${c.visual.admin_grid_items}, | |
49 | order: [[ 0, "asc" ]], |
|
51 | order: [[ 0, "asc" ]], | |
50 | columns: [ |
|
52 | columns: [ | |
51 | { data: {"_": "group_name", |
|
53 | { data: {"_": "group_name", | |
52 | "sort": "group_name"}, title: "${_('Name')}", className: "td-componentname," , |
|
54 | "sort": "group_name"}, title: "${_('Name')}", className: "td-componentname," , | |
53 | render: function (data,type,full,meta) |
|
55 | render: function (data,type,full,meta) | |
54 | {return '<div><i class="icon-group" title="User group">'+data+'</i></div>'}}, |
|
56 | {return '<div><i class="icon-group" title="User group">'+data+'</i></div>'}}, | |
55 |
|
57 | |||
56 | { data: {"_": "group_description", |
|
58 | { data: {"_": "group_description", | |
57 | "sort": "group_description"}, title: "${_('Description')}", className: "td-description" }, |
|
59 | "sort": "group_description"}, title: "${_('Description')}", className: "td-description" }, | |
58 | { data: {"_": "users_group_id"}, className: "td-user", |
|
60 | { data: {"_": "users_group_id"}, className: "td-user", | |
59 | render: function (data,type,full,meta) |
|
61 | render: function (data,type,full,meta) | |
60 | {return '<input type="hidden" name="users_group_id" value="'+data+'">'}}, |
|
62 | {return '<input type="hidden" name="users_group_id" value="'+data+'">'}}, | |
61 | { data: {"_": "active", |
|
63 | { data: {"_": "active", | |
62 | "sort": "active"}, title: "${_('Active')}", className: "td-active", className: "td-number"}, |
|
64 | "sort": "active"}, title: "${_('Active')}", className: "td-active", className: "td-number"}, | |
63 | { data: {"_": "owner_data"}, title: "${_('Owner')}", className: "td-user", |
|
65 | { data: {"_": "owner_data"}, title: "${_('Owner')}", className: "td-user", | |
64 | render: function (data,type,full,meta) |
|
66 | render: function (data,type,full,meta) | |
65 | {return '<div class="rc-user tooltip">'+ |
|
67 | {return '<div class="rc-user tooltip">'+ | |
66 | '<img class="gravatar" src="'+ data.owner_icon +'" height="16" width="16">'+ |
|
68 | '<img class="gravatar" src="'+ data.owner_icon +'" height="16" width="16">'+ | |
67 | data.owner +'</div>' |
|
69 | data.owner +'</div>' | |
68 | } |
|
70 | } | |
69 | }, |
|
71 | }, | |
70 | { data: null, |
|
72 | { data: null, | |
71 | title: "${_('Action')}", |
|
73 | title: "${_('Action')}", | |
72 | className: "td-action", |
|
74 | className: "td-action", | |
73 | defaultContent: '<a href="" class="btn btn-link btn-danger">Delete</a>' |
|
75 | defaultContent: '<a href="" class="btn btn-link btn-danger">Delete</a>' | |
74 | }, |
|
76 | }, | |
75 | ], |
|
77 | ], | |
76 | language: { |
|
78 | language: { | |
77 | paginate: DEFAULT_GRID_PAGINATION, |
|
79 | paginate: DEFAULT_GRID_PAGINATION, | |
78 | emptyTable: _gettext("No user groups available yet.") |
|
80 | emptyTable: _gettext("No user groups available yet.") | |
79 | }, |
|
81 | }, | |
80 | "initComplete": function( settings, json ) { |
|
82 | "initComplete": function( settings, json ) { | |
81 | var data_grid = $('#user_group_list_table').dataTable(); |
|
83 | var data_grid = $('#user_group_list_table').dataTable(); | |
82 | api = data_grid.api(); |
|
84 | api = data_grid.api(); | |
83 | get_datatable_count(); |
|
85 | get_datatable_count(); | |
84 | } |
|
86 | } | |
85 | }); |
|
87 | }); | |
86 |
|
88 | |||
87 | // update the counter when doing search |
|
89 | // update the counter when doing search | |
88 | $('#user_group_list_table').on( 'search.dt', function (e,settings) { |
|
90 | $('#user_group_list_table').on( 'search.dt', function (e,settings) { | |
89 | get_datatable_count(); |
|
91 | get_datatable_count(); | |
90 | }); |
|
92 | }); | |
91 |
|
93 | |||
92 | // filter, filter both grids |
|
94 | // filter, filter both grids | |
93 | $('#q_filter').on( 'keyup', function () { |
|
95 | $('#q_filter').on( 'keyup', function () { | |
94 | var user_api = $('#user_group_list_table').dataTable().api(); |
|
96 | var user_api = $('#user_group_list_table').dataTable().api(); | |
95 | user_api |
|
97 | user_api | |
96 | .columns(0) |
|
98 | .columns(0) | |
97 | .search(this.value) |
|
99 | .search(this.value) | |
98 | .draw(); |
|
100 | .draw(); | |
99 | }); |
|
101 | }); | |
100 |
|
102 | |||
101 | // refilter table if page load via back button |
|
103 | // refilter table if page load via back button | |
102 | $("#q_filter").trigger('keyup'); |
|
104 | $("#q_filter").trigger('keyup'); | |
103 |
|
105 | |||
104 | }); |
|
106 | }); | |
105 |
|
107 | |||
106 | $('#language').select2({ |
|
108 | $('#language').select2({ | |
107 | 'containerCssClass': "drop-menu", |
|
109 | 'containerCssClass': "drop-menu", | |
108 | 'dropdownCssClass': "drop-menu-dropdown", |
|
110 | 'dropdownCssClass': "drop-menu-dropdown", | |
109 | 'dropdownAutoWidth': true |
|
111 | 'dropdownAutoWidth': true | |
110 | }); |
|
112 | }); | |
111 |
|
113 | |||
112 |
|
114 | |||
113 |
|
115 | |||
114 | $(document).ready(function(){ |
|
116 | $(document).ready(function(){ | |
115 | $("#group_parent_id").select2({ |
|
117 | $("#group_parent_id").select2({ | |
116 | 'containerCssClass': "drop-menu", |
|
118 | 'containerCssClass': "drop-menu", | |
117 | 'dropdownCssClass': "drop-menu-dropdown", |
|
119 | 'dropdownCssClass': "drop-menu-dropdown", | |
118 | 'dropdownAutoWidth': true |
|
120 | 'dropdownAutoWidth': true | |
119 | }); |
|
121 | }); | |
120 |
|
122 | |||
121 | $('#add_user_to_group').autocomplete({ |
|
123 | $('#add_user_to_group').autocomplete({ | |
122 | serviceUrl: pyroutes.url('user_group_autocomplete_data'), |
|
124 | serviceUrl: pyroutes.url('user_group_autocomplete_data'), | |
123 | minChars:2, |
|
125 | minChars:2, | |
124 | maxHeight:400, |
|
126 | maxHeight:400, | |
125 | width:300, |
|
127 | width:300, | |
126 | deferRequestBy: 300, //miliseconds |
|
128 | deferRequestBy: 300, //miliseconds | |
127 | showNoSuggestionNotice: true, |
|
129 | showNoSuggestionNotice: true, | |
128 | params: { user_groups:true }, |
|
130 | params: { user_groups:true }, | |
129 | formatResult: autocompleteFormatResult, |
|
131 | formatResult: autocompleteFormatResult, | |
130 | lookupFilter: autocompleteFilterResult, |
|
132 | lookupFilter: autocompleteFilterResult, | |
131 | onSelect: function(element, suggestion){ |
|
133 | onSelect: function(element, suggestion){ | |
132 | var owner = {owner_icon: suggestion.owner_icon, owner:suggestion.owner}; |
|
134 | var owner = {owner_icon: suggestion.owner_icon, owner:suggestion.owner}; | |
133 | api.row.add( |
|
135 | api.row.add( | |
134 | {"active": suggestion.active, |
|
136 | {"active": suggestion.active, | |
135 | "owner_data": owner, |
|
137 | "owner_data": owner, | |
136 | "users_group_id": suggestion.id, |
|
138 | "users_group_id": suggestion.id, | |
137 | "group_description": suggestion.description, |
|
139 | "group_description": suggestion.description, | |
138 | "group_name": suggestion.value}).draw(); |
|
140 | "group_name": suggestion.value}).draw(); | |
139 | } |
|
141 | } | |
140 | }); |
|
142 | }); | |
141 | }) |
|
143 | }) | |
142 |
|
144 | |||
143 | </script> |
|
145 | </script> | |
144 |
|
146 | |||
145 |
|
147 |
General Comments 0
You need to be logged in to leave comments.
Login now