Skip to content

Commit fdb96f0

Browse files
committed
refactor(tags): reduce tags if they're empty
1 parent c63a492 commit fdb96f0

File tree

12 files changed

+29
-20
lines changed

12 files changed

+29
-20
lines changed

src/journey/admin/anime/post_edit_anime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const postEditAnime = async (req, res, next) => {
2626
try {
2727
await animeHandlerInstance.editAnime(
2828
req.params.animeId, req.body[ 'show-review' ],
29-
req.body[ 'show-tags' ].split(/, ?/u),
29+
req.body[ 'show-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3030
);
3131
res.redirect(303, `/admin/anime/${req.params.animeId}`, next);
3232
} catch (e) {

src/journey/admin/art/create_new_art_piece.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const postNewArtPiece = async (req, res, next) => {
3131
const imageAsBase64 = fs.readFileSync(req.files[ 'art-image' ].path, 'base64');
3232
const savedArt = await artHandlerInstance.addNewArtItem(
3333
req.body[ 'art-title' ], req.body[ 'art-completed-date' ],
34-
imageAsBase64, req.body[ 'art-tags' ].split(/, ?/u),
34+
imageAsBase64,
35+
req.body[ 'art-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3536
req.body[ 'art-notes' ],
3637
);
3738
res.redirect(303, `/admin/art/${savedArt._id}`, next);

src/journey/admin/art/edit_art_piece.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const submitEditedArtPiece = async (req, res, next) => {
2828
await artHandlerInstance.updateExistingArtPiece(
2929
req.params.artId, req.body[ 'art-title' ],
3030
req.body[ 'art-completed-date' ], req.files[ 'art-image' ],
31-
req.body[ 'art-tags' ].split(/, ?/u), req.body[ 'art-notes' ],
31+
req.body[ 'art-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
32+
req.body[ 'art-notes' ],
3233
);
3334
res.redirect(303, `/admin/art/${req.params.artId}`, next);
3435
} catch (e) {

src/journey/admin/blog/create_new_blog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const postNewBlog = async (req, res, next) => {
2727
try {
2828
const savedBlog = await blogHandlerInstance.insertBlog(
2929
req.body[ 'blog-title' ], req.body[ 'blog-text' ],
30-
req.body[ 'blog-visible' ] === 'Y', req.body[ 'blog-tags' ].split(/, ?/u)
30+
req.body[ 'blog-visible' ] === 'Y',
31+
req.body[ 'blog-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3132
);
3233
res.redirect(303, `/admin/blog/${savedBlog._id}`, next);
3334
next();

src/journey/admin/blog/edit_one_blog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const postEditDetails = async (req, res, next) => {
2828
await blogHandlerInstance.editBlog(
2929
req.params.blogId, req.body[ 'blog-title' ],
3030
req.body[ 'blog-text' ], req.body[ 'blog-visible' ] === 'Y',
31-
req.body[ 'blog-tags' ].split(/, ?/u)
31+
req.body[ 'blog-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3232
);
3333
res.redirect(303, `/admin/blog/${req.params.blogId}`, next);
3434
} catch (e) {

src/journey/admin/chapters/create_new_chapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ const createNewChapter = async (req, res, next) => {
3333
const uploadedChapter = await chapterHandlerInstance.addNewChapter(
3434
req.params.storyId, req.body[ 'chapter-number' ],
3535
req.body[ 'chapter-title' ], req.body[ 'chapter-text' ],
36-
req.body[ 'chapter-comments' ]
36+
req.body[ 'chapter-comments' ],
3737
);
3838
await storyHandlerInstance.addChapterToStory(
3939
req.params.storyId, uploadedChapter.chapter_number,
40-
uploadedChapter._id
40+
uploadedChapter._id,
4141
);
4242
res.redirect(303, `/admin/stories/${req.params.storyId}`, next);
4343
} catch (e) {

src/journey/admin/manga/edit_single_manga.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const editSingleManga = async (req, res, next) => {
2727
try {
2828
await mangaHandlerInstance.editManga(
2929
req.params.mangaId, req.body[ 'book-review' ],
30-
req.body[ 'book-tags' ].split(/, ?/u)
30+
req.body[ 'book-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3131
);
3232
res.redirect(303, `/admin/manga/${req.params.mangaId}`, next);
3333
} catch (e) {

src/journey/admin/projects/create_new_project.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const postNewProject = async (req, res, next) => {
2727
try {
2828
const savedProject = await projectHandlerInstance.insertProject(
2929
req.body[ 'project-title' ], req.body[ 'project-text' ],
30-
req.body[ 'project-visible' ] === 'Y', req.body[ 'project-tags' ].split(/, */u)
30+
req.body[ 'project-visible' ] === 'Y',
31+
req.body[ 'project-tags' ].split(/, */u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3132
);
3233
res.redirect(303, `/admin/projects/${savedProject._id}`, next);
3334
} catch (e) {

src/journey/admin/projects/edit_single_project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const editSingleProject = async (req, res, next) => {
2828
await projectHandlerInstance.editProject(
2929
req.params.projectId, req.body[ 'project-title' ],
3030
req.body[ 'project-text' ], req.body[ 'project-visible' ] === 'Y',
31-
req.body[ 'project-tags' ].split(/, */u)
31+
req.body[ 'project-tags' ].split(/, */u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
3232
);
3333
res.redirect(303, `/admin/projects/${req.params.projectId}`, next);
3434
} catch (e) {

src/journey/admin/stories/create_new_story.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ const createNewStory = async (req, res, next) => {
3434
}
3535
const savedStory = await storyHandlerInstance.addNewStory(
3636
req.body[ 'story-title' ], req.body[ 'story-status' ], req.body[ 'story-type' ],
37-
req.body[ 'story-synopsis' ], imageAsBase64, req.body[ 'story-tags' ].split(/, ?/u),
38-
req.body[ 'story-notes' ]
37+
req.body[ 'story-synopsis' ], imageAsBase64,
38+
req.body[ 'story-tags' ].split(/, ?/u).map((tag) => tag.trim()).filter((tag) => tag !== ''),
39+
req.body[ 'story-notes' ],
3940
);
4041
res.redirect(303, `/admin/stories/${savedStory._id}`, next);
4142
} catch (e) {

0 commit comments

Comments
 (0)