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 = "
" + "
" + "
" + "
" + "" + "
" + "

" + customListItem.Name + "

" + "

" + "" + "
" + "
" + "
" + "
"; 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); } }