public static final String PROJECT_EDITOR_QUEUE = "PROJECT_EDITOR_QUEUE";
public static final String PROCESS_EVENT_QUEUE = "PROJECT_EDITOR_QUEUE";
public static final String SHOW_PROJECT_EDITOR = "SHOW_PROJECT_EDITOR";
+ public static final String SHOW_INVOICE_PAYMENT = "SHOW_INVOICE_PAYMENT";
public static final String SHOW_PROJECTS_LIST = "SHOW_PROJECTS_LIST";
public static final String SHOW_SERVICE_RECORDS_LIST = "SHOW_SERVICE_RECORDS_LIST";
public static final String SET_SERVICE_RECORDS_LIST_DATA = "SET_SERVICE_RECORDS_LIST_DATA";
public static final String SET_PROJECT_EDITOR_DATA = "SET_PROJECT_EDITOR_DATA";
+ public static final String SET_INVOICE_PAYMENT_DATA = "SET_INVOICE_PAYMENT_DATA";
public static final String SET_PROJECTS_LIST_DATA = "SET_PROJECTS_LIST_DATA";
public static final String REFRESH_INVOICE_IMPORT_TASKS = "REFRESH_INVOICE_IMPORT_TASKS";
public static final String NAV_PARTNERS = "/partners";
--- /dev/null
+package hu.user.lis.ui.editor;
+
+import hu.user.lis.ui.view.ProjectsViewModel;
+import lombok.Getter;
+import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.annotation.BindingParam;
+import org.zkoss.bind.annotation.Command;
+import org.zkoss.bind.annotation.Init;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.Events;
+import org.zkoss.zul.Window;
+
+import java.util.Objects;
+
+
+@Getter
+@Log4j2
+public class ProjectAttachEditorModel extends ProjectsViewModel {
+
+ @Init
+ @Override
+ public void init() {
+ super.init();
+ }
+
+ @Override
+ protected String getNavigation() {
+ return null;
+ }
+
+ @Command
+ public void onCloseWindow(@BindingParam("target") Window target, @BindingParam("save") boolean save) {
+ if (save) {
+ if (Objects.nonNull(getSelectedEntity())) {
+ Events.postEvent(new Event("onClose", target, getSelectedEntity()));
+ }
+ } else {
+ Events.postEvent(new Event("onClose", target, null));
+ }
+ }
+}
public static final String TREASURY = "~./editor/treasury-editor.zul";
public static final String ASSOCIATE = "~./editor/associate-editor.zul";
public static final String PARTNER = "~./editor/partner-editor.zul";
+ public static final String PROJECT_ATTACH = "~./editor/project-attach.zul";
public static final String IMPORT_INVOICE_ASSIGN = "~./editor/import-invoice-assign-editor.zul";
public static final String IMPORT_INVOICE_APPROVE = "~./editor/import-invoice-approve-editor.zul";
public static final String PROJECT = "~./editor/project-editor.zul";
+ public static final String INVOICE_PAYMENT = "~./invoice-payment.zul";
public static final String POPUP_EDITOR = "~./editor/popup-editor.zul";
public static <E> void doEdit(String page, E entity, EditCompleted<E> editCompleted) {
eventBus.registerForBinding(this);
origDocument = (T) Executions.getCurrent().getArg().get("origDocument");
formDocument = (T) Executions.getCurrent().getArg().get("formDocument");
- if (Objects.nonNull(getFormValidator())) {
+ if (Objects.nonNull(getFormValidator()) && Objects.nonNull(getFormDocument())) {
getFormValidator().validate(getFormDocument());
}
}
getQueue().publish(new Event(Constants.SHOW_PROJECT_EDITOR, null, data));
}
+ public void showInvoicePayment(Object data) {
+ getQueue().publish(new Event(Constants.SHOW_INVOICE_PAYMENT, null, data));
+ }
+
public void showServiceRecordsList(Object data) {
getQueue().publish(new Event(Constants.SHOW_SERVICE_RECORDS_LIST, null, data));
}
getQueue().publish(new Event(Constants.SET_SERVICE_RECORDS_LIST_DATA, null, data));
}
- public void setProjectEditorData(Long data) {
- getQueue().publish(new Event(Constants.SET_PROJECT_EDITOR_DATA, null, data));
+ public void setProjectEditorData(Long id) {
+ getQueue().publish(new Event(Constants.SET_PROJECT_EDITOR_DATA, null, id));
+ }
+
+ public void setInvoicePaymentData(Long data) {
+ getQueue().publish(InvoicePaymentData.builder().id(data).build());
}
public void setProjectsListData(Object data) {
--- /dev/null
+package hu.user.lis.ui.event;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+import org.zkoss.zk.ui.event.Event;
+
+import static hu.user.lis.ui.Constants.SET_INVOICE_PAYMENT_DATA;
+
+@Getter
+@Setter
+@Builder
+public class InvoicePaymentData extends Event {
+ private final Long id;
+
+ public InvoicePaymentData(Long id) {
+ super(SET_INVOICE_PAYMENT_DATA);
+ this.id = id;
+ }
+}
--- /dev/null
+package hu.user.lis.ui.event;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+import org.zkoss.zk.ui.event.Event;
+
+import static hu.user.lis.ui.Constants.SET_PROJECT_EDITOR_DATA;
+
+@Getter
+@Setter
+@Builder
+public class ProjectEditorData extends Event {
+ private final Long id;
+
+ public ProjectEditorData(Long id) {
+ super(SET_PROJECT_EDITOR_DATA);
+ this.id = id;
+ }
+}
@Command
@NotifyChange("approveInvoicesDataModel")
public void onRefresh() {
+ approveInvoicesDataModel.clearSelection();
setSelectedEntity(null);
approveInvoicesDataModel.refresh();
BindUtils.postNotifyChange(this, "selectedEntity");
@Command
public void onRefresh() {
+ assignInvoicesDataModel.clearSelection();
setSelectedEntity(null);
assignInvoicesDataModel.refresh();
BindUtils.postNotifyChange(this, "selectedEntity");
import hu.user.lis.ui.view.common.FilterActiveViewModel;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
} else {
associatesDataModel.search(isFilterShowActive(), isFilterShowInActive());
}
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
import hu.user.lis.workflow.invoice.service.WorkflowManagerService;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.BindUtils;
import org.zkoss.bind.PropertyChangeEvent;
import org.zkoss.bind.annotation.*;
import org.zkoss.zk.ui.Component;
@Command
public void refresh() {
invoicesDataModel.clearSelection();
+ setSelectedEntity(null);
invoicesDataModel.search(invoiceFilter);
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
package hu.user.lis.ui.view;
+import com.google.common.collect.ImmutableMap;
import hu.user.lis.ui.Constants;
import hu.user.lis.ui.auth.CurrentProfile;
import hu.user.lis.ui.editor.common.Editors;
@WireVariable
private EventBus eventBus;
-
@WireVariable
private BuildProperties buildProperties;
-
@WireVariable
private SessionSettings sessionSettings;
-
@WireVariable
private CurrentProfile currentProfile;
-
@WireVariable
private WorkflowManagerService workflowManagerService;
-
private String searchPhrase;
-
private String page;
-
+ private final Map<String, SpecialRoute> specialRoutes = ImmutableMap.of(
+ Constants.NAV_PROJECTS, this::showProjectEditor,
+ Constants.NAV_INVOICE_PAYMENT, this::showInvoicePayment
+ );
private String importInvoiceMenuClassName;
-
private String assignInvoiceMenuClassName;
-
private String approveInvoiceMenuClassName;
-
private String assignInvoicesLabel;
-
private String approveInvoicesLabel;
+ private final Map<String, UIEventHandler> eventHandlers = ImmutableMap.of(
+ Constants.REFRESH_INVOICE_IMPORT_TASKS, this::updateImportInvoiceMenus,
+ Constants.SHOW_SERVICE_RECORDS_LIST, this::showServiceRecords,
+ Constants.SHOW_PROJECT_EDITOR, this::showProjectEditor,
+ Constants.SHOW_INVOICE_PAYMENT, this::showInvoicePayment,
+ Constants.SHOW_PROJECTS_LIST, this::showProjects
+ );
@Init
public void init() {
String path = sessionSettings.getCurrentPath();
log.info("2. Current session is {} path {}", sessionSettings.getSessionId(), path);
route(path);
- updateImportInvoiceMenus();
+ updateImportInvoiceMenus(null);
}
private void route(String path) {
- if (path.startsWith(Constants.NAV_PROJECTS + "/") && path.split("/").length > 2) {
- String id = path.split("/")[2];
- selectPage(Editors.PROJECT);
- eventBus.setProjectEditorData(Long.parseLong(id));
+ if (Constants.NAV_ROOT.equals(path))
+ path = Constants.NAV_PARTNERS;
+
+ String[] pathTokens = path.split("/");
+ if (pathTokens.length > 2) {
+ Long id = Long.parseLong(pathTokens[2]);
+ specialRoutes.get(path).route(id);
} else {
- if (Constants.NAV_ROOT.equals(path))
- path = Constants.NAV_PARTNERS;
setPage("~." + path + ".zul");
}
}
+ public void showProjectEditor(Long id) {
+ selectPage(Editors.PROJECT);
+ eventBus.setProjectEditorData(id);
+ }
+
+ public void showInvoicePayment(Long id) {
+ selectPage(Editors.INVOICE_PAYMENT);
+ eventBus.setInvoicePaymentData(id);
+ }
@Command
public void selectPage(@BindingParam("page") String page) {
@Override
public void onEvent(Event event) {
- if (Constants.SHOW_SERVICE_RECORDS_LIST.equals(event.getName())) {
- selectPage(SERVICE_RECORDS_LIST);
- eventBus.setServiceRecordsListData(event.getData());
- }
- if (Constants.SHOW_PROJECT_EDITOR.equals(event.getName())) {
- selectPage(Editors.PROJECT);
- eventBus.setProjectEditorData((Long) event.getData());
- }
- if (Constants.SHOW_PROJECTS_LIST.equals(event.getName())) {
- selectPage(PROJECTS_LIST);
- if (event.getData() != null) {
- eventBus.setProjectsListData(event.getData());
- }
+ if (eventHandlers.containsKey(event.getName())) {
+ eventHandlers.get(event.getName()).handle(event);
}
- if (Constants.REFRESH_INVOICE_IMPORT_TASKS.equals(event.getName())) {
- updateImportInvoiceMenus();
+ }
+
+ private void showServiceRecords(Event event) {
+ selectPage(SERVICE_RECORDS_LIST);
+ eventBus.setServiceRecordsListData(event.getData());
+ }
+
+ private void showProjectEditor(Event event) {
+ showProjectEditor((Long) event.getData());
+ }
+
+ private void showInvoicePayment(Event event) {
+ selectPage(Editors.INVOICE_PAYMENT);
+ eventBus.setInvoicePaymentData((Long) event.getData());
+ }
+
+ private void showProjects(Event event) {
+ selectPage(PROJECTS_LIST);
+ if (event.getData() != null) {
+ eventBus.setProjectsListData(event.getData());
}
}
- private void updateImportInvoiceMenus() {
+ private void updateImportInvoiceMenus(Event event) {
long assignInvoiceTaskCount = workflowManagerService.countAssignInvoiceTasks();
long approveInvoiceTaskCount = workflowManagerService.countApproveInvoiceTasks();
if (assignInvoiceTaskCount > 0) {
});
}
-
}
import hu.user.lis.ui.data.common.CachedSpringDataModel;
import hu.user.lis.ui.editor.selector.EntitySelectorRouter;
import hu.user.lis.ui.event.EventBus;
+import hu.user.lis.ui.event.InvoicePaymentData;
import hu.user.lis.ui.view.common.EntityViewModel;
import lombok.Getter;
import lombok.Setter;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
+import org.zkoss.zk.ui.event.Event;
+import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zk.ui.util.Notification;
import org.zkoss.zul.ListModelList;
import java.util.Objects;
import java.util.Optional;
+import static hu.user.lis.ui.Constants.SET_INVOICE_PAYMENT_DATA;
+
@Log4j2
-public class InvoicePaymentViewModel extends EntityViewModel<Payment> {
+public class InvoicePaymentViewModel extends EntityViewModel<Payment> implements EventListener {
@Getter
private final ListModelList<Partner> partners = new ListModelList<>();
@Override
public void init() {
super.init();
+ eventBus.register(this);
setReadonlyForm(true);
// addColumns(ImmutableMap.of(
// "partner.name", ASCENDING,
getFormDocument().setPaid(newPaymentDisabled);
invoiceRepository.save(getFormDocument());
}
+ }
+
+ @Override
+ public void onEvent(Event event) throws Exception {
+ if (SET_INVOICE_PAYMENT_DATA.equals(event.getName())) {
+ Optional<Invoice> opInvoice = invoiceRepository.findById(((InvoicePaymentData) event).getId());
+ opInvoice.ifPresent(invoice -> {
+ this.showEditor(invoice);
+ invoiceNumber = invoice.getHumanId();
+ filterPartner = null;
+ setPartnerRequired(false);
+ BindUtils.postNotifyChange(this, "partnerRequired");
+ BindUtils.postNotifyChange(this, "invoiceNumber");
+ });
+ }
}
+
+
}
@Command
public void refresh() {
invoicesDataModel.clearSelection();
+ setSelectedEntity(null);
invoicesDataModel.search(invoiceFilter);
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
// (this.equals(propertyEvent.getBase()) && propertyEvent.getProperty().startsWith("invoiceFilter")))
if (invoiceFilter.equals(propertyEvent.getBase())) {
log.info("Refresh needed, {} changed", propertyEvent.getProperty());
-
refresh();
}
}
});
}
+ @Command
+ public void onChangeProject() {
+ Editors.doEdit(Editors.PROJECT_ATTACH, getSelectedEntity().getProject(), null, modifiedEntity -> {
+ if (modifiedEntity != null) {
+ getSelectedEntity().setProject(modifiedEntity);
+ invoiceDataModel.save(getSelectedEntity());
+ refresh();
+ }
+ });
+
+ }
+
+ @Command
+ public void onInvoicePayment() {
+ eventBus.showInvoicePayment(getSelectedEntity().getId());
+ }
}
import hu.user.lis.ui.view.common.FilterActiveViewModel;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
protected void refresh() {
partnersDataModel.clearSelection();
+ setSelectedEntity(null);
if (isFilterShowBoth()) {
partnersDataModel.search(true, true);
} else {
partnersDataModel.search(isFilterShowActive(), isFilterShowInActive());
}
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
import hu.user.lis.ui.view.common.FilterActiveViewModel;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
+import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Destroy;
import org.zkoss.bind.annotation.Init;
} else {
projectsDataModel.search(isFilterShowActive(), isFilterShowInActive());
}
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import org.zkoss.bind.BindContext;
+import org.zkoss.bind.BindUtils;
import org.zkoss.bind.PropertyChangeEvent;
import org.zkoss.bind.annotation.*;
import org.zkoss.zk.ui.Component;
} else {
serviceRecordsDataModel.listAll();
}
+ BindUtils.postNotifyChange(this, "selectedEntity");
}
@Command
--- /dev/null
+package hu.user.lis.ui.view;
+
+public interface SpecialRoute {
+ void route(Long id);
+}
--- /dev/null
+package hu.user.lis.ui.view;
+
+import org.zkoss.zk.ui.event.Event;
+
+public interface UIEventHandler {
+ void handle(Event event);
+}
--- /dev/null
+<zk>
+ <window id="projectAttachPopup" width="600px" height="400px"
+ viewModel="@id('vm') @init('hu.user.lis.ui.editor.ProjectAttachEditorModel')">
+ <caption label="Projektek"/>
+ <borderlayout>
+ <north flex="true">
+ <toolbar>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-check" label="Aktív"
+ checked="@bind(vm.filterShowActive)"/>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-ban" label="Inaktív"
+ checked="@bind(vm.filterShowInActive)"/>
+ <toolbarbutton mode="toggle" iconSclass="z-icon-adjust" label="Mind"
+ checked="@bind(vm.filterShowBoth)"/>
+ </toolbar>
+ </north>
+ <center border="none" flex="true">
+ <listbox vflex="true" model="@load(vm.projectsDataModel)"
+ autopaging="true" pagingPosition="top" multiple="false"
+ onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')">
+ <listhead sizable="true">
+ <listheader label="Azonosító" sort="auto(humanId)" align="left"
+ sortDirection="@load(vm.cols['humanId'].sortDirection)"/>
+ <listheader label="Ügyfél" sort="auto(partner.name)" align="left"
+ sortDirection="@load(vm.cols['partner.name'].sortDirection)"/>
+ <listheader label="Státusz" sort="auto(projectStatus.name)" align="left"
+ sortDirection="@load(vm.cols['projectStatus.name'].sortDirection)"/>
+ <listheader label="Megnevezés" sort="auto(name)" align="left"
+ sortDirection="@load(vm.cols['name'].sortDirection)"/>
+ <listheader label="Kapcsolattartó" sort="auto(contactName)" align="left"
+ sortDirection="@load(vm.cols['contactName'].sortDirection)"/>
+ <listheader label="Aktív" sort="auto(active)" align="left"
+ sortDirection="@load(vm.cols['active'].sortDirection)"/>
+ </listhead>
+ <template name="model">
+ <listitem>
+ <listcell label="@load(each.humanId)"/>
+ <listcell label="@load(each.partner.name)"/>
+ <listcell label="@load(each.projectStatus.name)"/>
+ <listcell label="@load(each.name)"/>
+ <listcell label="@load(each.contactName)"/>
+ <listcell>
+ <a iconSclass="z-icon-check" visible="@load(each.active)"/>
+ <a iconSclass="z-icon-ban" visible="@load(!each.active)"/>
+ </listcell>
+ </listitem>
+ </template>
+ </listbox>
+ </center>
+ <south border="none" flex="true" style="text-align: right; padding: 10px">
+ <hlayout>
+ <button id="cancel" label="Bezár"
+ onClick="@command('onCloseWindow', target=projectAttachPopup, save=false)"/>
+ <button id="submit" label="Mentés"
+ onClick="@command('onCloseWindow', target=projectAttachPopup, save=true)"
+ disabled="@bind(empty vm.selectedEntity)"/>
+ <!-- <button iconSclass="z-icon-question-circle-o" disabled="false"-->
+ <!-- popup="formValidation, position=before_end"/>-->
+ <!-- <popup id="formValidation">-->
+ <!-- <html content="@load(vm.validationMessages)"/>-->
+ <!-- </popup>-->
+ </hlayout>
+ </south>
+ </borderlayout>
+
+ </window>
+</zk>
\ No newline at end of file
<north hflex="true">
<vlayout>
<toolbar>
- <!-- <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>-->
- <!-- <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit" onClick="@command('onEdit')"-->
- <!-- disabled="@load(empty vm.selectedEntity)"/>-->
- <!-- <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"-->
- <!-- disabled="@load(empty vm.selectedEntity)"/>-->
<label value="Partner"/>
<separator orient="vertical"/>
<entity-selector entity="Partner" style="display: inline-block;" width="300px"/>
<!-- <toolbarbutton iconSclass="z-icon-search" label="Szűrés"-->
<!-- onClick="@command('search')"/>-->
</toolbar>
+ <toolbar>
+ <toolbarbutton label="Szerkesztés" iconSclass="z-icon-edit" onClick="@command('onEdit')"
+ disabled="@load(empty vm.selectedEntity)"/>
+ <toolbarbutton label="Projekt módosítás" iconSclass="z-icon-forward"
+ onClick="@command('onChangeProject')" disabled="@load(empty vm.selectedEntity)"/>
+ <toolbarbutton label="Számla kiegyenlítés" iconSclass="z-icon-credit-card"
+ onClick="@command('onInvoicePayment')"
+ disabled="@load(empty vm.selectedEntity)"/>
+
+ <!-- <toolbarbutton label="Hozzáadás" iconSclass="z-icon-plus" onClick="@command('onAdd')"/>-->
+ <!-- <toolbarbutton label="Törlés" iconSclass="z-icon-remove" onClick="@command('onDelete')"-->
+ <!-- disabled="@load(empty vm.selectedEntity)"/>-->
+ </toolbar>
</vlayout>
</north>
<center border="none" hflex="true" vflex="true">
</toolbar>
</north>
<center border="none" flex="true">
- <listbox id="partnersList" vflex="true" model="@load(vm.projectsDataModel)"
+ <listbox vflex="true" model="@load(vm.projectsDataModel)"
autopaging="true" pagingPosition="top" multiple="false"
onSelect="@command('onListSelection')" onDoubleClick="@command('onEdit')">
<listhead sizable="true">
--- /dev/null
+2023-11-25 22:44:17,628 INFO org.hibernate.validator.internal.util.Version [background-preinit] HV000001: Hibernate Validator 6.2.5.Final
+2023-11-25 22:44:18,754 INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate [main] Bootstrapping Spring Data JPA repositories in DEFAULT mode.
+2023-11-25 22:44:18,879 INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate [main] Finished Spring Data repository scanning in 113 ms. Found 11 JPA repository interfaces.