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:" />
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```java
|
||||
|
|
@ -74,3 +87,11 @@ K76233 HSH Papier GmbH & Co. KG
|
|||
D16233 Manfred Ziegler Transport GmbH
|
||||
|
||||
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.exceptions.QueryException;
|
||||
import org.imixs.workflow.faces.data.WorkflowController;
|
||||
import org.imixs.workflow.office.forms.AnalyticController;
|
||||
import org.imixs.workflow.office.forms.AnalyticEvent;
|
||||
|
||||
import jakarta.enterprise.context.ConversationScoped;
|
||||
|
|
@ -44,7 +43,7 @@ import jakarta.inject.Named;
|
|||
public class AGLAnalyticControllerDebitor implements Serializable {
|
||||
|
||||
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
|
||||
protected DocumentService documentService;
|
||||
|
|
@ -92,7 +91,7 @@ public class AGLAnalyticControllerDebitor implements Serializable {
|
|||
}
|
||||
|
||||
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");
|
||||
|
||||
// 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" />
|
||||
* }
|
||||
*/
|
||||
public void search(String regexPattern) {
|
||||
public void search(String options) {
|
||||
List<ItemCollection> resultList = null;
|
||||
searchResult = new ArrayList<BusinessPartnerSearchEntry>();
|
||||
// get the param from faces context....
|
||||
|
|
@ -128,11 +128,12 @@ public class BusinessPartnerController implements Serializable {
|
|||
return;
|
||||
}
|
||||
logger.fine("search for=" + phrase);
|
||||
resultList = businessPartnerService.search(phrase);
|
||||
// Compile the regex pattern
|
||||
logger.fine("regex=" + regexPattern);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
* Eintrag
|
||||
|
|
@ -314,7 +329,7 @@ public class BusinessPartnerController implements Serializable {
|
|||
public void updateMetaData() {
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String bpid = fc.getExternalContext().getRequestParameterMap().get("partnerID");
|
||||
logger.fine(".........bpid = " + bpid);
|
||||
logger.info("....update metadata.....bpid = " + bpid);
|
||||
ItemCollection businessPartner = businessPartnerService.getBusinessPartnerByID(bpid);
|
||||
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"
|
||||
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: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>
|
||||
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 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: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">
|
||||
|
||||
|
||||
<!-- the following code computes the txtworkflow abstract from the current modelversion and processid -->
|
||||
<ui:param name="instruction"
|
||||
value="#{modelController.getProcessDescription(workflowController.workitem.item['$taskid'],workflowController.workitem.item['$ModelVersion'],workflowController.workitem)}"></ui:param>
|
||||
<h:panelGroup layout="block" styleClass="imixs-instruction"
|
||||
rendered="#{! empty instruction}">
|
||||
value="#{modelController.getProcessDescription(workflowController.workitem.item['$taskid'],workflowController.workitem.item['$ModelVersion'],workflowController.workitem)}">
|
||||
</ui:param>
|
||||
<h:panelGroup layout="block" styleClass="imixs-instruction" rendered="#{! empty instruction}">
|
||||
<h:outputText escape="false" value="#{instruction}" />
|
||||
</h:panelGroup>
|
||||
|
||||
|
|
@ -36,8 +22,7 @@
|
|||
|
||||
|
||||
<!-- sub forms (optional) -->
|
||||
<c:forEach items="#{formController.formDefinition.sections}"
|
||||
var="section">
|
||||
<c:forEach items="#{formController.formDefinition.sections}" var="section">
|
||||
<div class="imixs-form-panel">
|
||||
<h3>
|
||||
<h:outputText value="#{section.name}" />
|
||||
|
|
|
|||
|
|
@ -5,36 +5,35 @@
|
|||
|
||||
<!-- businsspartner Search integration
|
||||
|
||||
This subform is a custom form part for the items 'item.id' and 'item.name'
|
||||
This subform provides a search feature for business partners and
|
||||
automatically updates partner.id and partner.name
|
||||
|
||||
The subform provides a jsf commandScript which calls the businessPartnerController.search method in the backend.
|
||||
When 'options=rerender' the full form will be refreshed after selection. This is usefull for DebitorAanaylye
|
||||
|
||||
The script below inits a autocompletion feature for the input field.
|
||||
See imixs-office.autocompletion.js
|
||||
Optional the options can also include a regex pattern
|
||||
|
||||
See also:
|
||||
https://stackoverflow.com/questions/16588327/how-to-invoke-a-jsf-managed-bean-on-a-html-dom-event-using-native-javascript
|
||||
https://dzone.com/articles/execute-a-jsf-ajax-request-by-just-a-function-call
|
||||
https://www.w3schools.com/howto/howto_js_autocomplete.asp
|
||||
options=rerender;regexPattern=(...)
|
||||
-->
|
||||
|
||||
|
||||
<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:inputHidden value="#{workitem.item['partner.name']}" pt:data-item="partner.name" />
|
||||
<br />
|
||||
<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">
|
||||
/*<![CDATA[*/
|
||||
|
||||
// init input fields...
|
||||
$(document).ready(function () {
|
||||
//initBPSearch();
|
||||
// add autocomplete feature ..
|
||||
var creditorField = $("input[data-item='partner.id']");
|
||||
$(creditorField).each(function () {
|
||||
|
|
@ -64,10 +63,22 @@
|
|||
}
|
||||
|
||||
function handleUpdateEvent(data) {
|
||||
console.log('bin in handleUpdaetEvent');
|
||||
if (typeof ajaxUpdateInvoiceSelection === 'function') {
|
||||
console.log('und wir haben die fuktion');
|
||||
ajaxUpdateInvoiceSelection(data);
|
||||
var $body = $("body");
|
||||
if (data.status === 'begin') {
|
||||
// show ajax loader...
|
||||
$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>
|
||||
</ui:repeat>
|
||||
</h:panelGroup>
|
||||
|
||||
</ui:fragment>
|
||||
|
||||
<!-- Read only -->
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ th { font-weight: bold;}
|
|||
<bpmn2:dataObject id="DataObject_1" name="Form">
|
||||
<bpmn2:documentation id="Documentation_17"><![CDATA[<imixs-form>
|
||||
<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 columns="4" label="Invoices">
|
||||
|
|
|
|||
Loading…
Reference in a new issue