optimierung Business Partnersuche
This commit is contained in:
parent
aa5f000715
commit
81fb527029
6 changed files with 85 additions and 54 deletions
|
|
@ -32,6 +32,19 @@ Z.b. kann das als Custom Part in eine Form eingebunden werden:
|
||||||
<item name="bpid" type="custom" path="alexander/businesspartner_search" required="true" label="Businesspartner:" />
|
<item name="bpid" type="custom" path="alexander/businesspartner_search" required="true" label="Businesspartner:" />
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Der name ist heirbei irrelevant, da immer die Items `partner.id` und `partner.name` ausgefüllt werden.
|
||||||
|
Zusätzlich kann man mit den Options angeben ob die Maske komplett neu gerendert werden soll. Das ist z.b. bei dem Modell `analyse-debitor.bpmn` der Fall
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<item name="dbtr.number" type="custom" path="alexander/businesspartner_search" required="true" label="Debtor:" options="rerender" />
|
||||||
|
```
|
||||||
|
|
||||||
|
Man kann auch noch über die options eine regular Expression mitgeben wodurch die Filterliste eingeschränkt werden kann:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<item name="dbtr.number" type="custom" path="alexander/businesspartner_search" required="true" label="Debtor:" options="rerender;regexPattern=(ABC)" />
|
||||||
|
```
|
||||||
|
|
||||||
Alternativ kann im Backend über die EJB BusinessPartnerService nach bpid gesucht werden:
|
Alternativ kann im Backend über die EJB BusinessPartnerService nach bpid gesucht werden:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
@ -74,3 +87,11 @@ K76233 HSH Papier GmbH & Co. KG
|
||||||
D16233 Manfred Ziegler Transport GmbH
|
D16233 Manfred Ziegler Transport GmbH
|
||||||
|
|
||||||
Problemkind: https://alexander-logistics-dwc.office-workflow.de/pages/workitems/workitem.xhtml?id=9dd64b0a-cfe1-4174-aea4-0e8af45b823f
|
Problemkind: https://alexander-logistics-dwc.office-workflow.de/pages/workitems/workitem.xhtml?id=9dd64b0a-cfe1-4174-aea4-0e8af45b823f
|
||||||
|
|
||||||
|
# Business Parter Serach Widget
|
||||||
|
|
||||||
|
wir müssten eigentlich nach Auswahl des Partner
|
||||||
|
|
||||||
|
execute="#{customFormComponents.clientId}" render="#{customFormComponents.clientId}"
|
||||||
|
|
||||||
|
machnen, aber das hat einen blöden effekt
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import org.imixs.workflow.ItemCollection;
|
||||||
import org.imixs.workflow.engine.DocumentService;
|
import org.imixs.workflow.engine.DocumentService;
|
||||||
import org.imixs.workflow.exceptions.QueryException;
|
import org.imixs.workflow.exceptions.QueryException;
|
||||||
import org.imixs.workflow.faces.data.WorkflowController;
|
import org.imixs.workflow.faces.data.WorkflowController;
|
||||||
import org.imixs.workflow.office.forms.AnalyticController;
|
|
||||||
import org.imixs.workflow.office.forms.AnalyticEvent;
|
import org.imixs.workflow.office.forms.AnalyticEvent;
|
||||||
|
|
||||||
import jakarta.enterprise.context.ConversationScoped;
|
import jakarta.enterprise.context.ConversationScoped;
|
||||||
|
|
@ -44,7 +43,7 @@ import jakarta.inject.Named;
|
||||||
public class AGLAnalyticControllerDebitor implements Serializable {
|
public class AGLAnalyticControllerDebitor implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static Logger logger = Logger.getLogger(AnalyticController.class.getName());
|
private static Logger logger = Logger.getLogger(AGLAnalyticControllerDebitor.class.getName());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected DocumentService documentService;
|
protected DocumentService documentService;
|
||||||
|
|
@ -92,7 +91,7 @@ public class AGLAnalyticControllerDebitor implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
String dbtrNumber = event.getWorkitem().getItemValueString("dbtr.number");
|
String dbtrNumber = event.getWorkitem().getItemValueString("dbtr.number");
|
||||||
logger.info("Analytic Event : " + dbtrNumber);
|
logger.fine("Analytic Event : " + dbtrNumber);
|
||||||
String dbtrNumberLast = event.getWorkitem().getItemValueString("dbtr.number.last");
|
String dbtrNumberLast = event.getWorkitem().getItemValueString("dbtr.number.last");
|
||||||
|
|
||||||
// Recompute only if last dbtr.number has changed or no values yet computed
|
// Recompute only if last dbtr.number has changed or no values yet computed
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public class BusinessPartnerController implements Serializable {
|
||||||
* render="autocomplete-resultlist-datev" onevent="autocompleteShowResult" />
|
* render="autocomplete-resultlist-datev" onevent="autocompleteShowResult" />
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public void search(String regexPattern) {
|
public void search(String options) {
|
||||||
List<ItemCollection> resultList = null;
|
List<ItemCollection> resultList = null;
|
||||||
searchResult = new ArrayList<BusinessPartnerSearchEntry>();
|
searchResult = new ArrayList<BusinessPartnerSearchEntry>();
|
||||||
// get the param from faces context....
|
// get the param from faces context....
|
||||||
|
|
@ -128,11 +128,12 @@ public class BusinessPartnerController implements Serializable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.fine("search for=" + phrase);
|
logger.fine("search for=" + phrase);
|
||||||
resultList = businessPartnerService.search(phrase);
|
|
||||||
// Compile the regex pattern
|
|
||||||
logger.fine("regex=" + regexPattern);
|
|
||||||
Pattern pattern = null;
|
Pattern pattern = null;
|
||||||
if (regexPattern != null && !regexPattern.isEmpty()) {
|
resultList = businessPartnerService.search(phrase);
|
||||||
|
// Compile the regex pattern if available
|
||||||
|
if (options.contains("regexPattern=")) {
|
||||||
|
String regexPattern = options.substring(options.indexOf("regexPattern=") + 13);
|
||||||
|
logger.fine("regex=" + regexPattern);
|
||||||
pattern = Pattern.compile(regexPattern);
|
pattern = Pattern.compile(regexPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +158,20 @@ public class BusinessPartnerController implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Helper Method liefert true wenn in den Options von Form Part 'reRender'
|
||||||
|
* angegeben wurde.
|
||||||
|
* Damit löst die Suchmaske businesspartner_search.xhtml eine komplette rerender
|
||||||
|
* Phase der Form aus.
|
||||||
|
* Dies ist z.b. für den workflow 'analyse-debitor.bpmn' nützlich
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isRerenderMode(String options) {
|
||||||
|
return options.toLowerCase().contains("rerender");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Die Resultliste wird als eine Liste einen Arrays zurückgegeben. Der Erste
|
* Die Resultliste wird als eine Liste einen Arrays zurückgegeben. Der Erste
|
||||||
* Eintrag
|
* Eintrag
|
||||||
|
|
@ -314,7 +329,7 @@ public class BusinessPartnerController implements Serializable {
|
||||||
public void updateMetaData() {
|
public void updateMetaData() {
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
String bpid = fc.getExternalContext().getRequestParameterMap().get("partnerID");
|
String bpid = fc.getExternalContext().getRequestParameterMap().get("partnerID");
|
||||||
logger.fine(".........bpid = " + bpid);
|
logger.info("....update metadata.....bpid = " + bpid);
|
||||||
ItemCollection businessPartner = businessPartnerService.getBusinessPartnerByID(bpid);
|
ItemCollection businessPartner = businessPartnerService.getBusinessPartnerByID(bpid);
|
||||||
if (businessPartner != null) {
|
if (businessPartner != null) {
|
||||||
|
|
||||||
|
|
@ -359,6 +374,7 @@ public class BusinessPartnerController implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
searchResult = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,14 @@
|
||||||
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
|
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core"
|
||||||
xmlns:f="http://xmlns.jcp.org/jsf/core"
|
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
|
||||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
xmlns:marty="http://xmlns.jcp.org/jsf/composite/marty" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs">
|
||||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
|
||||||
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
|
|
||||||
xmlns:marty="http://xmlns.jcp.org/jsf/composite/marty"
|
|
||||||
xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Cargosoft Creditor Search integration -->
|
|
||||||
<ui:include src="/pages/workitems/forms/alexander/cargsoft-creditor-search.xhtml">
|
|
||||||
<ui:param name="workitem" value="#{workflowController.workitem}" />
|
|
||||||
<ui:param name="searchmode" value="multi" /> <!-- display multiple ibans in separate lines -->
|
|
||||||
</ui:include>
|
|
||||||
<ui:include src="/pages/workitems/forms/alexander/cargsoft-debitor-search.xhtml">
|
|
||||||
<ui:param name="workitem" value="#{workflowController.workitem}" />
|
|
||||||
</ui:include>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- the following code computes the txtworkflow abstract from the current modelversion and processid -->
|
<!-- the following code computes the txtworkflow abstract from the current modelversion and processid -->
|
||||||
<ui:param name="instruction"
|
<ui:param name="instruction"
|
||||||
value="#{modelController.getProcessDescription(workflowController.workitem.item['$taskid'],workflowController.workitem.item['$ModelVersion'],workflowController.workitem)}"></ui:param>
|
value="#{modelController.getProcessDescription(workflowController.workitem.item['$taskid'],workflowController.workitem.item['$ModelVersion'],workflowController.workitem)}">
|
||||||
<h:panelGroup layout="block" styleClass="imixs-instruction"
|
</ui:param>
|
||||||
rendered="#{! empty instruction}">
|
<h:panelGroup layout="block" styleClass="imixs-instruction" rendered="#{! empty instruction}">
|
||||||
<h:outputText escape="false" value="#{instruction}" />
|
<h:outputText escape="false" value="#{instruction}" />
|
||||||
</h:panelGroup>
|
</h:panelGroup>
|
||||||
|
|
||||||
|
|
@ -36,8 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
<!-- sub forms (optional) -->
|
<!-- sub forms (optional) -->
|
||||||
<c:forEach items="#{formController.formDefinition.sections}"
|
<c:forEach items="#{formController.formDefinition.sections}" var="section">
|
||||||
var="section">
|
|
||||||
<div class="imixs-form-panel">
|
<div class="imixs-form-panel">
|
||||||
<h3>
|
<h3>
|
||||||
<h:outputText value="#{section.name}" />
|
<h:outputText value="#{section.name}" />
|
||||||
|
|
|
||||||
|
|
@ -4,37 +4,36 @@
|
||||||
xmlns:marty="http://xmlns.jcp.org/jsf/composite/marty" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs">
|
xmlns:marty="http://xmlns.jcp.org/jsf/composite/marty" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs">
|
||||||
|
|
||||||
<!-- businsspartner Search integration
|
<!-- businsspartner Search integration
|
||||||
|
|
||||||
This subform is a custom form part for the items 'item.id' and 'item.name'
|
|
||||||
|
|
||||||
The subform provides a jsf commandScript which calls the businessPartnerController.search method in the backend.
|
|
||||||
|
|
||||||
The script below inits a autocompletion feature for the input field.
|
|
||||||
See imixs-office.autocompletion.js
|
|
||||||
|
|
||||||
See also:
|
This subform provides a search feature for business partners and
|
||||||
https://stackoverflow.com/questions/16588327/how-to-invoke-a-jsf-managed-bean-on-a-html-dom-event-using-native-javascript
|
automatically updates partner.id and partner.name
|
||||||
https://dzone.com/articles/execute-a-jsf-ajax-request-by-just-a-function-call
|
|
||||||
https://www.w3schools.com/howto/howto_js_autocomplete.asp
|
When 'options=rerender' the full form will be refreshed after selection. This is usefull for DebitorAanaylye
|
||||||
|
|
||||||
|
Optional the options can also include a regex pattern
|
||||||
|
|
||||||
|
options=rerender;regexPattern=(...)
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
<ui:fragment rendered="#{!readonly}">
|
<ui:fragment rendered="#{!readonly}">
|
||||||
|
<h:commandScript name="updateBPForm" action="#{businessPartnerController.updateMetaData()}"
|
||||||
|
onevent="handleUpdateEvent"
|
||||||
|
execute="#{businessPartnerController.isRerenderMode(options)?customFormComponents.clientId:''}"
|
||||||
|
render="#{businessPartnerController.isRerenderMode(options)?customFormComponents.clientId:''}" />
|
||||||
|
<h:commandScript name="businsspartnerSearch" action="#{businessPartnerController.search(options)}"
|
||||||
|
render="autocomplete-resultlist-businsspartner" onevent="autocompleteShowResult" />
|
||||||
<h:inputText value="#{workitem.item['partner.id']}" pt:data-item="partner.id" />
|
<h:inputText value="#{workitem.item['partner.id']}" pt:data-item="partner.id" />
|
||||||
<h:inputHidden value="#{workitem.item['partner.name']}" pt:data-item="partner.name" />
|
<h:inputHidden value="#{workitem.item['partner.name']}" pt:data-item="partner.name" />
|
||||||
<br />
|
<br />
|
||||||
<span id='businsspartner-konto-id' class='small'>#{workitem.item['partner.name']}</span>
|
<span id='businsspartner-konto-id' class='small'>#{workitem.item['partner.name']}</span>
|
||||||
<h:commandScript name="businsspartnerSearch" action="#{businessPartnerController.search(options)}"
|
|
||||||
render="autocomplete-resultlist-businsspartner" onevent="autocompleteShowResult" />
|
|
||||||
|
|
||||||
<h:commandScript name="updateBPForm" action="#{businessPartnerController.updateMetaData()}"
|
|
||||||
render="#{opListContainer.clientId}" onevent="handleUpdateEvent" />
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/*<![CDATA[*/
|
/*<![CDATA[*/
|
||||||
|
|
||||||
// init input fields...
|
// init input fields...
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
//initBPSearch();
|
||||||
// add autocomplete feature ..
|
// add autocomplete feature ..
|
||||||
var creditorField = $("input[data-item='partner.id']");
|
var creditorField = $("input[data-item='partner.id']");
|
||||||
$(creditorField).each(function () {
|
$(creditorField).each(function () {
|
||||||
|
|
@ -64,10 +63,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateEvent(data) {
|
function handleUpdateEvent(data) {
|
||||||
console.log('bin in handleUpdaetEvent');
|
var $body = $("body");
|
||||||
if (typeof ajaxUpdateInvoiceSelection === 'function') {
|
if (data.status === 'begin') {
|
||||||
console.log('und wir haben die fuktion');
|
// show ajax loader...
|
||||||
ajaxUpdateInvoiceSelection(data);
|
$body.addClass("loading");
|
||||||
|
}
|
||||||
|
if (data.status === 'success') {
|
||||||
|
// avoid restarting search
|
||||||
|
autocompleteSearchReady = false;
|
||||||
|
// remove ajax loader
|
||||||
|
$body.removeClass("loading");
|
||||||
|
|
||||||
|
// console.log('bin in handleUpdaetEvent');
|
||||||
|
if (typeof ajaxUpdateInvoiceSelection === 'function') {
|
||||||
|
console.log('function: ajaxUpdateInvoiceSelection....');
|
||||||
|
ajaxUpdateInvoiceSelection(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +95,6 @@
|
||||||
</div>
|
</div>
|
||||||
</ui:repeat>
|
</ui:repeat>
|
||||||
</h:panelGroup>
|
</h:panelGroup>
|
||||||
|
|
||||||
</ui:fragment>
|
</ui:fragment>
|
||||||
|
|
||||||
<!-- Read only -->
|
<!-- Read only -->
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ th { font-weight: bold;}
|
||||||
<bpmn2:dataObject id="DataObject_1" name="Form">
|
<bpmn2:dataObject id="DataObject_1" name="Form">
|
||||||
<bpmn2:documentation id="Documentation_17"><![CDATA[<imixs-form>
|
<bpmn2:documentation id="Documentation_17"><![CDATA[<imixs-form>
|
||||||
<imixs-form-section columns="2">
|
<imixs-form-section columns="2">
|
||||||
<item name="dbtr.number" type="custom" path="alexander/businesspartner_search" required="true" label="Debtor:" />
|
<item name="dbtr.number" type="custom" path="alexander/businesspartner_search" required="true" label="Debtor:" options="rerender" />
|
||||||
</imixs-form-section>
|
</imixs-form-section>
|
||||||
|
|
||||||
<imixs-form-section columns="4" label="Invoices">
|
<imixs-form-section columns="4" label="Invoices">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue