From 683d45a8376570f2a872fdaf2ece264f7c5cacf3 Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Fri, 4 Jun 2021 16:44:59 +0200 Subject: [PATCH] H5P-3065 Allow to delete library if circular dependency --- js/h5p-library-list.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index 344b736..534a9f7 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -60,6 +60,9 @@ var H5PLibraryList = H5PLibraryList || {}; H5PLibraryList.addRestricted($('.h5p-admin-restricted', $libraryRow), library.restrictedUrl, library.restricted); 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) { $('.h5p-admin-upgrade-library', $libraryRow).remove(); } @@ -78,12 +81,13 @@ var H5PLibraryList = H5PLibraryList || {}; }); var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); - if (libraries.notCached !== undefined || - hasContent || - (library.numContentDependencies !== '' && - library.numContentDependencies !== 0) || - (library.numLibraryDependencies !== '' && - library.numLibraryDependencies !== 0)) { + if ( + libraries.notCached !== undefined || + hasContent || + hasContentDependencies || + hasLibraryDependencies && + !(library.hasCircularEditorDepencendy && library.numLibraryDependencies === 1) + ) { // Disabled delete if content. $deleteButton.attr('disabled', true); }