Subversion Repositories bacoAlunos

Rev

Rev 1782 | Rev 1862 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1626 jmachado 1
<%@ page import="jomm.dao.impl.AbstractDao" %>
1814 jmachado 2
<%@ page import="pt.estgp.estgweb.utils.Globals" %>
1626 jmachado 3
<%@ page import="pt.estgp.estgweb.domain.CourseDepartment" %>
4
<%@ page import="pt.estgp.estgweb.domain.CourseDepartmentImpl" %>
1670 jmachado 5
<%@ page import="pt.estgp.estgweb.domain.CourseSchool" %>
1626 jmachado 6
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
7
<%@ page import="pt.estgp.estgweb.web.filters.UserRoleProxy" %>
8
<%@ page import="java.util.ArrayList" %>
9
<%@ page import="java.util.List" %>
1670 jmachado 10
<%@ page import="pt.estgp.estgweb.domain.CourseSchoolImpl" %>
1626 jmachado 11
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
12
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
13
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
14
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
15
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
16
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
1670 jmachado 17
<%@ taglib tagdir="/WEB-INF/tags" prefix="bacoTags" %>
1626 jmachado 18
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
19
<%
20
    AbstractDao.getCurrentSession().beginTransaction();
1670 jmachado 21
 
1626 jmachado 22
    ArrayList<CourseDepartment> departments = (ArrayList<CourseDepartment>) DaoFactory.getCourseDepartmentDaoImpl().findAll();
1779 jmachado 23
    String jsonArrayDepartments = CourseDepartmentImpl.toJson(departments);
1670 jmachado 24
 
1782 jmachado 25
    List<CourseSchool> schools = DaoFactory.getCourseSchoolDaoImpl().findAll();
1779 jmachado 26
    String jsonArraySchools = CourseSchoolImpl.toJson(schools);
1670 jmachado 27
 
28
 
1626 jmachado 29
    request.setAttribute("jsonArrayDepartments",jsonArrayDepartments);
30
    request.setAttribute("departments",departments);
31
 
1670 jmachado 32
    request.setAttribute("jsonArraySchools",jsonArraySchools);
33
    request.setAttribute("schools",schools);
34
 
1626 jmachado 35
    List<String> rolesBoardDepartamento = UserRoleProxy.getUserRolesByPrefix("department.board");
36
    List<String> rolesDiretorDepartamento = UserRoleProxy.getUserRolesByPrefix("department.diretor");
1670 jmachado 37
 
1626 jmachado 38
    request.setAttribute("rolesBoardDepartamento",rolesBoardDepartamento);
39
    request.setAttribute("rolesDiretorDepartamento",rolesDiretorDepartamento);
40
 
41
%>
42
 
1670 jmachado 43
<div class="container-fluid">
1626 jmachado 44
 
1670 jmachado 45
    <div id="departmentsModule"
46
         ng-app="departmentsModule"
47
         ng-controller="departmentsModuleController">
1626 jmachado 48
 
1670 jmachado 49
        <script>
50
            //DECLARACAO DA APLICACAO LOCAL EM ANGULAR
51
            var departmentsModule = angular.module('departmentsModule', []);
52
            GLOBAL_BacoAngularAppDependencies.push('departmentsModule');
1626 jmachado 53
 
1670 jmachado 54
            departmentsModule.controller('departmentsModuleController', function($scope) {
55
                $scope.departments = ${jsonArrayDepartments};
56
                $scope.schools = ${jsonArraySchools};
57
                $scope.setDirty = function(department)
58
                {
59
                   department.dirty = "true";
60
                }
61
                $scope.save = function(department)
62
                {
63
                    var d = JSON.stringify(department);
1626 jmachado 64
 
1670 jmachado 65
                    widgetCallWithActionParameters(
66
                            "<%=request.getContextPath()%>/admin/adminDepartment.do",
67
                            "updateCourseDepartment",
68
                            {
69
                                "courseDepartmentJson" : d
70
                            },
71
                            ".form-horizontal",
72
                            function(departmentJson)
73
                            {
74
                                department.dirty = "false";
75
                                $scope.$apply();
76
                            }
1626 jmachado 77
 
1670 jmachado 78
                    );
79
                }
80
                $scope.removeDepartment = function(department,$index)
81
                {
1626 jmachado 82
 
1670 jmachado 83
                    var d = JSON.stringify(department);
84
                    widgetCallWithActionParameters(
85
                            "<%=request.getContextPath()%>/admin/adminDepartment.do",
86
                            "removeCourseDepartment",
87
                            {
88
                                "courseDepartmentJson" : d
89
                            },
90
                            ".form-horizontal",
91
                            function(departmentJson)
92
                            {
93
                                $scope.departments.splice($index,1);
94
                                $scope.$apply();
95
                            }
1626 jmachado 96
 
1670 jmachado 97
                    );
98
                }
99
                $scope.newDepartment = function()
100
                {
1626 jmachado 101
 
1670 jmachado 102
                    widgetCallWithActionParameters(
103
                            "<%=request.getContextPath()%>/admin/adminDepartment.do",
104
                            "newCourseDepartment",{},
105
                            ".form-horizontal",
106
                            function(departmentJson)
107
                            {
108
                                departmentJson.dirty = "true";
109
                                $scope.departments.push(departmentJson);
110
                                $scope.$apply();
111
                            }
1626 jmachado 112
 
1670 jmachado 113
                    );
114
                }
1626 jmachado 115
 
1670 jmachado 116
            });
117
        </script>
118
 
119
 
120
 
121
        <p><label class="label-info">Papeis dos Departamentos:</label> Os papeis de departamento são escolhidos da lista de papeis do sistema considerando-se todos os papeis com os prefixos:</p>
122
        <ul>
123
            <li>department.board: para membros da direcção</li>
124
            <li>department.diretor: para diretores direcção</li>
125
        </ul>
126
        <p>Caso seja necessário um novo papel deverá administrar os papeis institucionais dirija-se <html:link action="/user/configurationUserRoles">Aqui</html:link></p>
127
        <button class="btn btn-default" data-toggle="collapse" data-target=".languageNames">Mostrar Campos Multinliguisticos</button>
128
 
129
        <button class="btn btn-success pull-right" ng-click="newDepartment()"><span class="glyphicon glyphicon-plus"/></button>
130
        <div class="form-horizontal">
131
            <div class="web-messages"></div>
132
            <table class="tablesorter-blue">
133
                <thead>
134
                    <tr>
135
                        <th>Identificador</th>
1814 jmachado 136
                        <th>Trocar Para Identificador * </th>
1670 jmachado 137
                        <th>Ativo</th>
138
                        <th>Instituição</th>
139
                        <th style="width: 30%">Nome</th>
140
                        <th>Papel para Membro da Direcao</th>
141
                        <th>Papel para Director</th>
142
                        <th></th>
143
                        <th></th>
144
                    </tr>
145
                </thead>
146
                <tbody>
1692 jmachado 147
                    <tr ng-class="{dirty: d.dirty=='true'}" ng-repeat="d in departments | orderBy:name:false">
1670 jmachado 148
                        <td>
149
                            <div class="row">
150
                                <div class="col-md-8">
1814 jmachado 151
                                    <input readonly="true" class="form-control" type="text" ng-model="d.sigla" ng-keyup="setDirty(d)">
1670 jmachado 152
                                </div>
153
                                <div class="col-md-2">*</div>
154
                            </div>
1814 jmachado 155
 
1670 jmachado 156
                        </td>
157
                        <td>
1814 jmachado 158
                            <div class="row">
159
                                <div class="col-md-8">
160
                                    <input class="form-control" type="text" ng-model="d.siglaNova" ng-keyup="setDirty(d)">
161
                                </div>
162
                                <div class="col-md-2">*</div>
163
                            </div>
164
                        </td>
165
                        <td>
1670 jmachado 166
                            <select class="chosenOff form-control" ng-model="d.active" ng-change="setDirty(d)">
167
                                <option ng-value="true" ng-selected="d.active == true">Ativo</option>
168
                                <option ng-value="false" ng-selected="d.active == false">Inativo</option>
169
                            </select>
170
                        </td>
171
                        <td>
172
                            <select class="chosenOff form-control" ng-model="d.courseSchool.id" ng-change="setDirty(d)" ng-options="s.id as s.name for s in schools">
173
                            </select>
174
                        </td>
175
                        <td>
176
                            <input class="form-control" type="text" ng-model="d.name" ng-keyup="setDirty(d)">
177
                            <div class="languageNames collapse">
178
                                EN:<input class="form-control" type="text" ng-model="d.nameEn" ng-keyup="setDirty(d)">
179
                                ES:<input class="form-control" type="text" ng-model="d.nameEs" ng-keyup="setDirty(d)">
180
                                FR:<input class="form-control" type="text" ng-model="d.nameFr" ng-keyup="setDirty(d)">
181
                            </div>
182
                        </td>
183
 
184
                        <td style="font-size: 0.7em !important">
185
                            <select class="chosenOff form-control" ng-model="d.boardRole" ng-change="setDirty(d)">
186
                                <option value="">Escolha</option>
187
                                <logic:iterate id="role" name="rolesBoardDepartamento">
188
                                    <option value="${role}"><bean:message key="user.role.${role}"/></option>
189
                                </logic:iterate>
190
                            </select>
191
                        </td>
192
                        <td style="font-size: 0.7em !important">
193
                            <select class="chosenOff form-control" ng-model="d.directorRole" ng-change="setDirty(d)">
194
                                <option value="">Escolha</option>
195
                                <logic:iterate id="role" name="rolesDiretorDepartamento">
196
                                    <option value="${role}"><bean:message key="user.role.${role}"/></option>
197
                                </logic:iterate>
198
                            </select>
199
                        </td>
200
                        <td>
201
                            <button type="button" class="btn btn-success btn-xs" ng-click="save(d)">
202
                                <span class="glyphicon glyphicon-ok"/>
203
                            </button>
204
                        </td>
205
                        <td>
206
                            <bacoTags:confirm  msg="Tem a certeza que deseja remover o departamento {{d.name}}" targetFunction="angular.element($('#departmentsModule')).scope().removeDepartment({{d}},{{$index}});angular.element($('#departmentsModule')).scope().$apply();" btnClass="btn btn-danger btn-xs" icon="glyphicon glyphicon-remove"/>
207
                        </td>
208
 
209
 
210
 
211
                    </tr>
212
                </tbody>
213
            </table>
214
            <p class="label label-warning">* - A sigla é o identificador do departamento, altere a sigla apenas se perceber as suas implicações. Existem Classes no sistema que dependem da sigla do departamento, a sigla tem de ser unica</p>
215
            <%--
216
            <model:id name="department" property="id"/>
217
            <model:field name="department" property="name"/>
218
            <model:field name="department" property="nameEn"/>
219
            <model:field name="department" property="nameEs"/>
220
            <model:field name="department" property="nameFr"/>
221
            <model:remove name="department"/>
222
    --%>
223
        </div>
224
 
1778 jmachado 225
        <pre>
226
            {{departments | json}}
227
        </pre>
1670 jmachado 228
        <%-- DEBUG
229
        <pre>
230
            {{departments | json}}
231
        </pre>
232
        <pre>
233
            {{schools | json}}
234
        </pre>
235
        --%>
1626 jmachado 236
    </div>
237
 
238
 
239
</div>
1670 jmachado 240
 
1814 jmachado 241
<p>* Atenção o identificador é a base dos papeis, deverá trocar também as chaves dos papeis na administração de papeis institucionais, procurando pelos papeis respectivos e alterando a sua chave para a nova sigla ou criando novos papeis</p>
1670 jmachado 242
 
1814 jmachado 243
 
1626 jmachado 244
<%
245
    AbstractDao.getCurrentSession().getTransaction().commit();
246
%>