Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
e492371c
Unverified
Commit
e492371c
authored
Jun 30, 2023
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: file manager open to current folder
parent
5efa0abe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
14 deletions
+50
-14
pages.mjs
server/models/pages.mjs
+2
-2
tree.mjs
server/models/tree.mjs
+2
-2
FileManager.vue
ux/src/components/FileManager.vue
+33
-5
TreeBrowserDialog.vue
ux/src/components/TreeBrowserDialog.vue
+13
-5
No files found.
server/models/pages.mjs
View file @
e492371c
...
...
@@ -18,8 +18,8 @@ import { PageLink } from './pageLinks.mjs'
import
{
Tag
}
from
'./tags.mjs'
import
{
User
}
from
'./users.mjs'
const
pageRegex
=
/^
[
a-zA
0-9
0-9-_
/]
*$/
const
aliasRegex
=
/^
[
a-zA
0-9
0-9-_
]
*$/
const
pageRegex
=
/^
[
a-zA
-Z
0-9-_
/]
*$/
const
aliasRegex
=
/^
[
a-zA
-Z
0-9-_
]
*$/
const
frontmatterRegex
=
{
html
:
/^
(
<!-
{2}(?:\n
|
\r)([\w\W]
+
?)(?:\n
|
\r)
-
{2}
>
)?(?:\n
|
\r)
*
([\w\W]
*
)
*/
,
...
...
server/models/tree.mjs
View file @
e492371c
...
...
@@ -132,8 +132,8 @@ export class Tree extends Model {
*/
static
async
addPage
({
id
,
parentId
,
parentPath
,
fileName
,
title
,
locale
,
siteId
,
meta
=
{}
})
{
const
folder
=
(
parentId
||
parentPath
)
?
await
WIKI
.
db
.
tree
.
getFolder
({
parentId
,
parentPath
,
id
:
parentId
,
pa
th
:
pa
rentPath
,
locale
,
siteId
,
createIfMissing
:
true
...
...
ux/src/components/FileManager.vue
View file @
e492371c
...
...
@@ -320,7 +320,7 @@ import { computed, defineAsyncComponent, nextTick, onMounted, reactive, ref, toR
import
{
filesize
}
from
'filesize'
import
{
useQuasar
}
from
'quasar'
import
{
DateTime
}
from
'luxon'
import
{
cloneDeep
,
find
}
from
'lodash-es'
import
{
cloneDeep
,
dropRight
,
find
,
findKey
,
initial
,
last
,
nth
}
from
'lodash-es'
import
{
useRoute
,
useRouter
}
from
'vue-router'
import
gql
from
'graphql-tag'
import
Fuse
from
'fuse.js/dist/fuse.basic.esm'
...
...
@@ -622,8 +622,14 @@ async function loadTree ({ parentId = null, parentPath = null, types, initLoad =
// -> Set Ancestors / Tree Roots
if
(
item
.
folderPath
)
{
if
(
item
.
id
!==
parentId
&&
!
state
.
treeNodes
[
parentId
].
children
.
includes
(
item
.
id
))
{
state
.
treeNodes
[
parentId
].
children
.
push
(
item
.
id
)
let
folderParentId
=
parentId
if
(
!
folderParentId
)
{
const
parentFolderParts
=
item
.
folderPath
.
split
(
'/'
)
const
parentFolder
=
find
(
items
,
{
folderPath
:
parentFolderParts
.
length
>
1
?
initial
(
parentFolderParts
).
join
(
'/'
)
:
''
,
fileName
:
last
(
parentFolderParts
)
})
folderParentId
=
parentFolder
.
id
}
if
(
item
.
id
!==
folderParentId
&&
!
state
.
treeNodes
[
folderParentId
]?.
children
?.
includes
(
item
.
id
))
{
state
.
treeNodes
[
folderParentId
]?.
children
?.
push
(
item
.
id
)
}
}
else
{
newTreeRoots
.
push
(
item
.
id
)
...
...
@@ -990,8 +996,30 @@ function delItem (item) {
// MOUNTED
onMounted
(()
=>
{
loadTree
({})
onMounted
(
async
()
=>
{
const
pathParts
=
pageStore
.
path
.
split
(
'/'
)
const
parentPath
=
initial
(
pathParts
).
join
(
'/'
)
await
loadTree
({
parentPath
,
initLoad
:
true
})
// -> Open tree up to current folder
const
folderFolderPath
=
dropRight
(
pathParts
,
2
).
join
(
'/'
)
const
folderFileName
=
nth
(
pathParts
,
-
2
)
for
(
const
[
id
,
node
]
of
Object
.
entries
(
state
.
treeNodes
))
{
if
(
parentPath
.
startsWith
(
node
.
folderPath
?
`
${
node
.
folderPath
}
/
${
node
.
fileName
}
`
:
node
.
fileName
))
{
treeComp
.
value
.
setOpened
(
id
)
}
}
// -> Switch to current folder (from page path)
const
currentNodeId
=
findKey
(
state
.
treeNodes
,
n
=>
n
.
folderPath
===
folderFolderPath
&&
n
.
fileName
===
folderFileName
)
if
(
currentNodeId
)
{
state
.
currentFolderId
=
currentNodeId
}
})
</
script
>
...
...
ux/src/components/TreeBrowserDialog.vue
View file @
e492371c
...
...
@@ -114,7 +114,7 @@ q-dialog(ref='dialogRef', @hide='onDialogHide')
import
{
useI18n
}
from
'vue-i18n'
import
{
computed
,
onMounted
,
reactive
}
from
'vue'
import
{
useDialogPluginComponent
,
useQuasar
}
from
'quasar'
import
{
cloneDeep
,
find
,
last
}
from
'lodash-es'
import
{
cloneDeep
,
find
,
initial
,
last
}
from
'lodash-es'
import
gql
from
'graphql-tag'
import
fileTypes
from
'../helpers/fileTypes'
...
...
@@ -233,7 +233,7 @@ const files = computed(() => {
async
function
save
()
{
onDialogOK
({
title
:
state
.
title
,
path
:
state
.
path
path
:
currentFolderPath
.
value
.
length
>
1
?
`
${
currentFolderPath
.
value
.
substring
(
1
)}${
state
.
path
}
`
:
state
.
path
})
}
...
...
@@ -307,10 +307,18 @@ async function loadTree ({ parentId = null, parentPath = null, types, initLoad =
title
:
item
.
title
,
children
:
[]
}
if
(
!
item
.
folderPath
)
{
newTreeRoots
.
push
(
item
.
id
)
if
(
item
.
folderPath
)
{
let
folderParentId
=
parentId
if
(
!
folderParentId
)
{
const
parentFolderParts
=
item
.
folderPath
.
split
(
'/'
)
const
parentFolder
=
find
(
items
,
{
folderPath
:
parentFolderParts
.
length
>
1
?
initial
(
parentFolderParts
).
join
(
'/'
)
:
''
,
fileName
:
last
(
parentFolderParts
)
})
folderParentId
=
parentFolder
.
id
}
if
(
item
.
id
!==
folderParentId
&&
!
state
.
treeNodes
[
folderParentId
]?.
children
?.
includes
(
item
.
id
))
{
state
.
treeNodes
[
folderParentId
].
children
.
push
(
item
.
id
)
}
}
else
{
state
.
treeNodes
[
parentId
].
children
.
push
(
item
.
id
)
newTreeRoots
.
push
(
item
.
id
)
}
break
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment