Subversion Repositories bacoAlunos

Rev

Rev 1860 | 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
                {
1876 grupo4 59
                    department.dirty = "true";
1670 jmachado 60
                }
61
                $scope.save = function(department)
62
                {
63
                    var d = JSON.stringify(department);
1626 jmachado 64
 
1670 jmachado 65
                    widgetCallWithActionParameters(
1876 grupo4 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
                }
1876 grupo4 80
 
81
                $scope.createRoles = function(department)
82
                {
83
                    var d = JSON.stringify(department);
84
 
85
                    widgetCallWithActionParameters(
86
                        "<%=request.getContextPath()%>/admin/adminDepartment.do",
87
                        "createRolesForDeparment",
88
                        {
89
                            "courseDepartmentJson" : d
90
                        },
91
                        ".form-horizontal",
92
                        function(departmentJson)
93
                        {
94
                            window.location.reload();
95
                        }
96
 
97
                    );
98
                }
1670 jmachado 99
                $scope.removeDepartment = function(department,$index)
100
                {
1626 jmachado 101
 
1670 jmachado 102
                    var d = JSON.stringify(department);
103
                    widgetCallWithActionParameters(
1876 grupo4 104
                        "<%=request.getContextPath()%>/admin/adminDepartment.do",
105
                        "removeCourseDepartment",
106
                        {
107
                            "courseDepartmentJson" : d
108
                        },
109
                        ".form-horizontal",
110
                        function(departmentJson)
111
                        {
112
                            $scope.departments.splice($index,1);
113
                            $scope.$apply();
114
                        }
1626 jmachado 115
 
1670 jmachado 116
                    );
117
                }
118
                $scope.newDepartment = function()
119
                {
1626 jmachado 120
 
1670 jmachado 121
                    widgetCallWithActionParameters(
1876 grupo4 122
                        "<%=request.getContextPath()%>/admin/adminDepartment.do",
123
                        "newCourseDepartment",{},
124
                        ".form-horizontal",
125
                        function(departmentJson)
126
                        {
127
                            departmentJson.dirty = "true";
128
                            $scope.departments.push(departmentJson);
129
                            $scope.$apply();
130
                        }
1626 jmachado 131
 
1670 jmachado 132
                    );
133
                }
1626 jmachado 134
 
1670 jmachado 135
            });
136
        </script>
137
 
138
 
139
 
1876 grupo4 140
        <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>
1670 jmachado 141
        <ul>
1876 grupo4 142
            <li>department.board: para membros da direcção</li>
143
            <li>department.diretor: para diretores direcção</li>
1670 jmachado 144
        </ul>
1876 grupo4 145
        <p>Caso seja necessário um novo papel deverá administrar os papeis institucionais dirija-se <html:link action="/user/configurationUserRoles">Aqui</html:link></p>
1670 jmachado 146
        <button class="btn btn-default" data-toggle="collapse" data-target=".languageNames">Mostrar Campos Multinliguisticos</button>
147
 
148
        <button class="btn btn-success pull-right" ng-click="newDepartment()"><span class="glyphicon glyphicon-plus"/></button>
149
        <div class="form-horizontal">
150
            <div class="web-messages"></div>
151
            <table class="tablesorter-blue">
152
                <thead>
1876 grupo4 153
                <tr>
154
                    <th>Identificador</th>
155
                    <th>Trocar Para Identificador * </th>
156
                    <th>Ativo</th>
157
                    <th>Instituição</th>
158
                    <th style="width: 30%">Nome</th>
159
                    <th>Papel para Membro da Direcao</th>
160
                    <th>Papel para Director</th>
161
                    <th></th>
162
                    <th></th>
163
                    <th></th>
164
                </tr>
1670 jmachado 165
                </thead>
166
                <tbody>
1876 grupo4 167
                <tr ng-class="{dirty: d.dirty=='true'}" ng-repeat="d in departments | orderBy:name:false">
168
                    <td>
169
                        <div class="row">
170
                            <div class="col-md-8">
171
                                <input readonly="true" class="form-control" type="text" ng-model="d.sigla" ng-keyup="setDirty(d)">
1670 jmachado 172
                            </div>
1876 grupo4 173
                            <div class="col-md-2">*</div>
174
                        </div>
1814 jmachado 175
 
1876 grupo4 176
                    </td>
177
                    <td>
178
                        <div class="row">
179
                            <div class="col-md-8">
180
                                <input class="form-control" type="text" ng-model="d.siglaNova" ng-keyup="setDirty(d)">
1814 jmachado 181
                            </div>
1876 grupo4 182
                            <div class="col-md-2">*</div>
183
                        </div>
184
                    </td>
185
                    <td>
186
                        <select class="chosenOff form-control" ng-model="d.active" ng-change="setDirty(d)">
187
                            <option ng-value="true" ng-selected="d.active == true">Ativo</option>
188
                            <option ng-value="false" ng-selected="d.active == false">Inativo</option>
189
                        </select>
190
                    </td>
191
                    <td>
192
                        <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">
193
                        </select>
194
                    </td>
195
                    <td>
196
                        <input class="form-control" type="text" ng-model="d.name" ng-keyup="setDirty(d)">
197
                        <div class="languageNames collapse">
198
                            EN:<input class="form-control" type="text" ng-model="d.nameEn" ng-keyup="setDirty(d)">
199
                            ES:<input class="form-control" type="text" ng-model="d.nameEs" ng-keyup="setDirty(d)">
200
                            FR:<input class="form-control" type="text" ng-model="d.nameFr" ng-keyup="setDirty(d)">
201
                        </div>
202
                    </td>
1670 jmachado 203
 
1876 grupo4 204
                    <td style="font-size: 0.7em !important">
205
                        <select class="chosenOff form-control" ng-model="d.boardRole" ng-change="setDirty(d)">
206
                            <option value="">Escolha</option>
207
                            <logic:iterate id="role" name="rolesBoardDepartamento">
208
                                <option value="${role}"><bean:message key="user.role.${role}"/></option>
209
                            </logic:iterate>
210
                        </select>
211
                    </td>
212
                    <td style="font-size: 0.7em !important">
213
                        <select class="chosenOff form-control" ng-model="d.directorRole" ng-change="setDirty(d)">
214
                            <option value="">Escolha</option>
215
                            <logic:iterate id="role" name="rolesDiretorDepartamento">
216
                                <option value="${role}"><bean:message key="user.role.${role}"/></option>
217
                            </logic:iterate>
218
                        </select>
219
                    </td>
220
                    <td>
221
                        <button type="button" class="btn btn-success btn-xs" ng-click="save(d)">
222
                            <span class="glyphicon glyphicon-ok"/>
223
                        </button>
224
                    </td>
225
                    <td>
226
                        <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"/>
227
                    </td>
228
                    <td>
229
                        <button ng-if="!d.directorRole && !d.boardRole" data-toggle="tooltip" data-title="Criar Roles para este departamento" type="button" class="btn btn-success btn-xs" ng-click="createRoles(d)">
230
                            <span class="glyphicon glyphicon-user"/>
231
                        </button>
232
                    </td>
1670 jmachado 233
 
234
 
235
 
1876 grupo4 236
                </tr>
1670 jmachado 237
                </tbody>
238
            </table>
1876 grupo4 239
            <h2 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</h2>
240
            <h2 class="label label-warning">* - A sigla apenas pode ser alterada se não houver docentes nem cursos a apontar para o departamento que pretende alterar</h2>
1670 jmachado 241
            <%--
242
            <model:id name="department" property="id"/>
243
            <model:field name="department" property="name"/>
244
            <model:field name="department" property="nameEn"/>
245
            <model:field name="department" property="nameEs"/>
246
            <model:field name="department" property="nameFr"/>
247
            <model:remove name="department"/>
1876 grupo4 248
        --%>
1670 jmachado 249
        </div>
250
 
1876 grupo4 251
        <!--<pre>
1778 jmachado 252
            {{departments | json}}
1876 grupo4 253
        </pre>-->
1670 jmachado 254
        <%-- DEBUG
255
        <pre>
256
            {{departments | json}}
257
        </pre>
258
        <pre>
259
            {{schools | json}}
260
        </pre>
261
        --%>
1626 jmachado 262
    </div>
263
 
264
 
265
</div>
1670 jmachado 266
 
1876 grupo4 267
<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 268
 
1814 jmachado 269
 
1626 jmachado 270
<%
271
    AbstractDao.getCurrentSession().getTransaction().commit();
272
%>