Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
867ce787
Commit
867ce787
authored
Jun 04, 2019
by
Winnie Hellmann
Committed by
Phil Hughes
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract toggleFilter() into issue boards store
parent
57f98564
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
18 deletions
+54
-18
app/assets/javascripts/boards/components/issue_card_inner.vue
...assets/javascripts/boards/components/issue_card_inner.vue
+1
-18
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+19
-0
spec/javascripts/boards/boards_store_spec.js
spec/javascripts/boards/boards_store_spec.js
+34
-0
No files found.
app/assets/javascripts/boards/components/issue_card_inner.vue
View file @
867ce787
...
@@ -6,7 +6,6 @@ import Icon from '~/vue_shared/components/icon.vue';
...
@@ -6,7 +6,6 @@ import Icon from '~/vue_shared/components/icon.vue';
import
TooltipOnTruncate
from
'
~/vue_shared/components/tooltip_on_truncate.vue
'
;
import
TooltipOnTruncate
from
'
~/vue_shared/components/tooltip_on_truncate.vue
'
;
import
issueCardInner
from
'
ee_else_ce/boards/mixins/issue_card_inner
'
;
import
issueCardInner
from
'
ee_else_ce/boards/mixins/issue_card_inner
'
;
import
UserAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
eventHub
from
'
../eventhub
'
;
import
IssueDueDate
from
'
./issue_due_date.vue
'
;
import
IssueDueDate
from
'
./issue_due_date.vue
'
;
import
IssueTimeEstimate
from
'
./issue_time_estimate.vue
'
;
import
IssueTimeEstimate
from
'
./issue_time_estimate.vue
'
;
import
boardsStore
from
'
../stores/boards_store
'
;
import
boardsStore
from
'
../stores/boards_store
'
;
...
@@ -136,23 +135,7 @@ export default {
...
@@ -136,23 +135,7 @@ export default {
const
labelTitle
=
encodeURIComponent
(
label
.
title
);
const
labelTitle
=
encodeURIComponent
(
label
.
title
);
const
filter
=
`label_name[]=
${
labelTitle
}
`
;
const
filter
=
`label_name[]=
${
labelTitle
}
`
;
this
.
applyFilter
(
filter
);
boardsStore
.
toggleFilter
(
filter
);
},
applyFilter
(
filter
)
{
const
filterPath
=
boardsStore
.
filter
.
path
.
split
(
'
&
'
);
const
filterIndex
=
filterPath
.
indexOf
(
filter
);
if
(
filterIndex
===
-
1
)
{
filterPath
.
push
(
filter
);
}
else
{
filterPath
.
splice
(
filterIndex
,
1
);
}
boardsStore
.
filter
.
path
=
filterPath
.
join
(
'
&
'
);
boardsStore
.
updateFiltersUrl
();
eventHub
.
$emit
(
'
updateTokens
'
);
},
},
labelStyle
(
label
)
{
labelStyle
(
label
)
{
return
{
return
{
...
...
app/assets/javascripts/boards/stores/boards_store.js
View file @
867ce787
...
@@ -8,6 +8,7 @@ import Cookies from 'js-cookie';
...
@@ -8,6 +8,7 @@ import Cookies from 'js-cookie';
import
BoardsStoreEE
from
'
ee_else_ce/boards/stores/boards_store_ee
'
;
import
BoardsStoreEE
from
'
ee_else_ce/boards/stores/boards_store_ee
'
;
import
{
getUrlParamsArray
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
getUrlParamsArray
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
eventHub
from
'
../eventhub
'
;
const
boardsStore
=
{
const
boardsStore
=
{
disabled
:
false
,
disabled
:
false
,
...
@@ -188,6 +189,24 @@ const boardsStore = {
...
@@ -188,6 +189,24 @@ const boardsStore = {
findListByLabelId
(
id
)
{
findListByLabelId
(
id
)
{
return
this
.
state
.
lists
.
find
(
list
=>
list
.
type
===
'
label
'
&&
list
.
label
.
id
===
id
);
return
this
.
state
.
lists
.
find
(
list
=>
list
.
type
===
'
label
'
&&
list
.
label
.
id
===
id
);
},
},
toggleFilter
(
filter
)
{
const
filterPath
=
this
.
filter
.
path
.
split
(
'
&
'
);
const
filterIndex
=
filterPath
.
indexOf
(
filter
);
if
(
filterIndex
===
-
1
)
{
filterPath
.
push
(
filter
);
}
else
{
filterPath
.
splice
(
filterIndex
,
1
);
}
this
.
filter
.
path
=
filterPath
.
join
(
'
&
'
);
this
.
updateFiltersUrl
();
eventHub
.
$emit
(
'
updateTokens
'
);
},
updateFiltersUrl
()
{
updateFiltersUrl
()
{
window
.
history
.
pushState
(
null
,
null
,
`?
${
this
.
filter
.
path
}
`
);
window
.
history
.
pushState
(
null
,
null
,
`?
${
this
.
filter
.
path
}
`
);
},
},
...
...
spec/javascripts/boards/boards_store_spec.js
View file @
867ce787
...
@@ -12,6 +12,7 @@ import '~/boards/models/issue';
...
@@ -12,6 +12,7 @@ import '~/boards/models/issue';
import
'
~/boards/models/list
'
;
import
'
~/boards/models/list
'
;
import
'
~/boards/services/board_service
'
;
import
'
~/boards/services/board_service
'
;
import
boardsStore
from
'
~/boards/stores/boards_store
'
;
import
boardsStore
from
'
~/boards/stores/boards_store
'
;
import
eventHub
from
'
~/boards/eventhub
'
;
import
{
listObj
,
listObjDuplicate
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
import
{
listObj
,
listObjDuplicate
,
boardsMockInterceptor
,
mockBoardService
}
from
'
./mock_data
'
;
describe
(
'
Store
'
,
()
=>
{
describe
(
'
Store
'
,
()
=>
{
...
@@ -53,6 +54,39 @@ describe('Store', () => {
...
@@ -53,6 +54,39 @@ describe('Store', () => {
});
});
});
});
describe
(
'
toggleFilter
'
,
()
=>
{
const
dummyFilter
=
'
x=42
'
;
let
updateTokensSpy
;
beforeEach
(()
=>
{
updateTokensSpy
=
jasmine
.
createSpy
(
'
updateTokens
'
);
eventHub
.
$once
(
'
updateTokens
'
,
updateTokensSpy
);
// prevent using window.history
spyOn
(
boardsStore
,
'
updateFiltersUrl
'
).
and
.
callFake
(()
=>
{});
});
it
(
'
adds the filter if it is not present
'
,
()
=>
{
boardsStore
.
filter
.
path
=
'
something
'
;
boardsStore
.
toggleFilter
(
dummyFilter
);
expect
(
boardsStore
.
filter
.
path
).
toEqual
(
`something&
${
dummyFilter
}
`
);
expect
(
updateTokensSpy
).
toHaveBeenCalled
();
expect
(
boardsStore
.
updateFiltersUrl
).
toHaveBeenCalled
();
});
it
(
'
removes the filter if it is present
'
,
()
=>
{
boardsStore
.
filter
.
path
=
`something&
${
dummyFilter
}
`
;
boardsStore
.
toggleFilter
(
dummyFilter
);
expect
(
boardsStore
.
filter
.
path
).
toEqual
(
'
something
'
);
expect
(
updateTokensSpy
).
toHaveBeenCalled
();
expect
(
boardsStore
.
updateFiltersUrl
).
toHaveBeenCalled
();
});
});
describe
(
'
lists
'
,
()
=>
{
describe
(
'
lists
'
,
()
=>
{
it
(
'
creates new list without persisting to DB
'
,
()
=>
{
it
(
'
creates new list without persisting to DB
'
,
()
=>
{
boardsStore
.
addList
(
listObj
);
boardsStore
.
addList
(
listObj
);
...
...
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