urls and files: hide custom slug field when generating automatically
This commit is contained in:
parent
1e00834324
commit
33947012e4
@ -14,16 +14,38 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const autogenUrlCheckbox = document.querySelector<HTMLInputElement>('#field-autogen_url');
|
const autogenUrlCheckbox = document.querySelector<HTMLInputElement>('#field-autogen_url');
|
||||||
const slugField = document.querySelector<HTMLInputElement>('#field-slug');
|
const slugField = document.querySelector<HTMLInputElement>('#field-slug');
|
||||||
|
|
||||||
if (expireAfterDaysField) {
|
if (expireAfterDaysField && neverExpireCheckbox) {
|
||||||
neverExpireCheckbox?.addEventListener('change', () => {
|
const updateExpireAfterDaysField = () => {
|
||||||
expireAfterDaysField.disabled = neverExpireCheckbox.checked;
|
expireAfterDaysField.disabled = neverExpireCheckbox.checked;
|
||||||
});
|
|
||||||
|
const parent = expireAfterDaysField.parentElement?.parentElement;
|
||||||
|
if (parent) {
|
||||||
|
if (neverExpireCheckbox.checked) {
|
||||||
|
parent.classList.add('hidden');
|
||||||
|
} else {
|
||||||
|
parent.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
neverExpireCheckbox.addEventListener('change', updateExpireAfterDaysField);
|
||||||
|
updateExpireAfterDaysField();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slugField) {
|
if (slugField && autogenUrlCheckbox) {
|
||||||
autogenUrlCheckbox?.addEventListener('change', () => {
|
const updateSlugField = () => {
|
||||||
slugField.disabled = autogenUrlCheckbox.checked;
|
slugField.disabled = autogenUrlCheckbox.checked;
|
||||||
});
|
|
||||||
|
const parent = slugField.parentElement?.parentElement;
|
||||||
|
if (parent) {
|
||||||
|
if (autogenUrlCheckbox.checked) {
|
||||||
|
parent.classList.add('hidden');
|
||||||
|
} else {
|
||||||
|
parent.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
autogenUrlCheckbox.addEventListener('change', updateSlugField);
|
||||||
|
updateSlugField();
|
||||||
}
|
}
|
||||||
|
|
||||||
let uploadForm: UploadForm | undefined;
|
let uploadForm: UploadForm | undefined;
|
||||||
|
@ -5,9 +5,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const autogenUrlCheckbox = document.querySelector<HTMLInputElement>('#field-autogen_url');
|
const autogenUrlCheckbox = document.querySelector<HTMLInputElement>('#field-autogen_url');
|
||||||
const slugField = document.querySelector<HTMLInputElement>('#field-slug');
|
const slugField = document.querySelector<HTMLInputElement>('#field-slug');
|
||||||
|
|
||||||
if (slugField) {
|
if (slugField && autogenUrlCheckbox) {
|
||||||
autogenUrlCheckbox?.addEventListener('change', () => {
|
const updateSlugField = () => {
|
||||||
slugField.disabled = autogenUrlCheckbox.checked;
|
slugField.disabled = autogenUrlCheckbox.checked;
|
||||||
});
|
|
||||||
|
const parent = slugField.parentElement?.parentElement;
|
||||||
|
if (parent) {
|
||||||
|
if (autogenUrlCheckbox.checked) {
|
||||||
|
parent.classList.add('hidden');
|
||||||
|
} else {
|
||||||
|
parent.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
autogenUrlCheckbox.addEventListener('change', updateSlugField);
|
||||||
|
updateSlugField();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user