Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Frontend
Commits
09ebacc4
Commit
09ebacc4
authored
2 years ago
by
ml bonhomme
Committed by
Erwan Rouchet
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
select/unselect all uploaded files in file import
parent
4ba55b17
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1326
select/unselect all uploaded files in file import
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/Imports/Files/Selector.vue
+12
-2
12 additions, 2 deletions
src/components/Imports/Files/Selector.vue
src/store/files.js
+6
-0
6 additions, 0 deletions
src/store/files.js
tests/unit/store/files.spec.js
+71
-0
71 additions, 0 deletions
tests/unit/store/files.spec.js
with
89 additions
and
2 deletions
src/components/Imports/Files/Selector.vue
+
12
−
2
View file @
09ebacc4
...
...
@@ -2,7 +2,12 @@
<div
v-if=
"files"
>
<Uploader
:corpus-id=
"corpusId"
v-if=
"isVerified && canWrite(corpus)"
/>
<br
/>
<div
class=
"control is-pulled-right"
>
<button
v-if=
"filesSelected"
class=
"button"
v-on:click=
"setAllSelected(false)"
>
Unselect all
</button>
<button
v-else
class=
"button"
v-on:click=
"setAllSelected(true)"
>
Select all
</button>
</div>
<h2
class=
"subtitle is-marginless"
>
Available files to import
</h2>
<br
/>
<div
class=
"columns is-multiline is-vcentered"
>
<div
class=
"column is-one-quarter-fullhd is-one-third-widescreen is-half-tablet"
v-for=
"file in files"
:key=
"file.id"
>
<File
:file=
"file"
/>
...
...
@@ -18,7 +23,7 @@
</
template
>
<
script
>
import
{
mapState
,
mapGetters
}
from
'
vuex
'
import
{
mapState
,
mapGetters
,
mapMutations
}
from
'
vuex
'
import
{
corporaMixin
}
from
'
@/mixins.js
'
import
Uploader
from
'
./Uploader
'
import
File
from
'
./File
'
...
...
@@ -45,9 +50,14 @@ export default {
},
computed
:
{
...
mapGetters
(
'
auth
'
,
[
'
isVerified
'
]),
...
mapState
(
'
files
'
,
[
'
files
'
,
'
loaded
'
])
...
mapState
(
'
files
'
,
[
'
files
'
,
'
loaded
'
]),
filesSelected
()
{
if
(
!
this
.
files
)
return
false
return
Object
.
values
(
this
.
files
).
some
(
file
=>
file
.
selected
)
}
},
methods
:
{
...
mapMutations
(
'
files
'
,
[
'
setAllSelected
'
]),
list
()
{
this
.
$store
.
dispatch
(
'
files/list
'
,
{
corpus
:
this
.
corpusId
})
},
...
...
This diff is collapsed.
Click to expand it.
src/store/files.js
+
6
−
0
View file @
09ebacc4
...
...
@@ -22,6 +22,12 @@ export const mutations = {
},
reset
(
state
)
{
assign
(
state
,
initialState
())
},
setAllSelected
(
state
,
selected
)
{
if
(
typeof
(
selected
)
!==
'
boolean
'
)
{
throw
new
Error
(
'
"selected" value must be a boolean.
'
)
}
state
.
files
=
Object
.
fromEntries
(
Object
.
values
(
state
.
files
).
map
(
file
=>
[
file
.
id
,
{
...
file
,
selected
}]))
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/store/files.spec.js
+
71
−
0
View file @
09ebacc4
...
...
@@ -48,6 +48,77 @@ describe('files', () => {
mutations
.
reset
(
state
)
assert
.
deepStrictEqual
(
state
,
{
files
:
{},
loaded
:
false
})
})
describe
(
'
setAllSelected
'
,
()
=>
{
it
(
'
selects all files
'
,
()
=>
{
const
state
=
{
files
:
{
file1
,
file2
},
loaded
:
true
}
const
expectedState
=
{
files
:
{
file1
:
{
id
:
'
file1
'
,
name
:
'
lol.json
'
,
selected
:
true
},
file2
:
{
id
:
'
file2
'
,
name
:
'
image.jpg
'
,
selected
:
true
}
},
loaded
:
true
}
mutations
.
setAllSelected
(
state
,
true
)
assert
.
deepStrictEqual
(
state
,
expectedState
)
})
it
(
'
unselects all files
'
,
()
=>
{
const
state
=
{
files
:
{
file1
:
{
id
:
'
file1
'
,
name
:
'
lol.json
'
,
selected
:
true
},
file2
:
{
id
:
'
file2
'
,
name
:
'
image.jpg
'
,
selected
:
true
}
},
loaded
:
true
}
const
expectedState
=
{
files
:
{
file1
:
{
id
:
'
file1
'
,
name
:
'
lol.json
'
,
selected
:
false
},
file2
:
{
id
:
'
file2
'
,
name
:
'
image.jpg
'
,
selected
:
false
}
},
loaded
:
true
}
mutations
.
setAllSelected
(
state
,
false
)
assert
.
deepStrictEqual
(
state
,
expectedState
)
})
it
(
'
requires a boolean value
'
,
()
=>
{
const
state
=
{
files
:
{
file1
,
file2
},
loaded
:
true
}
assert
.
throws
(
()
=>
mutations
.
setAllSelected
(
2
),
'
"selected" value must be a boolean.
'
)
assert
.
deepStrictEqual
(
state
,
state
)
})
})
})
describe
(
'
actions
'
,
()
=>
{
...
...
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