multitenant
Josef Rokos 11 years ago
commit 4d3f60c664

@ -1,5 +1,7 @@
package info.bukova.isspst; package info.bukova.isspst;
import java.util.List;
import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
@ -44,6 +46,7 @@ public class AppInitListener implements ServletContextListener {
checkRoles(); checkRoles();
checkUsers(); checkUsers();
checkPermissions(); checkPermissions();
checkAllAdminRights();
userService.removeAccess(); userService.removeAccess();
loadModuleReports(); loadModuleReports();
@ -97,6 +100,23 @@ public class AppInitListener implements ServletContextListener {
} }
} }
private void checkAllAdminRights()
{
Role adminRole = roleService.getRoleByAuthority(Constants.ROLE_ADMIN);
List<Permission> permissionList = adminRole.getPermissions();
List<Permission> permissionListAvailable = permService.getAll();
for (Permission permitionAvailable : permissionListAvailable)
{
if (!permissionList.contains(permitionAvailable))
{
adminRole.addPermission(permitionAvailable);
}
}
roleService.update(adminRole);
}
private void loadModuleReports() { private void loadModuleReports() {
for (Module m : Constants.MODULES) { for (Module m : Constants.MODULES) {
Report rep = new Report(); Report rep = new Report();

@ -54,6 +54,7 @@ public class ListViewModel<T extends DataModel> {
return dataList; return dataList;
} }
@NotifyChange({"dataBean","ableToDelete"})
public void setDataBean(T data) { public void setDataBean(T data) {
this.dataBean = data; this.dataBean = data;
} }
@ -327,4 +328,13 @@ public class ListViewModel<T extends DataModel> {
this.fullFill = fullFill; this.fullFill = fullFill;
} }
public boolean isRecordSelected()
{
return (dataBean != null);
}
public boolean isAbleToDelete()
{
return this.isRecordSelected();
}
} }

@ -72,4 +72,21 @@ public class UsersList extends ListViewModel<User> {
return ret; return ret;
} }
@Override
public boolean isAbleToDelete() {
if (!super.isAbleToDelete())
{
return false;
}
if (getDataBean().getUsername() == "admin")
{
return false;
}
return true;
}
} }

@ -15,7 +15,7 @@
<caption label="@load(module.name)"/> <caption label="@load(module.name)"/>
<hbox children="@load(vm.rolePerms.permissionChecks)"> <hbox children="@load(vm.rolePerms.permissionChecks)">
<template name="children" var="perm"> <template name="children" var="perm">
<checkbox label="@load(perm.permission.description)" checked="@bind(perm.checked)" visible="@load(perm.permission.module eq module.id)"/> <checkbox label="@load(perm.permission.description)" checked="@bind(perm.checked)" visible="@load(perm.permission.module eq module.id)" disabled="@load(vm.dataBean.authority eq 'ROLE_ADMIN')" />
</template> </template>
</hbox> </hbox>
</groupbox> </groupbox>

@ -19,14 +19,14 @@
<row><label value=""/><checkbox label="${labels.UsersFormSendNotify}" checked="@bind(vm.dataBean.notify)"/></row> <row><label value=""/><checkbox label="${labels.UsersFormSendNotify}" checked="@bind(vm.dataBean.notify)"/></row>
<row><label value="${labels.UsersFormPassword}"/><textbox value="@bind(vm.password)" type="password" instant="true"/></row> <row><label value="${labels.UsersFormPassword}"/><textbox value="@bind(vm.password)" type="password" instant="true"/></row>
<row><label value="${labels.UsersFormRepeatPassword}"/><textbox value="@bind(vm.retPasswd)" type="password" instant="true"/><label value="Hesla nesouhlasí" sclass="error" visible="@load(not vm.pwMatches)"/></row> <row><label value="${labels.UsersFormRepeatPassword}"/><textbox value="@bind(vm.retPasswd)" type="password" instant="true"/><label value="Hesla nesouhlasí" sclass="error" visible="@load(not vm.pwMatches)"/></row>
<row><label value=""/><checkbox label="${labels.UsersFormActive}" checked="@bind(vm.dataBean.enabled)"/></row> <row><label value=""/><checkbox label="${labels.UsersFormActive}" checked="@bind(vm.dataBean.enabled)" disabled="@load(vm.dataBean.username eq 'admin')" /></row>
</rows> </rows>
</grid> </grid>
<groupbox mold="3d"> <groupbox mold="3d">
<caption label="Role"/> <caption label="Role"/>
<vbox children="@load(vm.userRoles.roleChecks)"> <vbox children="@load(vm.userRoles.roleChecks)">
<template name="children"> <template name="children">
<checkbox label="@load(each.role.description)" checked="@bind(each.checked)"/> <checkbox label="@load(each.role.description)" checked="@bind(each.checked)" disabled="@load(vm.dataBean.username eq 'admin')" />
</template> </template>
</vbox> </vbox>
</groupbox> </groupbox>

@ -3,7 +3,7 @@
<toolbar> <toolbar>
<toolbarbutton image="/img/add.png" tooltiptext="${labels.ToolbarRecNew}" id="btnNew" onClick="@command('addNew')" disabled="@load(vm.filter)" /> <toolbarbutton image="/img/add.png" tooltiptext="${labels.ToolbarRecNew}" id="btnNew" onClick="@command('addNew')" disabled="@load(vm.filter)" />
<toolbarbutton image="/img/edit.png" tooltiptext="${labels.ToolbarRecEdit}" id="btnEdit" onClick="@command('edit')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/> <toolbarbutton image="/img/edit.png" tooltiptext="${labels.ToolbarRecEdit}" id="btnEdit" onClick="@command('edit')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/>
<toolbarbutton image="/img/delete.png" tooltiptext="${labels.ToolbarRecDelete}" id="btnDelete" onClick="@command('delete')" disabled="@load(empty vm.dataBean ? 'true' : 'false')"/> <toolbarbutton image="/img/delete.png" tooltiptext="${labels.ToolbarRecDelete}" id="btnDelete" onClick="@command('delete')" disabled="@load(not vm.ableToDelete)" />
<toolbarbutton image="/img/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" /> <toolbarbutton image="/img/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" /> <toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" />
</toolbar> </toolbar>

Loading…
Cancel
Save