Subversion Repositories bacoAlunos

Rev

Rev 1692 | Rev 1779 | 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" %>
2
<%@ page import="pt.estgp.estgweb.Globals" %>
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();
23
    String jsonArrayDepartments = CourseDepartmentImpl.getJson(departments);
1670 jmachado 24
 
25
    ArrayList<CourseSchool> schools = (ArrayList<CourseSchool>) DaoFactory.getCourseSchoolDaoImpl().findAll();
26
    String jsonArraySchools = CourseSchoolImpl.getJson(schools);
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>
136
                        <th>Ativo</th>
137
                        <th>Instituição</th>
138
                        <th style="width: 30%">Nome</th>
139
                        <th>Papel para Membro da Direcao</th>
140
                        <th>Papel para Director</th>
141
                        <th></th>
142
                        <th></th>
143
                    </tr>
144
                </thead>
145
                <tbody>
1692 jmachado 146
                    <tr ng-class="{dirty: d.dirty=='true'}" ng-repeat="d in departments | orderBy:name:false">
1670 jmachado 147
                        <td>
148
                            <div class="row">
149
                                <div class="col-md-8">
150
                                    <input class="form-control" type="text" ng-model="d.sigla" ng-keyup="setDirty(d)">
151
                                </div>
152
                                <div class="col-md-2">*</div>
153
                            </div>
154
                        </td>
155
                        <td>
156
                            <select class="chosenOff form-control" ng-model="d.active" ng-change="setDirty(d)">
157
                                <option ng-value="true" ng-selected="d.active == true">Ativo</option>
158
                                <option ng-value="false" ng-selected="d.active == false">Inativo</option>
159
                            </select>
160
                        </td>
161
                        <td>
162
                            <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">
163
                            </select>
164
                        </td>
165
                        <td>
166
                            <input class="form-control" type="text" ng-model="d.name" ng-keyup="setDirty(d)">
167
                            <div class="languageNames collapse">
168
                                EN:<input class="form-control" type="text" ng-model="d.nameEn" ng-keyup="setDirty(d)">
169
                                ES:<input class="form-control" type="text" ng-model="d.nameEs" ng-keyup="setDirty(d)">
170
                                FR:<input class="form-control" type="text" ng-model="d.nameFr" ng-keyup="setDirty(d)">
171
                            </div>
172
                        </td>
173
 
174
                        <td style="font-size: 0.7em !important">
175
                            <select class="chosenOff form-control" ng-model="d.boardRole" ng-change="setDirty(d)">
176
                                <option value="">Escolha</option>
177
                                <logic:iterate id="role" name="rolesBoardDepartamento">
178
                                    <option value="${role}"><bean:message key="user.role.${role}"/></option>
179
                                </logic:iterate>
180
                            </select>
181
                        </td>
182
                        <td style="font-size: 0.7em !important">
183
                            <select class="chosenOff form-control" ng-model="d.directorRole" ng-change="setDirty(d)">
184
                                <option value="">Escolha</option>
185
                                <logic:iterate id="role" name="rolesDiretorDepartamento">
186
                                    <option value="${role}"><bean:message key="user.role.${role}"/></option>
187
                                </logic:iterate>
188
                            </select>
189
                        </td>
190
                        <td>
191
                            <button type="button" class="btn btn-success btn-xs" ng-click="save(d)">
192
                                <span class="glyphicon glyphicon-ok"/>
193
                            </button>
194
                        </td>
195
                        <td>
196
                            <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"/>
197
                        </td>
198
 
199
 
200
 
201
                    </tr>
202
                </tbody>
203
            </table>
204
            <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>
205
            <%--
206
            <model:id name="department" property="id"/>
207
            <model:field name="department" property="name"/>
208
            <model:field name="department" property="nameEn"/>
209
            <model:field name="department" property="nameEs"/>
210
            <model:field name="department" property="nameFr"/>
211
            <model:remove name="department"/>
212
    --%>
213
        </div>
214
 
1778 jmachado 215
        <pre>
216
            {{departments | json}}
217
        </pre>
1670 jmachado 218
        <%-- DEBUG
219
        <pre>
220
            {{departments | json}}
221
        </pre>
222
        <pre>
223
            {{schools | json}}
224
        </pre>
225
        --%>
1626 jmachado 226
    </div>
227
 
228
 
229
</div>
1670 jmachado 230
 
231
 
1626 jmachado 232
<%
233
    AbstractDao.getCurrentSession().getTransaction().commit();
234
%>