feat(life): require at least one tag for life posts
Update design spec to mandate tag selection Add frontend and backend validation for tag requirement Add localization strings for tag required errors
This commit is contained in:
@@ -218,10 +218,14 @@ function resetForm() {
|
||||
function payload() {
|
||||
return {
|
||||
body: body.value.trim(),
|
||||
tagIds: selectedTagIds.value.map((tagId) => Number(tagId)).filter((tagId) => Number.isInteger(tagId) && tagId > 0)
|
||||
tagIds: selectedLifeTagIds()
|
||||
};
|
||||
}
|
||||
|
||||
function selectedLifeTagIds() {
|
||||
return selectedTagIds.value.map((tagId) => Number(tagId)).filter((tagId) => Number.isInteger(tagId) && tagId > 0);
|
||||
}
|
||||
|
||||
function submitSearch() {
|
||||
const nextSearch = searchDraft.value.trim();
|
||||
if (nextSearch === submittedSearch.value && !loadError.value) {
|
||||
@@ -281,6 +285,12 @@ async function submitPost() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedLifeTagIds().length === 0) {
|
||||
formError.value = t('pages.life.tagRequired');
|
||||
document.getElementById('life-post-tags')?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
busy.value = true;
|
||||
formError.value = '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user