mirror of
https://github.com/logos-co/open-law.git
synced 2025-01-09 14:25:58 +00:00
done
This commit is contained in:
parent
42137ca8d7
commit
396b4d3c23
File diff suppressed because one or more lines are too long
22
app/templates/book/modals/delete_contributor_modal.html
Normal file
22
app/templates/book/modals/delete_contributor_modal.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!-- prettier-ignore-->
|
||||
<div id="delete_contributor_modal" tabindex="-1" aria-hidden="true" class="fixed top-0 left-0 right-0 z-[150] hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-2xl max-h-full">
|
||||
<!-- Modal content -->
|
||||
<form action="{{ url_for('book.delete_contributor', book_id=book.id) }}" id="delete_contributor_modal_form" method="post" class="relative bg-white rounded-lg shadow dark:bg-gray-700">
|
||||
{{ form_hidden_tag() }}
|
||||
<!-- Modal header -->
|
||||
<div class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600">
|
||||
<h3 class="text-xl font-semibold text-gray-900 dark:text-white"> Are you sure you want to delete this contributor? </h3>
|
||||
<button id="modalDeleteContributorCloseButton" data-modal-hide="delete_contributor_modal" type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white"> <svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg> </button>
|
||||
</div>
|
||||
<!-- Modal body -->
|
||||
<input type="hidden" name="user_id" id="delete_contributor_modal_user_id" value="" />
|
||||
|
||||
<!-- Modal footer -->
|
||||
<div class="flex flex-col items-start p-6 border-t border-gray-200 rounded-b dark:border-gray-600">
|
||||
<button id="modalDeleteContributorCloseButton" data-modal-hide="delete_contributor_modal" type="button" class="text-white mb-2 bg-red-700 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-800">No, cancel</button>
|
||||
<button name="submit" type="submit" class="text-white mb-2 bg-red-700 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-800">Yes, delete contributor</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -9,6 +9,7 @@
|
||||
{% include 'book/modals/access_level_modal.html' %}
|
||||
{% include 'book/modals/add_contributor_modal.html' %}
|
||||
{% include 'book/modals/delete_book_modal.html' %}
|
||||
{% include 'book/modals/delete_contributor_modal.html' %}
|
||||
|
||||
<!-- Hide right_sidebar -->
|
||||
<!-- prettier-ignore -->
|
||||
@ -146,13 +147,9 @@
|
||||
<td class="px-6 py-4">
|
||||
<!-- prettier-ignore -->
|
||||
{% if current_user.id != contributor.user_id %}
|
||||
<form class="mb-0 flex justify-end" action="{{ url_for('book.delete_contributor', book_id=book.id) }}" method="post">
|
||||
{{ form_hidden_tag() }}
|
||||
<input type="hidden" name="user_id" id="user_id" value="{{ contributor.user_id }}" />
|
||||
<button type="submit" class="text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 font-sm rounded-lg text-sm px-5 py-1.5 dark:bg-red-600 dark:hover:bg-red-700 focus:outline-none dark:focus:ring-red-800">
|
||||
<button type="button" id="callDeleteContributorModal" data-user-id="{{contributor.user.id}}" data-modal-target="delete_contributor_modal" data-modal-toggle="delete_contributor_modal" class="text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 font-sm rounded-lg text-sm px-5 py-1.5 dark:bg-red-600 dark:hover:bg-red-700 focus:outline-none dark:focus:ring-red-800">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -130,7 +130,7 @@ def delete_contributor(book_id: int):
|
||||
flash("Success!", "success")
|
||||
return redirect(url_for("book.settings", book_id=book_id))
|
||||
else:
|
||||
log(log.ERROR, "Book create errors: [%s]", form.errors)
|
||||
log(log.ERROR, "Delete contributor errors: [%s]", form.errors)
|
||||
for field, errors in form.errors.items():
|
||||
field_label = form._fields[field].label.text
|
||||
for error in errors:
|
||||
@ -195,7 +195,7 @@ def edit_contributor_role(book_id: int):
|
||||
flash("Success!", "success")
|
||||
return redirect(url_for("book.settings", book_id=book_id))
|
||||
else:
|
||||
log(log.ERROR, "Book create errors: [%s]", form.errors)
|
||||
log(log.ERROR, "Edit contributor errors: [%s]", form.errors)
|
||||
for field, errors in form.errors.items():
|
||||
field_label = form._fields[field].label.text
|
||||
for error in errors:
|
||||
|
@ -34,7 +34,6 @@ export function addSection() {
|
||||
);
|
||||
}
|
||||
if (newActionPath.includes('/0')) {
|
||||
console.log('ALERT');
|
||||
return;
|
||||
}
|
||||
|
||||
|
54
src/deleteContributor.ts
Normal file
54
src/deleteContributor.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import {Modal} from 'flowbite';
|
||||
import type {ModalOptions, ModalInterface} from 'flowbite';
|
||||
export function deleteContributor() {
|
||||
const deleteContributorModal: HTMLElement = document.querySelector(
|
||||
'#delete_contributor_modal',
|
||||
);
|
||||
|
||||
const deleteContributorModalBtns = document.querySelectorAll(
|
||||
'#callDeleteContributorModal',
|
||||
);
|
||||
const userIdInDeleteContributorModal: HTMLInputElement =
|
||||
document.querySelector('#delete_contributor_modal_user_id');
|
||||
|
||||
const deleteContributorForm: HTMLFormElement = document.querySelector(
|
||||
'#delete_contributor_modal_form',
|
||||
);
|
||||
|
||||
if (
|
||||
deleteContributorModal &&
|
||||
deleteContributorModalBtns &&
|
||||
userIdInDeleteContributorModal &&
|
||||
deleteContributorForm
|
||||
) {
|
||||
const deleteModalCloseBtn = document.querySelector(
|
||||
'#modalDeleteContributorCloseButton',
|
||||
);
|
||||
if (deleteModalCloseBtn) {
|
||||
deleteModalCloseBtn.addEventListener('click', () => {
|
||||
contributorDeleteModal.hide();
|
||||
});
|
||||
}
|
||||
deleteContributorModalBtns.forEach(btn =>
|
||||
btn.addEventListener('click', () => {
|
||||
const userId = btn.getAttribute('data-user-id');
|
||||
userIdInDeleteContributorModal.value = userId;
|
||||
contributorDeleteModal.show();
|
||||
}),
|
||||
);
|
||||
const modalOptions: ModalOptions = {
|
||||
placement: 'bottom-right',
|
||||
closable: true,
|
||||
onHide: () => {
|
||||
deleteContributorForm.setAttribute('action', '');
|
||||
},
|
||||
onShow: () => {},
|
||||
onToggle: () => {},
|
||||
};
|
||||
|
||||
const contributorDeleteModal: ModalInterface = new Modal(
|
||||
deleteContributorModal,
|
||||
modalOptions,
|
||||
);
|
||||
}
|
||||
}
|
@ -42,7 +42,6 @@ export function deleteInterpretation() {
|
||||
'0/delete_interpretation',
|
||||
`${interpretationId}/delete_interpretation`,
|
||||
);
|
||||
console.log(defaultActionPath);
|
||||
|
||||
deleteInterpretationForm.setAttribute('action', `${newActionPath}`);
|
||||
interpretationDeleteModal.show();
|
||||
|
@ -32,6 +32,7 @@ import {editInterpretations} from './editInterpretations';
|
||||
import {deleteInterpretation} from './deleteInterpretation';
|
||||
import {indeterminateInputs} from './indeterminateInputs';
|
||||
import {initRefreshAccessLevelTree} from './refreshAccessLevelTree';
|
||||
import {deleteContributor} from './deleteContributor';
|
||||
|
||||
initQuillReadOnly();
|
||||
initBooks();
|
||||
@ -67,3 +68,4 @@ editInterpretations();
|
||||
deleteInterpretation();
|
||||
indeterminateInputs();
|
||||
initRefreshAccessLevelTree();
|
||||
deleteContributor();
|
||||
|
@ -22,7 +22,6 @@ export function renameSection() {
|
||||
inputsForRename[index].addEventListener('blur', () => {
|
||||
inputsForRename[index].value = oldName;
|
||||
});
|
||||
console.log(sectionRenameForms[index]);
|
||||
sectionRenameForms[index].addEventListener('submit', async e => {
|
||||
e.preventDefault();
|
||||
const bookId = sectionRenameForms[index].getAttribute('data-book-id');
|
||||
|
Loading…
x
Reference in New Issue
Block a user