H5P-3065 Allow to delete library if circular dependency

pull/101/head
Oliver Tacke 2021-06-04 16:44:59 +02:00
parent 4599291d7c
commit 683d45a837
1 changed files with 10 additions and 6 deletions

View File

@ -60,6 +60,9 @@ var H5PLibraryList = H5PLibraryList || {};
H5PLibraryList.addRestricted($('.h5p-admin-restricted', $libraryRow), library.restrictedUrl, library.restricted); H5PLibraryList.addRestricted($('.h5p-admin-restricted', $libraryRow), library.restrictedUrl, library.restricted);
var hasContent = !(library.numContent === '' || library.numContent === 0); var hasContent = !(library.numContent === '' || library.numContent === 0);
const hasContentDependencies = (library.numContentDependencies !== '' && library.numContentDependencies !== 0);
const hasLibraryDependencies = (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0);
if (library.upgradeUrl === null) { if (library.upgradeUrl === null) {
$('.h5p-admin-upgrade-library', $libraryRow).remove(); $('.h5p-admin-upgrade-library', $libraryRow).remove();
} }
@ -78,12 +81,13 @@ var H5PLibraryList = H5PLibraryList || {};
}); });
var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); var $deleteButton = $('.h5p-admin-delete-library', $libraryRow);
if (libraries.notCached !== undefined || if (
hasContent || libraries.notCached !== undefined ||
(library.numContentDependencies !== '' && hasContent ||
library.numContentDependencies !== 0) || hasContentDependencies ||
(library.numLibraryDependencies !== '' && hasLibraryDependencies &&
library.numLibraryDependencies !== 0)) { !(library.hasCircularEditorDepencendy && library.numLibraryDependencies === 1)
) {
// Disabled delete if content. // Disabled delete if content.
$deleteButton.attr('disabled', true); $deleteButton.attr('disabled', true);
} }