93 lines
3.1 KiB
JavaScript
93 lines
3.1 KiB
JavaScript
function changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, checkBoxIdSuffix) {
|
|
try {
|
|
if (url === undefined || url === null) {
|
|
return;
|
|
}
|
|
|
|
var oidStr = "";
|
|
|
|
$("#" + popupId + " input:checked").each(function() {
|
|
var id = $(this).attr("id").split("-")[1];
|
|
oidStr += id + ",";
|
|
});
|
|
|
|
$.get(url, { oidString: oidStr }).done(function (jsonResult) {
|
|
updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url);
|
|
});
|
|
} catch(error) {
|
|
logError(error.message);
|
|
}
|
|
}
|
|
|
|
// Col-Value berechnen
|
|
function updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url) {
|
|
try {
|
|
if(isEmptyOrSpaces(jsonResult)) {
|
|
return;
|
|
}
|
|
|
|
var listItems = $.parseJSON(jsonResult);
|
|
|
|
var list = $("#" + listId);
|
|
list.empty();
|
|
|
|
var colorClass = "text-bewo-employee";
|
|
|
|
if(isCustomer === true) {
|
|
colorClass = "text-bewo-customers";
|
|
}
|
|
|
|
$.each(listItems, function (index, item) {
|
|
var oid;
|
|
|
|
if(isCustomer === true) {
|
|
oid = item.CustomerOid;
|
|
} else {
|
|
oid = item.EmployeeOid;
|
|
}
|
|
|
|
var id = itemIdPrefix + oid;
|
|
|
|
var removeParams = oid + ", '" + checkBoxIdSuffix + "', " + isCustomer + ", '" + url + "', '" + popupId + "', '" + listId + "', '" + itemIdPrefix + "'";
|
|
|
|
var html =
|
|
"<div class=\"list-group-item my-auto\" id=\"" + id + "\">" +
|
|
"<div class=\"row\">" +
|
|
"<div class=\"input-group\">" +
|
|
"<div class=\"input-group-prepend\">" +
|
|
"<i class='fas fa-user " + colorClass + " h-100'></i>" +
|
|
"</div>" +
|
|
"<p class=\"form-control border-0 bg-transparent text-truncate\">" +
|
|
item.LastName + ", " + item.FirstName +
|
|
"</p>" +
|
|
"<div class=\"input-group-append\">" +
|
|
'<button class="btn btn-primary ficken" type="button" onclick="removeSelectedItem(' + removeParams + ')">' +
|
|
"<span class='fas fa-times-circle'></span>" +
|
|
"</button>" +
|
|
"</div>" +
|
|
"</div>" +
|
|
"</div>" +
|
|
"</div>";
|
|
|
|
list.append(html);
|
|
});
|
|
} catch(error) {
|
|
logError(error.message);
|
|
}
|
|
}
|
|
|
|
function removeSelectedItem(itemOid, itemSuffix, isCustomer, url, popupId, listId, itemIdPrefix) {
|
|
try {
|
|
var prefix = isCustomer ? "customer-" : "employee-";
|
|
|
|
var checkBox = $("#" + prefix + itemOid + itemSuffix).remove();
|
|
|
|
if(checkBox.length) {
|
|
checkBox.prop("checked", false);
|
|
}
|
|
|
|
changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, itemSuffix);
|
|
} catch(error) {
|
|
logError(error);
|
|
}
|
|
} |