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
07ca3dc4
Commit
07ca3dc4
authored
Apr 12, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip ci] refactor to only use id
parent
6da80dbd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
69 deletions
+36
-69
app/assets/javascripts/gl_dropdown.js
app/assets/javascripts/gl_dropdown.js
+0
-6
app/assets/javascripts/sidebar_assignees/sidebar_assignees_options.js
...avascripts/sidebar_assignees/sidebar_assignees_options.js
+10
-13
app/assets/javascripts/sidebar_assignees/stores/sidebar_assignees_store.js
...ripts/sidebar_assignees/stores/sidebar_assignees_store.js
+23
-36
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+1
-7
app/assets/stylesheets/framework/avatar.scss
app/assets/stylesheets/framework/avatar.scss
+1
-1
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-6
No files found.
app/assets/javascripts/gl_dropdown.js
View file @
07ca3dc4
...
...
@@ -727,12 +727,6 @@ GitLabDropdown = (function() {
$input
.
attr
(
'
id
'
,
this
.
options
.
inputId
);
}
if
(
this
.
options
.
saveUserDataToInput
)
{
$input
.
attr
(
'
data-name
'
,
selectedObject
.
name
);
$input
.
attr
(
'
data-username
'
,
selectedObject
.
username
);
$input
.
attr
(
'
data-avatar-url
'
,
selectedObject
.
avatar_url
);
}
return
this
.
dropdown
.
before
(
$input
);
};
...
...
app/assets/javascripts/sidebar_assignees/sidebar_assignees_options.js
View file @
07ca3dc4
/* global Flash */
import
Vue
from
'
vue
'
;
import
eventHub
from
'
./event_hub
'
;
...
...
@@ -23,16 +25,11 @@ export default {
const
path
=
element
.
dataset
.
path
;
const
field
=
element
.
dataset
.
field
;
const
editable
=
element
.
hasAttribute
(
'
data-editable
'
);
const
currentUser
=
{
id
:
parseInt
(
element
.
dataset
.
userId
,
10
),
name
:
element
.
dataset
.
userName
,
username
:
element
.
dataset
.
userUserName
,
avatarUrl
:
element
.
dataset
.
avatar_url
,
};
const
currentUserId
=
parseInt
(
element
.
dataset
.
userId
,
10
);
const
service
=
new
SidebarAssigneesService
(
path
,
field
);
const
store
=
new
SidebarAssigneesStore
({
currentUser
,
currentUser
Id
,
rootPath
,
editable
,
assignees
:
gl
.
sidebarAssigneesData
,
...
...
@@ -50,14 +47,14 @@ export default {
},
created
()
{
eventHub
.
$on
(
'
addCurrentUser
'
,
this
.
addCurrentUser
);
eventHub
.
$on
(
'
addUser
'
,
this
.
store
.
addUser
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
removeUser
'
,
this
.
store
.
removeUser
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
removeAllUsers
'
,
this
.
store
.
removeAllUsers
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
addUser
'
,
this
.
store
.
addUser
Id
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
removeUser
'
,
this
.
store
.
removeUser
Id
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
removeAllUsers
'
,
this
.
store
.
removeAllUser
Id
s
.
bind
(
this
.
store
));
eventHub
.
$on
(
'
saveUsers
'
,
this
.
saveUsers
);
},
methods
:
{
addCurrentUser
()
{
this
.
store
.
addCurrentUser
();
this
.
store
.
addCurrentUser
Id
();
this
.
saveUsers
();
},
saveUsers
()
{
...
...
@@ -65,7 +62,7 @@ export default {
this
.
service
.
update
(
this
.
store
.
getUserIds
())
.
then
((
response
)
=>
{
this
.
store
.
loading
=
false
;
this
.
store
.
s
ave
Users
(
response
.
data
.
assignees
);
this
.
store
.
s
et
Users
(
response
.
data
.
assignees
);
}).
catch
(()
=>
{
this
.
store
.
loading
=
false
;
return
new
Flash
(
'
An error occured while saving assignees
'
,
'
alert
'
);
...
...
@@ -82,7 +79,7 @@ export default {
template
:
`
<div>
<assignee-title
:numberOfAssignees="store.users.length"
:numberOfAssignees="store.user
Id
s.length"
:loading="store.loading"
:editable="store.editable"
/>
...
...
app/assets/javascripts/sidebar_assignees/stores/sidebar_assignees_store.js
View file @
07ca3dc4
/* global Flash */
import
'
~/flash
'
;
export
default
class
SidebarAssigneesStore
{
constructor
(
store
)
{
const
{
currentUser
,
assignees
,
rootPath
,
editable
}
=
store
;
const
{
currentUser
Id
,
assignees
,
rootPath
,
editable
}
=
store
;
this
.
currentUser
=
currentUser
;
this
.
currentUser
Id
=
currentUserId
;
this
.
rootPath
=
rootPath
;
this
.
users
=
[];
this
.
user
Id
s
=
[];
this
.
loading
=
false
;
this
.
editable
=
editable
;
assignees
.
forEach
(
a
=>
this
.
addUser
(
this
.
destructUser
(
a
)));
this
.
setUsers
(
assignees
);
assignees
.
forEach
(
a
=>
this
.
addUserId
(
a
.
id
));
}
addUser
(
user
)
{
const
{
id
,
name
,
username
,
avatarUrl
}
=
user
;
this
.
users
.
push
({
id
,
name
,
username
,
avatarUrl
,
});
addUserId
(
id
)
{
this
.
userIds
.
push
(
id
);
}
addCurrentUser
(
)
{
this
.
addUser
(
this
.
currentUser
);
removeUserId
(
id
)
{
this
.
userIds
=
this
.
userIds
.
filter
(
uid
=>
uid
!==
id
);
}
remove
User
(
id
)
{
this
.
user
s
=
this
.
users
.
filter
(
u
=>
u
.
id
!==
id
)
;
remove
AllUserIds
(
)
{
this
.
user
Ids
=
[]
;
}
removeAllUsers
()
{
this
.
users
=
[]
;
addCurrentUserId
()
{
this
.
addUserId
(
this
.
currentUserId
)
;
}
getUserIds
()
{
const
ids
=
this
.
users
.
map
(
u
=>
u
.
id
);
// If there are no ids, that means we have to unassign (which is id = 0)
return
ids
.
length
>
0
?
ids
:
[
0
];
}
destructUser
(
u
)
{
return
{
id
:
u
.
id
,
name
:
u
.
name
,
username
:
u
.
username
,
avatarUrl
:
u
.
avatar_url
,
};
return
this
.
userIds
.
length
>
0
?
this
.
userIds
:
[
0
];
}
s
aveUsers
(
assignee
s
)
{
s
etUsers
(
user
s
)
{
this
.
users
=
[];
assignees
.
forEach
(
a
=>
this
.
addUser
(
this
.
destructUser
(
a
)));
users
.
forEach
((
u
)
=>
{
this
.
users
.
push
({
id
:
u
.
id
,
name
:
u
.
name
,
username
:
u
.
username
,
avatarUrl
:
u
.
avatar_url
,
});
});
}
}
app/assets/javascripts/users_select.js
View file @
07ca3dc4
...
...
@@ -264,7 +264,6 @@ import eventHub from './sidebar_assignees/event_hub';
return
$value
.
css
(
'
display
'
,
''
);
},
multiSelect
:
$dropdown
.
hasClass
(
'
js-multiselect
'
),
saveUserDataToInput
:
$dropdown
.
hasClass
(
'
js-save-user-data
'
),
vue
:
$dropdown
.
hasClass
(
'
js-issue-board-sidebar
'
),
clicked
:
function
(
user
,
$el
,
e
,
isMarking
)
{
if
(
$dropdown
.
hasClass
(
'
js-multiselect
'
))
{
...
...
@@ -281,12 +280,7 @@ import eventHub from './sidebar_assignees/event_hub';
eventHub
.
$emit
(
'
removeAllUsers
'
);
}
else
if
(
isActive
)
{
// user selected
eventHub
.
$emit
(
'
addUser
'
,
{
id
:
user
.
id
,
name
:
user
.
name
,
username
:
user
.
username
,
avatarUrl
:
user
.
avatar_url
});
eventHub
.
$emit
(
'
addUser
'
,
user
.
id
);
// Remove unassigned selection (if it was previously selected)
const
unassignedSelected
=
$dropdown
.
closest
(
'
.selectbox
'
)
...
...
app/assets/stylesheets/framework/avatar.scss
View file @
07ca3dc4
...
...
@@ -103,4 +103,4 @@
font-size
:
9px
;
line-height
:
16px
;
text-align
:
center
;
}
\ No newline at end of file
}
app/views/shared/issuable/_sidebar.html.haml
View file @
07ca3dc4
...
...
@@ -24,12 +24,7 @@
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
issuable
],
remote:
true
,
format: :json
,
html:
{
class:
'issuable-context-form inline-update js-issuable-update'
}
do
|
f
|
.block.assignee
-
if
issuable
.
instance_of?
(
Issue
)
#js-vue-sidebar-assignees
{
data:
{
path:
issuable_json_path
(
issuable
),
field:
"#{issuable.to_ability_name}[assignee_ids]"
,
'editable'
=>
can_edit_issuable
?
true
:
false
,
user:
{
id:
current_user
.
id
},
name:
current_user
.
name
,
username:
current_user
.
username
,
avatar_url:
current_user
.
avatar_url
,
root:
{
path:
root_path
}
}
}
.title.hide-collapsed
Assignee
=
icon
(
'spinner spin'
,
class:
'block-loading'
,
'aria-hidden'
:
'true'
)
-
if
can_edit_issuable
=
link_to
'Edit'
,
'#'
,
class:
'edit-link pull-right'
#js-vue-sidebar-assignees
{
data:
{
path:
issuable_json_path
(
issuable
),
field:
"#{issuable.to_ability_name}[assignee_ids]"
,
'editable'
=>
can_edit_issuable
?
true
:
false
,
user:
{
id:
current_user
.
id
},
root:
{
path:
root_path
}
}
}
-
content_for
:page_specific_javascripts
do
=
page_specific_javascript_bundle_tag
(
'sidebar_assignees'
)
:javascript
...
...
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