Use correct data attribute to avoid unnecessary data base calls

pull/7008/head
Henriette Dinger 6 years ago
parent b4103cf3ed
commit 30abc7fc76
  1. 1
      app/assets/stylesheets/content/_user.sass
  2. 7
      frontend/src/app/components/user/user-avatar/user-avatar.component.ts
  3. 2
      modules/avatars/lib/open_project/avatars/patches/avatar_helper_patch.rb
  4. 2
      modules/avatars/spec/helpers/avatar_helper_spec.rb

@ -39,6 +39,7 @@
vertical-align: -5px
&.avatar-default
line-height: 20px
font-size: 10px
.avatar-default

@ -76,7 +76,7 @@ export class UserAvatarComponent implements AfterViewInit {
public showUserAvatar() {
// When a user url is given,
// we have to get the information from the database
// we have to get the information from the database.
if (this.user) {
this.userID = WorkPackageResource.idFromLink(this.user);
this.userCacheService
@ -136,7 +136,10 @@ export class UserAvatarComponent implements AfterViewInit {
private isUserAGroup() {
// When an ID or an avatar is given, it must be a user.
// Otherwise we have to check the url
return !this.userID && !this.userAvatar && this.user.includes('group');
return !this.userID &&
!this.userAvatar &&
!!this.user &&
this.user.includes('group');
}
}

@ -142,7 +142,7 @@ AvatarHelper.class_eval do
content_tag 'user-avatar',
'',
'data-class-list': tag_options[:class],
'data-user': ::API::V3::Utilities::PathHelper::ApiV3Path.user(user.id),
'data-user-name': user.name,
'data-use-fallback': 'true'
end

@ -36,7 +36,7 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
def default_expected_user_avatar_tag(user)
tag_options = { 'data-use-fallback': "true",
'data-user': ::API::V3::Utilities::PathHelper::ApiV3Path.user(user.id),
'data-user-name': user.name,
'data-class-list': 'avatar avatar-default' }
content_tag 'user-avatar', '', tag_options

Loading…
Cancel
Save