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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
575544f6
Commit
575544f6
authored
Jul 08, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IssueNotesRefactor: Slightly refactor toggleAward to remove action.
parent
9869b6b3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
19 deletions
+15
-19
app/assets/javascripts/notes/components/issue_note_awards_list.vue
...s/javascripts/notes/components/issue_note_awards_list.vue
+2
-3
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+13
-16
No files found.
app/assets/javascripts/notes/components/issue_note_awards_list.vue
View file @
575544f6
...
@@ -139,10 +139,9 @@ export default {
...
@@ -139,10 +139,9 @@ export default {
return
title
;
return
title
;
},
},
handleAward
(
awardName
,
isAwarded
)
{
handleAward
(
awardName
)
{
const
data
=
{
const
data
=
{
endpoint
:
this
.
toggleAwardPath
,
endpoint
:
this
.
toggleAwardPath
,
action
:
isAwarded
?
'
remove
'
:
'
add
'
,
noteId
:
this
.
noteId
,
noteId
:
this
.
noteId
,
awardName
,
awardName
,
};
};
...
@@ -166,7 +165,7 @@ export default {
...
@@ -166,7 +165,7 @@ export default {
v-for=
"(awardList, awardName) in groupedAwards"
v-for=
"(awardList, awardName) in groupedAwards"
:class=
"getAwardClassBindings(awardList, awardName)"
:class=
"getAwardClassBindings(awardList, awardName)"
:title=
"awardTitle(awardList)"
:title=
"awardTitle(awardList)"
@
click=
"handleAward(awardName
, amIAwarded(awardList)
)"
@
click=
"handleAward(awardName)"
class=
"btn award-control has-tooltip"
class=
"btn award-control has-tooltip"
data-placement=
"bottom"
data-placement=
"bottom"
type=
"button"
>
type=
"button"
>
...
...
app/assets/javascripts/notes/stores/issue_notes_store.js
View file @
575544f6
...
@@ -85,15 +85,8 @@ const mutations = {
...
@@ -85,15 +85,8 @@ const mutations = {
storeState
.
notes
.
push
(
noteData
);
storeState
.
notes
.
push
(
noteData
);
},
},
toggleAward
(
storeState
,
data
)
{
toggleAward
(
storeState
,
data
)
{
const
{
awardName
,
note
,
action
}
=
data
;
const
{
awardName
,
note
}
=
data
;
const
{
id
,
name
,
username
}
=
window
.
gl
.
currentUserData
;
const
{
id
,
name
,
username
}
=
window
.
gl
.
currentUserData
;
if
(
action
===
'
add
'
)
{
note
.
award_emoji
.
push
({
name
:
awardName
,
user
:
{
id
,
name
,
username
},
});
}
else
if
(
action
===
'
remove
'
)
{
let
index
=
-
1
;
let
index
=
-
1
;
note
.
award_emoji
.
forEach
((
a
,
i
)
=>
{
note
.
award_emoji
.
forEach
((
a
,
i
)
=>
{
...
@@ -102,9 +95,13 @@ const mutations = {
...
@@ -102,9 +95,13 @@ const mutations = {
}
}
});
});
if
(
index
>
-
1
)
{
if
(
index
>
-
1
)
{
// if I am awarded, remove my award
note
.
award_emoji
.
splice
(
index
,
1
);
note
.
award_emoji
.
splice
(
index
,
1
);
}
}
else
{
note
.
award_emoji
.
push
({
name
:
awardName
,
user
:
{
id
,
name
,
username
},
});
}
}
},
},
};
};
...
@@ -189,14 +186,14 @@ const actions = {
...
@@ -189,14 +186,14 @@ const actions = {
});
});
},
},
toggleAward
(
context
,
data
)
{
toggleAward
(
context
,
data
)
{
const
{
endpoint
,
awardName
,
action
,
noteId
}
=
data
;
const
{
endpoint
,
awardName
,
noteId
}
=
data
;
const
note
=
context
.
getters
.
notesById
[
noteId
];
const
note
=
context
.
getters
.
notesById
[
noteId
];
return
service
return
service
.
toggleAward
(
endpoint
,
{
name
:
awardName
})
.
toggleAward
(
endpoint
,
{
name
:
awardName
})
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
.
then
(()
=>
{
.
then
(()
=>
{
context
.
commit
(
'
toggleAward
'
,
{
awardName
,
note
,
action
});
context
.
commit
(
'
toggleAward
'
,
{
awardName
,
note
});
});
});
},
},
};
};
...
...
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