Subversion Repositories bacoAlunos

Rev

Rev 1775 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@ page import="jomm.dao.impl.AbstractDao" %>
<%@ page import="pt.estgp.estgweb.domain.BpmnProcess" %>
<%@ page import="pt.estgp.estgweb.domain.BpmnProcessImpl" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.web.filters.UserRoleProxy" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="bacoTags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    AbstractDao.getCurrentSession().beginTransaction();

    ArrayList<BpmnProcess> processes = (ArrayList<BpmnProcess>) DaoFactory.getBpmnProcessDaoImpl().findAll();
    String jsonArrayProcesses = BpmnProcessImpl.toJsonArray(processes);




    request.setAttribute("jsonArrayProcesses",jsonArrayProcesses);


%>

<div class="container-fluid">

    <div id="processesModule"
         ng-app="processesModule"
         ng-controller="processesModuleController">

        <script>
            //DECLARACAO DA APLICACAO LOCAL EM ANGULAR
            var processesModule = angular.module('processesModule', []);
            GLOBAL_BacoAngularAppDependencies.push('processesModule');

            processesModule.controller('processesModuleController', function($scope) {
                $scope.processes = ${jsonArrayProcesses};
                $scope.setDirty = function(process)
                {
                    process.dirty = "true";
                }
                $scope.save = function(process)
                {

                    widgetCallWithActionParameters(
                            "<%=request.getContextPath()%>/admin/bpmn/bpmnController.do",
                            "updateProcess",
                            {
                                "processJson" : JSON.stringify(process)
                            },
                            ".form-horizontal",
                            function(processJson)
                            {
                                process.dirty = "false";
                                $scope.$apply();
                            }

                    );
                }
                $scope.removeProcess = function(process,$index)
                {

                    var d = JSON.stringify(process);
                    widgetCallWithActionParameters(
                            "<%=request.getContextPath()%>/admin/bpmn/bpmnController.do",
                            "removeProcess",
                            {
                                "processJson" : d
                            },
                            ".form-horizontal",
                            function(processJson)
                            {
                                $scope.processes.splice($index,1);
                                $scope.$apply();
                            }

                    );
                }
                $scope.newProcess = function()
                {

                    widgetCallWithActionParameters(
                            "<%=request.getContextPath()%>/admin/bpmn/bpmnController.do",
                            "newProcess",
                            {},
                            ".form-horizontal",
                            function(processJson)
                            {
                                processJson.dirty = "true";
                                $scope.processes.push(processJson);
                                $scope.$apply();
                            }

                    );
                }

            });
        </script>


        <div class="row">
            <div class="col-md-12">
                <button class="btn btn-success pull-right" ng-click="newProcess()"><span class="glyphicon glyphicon-plus"/></button>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 form-horizontal">
                <div class="web-messages">

                </div>
                <table class="tablesorter-blue">
                    <thead>
                    <tr>
                        <th>Identificador</th>
                        <th>Ativo</th>
                        <th>Nome</th>
                        <th></th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-class="{dirty: p.dirty=='true'}" ng-repeat="p in processes | orderBy:name:false">
                        <td>
                            <button ng-click="save(p)" class="btn btn-warning" ng-show="p.dirty=='true'" type="button"><span class="glyphicon glyphicon-floppy-disk"></span></button>
                            <input class="form-control" type="hidden" ng-model="p.id">
                            {{p.id}}
                        </td>
                        <td>
                            <select class="chosenOff" ng-model="p.active" ng-change="setDirty(p)">
                                <option ng-value="true" ng-selected="p.active == true">Ativo</option>
                                <option ng-value="false" ng-selected="p.active == false">Inativo</option>
                            </select>
                        </td>
                        <td>
                            <input class="form-control" type="text" ng-model="p.name" ng-keyup="setDirty(p)">
                        </td>

                        <td>
                            <html:link styleClass="btn btn-warning btn-xs" action="/admin/bpmn/processEditor?id={{p.id}}">
                                <span class="glyphicon glyphicon-pencil"></span>
                            </html:link>
                        </td>
                        <td>
                            <bacoTags:confirm  msg="Tem a certeza que deseja remover o departamento {{p.name}}" targetFunction="angular.element($('#schoolsModule')).scope().removeSchool({{d}},{{$index}});angular.element($('#schoolsModule')).scope().$apply();" btnClass="btn btn-danger btn-xs" icon="glyphicon glyphicon-remove"/>
                        </td>



                    </tr>
                    </tbody>
                </table>

            </div>
        </div>
        <pre>{{processes | json}}</pre>
    </div>
</div>
<%
    AbstractDao.getCurrentSession().getTransaction().commit();
%>

Generated by GNU Enscript 1.6.5.2.