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:
parent
30d96909d3
commit
b3d8a1bfd4
6 changed files with 191 additions and 5 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue