Das Mehrfachbuchungsformular hat ebenfalls die Schnittmenge der Leistungen und Kategorien von den ausgewählten Hilfeplänen. Das Caching ist wieder aktiviert. Und lädt pro Post-Aufruf nur noch einmal 13 MB und danach nur noch 300 kb herunter. Überall konsequent geprüft, ob das Model nicht null ist und falls dem so ist, wird ausgeloggt, damit es zu keinen Fehlern mehr kommt.
88 lines
4.0 KiB
JavaScript
88 lines
4.0 KiB
JavaScript
function changeResourceSelection(popupId, url, listId, listItemIdPrefix, checkBoxIdPrefix, filterAppointmentsUrl, selectAllCheckBoxId) {
|
|
var oidString = $("#" + popupId + " .category-card input:checked").map(function() { return $(this).prop("id").split("-")[1]; }).get().toString();
|
|
|
|
$.get(url, { resourceOids: oidString }).done(function(jsonResult) {
|
|
updateSelectedResourceList(jsonResult, listId, listItemIdPrefix, popupId, checkBoxIdPrefix, url, filterAppointmentsUrl, selectAllCheckBoxId);
|
|
|
|
var allResourcesCount = $("#" + popupId + " .category-card input[type=checkbox]").length;
|
|
var selectedResourcesCount = $("#" + popupId + " .category-card input:checked").length;
|
|
|
|
var areAllSelected = allResourcesCount === selectedResourcesCount;
|
|
|
|
if (isUndefinedOrNull(listId) === false && $("#" + listId).length) {
|
|
var listItemOidCount = $("#" + listId + " p").map(function() { return $(this).prop("id").split("-")[1]; }).get().length;
|
|
|
|
areAllSelected = listItemOidCount === allResourcesCount;
|
|
}
|
|
|
|
$("#" + selectAllCheckBoxId).prop("checked", areAllSelected);
|
|
|
|
if(popupId === "resources-popup2") {
|
|
$("#resource-count2").text(selectedResourcesCount);
|
|
}
|
|
|
|
if($("#one-day-scheduler-partial-container").length && filterAppointmentsUrl !== undefined && filterAppointmentsUrl !== null) {
|
|
|
|
$("#one-day-scheduler-partial-container").load(filterAppointmentsUrl);
|
|
}
|
|
});
|
|
}
|
|
|
|
function updateSelectedResourceList(jsonResult, listId, listItemIdPrefix, popupId, checkBoxIdPrefix, url, filterAppointmentsUrl, selectAllCheckBoxId) {
|
|
try {
|
|
var list = $("#" + listId);
|
|
|
|
list.empty();
|
|
|
|
if(false === checkJson(jsonResult)) {
|
|
logWarning("updateSelectedResourceList: Der zurückgegebene Wert ist kein gültiges JSON!");
|
|
hideSpinner();
|
|
return;
|
|
}
|
|
|
|
var resourceList = parseJason(jsonResult);
|
|
|
|
$.each(resourceList, function (index, customListItem) {
|
|
var listItemId = listItemIdPrefix + "" + customListItem.ResourceOid;
|
|
var checkBoxId = "resource-" + customListItem.ResourceOid + "" + checkBoxIdPrefix + "";
|
|
|
|
// Liste mit den ausgewählten Ressourcen
|
|
var html =
|
|
"<div class=\"list-group-item my-auto\" id=\"" + listItemId + "\">" +
|
|
"<div class=\"row\">" +
|
|
"<div class=\"input-group\">" +
|
|
"<div class=\"input-group-prepend\">" +
|
|
"<i class=\"fas fa-cubes text-bewo-resource h-100\"></i>" +
|
|
"</div>" +
|
|
"<p class=\"form-control border-0 bg-transparent text-truncate\" id=\"p-" + customListItem.ResourceOid + "\" >" + customListItem.Name + "<p>" +
|
|
"<div class=\"input-group-append\">" +
|
|
"<button class=\"btn btn-primary\" type=\"button\" onclick=\"removeSelectedResource('" + listItemId + "', '" + checkBoxId + "', '" + popupId + "', '" + url + "', '" + listId + "', '" + filterAppointmentsUrl + "', '" + listItemIdPrefix + "', '" + checkBoxIdPrefix + "', '" + selectAllCheckBoxId + "')\"><span class=\"fas fa-times-circle\"></span></button>" +
|
|
"</div>" +
|
|
"</div>" +
|
|
"</div>" +
|
|
"</div>";
|
|
|
|
list.append(html);
|
|
});
|
|
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function removeSelectedResource(listItemId, checkBoxId, popupId, url, listId, fetchAppointmentsUrl, listItemIdPrefix, checkBoxIdPrefix, selectAllCheckBoxId) {
|
|
try {
|
|
$("#" + listItemId).remove();
|
|
|
|
var checkbox = $("#" + checkBoxId);
|
|
|
|
if(checkbox.length) {
|
|
checkbox.prop("checked", false);
|
|
}
|
|
|
|
changeResourceSelection(popupId, url, listId, listItemIdPrefix, checkBoxIdPrefix, fetchAppointmentsUrl, selectAllCheckBoxId);
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|