static private final int SEARCH_LIMIT = 10;
@Autowired
ProjectService projectService;
- private String partialName;
- private String partialPartnerName;
- private String partialHumanId;
+ private String partialSearch;
private boolean filter(Project project) {
- if (StringUtils.isBlank(partialHumanId) && StringUtils.isBlank(partialName) && StringUtils.isBlank(partialPartnerName)) {
+ if (StringUtils.isBlank(partialSearch)) {
return true;
}
- if (StringUtils.isNotBlank(partialHumanId)) {
- if (project.getHumanId().toLowerCase().contains(partialHumanId.toLowerCase())) {
+ if (StringUtils.isNotBlank(partialSearch)) {
+ if (project.getHumanId().toLowerCase().contains(partialSearch.toLowerCase())) {
return true;
}
- }
- if (StringUtils.isNotBlank(partialName)) {
- if (project.getName().toLowerCase().contains(partialName.toLowerCase())) {
+ if (project.getName().toLowerCase().contains(partialSearch.toLowerCase())) {
return true;
}
- }
- if (StringUtils.isNotBlank(partialPartnerName)) {
- if (project.getPartner().getName().toLowerCase().contains(partialPartnerName.toLowerCase())) {
+ if (project.getPartner().getName().toLowerCase().contains(partialSearch.toLowerCase())) {
return true;
}
}
return result;
}
- public void search(String partialName, String partialPartnerName, String partialHumanId) {
- log.info("Searching projects using filter {} {} {}", partialHumanId, partialName, partialHumanId);
- this.partialPartnerName = partialPartnerName;
- this.partialHumanId = partialHumanId;
- this.partialName = partialName;
+ public void search(String partialSearch) {
+ log.info("Searching projects using filter {}", partialSearch);
+ this.partialSearch = partialSearch;
super.reset();
BindUtils.postNotifyChange(null, null, this, "*");
}
public void getLimited() {
log.info("Searching projects using limit {}", SEARCH_LIMIT);
- this.partialPartnerName = null;
- this.partialHumanId = null;
- this.partialName = null;
+ this.partialSearch = null;
super.reset();
BindUtils.postNotifyChange(null, null, this, "*");
}
import org.zkoss.zul.Window;
import java.util.Objects;
-import java.util.regex.Pattern;
@Log4j2
@Getter
}
private boolean isVatNumber(String vatNr) {
- Pattern pattern = Pattern.compile(VAT_NR_PATTERN);
- boolean result = pattern.matcher(vatNr).matches();
- log.info("Vat number regex match {}", result);
- return result;
+ return true;
+ //TODO not working properly
+// Pattern pattern = Pattern.compile(VAT_NR_PATTERN);
+// boolean result = pattern.matcher(vatNr).matches();
+// log.info("Vat number regex match {}", result);
+// return result;
}
private void updateFormInvalid(boolean invalid) {
import hu.user.lis.ui.converter.ProjectStatusConverter;
import hu.user.lis.ui.data.*;
import hu.user.lis.ui.event.EventBus;
+import hu.user.lis.ui.session.SessionSettings;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.WireVariable;
+import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkplus.spring.DelegatingVariableResolver;
import org.zkoss.zul.Center;
import org.zkoss.zul.Panel;
ProjectAssociateService projectAssociateServiceImpl;
@WireVariable
ServiceRecordService serviceRecordServiceImpl;
+ @WireVariable
+ SessionSettings sessionSettings;
private Project formDocument;
private Project origDocument;
private Map<String, Boolean> origAssociates;
@Override
public void onEvent(Event evt) {
if (Constants.SET_PROJECT_EDITOR_DATA.equals(evt.getName())) {
- Map<String, Object> data = (Map<String, Object>) evt.getData();
- origDocument = (Project) data.get("origDocument");
- formDocument = (Project) data.get("formDocument");
- serviceRecordsDataModel.search(formDocument, true);
- associatesDataModel.listAll();
- incomeMarginsDataModel.recalculate(formDocument);
- BindUtils.postNotifyChange(this, "formDocument");
+ log.info("Got event {}", Constants.SET_PROJECT_EDITOR_DATA);
+ Object data = evt.getData();
+ if (data instanceof Map) {
+ Map<String, Object> mapData = (Map<String, Object>) evt.getData();
+ origDocument = (Project) mapData.get("origDocument");
+ formDocument = (Project) mapData.get("formDocument");
+ }
+
+ if (data instanceof String) {
+ String id = (String) data;
+ log.info("Loading entity {} to editor", id);
+ origDocument = projectServiceImpl.getById(id);
+ formDocument = projectServiceImpl.copy(origDocument);
+ }
+
+ if (Objects.isNull(data)) {
+ formDocument = projectServiceImpl.createNew();
+ log.info("Loading new entity {} to editor", formDocument.getId());
+ }
+
+ if (Objects.nonNull(formDocument)) {
+ Clients.evalJavaScript(String.format("pushNav('/project/%s')", formDocument.getId()));
+ serviceRecordsDataModel.search(formDocument, true);
+ associatesDataModel.listAll();
+ incomeMarginsDataModel.recalculate(formDocument);
+ BindUtils.postNotifyChange(this, "formDocument");
+ }
}
}
@Command
public void onPopupPartners() {
String page = "~./suppliers.zul";
- Window suppliersWindow = (Window) Executions.createComponents(page, null, null);
- suppliersWindow.addEventListener("onClose", e -> {
+ Window editorWindow = (Window) Executions.createComponents(page, null, null);
+ editorWindow.addEventListener("onClose", e -> {
log.info("Suppliers popup result {}", e.getData());
if (e.getData() != null) {
partnerSelectorDataModel.clearSelection();
BindUtils.postNotifyChange(this, "selectedSupplierId");
}
});
-
- suppliersWindow.doModal();
+ editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Override
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
public void onProjectBandChanging(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
InputEvent event = (InputEvent) ctx.getTriggerEvent();
log.info("onProjectBandChanging: {}", event.getValue());
- projectSelectorDataModel.search(event.getValue(), null, null);
+ projectSelectorDataModel.search(event.getValue());
}
@Command
--- /dev/null
+package hu.user.lis.ui.session;
+
+import lombok.extern.log4j.Log4j2;
+import org.springframework.stereotype.Service;
+import org.zkoss.zk.ui.Executions;
+import org.zkoss.zk.ui.Sessions;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+@Service
+@Log4j2
+public class SessionSettings {
+
+ public SessionSettings() {
+ log.info("SessionSettings created");
+ }
+
+ private HttpServletRequest getNativeRequest() {
+ return (HttpServletRequest) Executions.getCurrent().getNativeRequest();
+ }
+
+ private HttpSession getNativeSession() {
+ return (HttpSession) Sessions.getCurrent().getNativeSession();
+ }
+
+ public String getCurrentPath() {
+ HttpServletRequest nativeRequest = getNativeRequest();
+ return (String) Executions.getCurrent().getAttribute("javax.servlet.forward.servlet_path");
+ }
+
+ public String getSessionId() {
+ return getNativeSession().getId();
+ }
+}
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
import com.google.common.collect.ImmutableMap;
import hu.user.lis.ui.Constants;
import hu.user.lis.ui.event.EventBus;
+import hu.user.lis.ui.session.SessionSettings;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Destroy;
import org.zkoss.bind.annotation.Init;
-import org.zkoss.zk.ui.Executions;
-import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.WireVariable;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import java.util.Map;
@Log4j2
@WireVariable
BuildProperties buildProperties;
+ @WireVariable
+ SessionSettings sessionSettings;
+
@WireVariable
EventBus eventBus;
String searchPhrase;
@Init
public void init() {
- HttpSession s = (HttpSession) Sessions.getCurrent().getNativeSession();
- log.info("Current session is {}", s.getId());
- HttpServletRequest nativeRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
- String path = (String) Executions.getCurrent().getAttribute("javax.servlet.forward.servlet_path");
- if (navigation.containsKey(path)) {
- setPage(navigation.get(path));
- } else {
- setPage(PARTNERS_LIST);
- }
eventBus.register(this);
+ log.info("Current session is {}", sessionSettings.getSessionId());
+ String path = sessionSettings.getCurrentPath();
+
+ //project editor
+ route(path);
+
log.info("Init {}", path);
}
+ private void route(String path) {
+ if (path.startsWith("/project/") && path.split("/").length > 2) {
+ String id = path.split("/")[2];
+ selectPage(PROJECT_EDITOR);
+// eventBus.setProjectEditorData(Collections.singletonMap("id", id));
+ eventBus.setProjectEditorData(id);
+ } else {
+ if (navigation.containsKey(path)) {
+ setPage(navigation.get(path));
+ } else {
+ setPage(PARTNERS_LIST);
+ }
+ }
+ }
+
@Command
public void selectPage(@BindingParam("page") String page) {
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
package hu.user.lis.ui.view;
-import com.google.common.collect.ImmutableMap;
import hu.user.lis.db.Project;
import hu.user.lis.db.ProjectStatus;
import hu.user.lis.services.data.ProjectStatusService;
@Command
public void onAdd() {
Project newEntity = projectsDataModel.getProjectService().createNew();
- eventBus.showProjectEditor(ImmutableMap.of("formDocument", newEntity));
+// eventBus.showProjectEditor(ImmutableMap.of("formDocument", newEntity));
+ eventBus.showProjectEditor(null);
}
@Command
if (Objects.isNull(selectedProject)) {
return;
}
- Project editEntity = projectsDataModel.getProjectService().copy(selectedProject);
- eventBus.showProjectEditor(ImmutableMap.of("origDocument", selectedProject, "formDocument", editEntity));
+// Project editEntity = projectsDataModel.getProjectService().copy(selectedProject);
+// eventBus.showProjectEditor(ImmutableMap.of("origDocument", selectedProject, "formDocument", editEntity));
+ eventBus.showProjectEditor(selectedProject.getId());
}
public boolean isFilterShowInActive() {
public void onProjectFilterBandChanging(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) {
InputEvent event = (InputEvent) ctx.getTriggerEvent();
log.info("onProjectFilterBandChanging: {}", event.getValue());
- projectSelectorDataModel.search(event.getValue(), null, null);
+ projectSelectorDataModel.search(event.getValue());
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
@Command
}
});
editorWindow.doModal();
+ editorWindow.setFocus(true);
}
public void setFilterProject(Project filterProject) {
format="locale:hu-HU" instant="true"
forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
<label value="Aktív"/>
- <checkbox mold="switch" checked="@bind(vm.formDocument.active) @validator(vm)"/>
+ <checkbox mold="switch" checked="@bind(vm.formDocument.active) @validator(vm)"/>
</vlayout>
</tabpanel>
</tabpanels>
import hu.user.lis.db.Currency;
ListModelList currencies = new ListModelList(Currency.values());
</zscript>
- <window id="invoicePopup" width="50%" height="500px" closable="true"
+ <window id="invoicePopup" width="50%" height="400px" closable="true"
maximizable="true" sizable="true" viewModel="@id('vm') @init('hu.user.lis.ui.editor.InvoiceEditorModel')">
<caption label="Bejövő számla szerkesztés"/>
<borderlayout>
<tabpanels>
<tabpanel>
<vlayout hflex="true">
- <label value="Tervezett"/>
- <checkbox mold="switch" checked="@bind(vm.formDocument.planned)"/>
<label value="Leírás"/>
<textbox hflex="true" instant="true"
value="@bind(vm.formDocument.title) @validator(vm)"
forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
</vlayout>
</hlayout>
+ <label value="Tervezett"/>
+ <checkbox mold="switch" checked="@bind(vm.formDocument.planned)"/>
</vlayout>
</tabpanel>
<tabpanel>
import hu.user.lis.db.Currency;
ListModelList currencies = new ListModelList(Currency.values());
</zscript>
- <window id="invoicePopup" width="50%" height="500px" closable="true"
+ <window id="invoicePopup" width="50%" height="400px" closable="true"
maximizable="true" sizable="true" viewModel="@id('vm') @init('hu.user.lis.ui.editor.InvoiceEditorModel')">
<caption label="Kimenő számla szerkesztés"/>
<borderlayout>
<tabpanels>
<tabpanel>
<vlayout hflex="true">
- <label value="Tervezett"/>
- <checkbox mold="switch" checked="@bind(vm.formDocument.planned)"/>
<label value="Leírás"/>
<textbox hflex="true" instant="true"
value="@bind(vm.formDocument.title) @validator(vm)"
forward="onOK=submit.onClick, onCancel=cancel.onClick"/>
</vlayout>
</hlayout>
+ <label value="Tervezett"/>
+ <checkbox mold="switch" checked="@bind(vm.formDocument.planned)"/>
</vlayout>
</tabpanel>
<tabpanel>