1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-29 10:09:42 +02:00

Fix sorting in dropdown (#187)

* fix: fix order of page categories with raw type

* refactor: change method location and others

* refactor: fix method names and variables also split methods to be clear their role

* fix: fix variable name

* fix: change the method to group of pages

* refactor: replace filter metethod to querying database

* refactor: fix typo, rename variable, add comments, improve code quality

* fix: add exit infinite loop

* fix: replace exiting loop to throwing exception
This commit is contained in:
YeoKyung Yoon 2022-06-22 07:09:08 -07:00 committed by GitHub
parent 30d96909d3
commit b3d8a1bfd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 191 additions and 5 deletions

View file

@ -11,10 +11,10 @@ const router = express.Router();
*/
router.get('/page/new', verifyToken, allowEdit, async (req: Request, res: Response, next: NextFunction) => {
try {
const pagesAvailable = await Pages.getAll();
const pagesAvailableGrouped = await Pages.groupByParent();
res.render('pages/form', {
pagesAvailable,
pagesAvailableGrouped,
page: null,
});
} catch (error) {
@ -32,6 +32,7 @@ router.get('/page/edit/:id', verifyToken, allowEdit, async (req: Request, res: R
try {
const page = await Pages.get(pageId);
const pagesAvailable = await Pages.getAllExceptChildren(pageId);
const pagesAvailableGrouped = await Pages.groupByParent(pageId);
if (!page._parent) {
throw new Error('Parent not found');
@ -42,7 +43,7 @@ router.get('/page/edit/:id', verifyToken, allowEdit, async (req: Request, res: R
res.render('pages/form', {
page,
parentsChildrenOrdered,
pagesAvailable,
pagesAvailableGrouped,
});
} catch (error) {
res.status(404);