forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1122 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
8b11f685af
commit
e2eda64344
@ -0,0 +1,67 @@
|
|||||||
|
package com.evolute.siprp.client.panels.apps.AnaliseAcidentesTrabalho;
|
||||||
|
|
||||||
|
import com.evolute.siprp.client.panels.utils.permissoes.AccessConstants;
|
||||||
|
import com.evolute.siprp.client.panels.utils.permissoes.PermissionsController;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
import com.google.gwt.user.client.ui.Button;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
public class ActualPanel extends Composite
|
||||||
|
{
|
||||||
|
|
||||||
|
private static ActualPanelUiBinder uiBinder = GWT.create( ActualPanelUiBinder.class );
|
||||||
|
interface ActualPanelUiBinder extends UiBinder< Widget, ActualPanel > { }
|
||||||
|
|
||||||
|
private PermissionsController permsController;
|
||||||
|
|
||||||
|
|
||||||
|
@UiField protected Button btnNewAnalysis;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ActualPanel()
|
||||||
|
{
|
||||||
|
permsController = new PermissionsController();
|
||||||
|
|
||||||
|
if ( permsController.hasPermissionTo( AccessConstants.VIEW_ACTUAL_PANEL ) )
|
||||||
|
{
|
||||||
|
setupComponent();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SimplePanel sp = new SimplePanel();
|
||||||
|
sp.setHeight( "0px" );
|
||||||
|
initWidget( sp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void setupComponent()
|
||||||
|
{
|
||||||
|
initWidget( uiBinder.createAndBindUi( this ) );
|
||||||
|
|
||||||
|
if ( permsController.hasPermissionTo( AccessConstants.VIEW_ACTUAL_PANEL_NOVA_ANALISE_BUTTON ) )
|
||||||
|
{
|
||||||
|
btnNewAnalysis.setText( "Criar nova an\u00E1lise de acidentes de trabalho" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@UiHandler( { "btnNewAnalysis" } )
|
||||||
|
protected void onClick( ClickEvent e )
|
||||||
|
{
|
||||||
|
if ( e.getSource().equals( btnNewAnalysis ) )
|
||||||
|
{
|
||||||
|
Window.alert( "new alanysis" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
|
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||||
|
<ui:style>
|
||||||
|
|
||||||
|
.bodyDiv {
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid black;
|
||||||
|
background-color: rgb( 238, 238, 238 );
|
||||||
|
}
|
||||||
|
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel>
|
||||||
|
|
||||||
|
<div class="{style.bodyDiv}">
|
||||||
|
<div class="alignCenterText lblBold font18">Actual</div>
|
||||||
|
|
||||||
|
<g:Button ui:field="btnNewAnalysis" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||||
xmlns:my="urn:import:com.evolute.siprp.client.panels.utils"
|
xmlns:my="urn:import:com.evolute.siprp.client.panels.utils.dialog"
|
||||||
>
|
>
|
||||||
<ui:style>
|
<ui:style>
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.evolute.siprp.client.panels.utils;
|
package com.evolute.siprp.client.panels.utils.dialog;
|
||||||
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.evolute.siprp.client.panels.utils;
|
package com.evolute.siprp.client.panels.utils.navigation;
|
||||||
|
|
||||||
public interface NavigationConstants
|
public interface NavigationConstants
|
||||||
{
|
{
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.evolute.siprp.client.panels.utils.permissoes;
|
||||||
|
|
||||||
|
public interface AccessConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int VIEW_ACTUAL_PANEL = 1;
|
||||||
|
public static final int VIEW_ACTUAL_PANEL_NOVA_ANALISE_BUTTON = 2;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.evolute.siprp.client.panels.utils.permissoes;
|
||||||
|
|
||||||
|
import com.evolute.siprp.client.panels.utils.navigation.PageNavigation;
|
||||||
|
import com.evolute.siprp.client.vo.Utilizador;
|
||||||
|
|
||||||
|
public class PermissionsController
|
||||||
|
{
|
||||||
|
|
||||||
|
private Utilizador userLogged = null;
|
||||||
|
private int userType;
|
||||||
|
|
||||||
|
public PermissionsController()
|
||||||
|
{
|
||||||
|
userLogged = PageNavigation.getProvider().getUserLogged();
|
||||||
|
userType = userLogged.getTipo_utilizador().intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasPermissionTo( Integer accessConstant )
|
||||||
|
{
|
||||||
|
Boolean canAccess = false;
|
||||||
|
|
||||||
|
switch ( accessConstant.intValue() )
|
||||||
|
{
|
||||||
|
case AccessConstants.VIEW_ACTUAL_PANEL:
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( userType == RolesConstants.TIPO_SEGURANCA
|
||||||
|
|| userType == RolesConstants.TIPO_RECURSOS_HUMANOS
|
||||||
|
|| userType == RolesConstants.TIPO_HIGIENE_SEGURANCA )
|
||||||
|
{
|
||||||
|
canAccess = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AccessConstants.VIEW_ACTUAL_PANEL_NOVA_ANALISE_BUTTON:
|
||||||
|
{
|
||||||
|
if ( userType == RolesConstants.TIPO_SEGURANCA )
|
||||||
|
{
|
||||||
|
canAccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return canAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.evolute.siprp.client.panels.utils.permissoes;
|
||||||
|
|
||||||
|
public interface RolesConstants
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
1 - "Segurança"
|
||||||
|
2 - "Recursos Humanos"
|
||||||
|
3 - "Higiene e Segurança"
|
||||||
|
5 - "Médico"
|
||||||
|
6 - "Gestão"
|
||||||
|
7 - "Direcção-Geral RH"
|
||||||
|
8 - "Director Siprp"
|
||||||
|
9 - "Director de Loja"
|
||||||
|
10 - "Director Nacional de Segurança"
|
||||||
|
*/
|
||||||
|
|
||||||
|
//campo 'tipo' em 'tipos_utilizadores'
|
||||||
|
|
||||||
|
public static final Integer TIPO_SEGURANCA = 1;
|
||||||
|
public static final Integer TIPO_RECURSOS_HUMANOS = 2;
|
||||||
|
public static final Integer TIPO_HIGIENE_SEGURANCA = 3;
|
||||||
|
public static final Integer TIPO_MEDICO = 5;
|
||||||
|
public static final Integer TIPO_GESTOR = 6;
|
||||||
|
public static final Integer TIPO_DIRECTOR_GERAL_RECURSOS_HUMANOS = 7;
|
||||||
|
public static final Integer TIPO_DIRECTOR_SIPRP = 8;
|
||||||
|
public static final Integer TIPO_DIRECTOR_LOJA = 9;
|
||||||
|
public static final Integer TIPO_DIRECTOR_NACIONAL_SEGURANCA = 10;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue