Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zwordi
funkwhale
Commits
b1194e50
Verified
Commit
b1194e50
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Move smart search bar in a dedicated component mixin
parent
47209ee5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
front/src/components/mixins/SmartSearch.vue
+55
-0
55 additions, 0 deletions
front/src/components/mixins/SmartSearch.vue
front/src/views/content/libraries/FilesTable.vue
+3
-44
3 additions, 44 deletions
front/src/views/content/libraries/FilesTable.vue
with
58 additions
and
44 deletions
front/src/components/mixins/SmartSearch.vue
0 → 100644
+
55
−
0
View file @
b1194e50
<
script
>
import
{
normalizeQuery
,
parseTokens
,
compileTokens
}
from
'
@/search
'
export
default
{
props
:
{
defaultQuery
:
{
type
:
String
,
default
:
''
,
required
:
false
},
},
methods
:
{
getTokenValue
(
key
,
fallback
)
{
let
matching
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
===
key
})
if
(
matching
.
length
>
0
)
{
return
matching
[
0
].
value
}
return
fallback
},
addSearchToken
(
key
,
value
)
{
if
(
!
value
)
{
// we remove existing matching tokens, if any
this
.
search
.
tokens
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
!=
key
})
}
else
{
let
existing
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
===
key
})
if
(
existing
.
length
>
0
)
{
// we replace the value in existing tokens, if any
existing
.
forEach
(
t
=>
{
t
.
value
=
value
})
}
else
{
// we add a new token
this
.
search
.
tokens
.
push
({
field
:
key
,
value
})
}
}
},
},
watch
:
{
'
search.query
'
(
newValue
)
{
this
.
search
.
tokens
=
parseTokens
(
normalizeQuery
(
newValue
))
},
'
search.tokens
'
:
{
handler
(
newValue
)
{
this
.
search
.
query
=
compileTokens
(
newValue
)
this
.
page
=
1
this
.
fetchData
()
},
deep
:
true
},
}
}
</
script
>
This diff is collapsed.
Click to expand it.
front/src/views/content/libraries/FilesTable.vue
+
3
−
44
View file @
b1194e50
...
...
@@ -125,19 +125,19 @@
import
axios
from
'
axios
'
import
_
from
'
@/lodash
'
import
time
from
'
@/utils/time
'
import
{
normalizeQuery
,
parseTokens
,
compileTokens
}
from
'
@/search
'
import
{
normalizeQuery
,
parseTokens
}
from
'
@/search
'
import
Pagination
from
'
@/components/Pagination
'
import
ActionTable
from
'
@/components/common/ActionTable
'
import
OrderingMixin
from
'
@/components/mixins/Ordering
'
import
TranslationsMixin
from
'
@/components/mixins/Translations
'
import
SmartSearchMixin
from
'
@/components/mixins/SmartSearch
'
export
default
{
mixins
:
[
OrderingMixin
,
TranslationsMixin
],
mixins
:
[
OrderingMixin
,
TranslationsMixin
,
SmartSearchMixin
],
props
:
{
filters
:
{
type
:
Object
,
required
:
false
},
needsRefresh
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
},
defaultQuery
:
{
type
:
String
,
default
:
''
},
customObjects
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
{
return
[]
}}
},
components
:
{
...
...
@@ -172,36 +172,6 @@ export default {
this
.
fetchData
()
},
methods
:
{
getTokenValue
(
key
,
fallback
)
{
let
matching
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
===
key
})
if
(
matching
.
length
>
0
)
{
return
matching
[
0
].
value
}
return
fallback
},
addSearchToken
(
key
,
value
)
{
if
(
!
value
)
{
// we remove existing matching tokens, if any
this
.
search
.
tokens
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
!=
key
})
}
else
{
let
existing
=
this
.
search
.
tokens
.
filter
(
t
=>
{
return
t
.
field
===
key
})
if
(
existing
.
length
>
0
)
{
// we replace the value in existing tokens, if any
existing
.
forEach
(
t
=>
{
t
.
value
=
value
})
}
else
{
// we add a new token
this
.
search
.
tokens
.
push
({
field
:
key
,
value
})
}
}
},
fetchData
()
{
this
.
$emit
(
'
fetch-start
'
)
let
params
=
_
.
merge
({
...
...
@@ -282,17 +252,6 @@ export default {
}
},
watch
:
{
'
search.query
'
(
newValue
)
{
this
.
search
.
tokens
=
parseTokens
(
normalizeQuery
(
newValue
))
},
'
search.tokens
'
:
{
handler
(
newValue
)
{
this
.
search
.
query
=
compileTokens
(
newValue
)
this
.
page
=
1
this
.
fetchData
()
},
deep
:
true
},
orderingDirection
:
function
()
{
this
.
page
=
1
this
.
fetchData
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment