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
77548c87
Commit
77548c87
authored
Apr 09, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: tags input normalization
parent
488ec4a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
editor-modal-properties.vue
client/components/editor/editor-modal-properties.vue
+12
-11
page.js
server/graph/resolvers/page.js
+6
-5
tags.js
server/models/tags.js
+1
-1
No files found.
client/components/editor/editor-modal-properties.vue
View file @
77548c87
...
...
@@ -80,19 +80,14 @@
v-combobox(
:label='$t(`editor:props.tags`)'
outlined
v-model='
tags
'
v-model='
newTag
'
:hint='$t(`editor:props.tagsHint`)'
:items='newTagSuggestions'
:loading='$apollo.queries.newTagSuggestions.loading'
persistent-hint
deletable-chips
hide-no-data
hide-selected
:search-input.sync='newTagSearch'
multiple
)
template(v-slot:selection='{ attrs, item, parent, selected }')
span
v-tab-item
v-card-text
.overline.pb-5
{{
$t
(
'editor:props.publishState'
)
}}
#[v-chip.ml-3(label, color='grey', small, outlined).white--text coming soon]
...
...
@@ -306,14 +301,20 @@ export default {
// this.$tours['editorPropertiesTour'].start()
},
500
)
}
},
newTag
(
newValue
,
oldValue
)
{
const
tagClean
=
_
.
trim
(
newValue
||
''
).
toLowerCase
()
if
(
tagClean
&&
tagClean
.
length
>
0
)
{
if
(
!
_
.
includes
(
this
.
tags
,
tagClean
))
{
this
.
tags
=
[...
this
.
tags
,
tagClean
]
}
this
.
$nextTick
(()
=>
{
this
.
newTag
=
null
})
}
}
},
methods
:
{
addTag
()
{
this
.
$nextTick
(()
=>
{
this
.
tags
.
push
(
this
.
newTag
)
})
},
removeTag
(
tag
)
{
this
.
tags
=
_
.
without
(
this
.
tags
,
tag
)
},
...
...
server/graph/resolvers/page.js
View file @
77548c87
...
...
@@ -110,7 +110,7 @@ module.exports = {
}
}
if
(
args
.
tags
&&
args
.
tags
.
length
>
0
)
{
queryBuilder
.
whereIn
(
'tags.tag'
,
args
.
tags
)
queryBuilder
.
whereIn
(
'tags.tag'
,
args
.
tags
.
map
(
t
=>
_
.
trim
(
t
).
toLowerCase
())
)
}
const
orderDir
=
args
.
orderByDirection
===
'DESC'
?
'desc'
:
'asc'
switch
(
args
.
orderBy
)
{
...
...
@@ -177,14 +177,15 @@ module.exports = {
* SEARCH TAGS
*/
async
searchTags
(
obj
,
args
,
context
,
info
)
{
const
query
=
_
.
trim
(
args
.
query
)
const
results
=
await
WIKI
.
models
.
tags
.
query
()
.
column
(
'tag'
)
.
where
(
builder
=>
{
builder
.
andWhere
(
builderSub
=>
{
if
(
WIKI
.
config
.
db
.
type
===
'postgres'
)
{
builderSub
.
where
(
'tag'
,
'ILIKE'
,
`%
${
args
.
query
}
%`
)
builderSub
.
where
(
'tag'
,
'ILIKE'
,
`%
${
query
}
%`
)
}
else
{
builderSub
.
where
(
'tag'
,
'LIKE'
,
`%
${
args
.
query
}
%`
)
builderSub
.
where
(
'tag'
,
'LIKE'
,
`%
${
query
}
%`
)
}
})
})
...
...
@@ -400,8 +401,8 @@ module.exports = {
const
affectedRows
=
await
WIKI
.
models
.
tags
.
query
()
.
findById
(
args
.
id
)
.
patch
({
tag
:
args
.
tag
,
title
:
args
.
title
tag
:
_
.
trim
(
args
.
tag
).
toLowerCase
()
,
title
:
_
.
trim
(
args
.
title
)
})
if
(
affectedRows
<
1
)
{
throw
new
Error
(
'This tag does not exist.'
)
...
...
server/models/tags.js
View file @
77548c87
...
...
@@ -55,7 +55,7 @@ module.exports = class Tag extends Model {
// Format tags
tags
=
_
.
uniq
(
tags
.
map
(
t
=>
t
.
toLowerCase
()))
tags
=
_
.
uniq
(
tags
.
map
(
t
=>
_
.
trim
(
t
)
.
toLowerCase
()))
// Create missing tags
...
...
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