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
62e7ea5b
Commit
62e7ea5b
authored
May 26, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: modal-create-page - vue component
parent
25edd663
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
14 deletions
+10
-14
modal-create-page.vue
client/js/components/modal-create-page.vue
+8
-9
modal-create-page.js
client/js/store/modules/modal-create-page.js
+2
-5
No files found.
client/js/components/modal-create-page.vue
View file @
62e7ea5b
...
...
@@ -7,7 +7,7 @@
section
label.label Enter the new document path:
p.control.is-fullwidth(v-bind:class='{ "is-loading": isLoading }')
input.input(type='text', placeholder='page-name', v-model='
entryp
ath', ref='createPageInput', @keyup.enter='create', @keyup.esc='cancel')
input.input(type='text', placeholder='page-name', v-model='
userP
ath', ref='createPageInput', @keyup.enter='create', @keyup.esc='cancel')
span.help.is-danger(v-show='isInvalid') This document path is invalid!
footer
a.button.is-grey.is-outlined(v-on:click='cancel') Discard
...
...
@@ -21,25 +21,25 @@
data
()
{
return
{
currentPath
:
''
,
isLoading
:
false
userPath
:
''
,
isLoading
:
false
,
isInvalid
:
false
}
},
computed
:
{
entrypath
()
{
return
this
.
$store
.
state
.
modalCreatePage
.
entrypath
}
isShown
()
{
if
(
this
.
$store
.
state
.
modalCreatePage
.
shown
)
{
this
.
makeSelection
()
}
return
this
.
$store
.
state
.
modalCreatePage
.
shown
}
isInvalid
()
{
return
this
.
$store
.
state
.
modalCreatePage
.
invalid
}
},
methods
:
{
makeSelection
:
function
()
{
let
self
=
this
;
self
.
_
.
delay
(()
=>
{
let
startPos
=
(
self
.
currentPath
.
length
>
0
)
?
self
.
currentPath
.
length
+
1
:
0
self
.
$helpers
.
form
.
setInputSelection
(
self
.
$refs
.
createPageInput
,
startPos
,
self
.
entryp
ath
.
length
)
self
.
$helpers
.
form
.
setInputSelection
(
self
.
$refs
.
createPageInput
,
startPos
,
self
.
userP
ath
.
length
)
},
100
)
},
cancel
:
function
()
{
...
...
@@ -47,9 +47,9 @@
},
create
:
function
()
{
this
.
isInvalid
=
false
let
newDocPath
=
this
.
$helpers
.
pages
.
makeSafePath
(
this
.
entryp
ath
)
let
newDocPath
=
this
.
$helpers
.
pages
.
makeSafePath
(
this
.
userP
ath
)
if
(
this
.
_
.
isEmpty
(
newDocPath
))
{
this
.
$store
.
createPage
.
commit
(
''
)
this
.
isInvalid
=
true
}
else
{
this
.
isLoading
=
true
window
.
location
.
assign
(
'/create/'
+
newDocPath
)
...
...
@@ -58,8 +58,7 @@
},
mounted
()
{
this
.
currentPath
=
(
this
.
basepath
===
'home'
)
?
''
:
this
.
basepath
let
newPage
=
(
this
.
_
.
isEmpty
(
this
.
currentPath
))
?
'new-page'
:
this
.
currentPath
+
'/new-page'
this
.
$store
.
commit
(
'modalCreatePage/pathChange'
,
newPage
)
this
.
userPath
=
(
this
.
_
.
isEmpty
(
this
.
currentPath
))
?
'new-page'
:
this
.
currentPath
+
'/new-page'
}
}
</
script
>
client/js/store/modules/modal-create-page.js
View file @
62e7ea5b
...
...
@@ -3,14 +3,11 @@
export
default
{
namespaced
:
true
,
state
:
{
entrypath
:
''
,
shown
:
false
,
invalid
:
false
shown
:
false
},
getters
:
{},
mutations
:
{
shownChange
:
(
state
,
shownState
)
=>
{
state
.
shown
=
shownState
},
pathChange
:
(
state
,
newpath
)
=>
{
state
.
entrypath
=
newpath
}
shownChange
:
(
state
,
shownState
)
=>
{
state
.
shown
=
shownState
}
},
actions
:
{
open
({
commit
})
{
commit
(
'shownChange'
,
true
)
},
...
...
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