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 =
|
||||
{ order: await this.store.sort(this.path, ...cmp) }
|
||||
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(){
|
||||
// not sorting single pages...
|
||||
if(this.length <= 1){
|
||||
|
||||
@ -692,8 +692,7 @@ module.BaseStore = {
|
||||
//*/
|
||||
|
||||
// XXX EXPERIMENTAL...
|
||||
// XXX should we handle undefined attr values???
|
||||
// XXX BUG: chains still not working correctly...
|
||||
// XXX add sort order saving???
|
||||
sort: function(paths, ...by){
|
||||
var that = this
|
||||
paths =
|
||||
@ -710,7 +709,14 @@ module.BaseStore = {
|
||||
.map(function(p, i){
|
||||
var d
|
||||
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(
|
||||
(cmp == 'path'
|
||||
|| 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
|
||||
* unify them to use the same name???
|
||||
* XXX parser: error handling: revise page quoting...
|
||||
@ -74,7 +68,6 @@
|
||||
* ...likely no...
|
||||
* ...would depend on where we iterate pages and on whether
|
||||
* 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
|
||||
* methods:
|
||||
* .get(..) -- DONE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user