Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue #396
  • Loading branch information
rsoika committed Dec 9, 2024
1 parent 4ea9d87 commit 8babd4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
35 changes: 6 additions & 29 deletions src/main/resources/META-INF/resources/marty/imixs-marty.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@ IMIXS.org.imixs.marty = (function () {

// init user input fields...
$(document).ready(function () {

// add autocomplete feature to all user inputs...
// var userInputField = $("input[data-item='marty.user.input']");
// $(userInputField).each(function () {
// console.log('---------___> Init userinput');
// imixsMarty.userInputInit(this, martyUserSearch, 'marty-userinput-resultlist'); // optional callback method allowed here!
// });

var userGroupInputField = $("textarea[data-item='marty.user.input']");
$(userGroupInputField).each(function () {
imixsMarty.userInputInit(this, martyUserSearch, 'marty-userinput-resultlist'); // optional callback method allowed here!
});


});






/*
* initializes an input element for autocompletion.
* the param 'resultlistid' is optional and defines the element
Expand All @@ -48,12 +35,10 @@ IMIXS.org.imixs.marty = (function () {
* from the suggest list
*/
var userInputInit = function (inputElement, searchCallback, resultlistId, selectCallback) {

// should be hidden
$(inputElement).hide();
hideResultList(inputElement);
autocompleteSearchReady = false;

// set id for result list element
if (!resultlistId || resultlistId === '') {
resultlistId = 'autocomplete-resultlist'; // default name
Expand Down Expand Up @@ -147,7 +132,12 @@ IMIXS.org.imixs.marty = (function () {
var id = $(inputElement).data('resultlist');
var parent = $("[id$='" + id + "']");
var resultElementListActive = $(".marty-userinput-resultlist-element.active", parent);
$("a", resultElementListActive).click();
if (resultElementListActive.length > 0) {
$("a", resultElementListActive).click();
} else {
// special use case overtake current input
selectUserID($(inputElement).val(), $(inputElement).val());
}
hideResultList(inputElement);
},

Expand Down Expand Up @@ -197,10 +187,6 @@ IMIXS.org.imixs.marty = (function () {
$(resultElementList[autcompleteSelectedElement]).addClass("active");
},





selectUserID = function (userid, username) {
// find the value field and the search field
var inputSearchField = $('input[name ="' + autocompleteInputID + '"]');
Expand Down Expand Up @@ -247,10 +233,8 @@ IMIXS.org.imixs.marty = (function () {
// clear input
inputSearchField.val('');
}

},


/* Deletes a given user id form a usergroup list */
deleteUserID = function (link) {
// find the value field based on the given link.
Expand Down Expand Up @@ -283,14 +267,9 @@ IMIXS.org.imixs.marty = (function () {
inputField.val(newValue);
// trigger on change event
inputField.trigger('change');

}


},



/*
* delay function
* see: https://stackoverflow.com/questions/1909441/how-to-delay-the-keyup-handler-until-the-user-stops-typing
Expand Down Expand Up @@ -320,5 +299,3 @@ IMIXS.org.imixs.marty = (function () {

// Define public namespace
var imixsMarty = IMIXS.org.imixs.marty;


Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<h:commandScript name="martyUserSearch" action="#{userInputController.searchUser()}"
render="marty-userinput-resultlist" onevent="imixsMarty.userSearchShowResult" />
<span id="marty-userinput-resultlist-defaultpos">default pos</span>
<span id="marty-userinput-resultlist-defaultpos"></span>
<h:panelGroup id="marty-userinput-resultlist" layout="block" class="marty-userinput-resultlist">
<ui:param name="suggestList" value="#{userInputController.searchResult}"></ui:param>
<ui:fragment rendered="#{! empty suggestList}">
Expand Down

0 comments on commit 8babd4e

Please sign in to comment.