-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from ferishili/issue-351-confirmation
Proposal: (delete block) removing seriesmapping with confirmation
- Loading branch information
Showing
8 changed files
with
206 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Javascript to add a custom block_delete handler | ||
* | ||
* @module block_opencast/block_delete_handler | ||
* @copyright 2024 Justus Dieckmann, University of Münster | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
import ModalFactory from 'core/modal_factory'; | ||
import Ajax from 'core/ajax'; | ||
import Templates from 'core/templates'; | ||
import Prefetch from "core/prefetch"; | ||
import {get_string} from 'core/str'; | ||
import Notification from "core/notification"; | ||
|
||
export const init = (contextid, deleteurl) => { | ||
Prefetch.prefetchTemplate('block_opencast/delete_block_modal'); | ||
Prefetch.prefetchString('block_opencast', 'deletecheck_title_modal'); | ||
const deleteButton = document.querySelector('.block_opencast a.dropdown-item.block_opencast_delete'); | ||
deleteButton.onclick = async(e) => { | ||
e.preventDefault(); | ||
|
||
const html = await Templates.render('block_opencast/delete_block_modal', { | ||
deleteblockurl: deleteurl | ||
}); | ||
|
||
const modal = await ModalFactory.create({ | ||
type: ModalFactory.types.CANCEL, | ||
body: html, | ||
title: await get_string('deletecheck_title_modal', 'block_opencast'), | ||
large: true | ||
}); | ||
await modal.show(); | ||
modal.body[0].querySelector('.block_opencast-delete-mapping').onclick = async() => { | ||
try { | ||
await Ajax.call([{ | ||
methodname: 'block_opencast_unlink_series', | ||
args: {contextid: contextid, ocinstanceid: -1, seriesid: 'all'} | ||
}])[0]; | ||
window.location = deleteurl; | ||
} catch (e) { | ||
Notification.exception(e); | ||
} | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{! | ||
This file is part of Moodle - http://moodle.org/ | ||
Moodle is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Moodle is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template block_opencast/delete_block_modal | ||
This template renders the delete modal | ||
Example context (json): | ||
{ | ||
"deleteblockurl": "https://moodle.local/blocks/opencast/managedefaults.php?courseid=3&ocinstanceid=1" | ||
} | ||
}} | ||
{{#str}} delete_mapping_explanation, block_opencast {{/str}} | ||
<div class="d-flex justify-content-end mt-3"> | ||
<div class="btn btn-primary mx-1 block_opencast-delete-mapping"> | ||
{{#str}} delete_block_and_mapping, block_opencast {{/str}} | ||
</div> | ||
<a class='btn btn-primary mx-1 block_opencast-keep-mapping' href="{{{deleteblockurl}}}"> | ||
{{#str}} only_delete_block, block_opencast {{/str}} | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters