mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
sort mostly done...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
23c3c3ad4f
commit
85b0962277
@ -563,6 +563,25 @@ object.Constructor('BasePage', {
|
|||||||
this.metadata =
|
this.metadata =
|
||||||
{ order: await this.store.sort(this.path, ...cmp) }
|
{ order: await this.store.sort(this.path, ...cmp) }
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
|
// XXX EXPERIMENTAL -- move this to store???
|
||||||
|
// .sortAs(<name>)
|
||||||
|
// .sortAs([<path>, .. ])
|
||||||
|
sortAs: async function(order){
|
||||||
|
this.metadata =
|
||||||
|
order instanceof Array ?
|
||||||
|
{ order }
|
||||||
|
: { order: (await this.metadata)['order_'+ order] }
|
||||||
|
return this },
|
||||||
|
// XXX EXPERIMENTAL -- move this to store???
|
||||||
|
// .saveSortAs(<name>)
|
||||||
|
// .saveSortAs(<name>, [<path>, .. ])
|
||||||
|
saveSortAs: async function(name, order=null){
|
||||||
|
order = order
|
||||||
|
?? (await this.metadata).order
|
||||||
|
this.metadata = {['order_'+ name]: order}
|
||||||
|
return this },
|
||||||
|
|
||||||
reverse: async function(){
|
reverse: async function(){
|
||||||
// not sorting single pages...
|
// not sorting single pages...
|
||||||
if(this.length <= 1){
|
if(this.length <= 1){
|
||||||
|
|||||||
@ -692,8 +692,7 @@ module.BaseStore = {
|
|||||||
//*/
|
//*/
|
||||||
|
|
||||||
// XXX EXPERIMENTAL...
|
// XXX EXPERIMENTAL...
|
||||||
// XXX should we handle undefined attr values???
|
// XXX add sort order saving???
|
||||||
// XXX BUG: chains still not working correctly...
|
|
||||||
sort: function(paths, ...by){
|
sort: function(paths, ...by){
|
||||||
var that = this
|
var that = this
|
||||||
paths =
|
paths =
|
||||||
@ -710,7 +709,14 @@ module.BaseStore = {
|
|||||||
.map(function(p, i){
|
.map(function(p, i){
|
||||||
var d
|
var d
|
||||||
var res = []
|
var res = []
|
||||||
for(var cmp of by){
|
// NOTE: this is the first and only instance so far where
|
||||||
|
// using let is simpler than doing this below:
|
||||||
|
// function(cmp){
|
||||||
|
// return (d = d ?? that.get(p))
|
||||||
|
// .then(function(data){
|
||||||
|
// return data[cmp] }) }.bind(this, cmp)
|
||||||
|
// ..still not sure if this is worth the special case...
|
||||||
|
for(let cmp of by){
|
||||||
res.push(
|
res.push(
|
||||||
(cmp == 'path'
|
(cmp == 'path'
|
||||||
|| cmp == 'location') ?
|
|| cmp == 'location') ?
|
||||||
|
|||||||
@ -36,12 +36,6 @@
|
|||||||
* -
|
* -
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX sort: define a generic sort path argument... DONE-ish
|
|
||||||
* XXX sort chains still not totally correct...
|
|
||||||
* This correctly shows Doc and WikiHome first
|
|
||||||
* await pwiki.store.sort('*', 'tags')
|
|
||||||
* This mixes them back up:
|
|
||||||
* await pwiki.store.sort('*', 'tags', 'ctime')
|
|
||||||
* XXX macros: else/default macro args essentially mean the same thing, should we
|
* XXX macros: else/default macro args essentially mean the same thing, should we
|
||||||
* unify them to use the same name???
|
* unify them to use the same name???
|
||||||
* XXX parser: error handling: revise page quoting...
|
* XXX parser: error handling: revise page quoting...
|
||||||
@ -74,7 +68,6 @@
|
|||||||
* ...likely no...
|
* ...likely no...
|
||||||
* ...would depend on where we iterate pages and on whether
|
* ...would depend on where we iterate pages and on whether
|
||||||
* we can/should reach that spot from within the parser...
|
* we can/should reach that spot from within the parser...
|
||||||
* XXX ASAP revise/update sort...
|
|
||||||
* XXX ASAP: MetaStore: need to correctly integrate the following store
|
* XXX ASAP: MetaStore: need to correctly integrate the following store
|
||||||
* methods:
|
* methods:
|
||||||
* .get(..) -- DONE
|
* .get(..) -- DONE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user