Subversion Repositories bacoAlunos

Rev

Rev 1699 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1283 jmachado 1
<%@ page import="pt.estgp.estgweb.domain.UserRoleConfig" %>
2
<%@ page import="pt.estgp.estgweb.web.filters.UserRoleProxy" %>
3
<%@ page import="pt.estgp.estgweb.web.form.configuration.ConfigurationUserRolesForm" %>
4
<%@ page import="java.util.List" %>
5
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
6
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
7
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
8
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
9
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
10
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
11
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
12
<%@ taglib prefix="hmlt" uri="http://jakarta.apache.org/struts/tags-html" %>
13
<jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSession" scope="request"/>
14
<jomm:messages/>
15
<html:errors/>
16
 
17
 
18
<script type="text/javascript" language="JavaScript">
19
    //TABLE SORTER
20
 
21
    $(document).ready(function()
22
    {
23
 
24
        // $('#myTable').tablesorter();
25
        //  $('#myTable2').tablesorter();
26
        $(".transl").hide();
27
        $('.tablesorter-filter-row td:eq(3)').hide();
28
        $('.tablesorter-filter-row td:eq(4)').hide();
29
        $('.tablesorter-filter-row td:eq(5)').hide();
30
        $('.tablesorter-filter-row td:eq(6)').hide();
31
    });
32
 
33
    function toogleFiltersTransl()
34
    {
35
        $('.tablesorter-filter-row td:eq(3)').toggle();
36
        $('.tablesorter-filter-row td:eq(4)').toggle();
37
        $('.tablesorter-filter-row td:eq(5)').toggle();
38
        $('.tablesorter-filter-row td:eq(6)').toggle();
39
    }
40
 
41
 
42
    function updatedField(field,posForId)
43
    {
44
        $("#Line"+posForId + " select").css('background-color','yellow');
45
        $("#Line"+posForId + " input:text").css('background-color','yellow');
46
        $("#Line"+posForId + " #dirty").val("true");
47
    }
48
 
49
    function initField(posForId)
50
    {
51
        if($("#Line"+posForId + " #dirty").val()=='true')
52
        {
53
            $("#Line"+posForId + " select").css('background-color','yellow');
54
            $("#Line"+posForId + " input:text").css('background-color','yellow');
55
        }
56
        if($("#Line"+posForId + " .bacoRoleSelect option:selected")=='false')
57
        {
58
            $("#Line"+posForId + " select").css('background-color','red');
59
            $("#Line"+posForId + " input:text").css('background-color','red');
60
        }
61
    }
62
 
63
    function setInvalid(posForId)
64
    {
65
 
66
        $("#Line"+posForId + " select").css('background-color','red');
67
        $("#Line"+posForId + " input:text").css('background-color','red');
68
 
69
    }
70
 
71
</script>
72
<%
73
 
74
 
75
 
76
 
77
 
78
%>
79
 
80
<div class="container">
81
 
82
<nested:form action="/user/userRoles" enctype="multipart/form-data">
83
    <jsp:useBean id="ConfigurationUserRolesForm" scope="request" type="pt.estgp.estgweb.web.form.configuration.ConfigurationUserRolesForm"/>
84
    <%
85
        if(ConfigurationUserRolesForm.isUserRolesConfigEmpty())
86
        {
87
            List<UserRoleConfig> userRoles = UserRoleProxy.getUserRoleConfigs();
88
            ConfigurationUserRolesForm.setUserRoleConfigs(userRoles);
89
        }
90
 
91
    %>
92
    <input type="hidden" name="dispatch" value="">
93
    <input type="hidden" name="op">
94
    <input type="hidden" name="id">
95
 
96
 
97
    <div class="panel panel-default">
98
        <div class="panel-heading">
99
 
100
            <button style="float: right" class="btn btn-success" onclick="this.form.op.value='addNew';set(this.form,'addNew');this.form.submit()">Adicionar Novo</button>
101
 
1618 jmachado 102
            <button style="float: right" class="btn btn-default" onclick="this.form.op.value='checkNewRoles';set(this.form,'checkNewRoles');this.form.submit()">Carregar Novos Papeis a partir da configuração</button>
1346 jmachado 103
 
1283 jmachado 104
            <button  type="button"  class="btn btn-info" onclick="$('.transl').toggle();toogleFiltersTransl();">Mostrar Traduções</button>
1699 jmachado 105
 
106
            <html:link action="/user/configurationUserRoles" styleClass="btn btn-success"><span class="glyphicon glyphicon-refresh"></span></html:link>
1283 jmachado 107
        </div>
108
            <div class="panel-body">
1312 jmachado 109
                <table class="tablesorter tablesorterfiltered">
1283 jmachado 110
                     <thead>
111
                        <tr>
1699 jmachado 112
                            <th>ID</th>
1283 jmachado 113
                            <th>Válido</th>
114
                            <th>Chave Única</th>
115
                            <th>Tradução Principal</th>
116
                            <th class="transl">Tradução PT</th>
117
                            <th class="transl">Tradução EN</th>
118
                            <th class="transl">Tradução ES</th>
119
                            <th class="transl">Tradução FR</th>
120
                            <th>Observações</th>
1700 jmachado 121
                            <th class="filter-false" data-sorter="false">
122
 
123
                            </th>
1283 jmachado 124
                            <baco:isSuperUser>
1312 jmachado 125
                            <th class="filter-false" data-sorter="false">Apagar</th>
1283 jmachado 126
                            </baco:isSuperUser>
127
                        </tr>
128
                        </thead>
129
                        <tbody>
130
                        <%
131
                        int posForId = 0;
132
                        %>
133
                        <nested:iterate id="userRole" property="userRolesConfig" type="pt.estgp.estgweb.domain.UserRoleConfig">
134
                            <%
135
                                posForId++;
136
                                request.setAttribute("posForId",posForId
137
                                );
138
                            %>
139
                            <tr id="Line<%=posForId%>">
140
                                <td>
1699 jmachado 141
                                    ${userRole.id}
142
                                </td>
143
                                <td>
1283 jmachado 144
                                    <nested:equal value="false" property="valid">
145
                                        <script>
146
                                            $(document).ready(
147
                                                    function()
148
                                                    {
149
                                                        setInvalid(<%=posForId%>);
150
                                                    }
151
                                            );
152
                                        </script>
153
                                    </nested:equal>
154
                                    <nested:select styleClass="bacoRoleSelect" property="valid" onchange="updatedField(this,${posForId})">
155
                                        <html:option value="true" key="yes"/>
156
                                        <html:option value="false" key="no"/>
157
                                    </nested:select>
158
                                </td>
159
                                <nested:equal value="true" property="dirty">
160
                                    <script>
161
                                        $(document).ready(
162
                                                function()
163
                                                {
164
                                                    initField(<%=posForId%>);
165
                                                }
166
                                        );
167
                                    </script>
168
                                </nested:equal>
169
                                <td>
170
                                    <baco:isSuperUser>
171
                                        <nested:text onkeyup="updatedField(this,${posForId})" property="role" style="width:100%"></nested:text>
172
                                    </baco:isSuperUser>
173
                                    <baco:hasNotRole role="all">
174
                                        <nested:equal value="" property="role">
175
                                            <nested:text onkeyup="updatedField(this, ${posForId})" property="role" style="width:100%"></nested:text>
176
                                        </nested:equal>
177
                                        <nested:notEqual value="" property="role">
178
                                            <nested:text property="role" readonly="true" style="width:100%"></nested:text>
179
                                        </nested:notEqual>
180
                                    </baco:hasNotRole>
181
                                </td>
182
                                <td>
183
                                    <%--
184
 
185
                                    Meter aqui o posForId obrigar o valor a ser o novo e apenas auxiliar
186
                                    --%>
187
                                    <nested:hidden property="id"/>
188
                                    <nested:hidden property="posForId" value="${posForId}"/>
189
                                    <nested:hidden styleId="dirty" property="dirty"/>
190
                                    <nested:text onkeyup="updatedField(this, ${posForId})" property="value" style="width:100%"></nested:text>
191
                                </td>
192
                                <td class="transl">
193
                                    <nested:text onkeyup="updatedField(this, ${posForId})" property="valuePt" style="width:100%"></nested:text>
194
                                </td>
195
                                <td class="transl">
196
                                    <nested:text onkeyup="updatedField(this,${posForId})" property="valueEn" style="width:100%"></nested:text>
197
                                </td>
198
                                <td class="transl">
199
                                    <nested:text onkeyup="updatedField(this,${posForId})" property="valueEs" style="width:100%"></nested:text>
200
                                </td>
201
                                <td class="transl">
202
                                    <nested:text onkeyup="updatedField(this,${posForId})" property="valueFr" style="width:100%"></nested:text>
203
                                </td>
204
                                <td>
205
                                    <nested:text onkeyup="updatedField(this, ${posForId})" property="obs" style="width:100%"></nested:text>
206
                                </td>
207
 
1312 jmachado 208
                                <td class="icons">
1283 jmachado 209
                                    <button style="float: right" class="btn btn-success btn-sm" onclick="this.form.op.value='saveUserRole';set(this.form,'saveUserRole');this.form.id.value='${posForId}';this.form.submit()"><span class="glyphicon glyphicon-ok"></span></button>
210
                                </td>
211
                                <baco:isSuperUser>
1312 jmachado 212
                                <td class="icons">
1283 jmachado 213
                                    <a style="float: right"  class="btn btn-danger btn-sm" href="<%=request.getContextPath()%><%--TODO FALTA APAGAR--%>"><span class="glyphicon glyphicon-remove"></span></a>
214
                                </td>
215
                                </baco:isSuperUser>
216
                            </tr>
217
 
218
                        </nested:iterate>
219
                        </tbody>
220
                    </table>
221
                </div>
1699 jmachado 222
            <%--<div class="panel-footer">
1283 jmachado 223
                    <html:submit styleClass="btn btn-warning" value="Salvar"/>
1699 jmachado 224
            </div--%>
1283 jmachado 225
 
226
    </div>
227
</nested:form>
228
 
229
 
230
 
231
</div>