multitenant
František Přibyl 10 years ago
commit 60a87e5d52

@ -22,8 +22,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
public class LoginSuccessHandler implements AuthenticationSuccessHandler { public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
@Autowired @Autowired
private SessionData sessionData; private SessionData sessionData;
@ -61,7 +62,7 @@ public class LoginSuccessHandler implements AuthenticationSuccessHandler {
userService.update(u); userService.update(u);
} }
response.sendRedirect("app/"); super.onAuthenticationSuccess(request, response, auth);
} }
} }

@ -10,6 +10,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils; import org.zkoss.bind.BindUtils;
@ -267,11 +269,37 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
newRec = false; newRec = false;
} }
Map<String, String[]> map = Executions.getCurrent().getParameterMap();
int id = -1;
try {
if (map.get("select") != null) {
id = Integer.parseInt(map.get("select")[0]);
}
} catch (NumberFormatException e) {
Logger logger = LoggerFactory.getLogger(this.getClass());
logger.warn("ID is not number: " + map.get("select")[0]);
}
if (id > 0) {
for (int i = 0; i < dataList.size(); i++) {
if (dataList.get(i).getId() == id) {
selIndex = i;
beforeSelectViaUrl();
break;
}
}
}
if (selIndex > -1) { if (selIndex > -1) {
this.setDataBean(dataList.get(selIndex)); this.setDataBean(dataList.get(selIndex));
} }
} }
protected void beforeSelectViaUrl() {
}
@Command @Command
@NotifyChange("dataBean") @NotifyChange("dataBean")
public void onSort(@BindingParam("column") String column) { public void onSort(@BindingParam("column") String column) {

@ -9,6 +9,10 @@ public class TabPanelsVM
private boolean showCentre; private boolean showCentre;
private boolean showWorkgroup; private boolean showWorkgroup;
private boolean showAll; private boolean showAll;
private boolean selectMy;
private boolean selectCentre;
private boolean selectWorkgroup;
private boolean selectAll;
@Init @Init
public void init() public void init()
@ -16,6 +20,11 @@ public class TabPanelsVM
showCentre = true; showCentre = true;
showWorkgroup = true; showWorkgroup = true;
showAll = true; showAll = true;
selectMy = true;
selectCentre = false;
selectWorkgroup = false;
selectAll = false;
} }
@GlobalCommand @GlobalCommand
@ -39,6 +48,27 @@ public class TabPanelsVM
showAll = false; showAll = false;
} }
@GlobalCommand
@NotifyChange("selectCentre")
public void selectCentre() {
selectMy = false;
selectCentre = true;
}
@GlobalCommand
@NotifyChange("selectWorkgroup")
public void selectWorkgroup() {
selectMy = false;
selectWorkgroup = true;
}
@GlobalCommand
@NotifyChange("selectAll")
public void selectAll() {
selectMy = false;
selectAll = true;
}
public boolean isShowCentre() public boolean isShowCentre()
{ {
return showCentre; return showCentre;
@ -53,4 +83,21 @@ public class TabPanelsVM
{ {
return showAll; return showAll;
} }
public boolean isSelectMy() {
return selectMy;
}
public boolean isSelectCentre() {
return selectCentre;
}
public boolean isSelectWorkgroup() {
return selectWorkgroup;
}
public boolean isSelectAll() {
return selectAll;
}
} }

@ -64,4 +64,9 @@ public class ReqListMyAll extends RequirementSubpage<Requirement>
{ {
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectAll", null);
}
} }

@ -64,4 +64,9 @@ public class ReqListMyCenters extends RequirementSubpage<Requirement>
{ {
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectCentre", null);
}
} }

@ -64,4 +64,9 @@ public class ReqListMyWorkgroups extends RequirementSubpage<Requirement>
{ {
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectWorkgroup", null);
}
} }

@ -60,4 +60,9 @@ public class TripRequirementListAll extends RequirementSubpage<TripRequirement>
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectAll", null);
}
} }

@ -57,4 +57,9 @@ public class TripRequirementListCentre extends RequirementSubpage<TripRequiremen
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectCentre", null);
}
} }

@ -63,4 +63,9 @@ public class TripRequirementListWorkgroup extends RequirementSubpage<TripRequire
this.reload(); this.reload();
} }
@Override
protected void beforeSelectViaUrl() {
BindUtils.postGlobalCommand(null, null, "selectWorkgroup", null);
}
} }

@ -1,5 +1,6 @@
package info.bukova.isspst.ui.settings; package info.bukova.isspst.ui.settings;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Address; import info.bukova.isspst.data.Address;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.SettingsData; import info.bukova.isspst.data.SettingsData;
@ -8,6 +9,7 @@ import info.bukova.isspst.mail.MailMessage;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.sort.ReflectionTools; import info.bukova.isspst.sort.ReflectionTools;
import info.bukova.isspst.ui.LocaleConverter; import info.bukova.isspst.ui.LocaleConverter;
import info.bukova.isspst.ui.SecurityHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -52,7 +54,7 @@ public class GlobalSettingsVM {
} }
public boolean isCanSave() { public boolean isCanSave() {
return true; return SecurityHelper.isAllGranted(Constants.ROLE_ADMIN);
} }
public LocaleConverter getLocConverter() { public LocaleConverter getLocConverter() {

@ -6,13 +6,16 @@
<tab label="${labels.RequirementsGridMy}" /> <tab label="${labels.RequirementsGridMy}" />
<tab <tab
label="${labels.RequirementsGridMyCentres}" label="${labels.RequirementsGridMyCentres}"
disabled="@load(not vm.showCentre)" /> disabled="@load(not vm.showCentre)"
selected="@load(vm.selectCentre)" />
<tab <tab
label="${labels.RequirementsGridMyWorkgroups}" label="${labels.RequirementsGridMyWorkgroups}"
disabled="@load(not vm.showWorkgroup)" /> disabled="@load(not vm.showWorkgroup)"
selected="@load(vm.selectWorkgroup)" />
<tab <tab
label="${labels.RequirementsGridAll}" label="${labels.RequirementsGridAll}"
disabled="@load(not vm.showAll)" /> disabled="@load(not vm.showAll)"
selected="@load(vm.selectAll)" />
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>

@ -8,37 +8,37 @@
<rows> <rows>
<row> <row>
<label value="${labels.SuppliersFormCompany}"/> <label value="${labels.SuppliersFormCompany}"/>
<textbox value="@bind(vm.settings.mainAddress.company)" width="100%"/> <textbox value="@bind(vm.settings.mainAddress.company)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormIC}"/> <label value="${labels.SuppliersFormIC}"/>
<textbox value="@bind(vm.settings.mainAddress.ic)"/> <textbox value="@bind(vm.settings.mainAddress.ic)" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormDIC}"/> <label value="${labels.SuppliersFormDIC}"/>
<textbox value="@bind(vm.settings.mainAddress.dic)"/> <textbox value="@bind(vm.settings.mainAddress.dic)" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormStreet}"/> <label value="${labels.SuppliersFormStreet}"/>
<textbox value="@bind(vm.settings.mainAddress.street)" width="100%"/> <textbox value="@bind(vm.settings.mainAddress.street)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormNo}"/> <label value="${labels.SuppliersFormNo}"/>
<textbox value="@bind(vm.settings.mainAddress.houseNumber)"/> <textbox value="@bind(vm.settings.mainAddress.houseNumber)" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormCity}"/> <label value="${labels.SuppliersFormCity}"/>
<textbox value="@bind(vm.settings.mainAddress.city)" width="100%"/> <textbox value="@bind(vm.settings.mainAddress.city)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.SuppliersFormZIP}"/> <label value="${labels.SuppliersFormZIP}"/>
<textbox value="@bind(vm.settings.mainAddress.zipCode)"/> <textbox value="@bind(vm.settings.mainAddress.zipCode)" readonly="@load(not vm.canSave)"/>
</row> </row>
</rows> </rows>
</grid> </grid>
<vbox> <vbox>
<label value="${labels.ShippingAddresses}"/> <label value="${labels.ShippingAddresses}"/>
<button label="${labels.AddItem}" onClick="@command('addAddress')"/> <button label="${labels.AddItem}" onClick="@command('addAddress')" disabled="@load(not vm.canSave)"/>
<listbox model="@load(vm.settings.shippingAddrs)"> <listbox model="@load(vm.settings.shippingAddrs)">
<listhead> <listhead>
<listheader label="${labels.SuppliersFormStreet}"/> <listheader label="${labels.SuppliersFormStreet}"/>
@ -50,19 +50,19 @@
<template name="model"> <template name="model">
<listitem> <listitem>
<listcell> <listcell>
<textbox inplace="true" value="@bind(each.street)"></textbox> <textbox inplace="true" value="@bind(each.street)" readonly="@load(not vm.canSave)"></textbox>
</listcell> </listcell>
<listcell> <listcell>
<textbox inplace="true" value="@bind(each.houseNumber)"></textbox> <textbox inplace="true" value="@bind(each.houseNumber)" readonly="@load(not vm.canSave)"></textbox>
</listcell> </listcell>
<listcell> <listcell>
<textbox inplace="true" value="@bind(each.city)"></textbox> <textbox inplace="true" value="@bind(each.city)" readonly="@load(not vm.canSave)"></textbox>
</listcell> </listcell>
<listcell> <listcell>
<textbox inplace="true" value="@bind(each.zipCode)"></textbox> <textbox inplace="true" value="@bind(each.zipCode)" readonly="@load(not vm.canSave)"></textbox>
</listcell> </listcell>
<listcell> <listcell>
<button label="${labels.RemoveItem }" onClick="@command('removeAddress', addr=each)"/> <button label="${labels.RemoveItem }" onClick="@command('removeAddress', addr=each)" disabled="@load(not vm.canSave)"/>
</listcell> </listcell>
</listitem> </listitem>
</template> </template>

@ -8,15 +8,15 @@
<rows> <rows>
<row> <row>
<label value="${labels.BankName}"/> <label value="${labels.BankName}"/>
<textbox value="@bind(vm.settings.bankName)" width="100%"/> <textbox value="@bind(vm.settings.bankName)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.AccountNumber}"/> <label value="${labels.AccountNumber}"/>
<textbox value="@bind(vm.settings.accountNumber)"/> <textbox value="@bind(vm.settings.accountNumber)" readonly="@load(not vm.canSave)"/>
</row> </row>
<row> <row>
<label value="${labels.BankCode}"/> <label value="${labels.BankCode}"/>
<textbox value="@bind(vm.settings.bankCode)"/> <textbox value="@bind(vm.settings.bankCode)" readonly="@load(not vm.canSave)"/>
</row> </row>
</rows> </rows>
</grid> </grid>

@ -15,12 +15,13 @@
</columns> </columns>
<rows> <rows>
<row> <row>
<label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.newReqTemplate.subject)" width="100%"/> <label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.newReqTemplate.subject)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row spans="2"> <row spans="2">
<vbox> <vbox>
<ckeditor toolbar="Basic" value="@bind(vm.settings.newReqTemplate.text)" width="460px" height="180px"/> <ckeditor toolbar="Basic" value="@bind(vm.settings.newReqTemplate.text)" width="460px" height="180px" if="${vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsNew, position=after_start"/> <html content="@load(vm.settings.newReqTemplate.text)" width="460px" height="180px" if="${not vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsNew, position=after_start" disabled="@load(not vm.canSave)"/>
</vbox> </vbox>
</row> </row>
</rows> </rows>
@ -34,12 +35,13 @@
</columns> </columns>
<rows> <rows>
<row> <row>
<label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.authReqTemplate.subject)" width="100%"/> <label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.authReqTemplate.subject)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row spans="2"> <row spans="2">
<vbox> <vbox>
<ckeditor toolbar="Basic" value="@bind(vm.settings.authReqTemplate.text)" width="460px" height="180px"/> <ckeditor toolbar="Basic" value="@bind(vm.settings.authReqTemplate.text)" width="460px" height="180px" if="${vm.canSave}" />
<button label="${labels.InsertField}" popup="fieldsAuth, position=after_start"/> <html content="@load(vm.settings.authReqTemplate.text)" width="460px" height="180px" if="${not vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsAuth, position=after_start" disabled="@load(not vm.canSave)"/>
</vbox> </vbox>
</row> </row>
</rows> </rows>
@ -53,12 +55,13 @@
</columns> </columns>
<rows> <rows>
<row> <row>
<label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.confReqTemplate.subject)" width="100%"/> <label value="${labels.MailSubject}"/> <textbox value="@bind(vm.settings.confReqTemplate.subject)" width="100%" readonly="@load(not vm.canSave)"/>
</row> </row>
<row spans="2"> <row spans="2">
<vbox> <vbox>
<ckeditor toolbar="Basic" value="@bind(vm.settings.confReqTemplate.text)" width="460px" height="180px"/> <ckeditor toolbar="Basic" value="@bind(vm.settings.confReqTemplate.text)" width="460px" height="180px" if="${vm.canSave}" />
<button label="${labels.InsertField}" popup="fieldsConfirm, position=after_start"/> <html content="@load(vm.settings.confReqTemplate.text)" width="460px" height="180px" if="${not vm.canSave}"/>
<button label="${labels.InsertField}" popup="fieldsConfirm, position=after_start" disabled="@load(not vm.canSave)"/>
</vbox> </vbox>
</row> </row>
</rows> </rows>

@ -23,10 +23,10 @@
<template name="model"> <template name="model">
<row> <row>
<label value="@load(each)"/> <label value="@load(each)"/>
<textbox value="@bind(vm.settings.refunds[each][0])" inplace="true"/> <textbox value="@bind(vm.settings.refunds[each][0])" inplace="true" readonly="@load(not vm.canSave)"/>
<textbox value="@bind(vm.settings.refunds[each][1])" inplace="true"/> <textbox value="@bind(vm.settings.refunds[each][1])" inplace="true" readonly="@load(not vm.canSave)"/>
<textbox value="@bind(vm.settings.refunds[each][2])" inplace="true"/> <textbox value="@bind(vm.settings.refunds[each][2])" inplace="true" readonly="@load(not vm.canSave)"/>
<textbox value="@bind(vm.settings.refunds[each][3])" inplace="true"/> <textbox value="@bind(vm.settings.refunds[each][3])" inplace="true" readonly="@load(not vm.canSave)"/>
</row> </row>
</template> </template>
@ -35,7 +35,7 @@
</tabpanel> </tabpanel>
<tabpanel> <tabpanel>
<vbox> <vbox>
<button label="${labels.AddItem}" onClick="@command('addVehicle')" sclass="nicebutton"/> <button label="${labels.AddItem}" onClick="@command('addVehicle')" sclass="nicebutton" disabled="@load(not vm.canSave)"/>
<grid model="@load(vm.settings.vehicles)"> <grid model="@load(vm.settings.vehicles)">
<columns> <columns>
<column label="${labels.code}"/> <column label="${labels.code}"/>
@ -45,9 +45,9 @@
<rows> <rows>
<template name="model"> <template name="model">
<row> <row>
<textbox inplace="true" value="@bind(each.code)"/> <textbox inplace="true" value="@bind(each.code)" readonly="@load(not vm.canSave)"/>
<textbox inplace="true" value="@bind(each.description)"/> <textbox inplace="true" value="@bind(each.description)" readonly="@load(not vm.canSave)"/>
<button label="${labels.RemoveItem}" onClick="@command('removeVehicle', vehicle=each)"/> <button label="${labels.RemoveItem}" onClick="@command('removeVehicle', vehicle=each)" disabled="@load(not vm.canSave)"/>
</row> </row>
</template> </template>
</rows> </rows>

@ -28,7 +28,7 @@
<div> <div>
<checkbox <checkbox
label="${labels.EnableRequirements}" label="${labels.EnableRequirements}"
checked="@bind(vm.settings.enableRequirements)" /> checked="@bind(vm.settings.enableRequirements)" disabled="@load(not vm.canSave)" />
</div> </div>
</tabpanel> </tabpanel>
<tabpanel> <tabpanel>

Loading…
Cancel
Save