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
0e53b116
Commit
0e53b116
authored
Apr 27, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip ci] rename user to assignee
parent
7c022ae7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
63 deletions
+65
-63
app/assets/javascripts/sidebar/components/assignees/assignees.js
...ets/javascripts/sidebar/components/assignees/assignees.js
+6
-3
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js
...scripts/sidebar/components/assignees/sidebar_assignees.js
+26
-19
app/assets/javascripts/sidebar/sidebar_mediator.js
app/assets/javascripts/sidebar/sidebar_mediator.js
+7
-18
app/assets/javascripts/sidebar/stores/sidebar_store.js
app/assets/javascripts/sidebar/stores/sidebar_store.js
+18
-17
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+7
-5
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
No files found.
app/assets/javascripts/sidebar/components/assignees/assignees.js
View file @
0e53b116
...
@@ -79,6 +79,9 @@ export default {
...
@@ -79,6 +79,9 @@ export default {
renderAssignee
(
index
)
{
renderAssignee
(
index
)
{
return
!
this
.
showLess
||
(
index
<
this
.
defaultRenderCount
&&
this
.
showLess
);
return
!
this
.
showLess
||
(
index
<
this
.
defaultRenderCount
&&
this
.
showLess
);
},
},
avatarUrl
(
user
)
{
return
user
.
avatarUrl
||
user
.
avatar_url
;
},
assigneeUrl
(
user
)
{
assigneeUrl
(
user
)
{
return
`
${
this
.
rootPath
}${
user
.
username
}
`
;
return
`
${
this
.
rootPath
}${
user
.
username
}
`
;
},
},
...
@@ -118,7 +121,7 @@ export default {
...
@@ -118,7 +121,7 @@ export default {
width="24"
width="24"
class="avatar avatar-inline s24"
class="avatar avatar-inline s24"
:alt="assigneeAlt(user)"
:alt="assigneeAlt(user)"
:src="
user.avatarUrl
"
:src="
avatarUrl(user)
"
/>
/>
<span class="author">
<span class="author">
{{ user.name }}
{{ user.name }}
...
@@ -158,7 +161,7 @@ export default {
...
@@ -158,7 +161,7 @@ export default {
width="32"
width="32"
class="avatar avatar-inline s32"
class="avatar avatar-inline s32"
:alt="assigneeAlt(firstUser)"
:alt="assigneeAlt(firstUser)"
:src="
firstUser.avatarUrl
"
:src="
avatarUrl(firstUser)
"
/>
/>
<span class="author">
<span class="author">
{{ firstUser.name }}
{{ firstUser.name }}
...
@@ -185,7 +188,7 @@ export default {
...
@@ -185,7 +188,7 @@ export default {
width="32"
width="32"
class="avatar avatar-inline s32"
class="avatar avatar-inline s32"
:alt="assigneeAlt(user)"
:alt="assigneeAlt(user)"
:src="
user.avatarUrl
"
:src="
avatarUrl(user)
"
/>
/>
</a>
</a>
</div>
</div>
...
...
app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js
View file @
0e53b116
/* global Flash */
import
AssigneeTitle
from
'
./assignee_title
'
;
import
AssigneeTitle
from
'
./assignee_title
'
;
import
Assignees
from
'
./assignees
'
;
import
Assignees
from
'
./assignees
'
;
...
@@ -20,39 +22,45 @@ export default {
...
@@ -20,39 +22,45 @@ export default {
'
assignee-title
'
:
AssigneeTitle
,
'
assignee-title
'
:
AssigneeTitle
,
assignees
:
Assignees
,
assignees
:
Assignees
,
},
},
computed
:
{
numberOfAssignees
()
{
return
this
.
store
.
selectedUserIds
.
length
;
},
},
methods
:
{
methods
:
{
assignSelf
()
{
assignSelf
()
{
// Notify gl dropdown that we are now assigning to current user
// Notify gl dropdown that we are now assigning to current user
this
.
$el
.
parentElement
.
dispatchEvent
(
new
Event
(
'
assignYourself
'
));
this
.
$el
.
parentElement
.
dispatchEvent
(
new
Event
(
'
assignYourself
'
));
this
.
mediator
.
assignYourself
();
this
.
mediator
.
assignYourself
();
this
.
save
User
s
();
this
.
save
Assignee
s
();
},
},
save
User
s
()
{
save
Assignee
s
()
{
this
.
loading
=
true
;
this
.
loading
=
true
;
function
setLoadingFalse
()
{
function
setLoadingFalse
()
{
this
.
loading
=
false
;
this
.
loading
=
false
;
}
}
const
setLoadingFalseWrapper
=
setLoadingFalse
.
bind
(
this
);
this
.
mediator
.
saveAssignees
(
this
.
field
)
.
then
(
setLoadingFalse
.
bind
(
this
))
this
.
mediator
.
saveSelectedUsers
(
this
.
field
)
.
catch
(()
=>
{
.
then
(
setLoadingFalseWrapper
)
setLoadingFalse
();
.
catch
(
setLoadingFalseWrapper
);
return
new
Flash
(
'
Error occurred when saving assignees
'
);
});
},
},
},
},
created
()
{
created
()
{
this
.
removeAssignee
=
this
.
store
.
removeAssignee
.
bind
(
this
.
store
);
this
.
addAssignee
=
this
.
store
.
addAssignee
.
bind
(
this
.
store
);
this
.
removeAllAssignees
=
this
.
store
.
removeAllAssignees
.
bind
(
this
.
store
);
// Get events from glDropdown
// Get events from glDropdown
eventHub
.
$on
(
'
sidebar.removeUser
'
,
this
.
store
.
removeUserId
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
sidebar.removeAssignee
'
,
this
.
removeAssignee
);
eventHub
.
$on
(
'
sidebar.addUser
'
,
this
.
store
.
addUserId
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
sidebar.addAssignee
'
,
this
.
addAssignee
);
eventHub
.
$on
(
'
sidebar.removeAllUsers
'
,
this
.
store
.
removeAllUserIds
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
sidebar.removeAllAssignees
'
,
this
.
removeAllAssignees
);
eventHub
.
$on
(
'
sidebar.saveUsers
'
,
this
.
saveUsers
);
eventHub
.
$on
(
'
sidebar.saveAssignees
'
,
this
.
saveAssignees
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
sidebar.removeAssignee
'
,
this
.
removeAssignee
);
eventHub
.
$off
(
'
sidebar.addAssignee
'
,
this
.
addAssignee
);
eventHub
.
$off
(
'
sidebar.removeAllAssignees
'
,
this
.
removeAllAssignees
);
eventHub
.
$off
(
'
sidebar.saveAssignees
'
,
this
.
saveAssignees
);
},
},
beforeMount
()
{
beforeMount
()
{
this
.
field
=
this
.
$el
.
dataset
.
field
;
this
.
field
=
this
.
$el
.
dataset
.
field
;
...
@@ -60,15 +68,14 @@ export default {
...
@@ -60,15 +68,14 @@ export default {
template
:
`
template
:
`
<div>
<div>
<assignee-title
<assignee-title
:number-of-assignees="store.
selectedUserId
s.length"
:number-of-assignees="store.
assignee
s.length"
:loading="loading"
:loading="loading"
:editable="store.editable"
:editable="store.editable"
/>
/>
<assignees
<assignees
class="value"
class="value"
v-if="!loading"
:root-path="store.rootPath"
:root-path="store.rootPath"
:users="store.
renderedUser
s"
:users="store.
assignee
s"
@assign-self="assignSelf"
@assign-self="assignSelf"
/>
/>
</div>
</div>
...
...
app/assets/javascripts/sidebar/sidebar_mediator.js
View file @
0e53b116
...
@@ -15,33 +15,22 @@ export default class SidebarMediator {
...
@@ -15,33 +15,22 @@ export default class SidebarMediator {
}
}
assignYourself
()
{
assignYourself
()
{
this
.
store
.
add
UserId
(
this
.
store
.
currentUserId
);
this
.
store
.
add
Assignee
(
this
.
store
.
currentUser
);
}
}
saveSelectedUsers
(
field
)
{
saveAssignees
(
field
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
selected
=
this
.
store
.
assignees
.
map
((
u
)
=>
u
.
id
);
const
selected
=
this
.
store
.
selectedUserIds
;
// If there are no ids, that means we have to unassign (which is id = 0)
// If there are no ids, that means we have to unassign (which is id = 0)
// And it only accepts an array, hence [0]
// And it only accepts an array, hence [0]
this
.
service
.
update
(
field
,
selected
.
length
===
0
?
[
0
]
:
selected
)
return
this
.
service
.
update
(
field
,
selected
.
length
===
0
?
[
0
]
:
selected
);
.
then
((
response
)
=>
{
const
data
=
response
.
json
();
this
.
store
.
processUserData
(
data
);
resolve
();
})
.
catch
(()
=>
{
reject
();
return
new
Flash
(
'
Error occurred when saving users
'
);
});
});
}
}
fetch
()
{
fetch
()
{
this
.
service
.
get
()
this
.
service
.
get
()
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
const
data
=
response
.
json
();
const
data
=
response
.
json
();
this
.
store
.
process
User
Data
(
data
);
this
.
store
.
process
Assignee
Data
(
data
);
this
.
store
.
processTimeTrackingData
(
data
);
this
.
store
.
processTimeTrackingData
(
data
);
})
})
.
catch
(()
=>
new
Flash
(
'
Error occured when fetching sidebar data
'
));
.
catch
(()
=>
new
Flash
(
'
Error occured when fetching sidebar data
'
));
...
...
app/assets/javascripts/sidebar/stores/sidebar_store.js
View file @
0e53b116
export
default
class
SidebarStore
{
export
default
class
SidebarStore
{
constructor
(
store
)
{
constructor
(
store
)
{
if
(
!
SidebarStore
.
singleton
)
{
if
(
!
SidebarStore
.
singleton
)
{
const
{
currentUser
Id
,
rootPath
,
editable
}
=
store
;
const
{
currentUser
,
rootPath
,
editable
}
=
store
;
this
.
currentUser
Id
=
currentUserId
;
this
.
currentUser
=
currentUser
;
this
.
rootPath
=
rootPath
;
this
.
rootPath
=
rootPath
;
this
.
editable
=
editable
;
this
.
editable
=
editable
;
this
.
timeEstimate
=
0
;
this
.
timeEstimate
=
0
;
this
.
totalTimeSpent
=
0
;
this
.
totalTimeSpent
=
0
;
this
.
humanTimeEstimate
=
''
;
this
.
humanTimeEstimate
=
''
;
this
.
humanTimeSpent
=
''
;
this
.
humanTimeSpent
=
''
;
this
.
selectedUserIds
=
[];
this
.
assignees
=
[];
this
.
renderedUsers
=
[];
SidebarStore
.
singleton
=
this
;
SidebarStore
.
singleton
=
this
;
}
}
...
@@ -18,17 +17,14 @@ export default class SidebarStore {
...
@@ -18,17 +17,14 @@ export default class SidebarStore {
return
SidebarStore
.
singleton
;
return
SidebarStore
.
singleton
;
}
}
process
User
Data
(
data
)
{
process
Assignee
Data
(
data
)
{
if
(
data
.
assignees
)
{
if
(
data
.
assignees
)
{
this
.
renderedUser
s
=
data
.
assignees
.
map
(
a
=>
{
this
.
assignee
s
=
data
.
assignees
.
map
(
a
=>
{
a
.
avatarUrl
=
a
.
avatar_url
;
a
.
avatarUrl
=
a
.
avatar_url
;
delete
a
.
avatar_url
;
delete
a
.
avatar_url
;
return
a
;
return
a
;
});
});
this
.
removeAllUserIds
();
this
.
renderedUsers
.
map
(
u
=>
this
.
addUserId
(
u
.
id
));
}
}
}
}
...
@@ -39,18 +35,23 @@ export default class SidebarStore {
...
@@ -39,18 +35,23 @@ export default class SidebarStore {
this
.
humanTimeSpent
=
data
.
human_time_spent
;
this
.
humanTimeSpent
=
data
.
human_time_spent
;
}
}
add
UserId
(
id
)
{
add
Assignee
(
assignee
)
{
// Prevent duplicate user id's from being added
if
(
!
this
.
findAssignee
(
assignee
))
{
if
(
this
.
selectedUserIds
.
indexOf
(
id
)
===
-
1
)
{
this
.
assignees
.
push
(
assignee
);
this
.
selectedUserIds
.
push
(
id
);
}
}
}
findAssignee
(
findAssignee
)
{
return
this
.
assignees
.
filter
(
assignee
=>
assignee
.
id
===
findAssignee
.
id
)[
0
];
}
}
removeUserId
(
id
)
{
removeAssignee
(
removeAssignee
)
{
this
.
selectedUserIds
=
this
.
selectedUserIds
.
filter
(
uid
=>
uid
!==
id
);
if
(
removeAssignee
)
{
this
.
assignees
=
this
.
assignees
.
filter
(
assignee
=>
assignee
.
id
!==
removeAssignee
.
id
);
}
}
}
removeAll
UserId
s
()
{
removeAll
Assignee
s
()
{
this
.
selectedUserId
s
=
[];
this
.
assignee
s
=
[];
}
}
}
}
app/assets/javascripts/users_select.js
View file @
0e53b116
...
@@ -277,7 +277,7 @@ import eventHub from './sidebar/event_hub';
...
@@ -277,7 +277,7 @@ import eventHub from './sidebar/event_hub';
defaultLabel
:
defaultLabel
,
defaultLabel
:
defaultLabel
,
hidden
:
function
(
e
)
{
hidden
:
function
(
e
)
{
if
(
$dropdown
.
hasClass
(
'
js-multiselect
'
))
{
if
(
$dropdown
.
hasClass
(
'
js-multiselect
'
))
{
eventHub
.
$emit
(
'
sidebar.save
User
s
'
);
eventHub
.
$emit
(
'
sidebar.save
Assignee
s
'
);
}
}
$selectbox
.
hide
();
$selectbox
.
hide
();
...
@@ -311,7 +311,9 @@ import eventHub from './sidebar/event_hub';
...
@@ -311,7 +311,9 @@ import eventHub from './sidebar/event_hub';
.
find
(
`input[name='
${
$dropdown
.
data
(
'
field-name
'
)}
'][value=
${
firstSelectedId
}
]`
);
.
find
(
`input[name='
${
$dropdown
.
data
(
'
field-name
'
)}
'][value=
${
firstSelectedId
}
]`
);
firstSelected
.
remove
();
firstSelected
.
remove
();
eventHub
.
$emit
(
'
sidebar.removeUser
'
,
firstSelectedId
);
eventHub
.
$emit
(
'
sidebar.removeAssignee
'
,
{
id
:
firstSelectedId
,
});
}
}
}
}
...
@@ -321,10 +323,10 @@ import eventHub from './sidebar/event_hub';
...
@@ -321,10 +323,10 @@ import eventHub from './sidebar/event_hub';
const
id
=
parseInt
(
element
.
value
,
10
);
const
id
=
parseInt
(
element
.
value
,
10
);
element
.
remove
();
element
.
remove
();
});
});
eventHub
.
$emit
(
'
sidebar.removeAll
User
s
'
);
eventHub
.
$emit
(
'
sidebar.removeAll
Assignee
s
'
);
}
else
if
(
isActive
)
{
}
else
if
(
isActive
)
{
// user selected
// user selected
eventHub
.
$emit
(
'
sidebar.add
User
'
,
user
.
id
);
eventHub
.
$emit
(
'
sidebar.add
Assignee
'
,
user
);
// Remove unassigned selection (if it was previously selected)
// Remove unassigned selection (if it was previously selected)
const
unassignedSelected
=
$dropdown
.
closest
(
'
.selectbox
'
)
const
unassignedSelected
=
$dropdown
.
closest
(
'
.selectbox
'
)
...
@@ -340,7 +342,7 @@ import eventHub from './sidebar/event_hub';
...
@@ -340,7 +342,7 @@ import eventHub from './sidebar/event_hub';
}
}
// User unselected
// User unselected
eventHub
.
$emit
(
'
sidebar.remove
User
'
,
user
.
id
);
eventHub
.
$emit
(
'
sidebar.remove
Assignee
'
,
user
);
}
}
}
}
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
0e53b116
...
@@ -219,7 +219,7 @@
...
@@ -219,7 +219,7 @@
gl
.
sidebarOptions
=
{
gl
.
sidebarOptions
=
{
endpoint
:
"
#{
issuable_json_path
(
issuable
)
}
"
,
endpoint
:
"
#{
issuable_json_path
(
issuable
)
}
"
,
editable
:
#{
can_edit_issuable
?
true
:
false
}
,
editable
:
#{
can_edit_issuable
?
true
:
false
}
,
currentUser
Id
:
#{
current_user
.
id
}
,
currentUser
:
#{
current_user
.
to_json
(
only:
[
:username
,
:id
,
:name
],
methods: :avatar_url
)
}
,
rootPath
:
"
#{
root_path
}
"
rootPath
:
"
#{
root_path
}
"
};
};
...
...
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