Rev 1617 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1617 | Rev 1618 | ||
---|---|---|---|
1 | <%@ tag import="jomm.dao.impl.AbstractDao" %> |
1 | <%@ tag import="jomm.dao.impl.AbstractDao" %> |
2 | 2 | ||
3 | <%@ tag import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
3 | <%@ tag import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
4 | 4 | ||
5 | <%@ tag import="jomm.utils.BytesUtils" %> |
5 | <%@ tag import="jomm.utils.BytesUtils" %> |
6 | <%@tag description="Tag to Call Ajax Request" pageEncoding="UTF-8"%> |
6 | <%@tag description="Tag to Call Ajax Request" pageEncoding="UTF-8"%> |
7 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
7 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
8 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
8 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
9 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
9 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
10 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
10 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
11 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
11 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
12 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
12 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
13 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
13 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
14 | <%@taglib prefix="bacoTags" tagdir="/WEB-INF/tags" %> |
14 | <%@taglib prefix="bacoTags" tagdir="/WEB-INF/tags" %> |
15 | 15 | ||
16 | <%@attribute name="role" type="java.lang.String" required="true" %> |
16 | <%@attribute name="role" type="java.lang.String" required="true" %> |
17 | <%@attribute name="title" type="java.lang.String" required="false" %> |
17 | <%@attribute name="title" type="java.lang.String" required="false" %> |
18 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
18 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
19 | <%@attribute name="printOnlyList" type="java.lang.Boolean" required="false" %> |
19 | <%@attribute name="printOnlyList" type="java.lang.Boolean" required="false" %> |
20 | <%@attribute name="ignoreUserId" type="java.lang.Long" required="false" %> |
20 | <%@attribute name="ignoreUserId" type="java.lang.Long" required="false" %> |
21 | <%@attribute name="useWellTitle" type="java.lang.Boolean" required="false" %> |
21 | <%@attribute name="useWellTitle" type="java.lang.Boolean" required="false" %> |
- | 22 | <%@attribute name="useModals" type="java.lang.Boolean" required="false" %> |
|
22 | 23 | ||
23 | <% |
24 | <% |
24 | String idTemp = BytesUtils.generateHexKey() + role.replaceAll(" ", "_").replaceAll("\\.","_"); |
25 | String idTemp = BytesUtils.generateHexKey() + role.replaceAll(" ", "_").replaceAll("\\.","_"); |
25 | %> |
26 | %> |
26 | 27 | ||
27 | <!-- Usar o Angular para Printar os Roles --> |
28 | <!-- Usar o Angular para Printar os Roles --> |
28 | <div class="clearfix"> |
29 | <div class="clearfix"> |
29 | 30 | ||
30 | <div class="col-md-12" id="printRoleModule<%=idTemp%>" ng-app="printRoleModule<%=idTemp%>" ng-controller="printRoleModuleController<%=idTemp%>"> |
31 | <div class="col-md-12" style="padding: 0; margin: 0" id="printRoleModule<%=idTemp%>" ng-app="printRoleModule<%=idTemp%>" ng-controller="printRoleModuleController<%=idTemp%>"> |
31 | 32 | ||
32 | <% |
33 | <% |
33 | if(printOnlyList == null || printOnlyList == false) |
34 | if(printOnlyList == null || printOnlyList == false) |
34 | { |
35 | { |
35 | %> |
36 | %> |
36 | <logic:notEmpty name="title"> |
37 | <logic:notEmpty name="title"> |
37 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>>${title}</h3> |
38 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>>${title}</h3> |
38 | </logic:notEmpty> |
39 | </logic:notEmpty> |
39 | <logic:empty name="title"> |
40 | <logic:empty name="title"> |
40 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>><bean:message key="user.role.${role}"/></h3> |
41 | <h3 <%if(useWellTitle != null && useWellTitle){%>class="well well-sm"<%}%>><bean:message key="user.role.${role}"/></h3> |
41 | </logic:empty> |
42 | </logic:empty> |
42 | <% |
43 | <% |
43 | } |
44 | } |
44 | %> |
45 | %> |
45 | <div class="col-md-6"> |
46 | <div class="col-md-6" style="padding: 2px; margin: 0"> |
46 | <ul> |
47 | <ul> |
47 | <li ng-repeat="u in roleUsers" class="roleUser{{u.id}}"> |
48 | <li ng-repeat="u in roleUsers" class="roleUser{{u.id}}"> |
- | 49 | <baco:hasRole role="admin,all,servicesRolesManagement,servicesCoursesManagement,services"> |
|
- | 50 | <% |
|
- | 51 | if(useModals != null && !useModals) |
|
- | 52 | { |
|
- | 53 | %> |
|
- | 54 | <button type="button" class="btn btn-danger btn-xs" ng-click="removeUser( u.id )"><span class="glyphicon glyphicon-remove"/></button> |
|
- | 55 | <% |
|
- | 56 | } |
|
48 | <baco:isAdmin> |
57 | else |
- | 58 | { |
|
- | 59 | %> |
|
49 | <bacoTags:confirm icon="glyphicon glyphicon-remove" btnClass="btn btn-danger btn-xs"> |
60 | <bacoTags:confirm icon="glyphicon glyphicon-remove" btnClass="btn btn-danger btn-xs"> |
50 | <jsp:attribute name="targetFunction">removeUser<%=idTemp%>({{u.id}})</jsp:attribute> |
61 | <jsp:attribute name="targetFunction">removeUser<%=idTemp%>({{u.id}})</jsp:attribute> |
51 | <jsp:attribute name="msg">Tem a certeza que deseja remover o utilizador {{u.name}} do grupo <bean:message key="user.role.${role}"/></jsp:attribute> |
62 | <jsp:attribute name="msg">Tem a certeza que deseja remover o utilizador {{u.name}} do grupo <bean:message key="user.role.${role}"/></jsp:attribute> |
52 | </bacoTags:confirm> |
63 | </bacoTags:confirm> |
- | 64 | <% |
|
- | 65 | } |
|
- | 66 | %> |
|
53 | </baco:isAdmin> |
67 | </baco:hasRole> |
54 | 68 | ||
55 | {{u.username}} |
69 | {{u.username}} |
56 | <label ng-if="u.name"> |
70 | <label ng-if="u.name"> |
57 | - {{u.name}} |
71 | - {{u.name}} |
58 | </label> |
72 | </label> |
59 | <label ng-if="u.sigesCode"> |
73 | <label ng-if="u.sigesCode"> |
60 | ({{u.sigesCode}}) |
74 | ({{u.sigesCode}}) |
61 | </label> |
75 | </label> |
62 | <%--</label>--%> |
76 | <%--</label>--%> |
63 | 77 | ||
64 | </li> |
78 | </li> |
65 | </ul> |
79 | </ul> |
66 | </div> |
80 | </div> |
67 | <baco:isAdmin> |
81 | <baco:hasRole role="admin,all,servicesRolesManagement,servicesCoursesManagement,services"> |
68 | <div class="col-md-6"> |
82 | <div class="col-md-6" style="padding: 2px; margin: 0"> |
69 | 83 | ||
70 | <div class="panel panel-default"> |
84 | <div class="panel panel-default"> |
71 | <div class="panel-heading"> |
85 | <div class="panel-heading"> |
72 | Adicionar elemento ao grupo <bean:message key="user.role.${role}"/> |
86 | Adicionar elemento ao grupo <bean:message key="user.role.${role}"/> |
73 | </div> |
87 | </div> |
74 | <div class="panel-body"> |
88 | <div class="panel-body"> |
75 | <div class="web-messages"> </div> |
89 | <div class="web-messages"> </div> |
76 | 90 | ||
77 | <div class="input-group"> |
91 | <div class="input-group"> |
78 | <input type="text" id="queryPersons<%=idTemp%>" class="form-control" placeholder="Pesquisar..."> |
92 | <input type="text" id="queryPersons<%=idTemp%>" onkeyup="if(event.keyCode == 13){searchPersons<%=idTemp%>();}" class="form-control" placeholder="Pesquisar..."> |
79 | <span class="input-group-btn"> |
93 | <span class="input-group-btn"> |
80 | <button class="btn btn-secondary" type="button" onclick="searchPersons<%=idTemp%>();return false;"><span class="glyphicon glyphicon-search"/></button> |
94 | <button class="btn btn-secondary" type="button" onclick="searchPersons<%=idTemp%>();return false;"><span class="glyphicon glyphicon-search"/></button> |
81 | </span> |
95 | </span> |
82 | </div> |
96 | </div> |
83 | <div ng-show="findUser.length > 0" class="clearfix" id="personsResults<%=idTemp%>" style="position: absolute; background-color: gray;border: 1px solid gray;z-index: 1000; right: 30px;left:30px;"> |
97 | <div ng-show="findUser.length > 0" class="clearfix" id="personsResults<%=idTemp%>" style="position: absolute; background-color: gray;border: 1px solid gray;z-index: 1000; right: 30px;left:30px;"> |
84 | <div class="clearfix" style="padding:0"> |
98 | <div class="clearfix" style="padding:0"> |
85 | <table class="tablesorter-blue" style="margin:0"> |
99 | <table class="tablesorter-blue" style="margin:0"> |
86 | <thead> |
100 | <thead> |
87 | <tr> |
101 | <tr> |
88 | <th>Nome</th> |
102 | <th>Nome</th> |
89 | <th>Tipo</th> |
103 | <th>Tipo</th> |
90 | <th>Código</th> |
104 | <th>Código</th> |
91 | <th><button ng-click="removeAllUsers()" type="button" class="btn btn-danger btn-xs pull-right clearfix"><span class="glyphicon glyphicon-remove"/></button></th> |
105 | <th><button ng-click="removeAllUsers()" type="button" class="btn btn-danger btn-xs pull-right clearfix"><span class="glyphicon glyphicon-remove"/></button></th> |
92 | </tr> |
106 | </tr> |
93 | </thead> |
107 | </thead> |
94 | <tbody> |
108 | <tbody> |
95 | <tr ng-repeat="f in findUser"> |
109 | <tr ng-repeat="f in findUser"> |
96 | <td>{{f.name}}</td> |
110 | <td>{{f.name}}</td> |
97 | <td ng-if="f.type == 'student'"> |
111 | <td ng-if="f.type == 'student'"> |
98 | Estudante |
112 | Estudante |
99 | </td> |
113 | </td> |
100 | <td ng-if="f.type == 'teacher'"> |
114 | <td ng-if="f.type == 'teacher'"> |
101 | Professor |
115 | Professor |
102 | </td> |
116 | </td> |
103 | <td ng-if="f.type != 'teacher' && f.type != 'student'"> |
117 | <td ng-if="f.type != 'teacher' && f.type != 'student'"> |
104 | User |
118 | User |
105 | </td> |
119 | </td> |
106 | <td>{{f.sigesCode}}</td> |
120 | <td>{{f.sigesCode}}</td> |
- | 121 | <td> |
|
- | 122 | <% |
|
- | 123 | if(useModals != null && !useModals) |
|
- | 124 | { |
|
- | 125 | %> |
|
- | 126 | <button type="button" class="btn btn-success btn-xs" ng-click="addUser( f.id )"><span class="glyphicon glyphicon-plus"/></button> |
|
- | 127 | <% |
|
- | 128 | } |
|
- | 129 | else |
|
- | 130 | { |
|
- | 131 | %> |
|
- | 132 | <bacoTags:confirm icon="glyphicon glyphicon-plus" btnClass="btn btn-success btn-xs"> |
|
- | 133 | <jsp:attribute name="targetFunction">addUser<%=idTemp%>({{f.id}});angular.element($('#printRoleModule<%=idTemp%>')).scope().removeAllUsers();angular.element($('#printRoleModule<%=idTemp%>')).scope().$apply();</jsp:attribute> |
|
- | 134 | <jsp:attribute name="msg">Tem a certeza que deseja adicionar o utilizador {{f.name}} ao grupo <bean:message key="user.role.${role}"/></jsp:attribute> |
|
- | 135 | </bacoTags:confirm> |
|
- | 136 | <% |
|
- | 137 | } |
|
- | 138 | %> |
|
- | 139 | </td> |
|
107 | </tr> |
140 | </tr> |
108 | </tbody> |
141 | </tbody> |
109 | </table> |
142 | </table> |
110 | </div> |
143 | </div> |
111 | </div> |
144 | </div> |
112 | 145 | ||
113 | </div> |
146 | </div> |
114 | </div> |
147 | </div> |
115 | 148 | ||
116 | <script> |
149 | <script> |
- | 150 | ||
- | 151 | ||
117 | //DECLARACAO DA APLICACAO LOCAL EM ANGULAR |
152 | //DECLARACAO DA APLICACAO LOCAL EM ANGULAR |
118 | var printRoleModule<%=idTemp%> = angular.module('printRoleModule<%=idTemp%>', []); |
153 | var printRoleModule<%=idTemp%> = angular.module('printRoleModule<%=idTemp%>', []); |
119 | GLOBAL_BacoAngularAppDependencies.push('printRoleModule<%=idTemp%>'); |
154 | GLOBAL_BacoAngularAppDependencies.push('printRoleModule<%=idTemp%>'); |
120 | printRoleModule<%=idTemp%>.controller('printRoleModuleController<%=idTemp%>', function($scope) { |
155 | printRoleModule<%=idTemp%>.controller('printRoleModuleController<%=idTemp%>', function($scope) { |
121 | //variavel para a pesquisa de users |
156 | //variavel para a pesquisa de users |
122 | $scope.findUser = []; |
157 | $scope.findUser = []; |
123 | $scope.roleUsers = []; |
158 | $scope.roleUsers = []; |
124 | $scope.removeAllUsers = function() |
159 | $scope.removeAllUsers = function() |
125 | { |
160 | { |
126 | $scope.findUser = []; |
161 | $scope.findUser = []; |
127 | } |
162 | } |
- | 163 | $scope.removeUser = function(id) |
|
- | 164 | { |
|
- | 165 | if(confirm("Tem a certeza que deseja remover o utilizador?")) |
|
- | 166 | removeUser<%=idTemp%>(id); |
|
- | 167 | } |
|
- | 168 | $scope.addUser = function(id) |
|
- | 169 | { |
|
- | 170 | if(confirm("Tem a certeza que deseja adicionar o utilizador?")) |
|
- | 171 | { |
|
- | 172 | addUser<%=idTemp%>(id); |
|
- | 173 | $scope.removeAllUsers(); |
|
- | 174 | } |
|
- | 175 | ||
- | 176 | } |
|
128 | }); |
177 | }); |
- | 178 | ||
129 | </script> |
179 | </script> |
130 | <script language="javascript"> |
180 | <script language="javascript"> |
131 | 181 | ||
132 | $(document).ready(function() |
182 | $(document).ready(function() |
133 | { |
183 | { |
134 | loadUserRoles<%=idTemp%>(); |
184 | loadUserRoles<%=idTemp%>(); |
135 | }); |
185 | }); |
136 | 186 | ||
137 | function removeUser<%=idTemp%>(id) |
187 | function removeUser<%=idTemp%>(id) |
138 | { |
188 | { |
139 | widgetCallWithActionParameters( |
189 | widgetCallWithActionParameters( |
140 | '<%=request.getContextPath()%>/user/json/model.do', |
190 | '<%=request.getContextPath()%>/user/json/model.do', |
141 | 'removeRole2User', |
191 | 'removeRole2User', |
142 | { |
192 | { |
143 | q : |
193 | q : |
144 | "{ userId : " + id + ", role : '${role}' }" |
194 | "{ userId : " + id + ", role : '${role}' }" |
145 | } |
195 | } |
146 | , |
196 | , |
147 | $("#printRoleModule<%=idTemp%>"), |
197 | $("#printRoleModule<%=idTemp%>"), |
148 | function(response) |
198 | function(response) |
149 | { |
199 | { |
150 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
200 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
151 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
201 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
152 | }, |
202 | }, |
153 | function(response) |
203 | function(response) |
154 | { |
204 | { |
155 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
205 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
156 | }); |
206 | }); |
157 | 207 | ||
158 | } |
208 | } |
- | 209 | ||
- | 210 | function addUser<%=idTemp%>(id) |
|
- | 211 | { |
|
- | 212 | widgetCallWithActionParameters( |
|
- | 213 | '<%=request.getContextPath()%>/user/json/model.do', |
|
- | 214 | 'addRole2User', |
|
- | 215 | { |
|
- | 216 | q : |
|
- | 217 | "{ userId : " + id + ", role : '${role}' }" |
|
- | 218 | } |
|
- | 219 | , |
|
- | 220 | $("#printRoleModule<%=idTemp%>"), |
|
- | 221 | function(response) |
|
- | 222 | { |
|
- | 223 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
|
- | 224 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
|
- | 225 | }, |
|
- | 226 | function(response) |
|
- | 227 | { |
|
- | 228 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
|
- | 229 | }); |
|
- | 230 | ||
- | 231 | } |
|
159 | function loadUserRoles<%=idTemp%>() |
232 | function loadUserRoles<%=idTemp%>() |
160 | { |
233 | { |
161 | widgetCallWithActionParameters( |
234 | widgetCallWithActionParameters( |
162 | '<%=request.getContextPath()%>/user/json/model.do', |
235 | '<%=request.getContextPath()%>/user/json/model.do', |
163 | 'findUserRoles', |
236 | 'findUserRoles', |
164 | { |
237 | { |
165 | q : "${role}" |
238 | q : "${role}" |
166 | } |
239 | } |
167 | , |
240 | , |
168 | $("#printRoleModule<%=idTemp%>"), |
241 | $("#printRoleModule<%=idTemp%>"), |
169 | function(response) |
242 | function(response) |
170 | { |
243 | { |
171 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
244 | angular.element($("#printRoleModule<%=idTemp%>")).scope().roleUsers = response.results; |
172 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
245 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
173 | }, |
246 | }, |
174 | function(response) |
247 | function(response) |
175 | { |
248 | { |
176 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
249 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
177 | }); |
250 | }); |
178 | } |
251 | } |
179 | 252 | ||
180 | function searchPersons<%=idTemp%>() |
253 | function searchPersons<%=idTemp%>() |
181 | { |
254 | { |
182 | 255 | ||
183 | widgetCallWithActionParameters( |
256 | widgetCallWithActionParameters( |
184 | '<%=request.getContextPath()%>/user/json/model.do', |
257 | '<%=request.getContextPath()%>/user/json/model.do', |
185 | 'findUser', |
258 | 'findUser', |
186 | { |
259 | { |
187 | q : $('#queryPersons<%=idTemp%>').val() |
260 | q : $('#queryPersons<%=idTemp%>').val() |
188 | } |
261 | } |
189 | , |
262 | , |
190 | $("#printRoleModule<%=idTemp%>"), |
263 | $("#printRoleModule<%=idTemp%>"), |
191 | function(response) |
264 | function(response) |
192 | { |
265 | { |
193 | angular.element($("#printRoleModule<%=idTemp%>")).scope().findUser = response.results; |
266 | angular.element($("#printRoleModule<%=idTemp%>")).scope().findUser = response.results; |
194 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
267 | angular.element($("#printRoleModule<%=idTemp%>")).scope().$apply(); |
195 | setTimeout(function() { evaluateTableSortersInside("#personsResults<%=idTemp%>"); }, 500); |
268 | setTimeout(function() { evaluateTableSortersInside("#personsResults<%=idTemp%>"); }, 500); |
196 | 269 | ||
197 | //evaluateTableSortersInside("#personsResults"); |
270 | //evaluateTableSortersInside("#personsResults"); |
198 | }, |
271 | }, |
199 | function(response) |
272 | function(response) |
200 | { |
273 | { |
201 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
274 | alert("Accao Falhou mas as resposta foi esta: " + JSON.stringify(response)); |
202 | }); |
275 | }); |
203 | 276 | ||
204 | } |
277 | } |
205 | 278 | ||
206 | </script> |
279 | </script> |
207 | </div> |
280 | </div> |
208 | </baco:isAdmin> |
281 | </baco:hasRole> |
209 | </div> |
282 | </div> |
210 | </div> |
283 | </div> |
211 | 284 | ||
212 | Generated by GNU Enscript 1.6.5.2. |
285 | Generated by GNU Enscript 1.6.5.2. |
213 | 286 | ||
214 | 287 |