mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-31 19:10:08 +00:00
now page's .move(..)/.copy(..)/.delete(..) support pattern paths -- still needs cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6e66baa213
commit
8fd14e4c38
@ -387,21 +387,43 @@ object.Constructor('BasePage', {
|
|||||||
: res },
|
: res },
|
||||||
//*/
|
//*/
|
||||||
resolve: relMatchProxy('resolve'),
|
resolve: relMatchProxy('resolve'),
|
||||||
delete: function(path='.'){
|
|
||||||
this.__delete__(path)
|
|
||||||
return this },
|
|
||||||
|
|
||||||
|
|
||||||
|
delete: async function(path='.', base=true){
|
||||||
|
var page = this.get(path)
|
||||||
|
if(page.isPattern){
|
||||||
|
base
|
||||||
|
&& this.__delete__(this.path.split('*')[0])
|
||||||
|
for(var p of await this.get('path').raw){
|
||||||
|
this.__delete__(p) }
|
||||||
|
} else {
|
||||||
|
this.__delete__(path) }
|
||||||
|
return this },
|
||||||
// XXX should these be implemented here or proxy to .store???
|
// XXX should these be implemented here or proxy to .store???
|
||||||
copy: async function(to){
|
// XXX do we sanity check to no not contain '*'???
|
||||||
this.get(to).data = await this.data
|
copy: async function(to, base=true){
|
||||||
|
// copy children...
|
||||||
|
if(this.isPattern){
|
||||||
|
var base = this.path.split('*')[0]
|
||||||
|
// copy the base...
|
||||||
|
base
|
||||||
|
&& (this.get(to).data = await this.get(base).data)
|
||||||
|
for(var from of await this.get('path').raw){
|
||||||
|
this.get(pwpath.join(to, from.slice(base.length))).data =
|
||||||
|
await this.get(from).data }
|
||||||
|
// copy self...
|
||||||
|
} else {
|
||||||
|
this.get(to).data = await this.data }
|
||||||
|
// change location...
|
||||||
this.path = to
|
this.path = to
|
||||||
return this },
|
return this },
|
||||||
move: async function(to){
|
move: async function(to, base=true){
|
||||||
var from = this.path
|
var from = this.path
|
||||||
await this.copy(to)
|
await this.copy(to, base)
|
||||||
this.delete(from)
|
this.delete(from, base)
|
||||||
return this },
|
return this },
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find current path (non-strict)
|
// Find current path (non-strict)
|
||||||
// .find()
|
// .find()
|
||||||
@ -2052,12 +2074,13 @@ module.System = {
|
|||||||
|
|
||||||
// actions...
|
// actions...
|
||||||
//
|
//
|
||||||
|
// XXX should ** be the default here...
|
||||||
delete: function(){
|
delete: function(){
|
||||||
var target = this.get('..')
|
var target = this.get('..')
|
||||||
|
|
||||||
console.log('DELETE:', target.path)
|
console.log('DELETE:', target.path)
|
||||||
|
|
||||||
target.delete()
|
target.delete('**')
|
||||||
|
|
||||||
// redirect...
|
// redirect...
|
||||||
this.renderer
|
this.renderer
|
||||||
@ -2078,7 +2101,7 @@ module.System = {
|
|||||||
console.log('MOVE:', from.path, to)
|
console.log('MOVE:', from.path, to)
|
||||||
|
|
||||||
to
|
to
|
||||||
&& await from.move(
|
&& await from.get('**').move(
|
||||||
/^[\\\/]/.test(to[0]) ?
|
/^[\\\/]/.test(to[0]) ?
|
||||||
to
|
to
|
||||||
: pwpath.join('..', to))
|
: pwpath.join('..', to))
|
||||||
|
|||||||
@ -11,12 +11,9 @@
|
|||||||
* await pwiki.get('/FlatNotes/* /delete').raw
|
* await pwiki.get('/FlatNotes/* /delete').raw
|
||||||
* opening/editing/deleting from ui breaks -- macro issue??
|
* opening/editing/deleting from ui breaks -- macro issue??
|
||||||
* ...seems to be at least a problem with macros eating up quotes...
|
* ...seems to be at least a problem with macros eating up quotes...
|
||||||
* XXX .delete() should support pattern pages, e.g.:
|
* do not see how we can resolve this issue transparently in any
|
||||||
* pwiki.get('/path/to/*').delete()
|
* way other than disallowing quotes...
|
||||||
* other actions should follow too:
|
* XXX BUG??? renaming a page does not rename sub-pages...
|
||||||
* - .move(..)
|
|
||||||
* - .copy(..)
|
|
||||||
* - ...
|
|
||||||
* XXX BUG: for some reason deleting and refreshing takes ~2x as long as
|
* XXX BUG: for some reason deleting and refreshing takes ~2x as long as
|
||||||
* refreshing...
|
* refreshing...
|
||||||
* to reproduce:
|
* to reproduce:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user