1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-21 22:29:40 +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

@ -75,6 +75,28 @@ class PageOrder {
return Promise.all(docs.map(doc => new PageOrder(doc)));
}
/**
* Returns only root page's order
*
* @returns {Promise<PageOrder[]>}
*/
public static async getRootPageOrder(): Promise<PageOrder> {
const docs = await db.findOne({ 'page': '0' });
return new PageOrder(docs);
}
/**
* Returns only child page's order
*
* @returns {Promise<PageOrder[]>}
*/
public static async getChildPageOrder(): Promise<PageOrder[]> {
const docs = await this.getAll({ 'page': { $ne: '0' } });
return Promise.all(docs.map(doc => new PageOrder(doc)));
}
/**
* constructor data setter
*