diff --git a/sources/ui/pom.xml b/sources/ui/pom.xml
index ce5eea1..85760b6 100644
--- a/sources/ui/pom.xml
+++ b/sources/ui/pom.xml
@@ -22,10 +22,10 @@
tools.dynamia.modules
tools.dynamia.modules.saas.parent
- 3.4.0
+ 3.4.1
tools.dynamia.modules.saas.ui
- 3.4.0
+ 3.4.1
DynamiaModules - SaaS UI
https://www.dynamia.tools/modules/saas
diff --git a/sources/ui/src/main/java/tools/dynamia/modules/saas/ui/customizers/AccountFormCustomizer.java b/sources/ui/src/main/java/tools/dynamia/modules/saas/ui/customizers/AccountFormCustomizer.java
new file mode 100644
index 0000000..ec1a951
--- /dev/null
+++ b/sources/ui/src/main/java/tools/dynamia/modules/saas/ui/customizers/AccountFormCustomizer.java
@@ -0,0 +1,84 @@
+package tools.dynamia.modules.saas.ui.customizers;
+
+import org.zkoss.zk.ui.event.Events;
+import org.zkoss.zul.Combobox;
+import tools.dynamia.integration.Containers;
+import tools.dynamia.modules.saas.domain.Account;
+import tools.dynamia.modules.saas.domain.AccountReseller;
+import tools.dynamia.modules.saas.domain.AccountResellerAgent;
+import tools.dynamia.modules.saas.services.AccountResellerService;
+import tools.dynamia.ui.UIMessages;
+import tools.dynamia.viewers.ViewCustomizer;
+import tools.dynamia.zk.util.ZKUtil;
+import tools.dynamia.zk.viewers.form.FormView;
+
+import java.util.List;
+
+/**
+ * Customizes the Account form view to handle reseller and reseller agent information.
+ * It sets up the comboboxes for selecting resellers and their agents, and updates the
+ * agent combobox based on the selected reseller.
+ *
+ * This class listens for value changes in the form and updates the reseller and agent
+ * information accordingly. It ensures that the agent combobox is populated with agents
+ */
+public class AccountFormCustomizer implements ViewCustomizer> {
+
+ @Override
+ public void customize(FormView view) {
+
+ view.addEventListener(FormView.ON_VALUE_CHANGED, e -> {
+ setupResellerInfo(view);
+ });
+
+
+ }
+
+ /**
+ * Setup reseller and reseller agent information in the form view.
+ *
+ * @param view
+ */
+ private void setupResellerInfo(FormView view) {
+ var resellers = view.getFieldComponent("reseller").getInputComponent();
+ var resellerAgents = view.getFieldComponent("resellerAgent").getInputComponent();
+
+ var account = view.getValue();
+
+ if (resellers instanceof Combobox resellerCombo && resellerAgents instanceof Combobox agentCombo) {
+
+ var service = Containers.get().findObject(AccountResellerService.class);
+
+ ZKUtil.fillCombobox(resellerCombo, service.findAllEnabledResellers(), account.getReseller(), true);
+
+ if (account.getReseller() != null) {
+ var agents = service.findAgentsByReseller(account.getReseller());
+ fillComboboxAgents(agentCombo, agents, account);
+ }
+
+ resellerCombo.addEventListener(Events.ON_CHANGE, e -> {
+ if (resellerCombo.getSelectedItem() == null) {
+ UIMessages.showMessage("Please select a valid reseller.");
+ return;
+ }
+ AccountReseller reseller = resellerCombo.getSelectedItem().getValue();
+ var agents = service.findAgentsByReseller(reseller);
+ fillComboboxAgents(agentCombo, agents, account);
+ });
+
+ }
+ }
+
+ private static void fillComboboxAgents(Combobox agentCombo, List agents, Account account) {
+ if (agents == null || agents.isEmpty()) {
+ agentCombo.setValue(null);
+ agentCombo.setPlaceholder(UIMessages.getLocalizedMessage("No agents available"));
+ return;
+ }
+
+ ZKUtil.fillCombobox(agentCombo, agents, account.getResellerAgent(), true);
+ agentCombo.setPlaceholder(agents.isEmpty() ?
+ UIMessages.getLocalizedMessage("No agents available") :
+ UIMessages.getLocalizedMessage("Select an agent"));
+ }
+}
diff --git a/sources/ui/src/main/resources/META-INF/descriptors/AccountForm.yml b/sources/ui/src/main/resources/META-INF/descriptors/AccountForm.yml
index 1f9eab0..c5f212e 100644
--- a/sources/ui/src/main/resources/META-INF/descriptors/AccountForm.yml
+++ b/sources/ui/src/main/resources/META-INF/descriptors/AccountForm.yml
@@ -1,5 +1,6 @@
view: form
beanClass: tools.dynamia.modules.saas.domain.Account
+customizer: tools.dynamia.modules.saas.ui.customizers.AccountFormCustomizer
autofields: false
fields:
@@ -24,7 +25,7 @@ fields:
accountRegion:
label: Region
profile:
- reseller:
+
channel:
creationDate:
category:
@@ -57,8 +58,6 @@ fields:
component: spiner
status:
customDomain:
- params:
- span: 2
maxUsers:
description: Override Account Type Config
params:
@@ -97,11 +96,39 @@ fields:
templateAccount:
+ reseller:
+ component: combobox
+ params:
+ readonly: true
+
+ resellerAgent:
+ label: Agent
+ component: combobox
+ params:
+ readonly: true
+
+ resellerInvoice:
+ label: Invoice
+
+ resellerInvoiceDate:
+ label: Invoice Date
+
+ resellerComments:
+ label: Comments
+ params:
+ span: 4
+ multiline: true
+ height: 80px
+
groups:
contactInfo:
fields: [ contactFirstName, contactLastName,phoneNumber,mobileNumber,contactEmail, city,region, country, address, customerInfo ]
+
+ resellerInfo:
+ fields: [ reseller, resellerAgent, resellerInvoice, resellerInvoiceDate, resellerComments ]
+
configuration:
fields: [ locale, timeZone,skin, maxUsers,statusDescription,uuid,instanceUuid,creationDate,remote,autoInit,requiredInstanceUuid,redirect,templateAccount ]
diff --git a/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentForm.yml b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentForm.yml
new file mode 100644
index 0000000..b86250a
--- /dev/null
+++ b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentForm.yml
@@ -0,0 +1,11 @@
+view: form
+beanClass: tools.dynamia.modules.saas.domain.AccountResellerAgent
+fields:
+ name:
+ identification:
+ email:
+ phone:
+
+
+layout:
+ columns: 2
\ No newline at end of file
diff --git a/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentTable.yml b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentTable.yml
new file mode 100644
index 0000000..a58b48a
--- /dev/null
+++ b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerAgentTable.yml
@@ -0,0 +1,11 @@
+view: table
+beanClass: tools.dynamia.modules.saas.domain.AccountResellerAgent
+fields:
+ name:
+ identification:
+ email:
+ phone:
+
+
+layout:
+ columns: 2
\ No newline at end of file
diff --git a/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerForm.yml b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerForm.yml
index 151d893..fad7cf6 100644
--- a/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerForm.yml
+++ b/sources/ui/src/main/resources/META-INF/descriptors/AccountResellerForm.yml
@@ -13,6 +13,9 @@ fields:
externalId:
enabled:
+ agents:
+ component: crudview
+
layout:
columns: 4
\ No newline at end of file