mirror of https://github.com/logos-co/open-law.git
issue Fix rename functionality #95
This commit is contained in:
parent
802cf752e8
commit
44fd27e467
|
@ -20,6 +20,7 @@
|
||||||
"jsonify",
|
"jsonify",
|
||||||
"pydantic",
|
"pydantic",
|
||||||
"pytest",
|
"pytest",
|
||||||
|
"scrf",
|
||||||
"siwe",
|
"siwe",
|
||||||
"sqlalchemy",
|
"sqlalchemy",
|
||||||
"tailwindcss",
|
"tailwindcss",
|
||||||
|
|
|
@ -15,7 +15,7 @@ class BaseConfig(BaseSettings):
|
||||||
APP_NAME: str = "Open Law"
|
APP_NAME: str = "Open Law"
|
||||||
SECRET_KEY: str
|
SECRET_KEY: str
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
|
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
|
||||||
WTF_CSRF_ENABLED: bool = False
|
WTF_CSRF_ENABLED: bool = True
|
||||||
|
|
||||||
# Super admin
|
# Super admin
|
||||||
ADMIN_USERNAME: str
|
ADMIN_USERNAME: str
|
||||||
|
|
|
@ -9,10 +9,15 @@ export function renameCollection() {
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
const inputsForRename: NodeListOf<HTMLInputElement> =
|
const inputsForRename: NodeListOf<HTMLInputElement> =
|
||||||
document.querySelectorAll(`[id^="edit-collection-label-"]`);
|
document.querySelectorAll(`[id^="edit-collection-label-"]`);
|
||||||
|
const scrfInput: HTMLInputElement =
|
||||||
|
document.querySelector('#csrf_token');
|
||||||
inputsForRename[index].removeAttribute('readonly');
|
inputsForRename[index].removeAttribute('readonly');
|
||||||
const oldName = inputsForRename[index].value;
|
const oldName = inputsForRename[index].value;
|
||||||
inputsForRename[index].value = '';
|
inputsForRename[index].value = oldName;
|
||||||
inputsForRename[index].focus();
|
inputsForRename[index].focus();
|
||||||
|
inputsForRename[index].selectionStart = inputsForRename[
|
||||||
|
index
|
||||||
|
].selectionEnd = 257;
|
||||||
inputsForRename[index].addEventListener('blur', () => {
|
inputsForRename[index].addEventListener('blur', () => {
|
||||||
inputsForRename[index].value = oldName;
|
inputsForRename[index].value = oldName;
|
||||||
});
|
});
|
||||||
|
@ -35,6 +40,7 @@ export function renameCollection() {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
label: newLabel,
|
label: newLabel,
|
||||||
|
csrf_token: scrfInput.value,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
|
|
|
@ -4,18 +4,26 @@ export function renameSection() {
|
||||||
);
|
);
|
||||||
const sectionRenameForms: NodeListOf<HTMLFormElement> =
|
const sectionRenameForms: NodeListOf<HTMLFormElement> =
|
||||||
document.querySelectorAll('[id^="rename-section-label-form-"]');
|
document.querySelectorAll('[id^="rename-section-label-form-"]');
|
||||||
|
|
||||||
if (renameSectionBtns.length > 0 && sectionRenameForms.length > 0) {
|
if (renameSectionBtns.length > 0 && sectionRenameForms.length > 0) {
|
||||||
renameSectionBtns.forEach((btn, index) => {
|
renameSectionBtns.forEach((btn, index) => {
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
const inputsForRename: NodeListOf<HTMLInputElement> =
|
const inputsForRename: NodeListOf<HTMLInputElement> =
|
||||||
document.querySelectorAll(`[id^="edit-section-label-"]`);
|
document.querySelectorAll(`[id^="edit-section-label-"]`);
|
||||||
|
const scrfInput: HTMLInputElement =
|
||||||
|
document.querySelector('#csrf_token');
|
||||||
|
console.log(scrfInput.value);
|
||||||
const oldName = inputsForRename[index].value;
|
const oldName = inputsForRename[index].value;
|
||||||
inputsForRename[index].removeAttribute('readonly');
|
inputsForRename[index].removeAttribute('readonly');
|
||||||
inputsForRename[index].value = '';
|
inputsForRename[index].value = oldName;
|
||||||
inputsForRename[index].focus();
|
inputsForRename[index].focus();
|
||||||
|
inputsForRename[index].selectionStart = inputsForRename[
|
||||||
|
index
|
||||||
|
].selectionEnd = 257;
|
||||||
inputsForRename[index].addEventListener('blur', () => {
|
inputsForRename[index].addEventListener('blur', () => {
|
||||||
inputsForRename[index].value = oldName;
|
inputsForRename[index].value = oldName;
|
||||||
});
|
});
|
||||||
|
console.log(sectionRenameForms[index]);
|
||||||
sectionRenameForms[index].addEventListener('submit', async e => {
|
sectionRenameForms[index].addEventListener('submit', async e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const bookId = sectionRenameForms[index].getAttribute('data-book-id');
|
const bookId = sectionRenameForms[index].getAttribute('data-book-id');
|
||||||
|
@ -36,6 +44,7 @@ export function renameSection() {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
label: newLabel,
|
label: newLabel,
|
||||||
section_id: sectionId,
|
section_id: sectionId,
|
||||||
|
csrf_token: scrfInput.value,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
|
|
|
@ -12,10 +12,15 @@ export function renameSubCollection() {
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
const inputsForRename: NodeListOf<HTMLInputElement> =
|
const inputsForRename: NodeListOf<HTMLInputElement> =
|
||||||
document.querySelectorAll(`[id^="edit-sub-collection-label-"]`);
|
document.querySelectorAll(`[id^="edit-sub-collection-label-"]`);
|
||||||
|
const scrfInput: HTMLInputElement =
|
||||||
|
document.querySelector('#csrf_token');
|
||||||
const oldName = inputsForRename[index].value;
|
const oldName = inputsForRename[index].value;
|
||||||
inputsForRename[index].removeAttribute('readonly');
|
inputsForRename[index].removeAttribute('readonly');
|
||||||
inputsForRename[index].value = '';
|
inputsForRename[index].value = oldName;
|
||||||
inputsForRename[index].focus();
|
inputsForRename[index].focus();
|
||||||
|
inputsForRename[index].selectionStart = inputsForRename[
|
||||||
|
index
|
||||||
|
].selectionEnd = 257;
|
||||||
inputsForRename[index].addEventListener('blur', () => {
|
inputsForRename[index].addEventListener('blur', () => {
|
||||||
inputsForRename[index].value = oldName;
|
inputsForRename[index].value = oldName;
|
||||||
});
|
});
|
||||||
|
@ -39,6 +44,7 @@ export function renameSubCollection() {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
label: newLabel,
|
label: newLabel,
|
||||||
|
csrf_token: scrfInput.value,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (response.status == 200) {
|
if (response.status == 200) {
|
||||||
|
|
Loading…
Reference in New Issue