Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[36243][30226] Different avatars for placeholders and groups (#9169)

Oliver Günther6dc662b1e41e
diff --git a/Gemfile.lock b/Gemfile.lock
index 0028d16f93f..eca21da90e9 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -35,6 +35,12 @@ GIT
mixlib-shellout (~> 2.1.0)
rubyzip
+PATH
+ remote: ../ownplugins/openproject-proto_plugin
+ specs:
+ openproject-proto_plugin (7.1.0)
+ rails (~> 6.0)
+
PATH
remote: modules/auth_plugins
specs:
@@ -1036,6 +1042,7 @@ DEPENDENCIES
openproject-meeting!
openproject-openid_connect!
openproject-pdf_export!
+ openproject-proto_plugin!
openproject-recaptcha!
openproject-reporting!
openproject-token (~> 2.1.1)
diff --git a/app/cells/members/row_cell.rb b/app/cells/members/row_cell.rb
index 7942f6d27e1..3f4fc07a2ad 100644
--- a/app/cells/members/row_cell.rb
+++ b/app/cells/members/row_cell.rb
@@ -18,7 +18,7 @@ module Members
end
def name
- icon = avatar principal, class: 'avatar-mini'
+ icon = avatar principal, size: :mini
icon + principal_link
end
diff --git a/app/cells/users/row_cell.rb b/app/cells/users/row_cell.rb
index 361de57e769..709555fb83a 100644
--- a/app/cells/users/row_cell.rb
+++ b/app/cells/users/row_cell.rb
@@ -15,7 +15,7 @@ module Users
end
def login
- icon = avatar user, class: 'avatar-mini'
+ icon = avatar user, size: :mini
link = link_to h(user.login), edit_user_path(user)
icon + link
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 7fe620ab050..bee1abe66e8 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -99,7 +99,9 @@ class MembersController < ApplicationController
(@principals | @project.principals)
respond_to do |format|
- format.json
+ format.json do
+ render json: build_members
+ end
end
end
@@ -109,6 +111,23 @@ class MembersController < ApplicationController
current_user.allowed_to?({ controller: controller, action: action }, @project)
end
+ def build_members
+ paths = API::V3::Utilities::PathHelper::ApiV3Path
+ principals = @principals.map do |principal|
+ {
+ id: principal.id,
+ name: principal.name,
+ href: paths.send(principal.type.underscore, principal.id)
+ }
+ end
+
+ if @email
+ principals << { id: @email, name: I18n.t('members.invite_by_mail', mail: @email) }
+ end
+
+ principals
+ end
+
def members_table_options(roles)
{
project: @project,
diff --git a/app/views/homescreen/blocks/_news.html.erb b/app/views/homescreen/blocks/_news.html.erb
index d91d2f25b04..285e3917891 100644
--- a/app/views/homescreen/blocks/_news.html.erb
+++ b/app/views/homescreen/blocks/_news.html.erb
@@ -4,7 +4,7 @@
<% @news.each do |news| %>
<li class="-widget-box--arrow-multiline">
<div>
- <%= avatar(news.author, {class: 'avatar news-author-avatar hidden-for-mobile'}) %>
+ <%= avatar(news.author, class: 'news-author-avatar hidden-for-mobile') %>
<div class="news-project">
<%= link_to_project(news.project) + ': ' %>
<%= link_to h(news.title), news_path(news) %>
diff --git a/app/views/members/autocomplete_for_member.json.erb b/app/views/members/autocomplete_for_member.json.erb
deleted file mode 100644
index ad3fc0d471b..00000000000
--- a/app/views/members/autocomplete_for_member.json.erb
+++ /dev/null
@@ -1,56 +0,0 @@
-<%#-- copyright
-OpenProject is an open source project management software.
-Copyright (C) 2012-2021 the OpenProject GmbH
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 3.
-
-OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-Copyright (C) 2006-2013 Jean-Philippe Lang
-Copyright (C) 2010-2013 the ChiliProject Team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-See docs/COPYRIGHT.rdoc for more details.
-
-++#%>
-
-<%#
- Lists found users (principals) to be used for the select box.
- If the user enters an email address, a 'result' in the form of
- 'Invite: <email>' will be returned.
-#%>
-
-{
- "results":
- {
- "items":[
- <% @principals.each_with_index do |principal, ix| %>
- {
- "id": <%= principal.id.to_json.html_safe %>,
- "name": <%= principal.name.to_json.html_safe %>
- } <%= "," unless !@email && ix == @principals.length - 1 %>
- <% end %>
- <% if @email %>
- {
- "id": "<%= @email %>",
- "name": "Invite <%= @email %>"
- }
- <% end %>
- ],
- "total": <%= @total ? @total : @principals.size %>,
- "more": <%= @more ? @more : 0 %>
-}
-}
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2e013460db5..7b3d8a6493e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -255,6 +255,7 @@ en:
index:
no_results_title_text: There are currently no members part of this project.
no_results_content_text: Add a member to the project
+ invite_by_mail: "Send invite to %{mail}"
my:
access_token:
diff --git a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts
index 3dab225d2fa..d044b703fda 100644
--- a/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts
+++ b/frontend/src/app/ckeditor/ckeditor-augmented-textarea.component.ts
@@ -170,7 +170,7 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
resource!.attachments.elements,
(attachment:HalResource) => attachment.id);
- const removedUrls = missingAttachments.map(attachment => attachment.downloadLocation.$href);
+ const removedUrls = missingAttachments.map(attachment => attachment.downloadLocation.href);
if (removedUrls.length) {
editor.model.fire('op:attachment-removed', removedUrls);
diff --git a/frontend/src/app/components/angular/tracking-functions.ts b/frontend/src/app/components/angular/tracking-functions.ts
index c47780cadf1..718fe9db5b7 100644
--- a/frontend/src/app/components/angular/tracking-functions.ts
+++ b/frontend/src/app/components/angular/tracking-functions.ts
@@ -2,7 +2,7 @@ import { HalResource } from 'core-app/modules/hal/resources/hal-resource';
export namespace AngularTrackingHelpers {
export function halHref<T extends HalResource>(_index:number, item:T):string|null {
- return item.$href;
+ return item.href;
}
export function compareByName<T extends HalResource>(a:T|undefined|null, b:T|undefined|null):boolean {
@@ -43,7 +43,7 @@ export namespace AngularTrackingHelpers {
export function compareByHref<T extends HalResource>(a:T|undefined|null, b:T|undefined|null):boolean {
const bothNil = !a && !b;
- return bothNil || (!!a && !!b && a.$href === b.$href);
+ return bothNil || (!!a && !!b && a.href === b.href);
}
export function compareByHrefOrString<T extends HalResource>(a:T|string|undefined|null, b:T|string|undefined|null):boolean {
diff --git a/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts b/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
index 7a4f7a6b4d8..acfa348d20d 100644
--- a/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
+++ b/frontend/src/app/components/filters/filter-searchable-multiselect-value/filter-searchable-multiselect-value.component.ts
@@ -102,7 +102,7 @@ export class FilterSearchableMultiselectValueComponent extends UntilDestroyedMix
public loadAvailable(matching:string):Observable<HalResource[]> {
const filters:ApiV3FilterBuilder = this.createFilters(matching);
- const href = (this.filter.currentSchema!.values!.allowedValues as any).$href;
+ const href = (this.filter.currentSchema!.values!.allowedValues as any).href;
const filteredData = (this.apiV3Service.collectionFromString(href) as
APIv3ResourceCollection<HalResource, CachableAPIV3Resource>)
diff --git a/frontend/src/app/components/filters/filter-toggled-multiselect-value/filter-toggled-multiselect-value.component.ts b/frontend/src/app/components/filters/filter-toggled-multiselect-value/filter-toggled-multiselect-value.component.ts
index 3df580c53c5..69105297f93 100644
--- a/frontend/src/app/components/filters/filter-toggled-multiselect-value/filter-toggled-multiselect-value.component.ts
+++ b/frontend/src/app/components/filters/filter-toggled-multiselect-value/filter-toggled-multiselect-value.component.ts
@@ -163,7 +163,7 @@ export class FilterToggledMultiselectValueComponent implements OnInit, AfterView
}
private addMeValue(currentUser:UserResource) {
- if (!(currentUser && currentUser.$href)) {
+ if (!(currentUser && currentUser.href)) {
return;
}
diff --git a/frontend/src/app/components/wp-activity/user/user-activity.component.html b/frontend/src/app/components/wp-activity/user/user-activity.component.html
index e17b6cede32..8ae39cc1007 100644
--- a/frontend/src/app/components/wp-activity/user/user-activity.component.html
+++ b/frontend/src/app/components/wp-activity/user/user-activity.component.html
@@ -1,16 +1,19 @@
-<div class="work-package-details-activities-activity-contents"
+<div class="op-user-activity work-package-details-activities-activity-contents"
*ngIf="workPackage"
(mouseenter)="focus()"
(mouseleave)="blur()">
- <op-principal
- *ngIf="userName"
- [principal]="user"
- [hide-name]="true"
- ></op-principal>
- <span class="user">
- <user-link [user]="user"></user-link>
- </span>
+ <div class="op-user-activity--user-line">
+ <op-principal
+ *ngIf="userName"
+ [principal]="user"
+ [hide-name]="true"
+ ></op-principal>
+
+ <span class="user">
+ <user-link [user]="user"></user-link>
+ </span>
+ </div>
<span class="date">
{{ isInitial ? text.label_created_on : text.label_updated_on }}
<op-date-time [dateTimeValue]="activity.createdAt"></op-date-time>
diff --git a/frontend/src/app/components/wp-activity/user/user-activity.component.sass b/frontend/src/app/components/wp-activity/user/user-activity.component.sass
new file mode 100644
index 00000000000..0182a9a38ad
--- /dev/null
+++ b/frontend/src/app/components/wp-activity/user/user-activity.component.sass
@@ -0,0 +1,3 @@
+.op-user-activity
+ &--user-line
+ display: flex
\ No newline at end of file
diff --git a/frontend/src/app/components/wp-activity/user/user-activity.component.ts b/frontend/src/app/components/wp-activity/user/user-activity.component.ts
index 1397baabaff..0b3f7d0f4ac 100644
--- a/frontend/src/app/components/wp-activity/user/user-activity.component.ts
+++ b/frontend/src/app/components/wp-activity/user/user-activity.component.ts
@@ -51,7 +51,8 @@ import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
@Component({
selector: 'user-activity',
changeDetection: ChangeDetectionStrategy.OnPush,
- templateUrl: './user-activity.component.html'
+ templateUrl: './user-activity.component.html',
+ styleUrls: ['./user-activity.component.sass']
})
export class UserActivityComponent extends WorkPackageCommentFieldHandler implements OnInit {
@Input() public workPackage:WorkPackageResource;
diff --git a/frontend/src/app/components/wp-edit-form/work-package-filter-values.ts b/frontend/src/app/components/wp-edit-form/work-package-filter-values.ts
index 5333c0c91b4..2193dbd8a49 100644
--- a/frontend/src/app/components/wp-edit-form/work-package-filter-values.ts
+++ b/frontend/src/app/components/wp-edit-form/work-package-filter-values.ts
@@ -102,7 +102,7 @@ export class WorkPackageFilterValues {
return value;
}
- if (value instanceof HalResource && value.$href === '/api/v3/users/me' && this.currentUser.isLoggedIn) {
+ if (value instanceof HalResource && value.href === '/api/v3/users/me' && this.currentUser.isLoggedIn) {
return this.halResourceService.fromSelfLink(`/api/v3/users/${this.currentUser.userId}`);
}
diff --git a/frontend/src/app/components/wp-fast-table/builders/modes/grouped/group-sums-builder.ts b/frontend/src/app/components/wp-fast-table/builders/modes/grouped/group-sums-builder.ts
index 909a9b13098..30e64debf38 100644
--- a/frontend/src/app/components/wp-fast-table/builders/modes/grouped/group-sums-builder.ts
+++ b/frontend/src/app/components/wp-fast-table/builders/modes/grouped/group-sums-builder.ts
@@ -51,7 +51,7 @@ export class GroupSumsBuilder extends SingleRowBuilder {
private get sumsSchema():SchemaResource {
// The schema is ensured to be loaded by wpViewAdditionalElementsService
const results = this.querySpace.results.value!;
- const href = results.sumsSchema!.$href!;
+ const href = results.sumsSchema!.href!;
return this.schemaCache.state(href).value!;
}
diff --git a/frontend/src/app/components/wp-fast-table/builders/modes/grouped/grouped-render-pass.ts b/frontend/src/app/components/wp-fast-table/builders/modes/grouped/grouped-render-pass.ts
index 248414fa594..eb2f3cc5261 100644
--- a/frontend/src/app/components/wp-fast-table/builders/modes/grouped/grouped-render-pass.ts
+++ b/frontend/src/app/components/wp-fast-table/builders/modes/grouped/grouped-render-pass.ts
@@ -80,8 +80,8 @@ export class GroupedRenderPass extends PlainRenderPass {
//// If its a linked resource, compare the href,
//// which is an array of links the resource offers
- if (property && property.$href) {
- return !!_.find(group._links.valueLink, (l:any):any => property.$href === l.href);
+ if (property && property.href) {
+ return !!_.find(group._links.valueLink, (l:any):any => property.href === l.href);
}
// Otherwise, fall back to simple value comparison.
diff --git a/frontend/src/app/components/wp-list/wp-list-invalid-query.service.ts b/frontend/src/app/components/wp-list/wp-list-invalid-query.service.ts
index 8d43c032c5a..e445aeadf41 100644
--- a/frontend/src/app/components/wp-list/wp-list-invalid-query.service.ts
+++ b/frontend/src/app/components/wp-list/wp-list-invalid-query.service.ts
@@ -53,7 +53,7 @@ export class WorkPackagesListInvalidQueryService {
private restoreFilters(query:QueryResource, payload:QueryResource, querySchema:SchemaResource) {
let filters = _.map((payload.filters), filter => {
const filterInstanceSchema = _.find(querySchema.filtersSchemas.elements, (schema:QueryFilterInstanceSchemaResource) => {
- return (schema.filter.allowedValues as QueryFilterResource[])[0].$href === filter.filter.$href;
+ return (schema.filter.allowedValues as QueryFilterResource[])[0].href === filter.filter.href;
});
if (!filterInstanceSchema) {
@@ -63,7 +63,7 @@ export class WorkPackagesListInvalidQueryService {
const recreatedFilter = filterInstanceSchema.getFilter();
const operator = _.find(filterInstanceSchema.operator.allowedValues, operator => {
- return operator.$href === filter.operator.$href;
+ return operator.href === filter.operator.href;
});
if (operator) {
@@ -86,7 +86,7 @@ export class WorkPackagesListInvalidQueryService {
private restoreColumns(query:QueryResource, stubQuery:QueryResource, schema:SchemaResource) {
let columns = _.map(stubQuery.columns, column => {
return _.find((schema.columns.allowedValues as QueryColumn[]), candidate => {
- return candidate.$href === column.$href;
+ return candidate.href === column.href;
});
});
@@ -99,7 +99,7 @@ export class WorkPackagesListInvalidQueryService {
private restoreSortBy(query:QueryResource, stubQuery:QueryResource, schema:SchemaResource) {
let sortBys = _.map((stubQuery.sortBy), sortBy => {
return _.find((schema.sortBy.allowedValues as QuerySortByResource[]), candidate => {
- return candidate.$href === sortBy.$href;
+ return candidate.href === sortBy.href;
})!;
});
@@ -111,7 +111,7 @@ export class WorkPackagesListInvalidQueryService {
private restoreGroupBy(query:QueryResource, stubQuery:QueryResource, schema:SchemaResource) {
const groupBy = _.find((schema.groupBy.allowedValues as QueryGroupByResource[]), candidate => {
- return stubQuery.groupBy && stubQuery.groupBy.$href === candidate.$href;
+ return stubQuery.groupBy && stubQuery.groupBy.href === candidate.href;
}) as any;
query.groupBy = groupBy;
diff --git a/frontend/src/app/components/wp-list/wp-list.service.ts b/frontend/src/app/components/wp-list/wp-list.service.ts
index c17d1f5d479..caf68ef4104 100644
--- a/frontend/src/app/components/wp-list/wp-list.service.ts
+++ b/frontend/src/app/components/wp-list/wp-list.service.ts
@@ -275,7 +275,7 @@ export class WorkPackagesListService {
let id;
if (query.project) {
- id = query.project.$href!.split('/').pop();
+ id = query.project.href!.split('/').pop();
}
this.loadDefaultQuery(id);
@@ -337,7 +337,7 @@ export class WorkPackagesListService {
private conditionallyLoadForm(query:QueryResource):void {
const currentForm = this.querySpace.queryForm.value;
- if (!currentForm || query.$links.update.$href !== currentForm.$href) {
+ if (!currentForm || query.$links.update.href !== currentForm.href) {
setTimeout(() => this.loadForm(query), 0);
}
}
diff --git a/frontend/src/app/components/wp-list/wp-states-initialization.service.ts b/frontend/src/app/components/wp-list/wp-states-initialization.service.ts
index af2f2ce3b38..06a2802f095 100644
--- a/frontend/src/app/components/wp-list/wp-states-initialization.service.ts
+++ b/frontend/src/app/components/wp-list/wp-states-initialization.service.ts
@@ -62,6 +62,12 @@ export class WorkPackageStatesInitializationService {
this.querySpace.query.putValue(query);
this.initializeFromQuery(query, results);
+ // If the form is loaded, update it with the query
+ const form = this.querySpace.queryForm.value;
+ if (form) {
+ this.updateStatesFromForm(query, form);
+ }
+
// Update the (local) table states
this.updateQuerySpace(query, results);
@@ -79,7 +85,7 @@ export class WorkPackageStatesInitializationService {
const schema:QuerySchemaResource = form.schema as any;
_.each(schema.filtersSchemas.elements, (schema) => {
- this.states.schemas.get(schema.$href as string).putValue(schema as any);
+ this.states.schemas.get(schema.href as string).putValue(schema as any);
});
this.wpTableFilters.initializeFilters(query, schema);
diff --git a/frontend/src/app/components/wp-query/url-params-helper.spec.ts b/frontend/src/app/components/wp-query/url-params-helper.spec.ts
index 3ffc93cdbc9..fbbde0f61dd 100644
--- a/frontend/src/app/components/wp-query/url-params-helper.spec.ts
+++ b/frontend/src/app/components/wp-query/url-params-helper.spec.ts
@@ -71,7 +71,7 @@ describe('UrlParamsHelper', function() {
id: '='
},
filter: {
- $href: '/api/filter/soße'
+ href: '/api/filter/soße'
},
values: ['knoblauch']
};
@@ -82,7 +82,7 @@ describe('UrlParamsHelper', function() {
id: '<t-'
},
filter: {
- $href: '/api/filter/created_at'
+ href: '/api/filter/created_at'
},
values: ['5']
};
@@ -172,7 +172,7 @@ describe('UrlParamsHelper', function() {
id: '='
},
filter: {
- $href: '/api/filter/soße'
+ href: '/api/filter/soße'
},
values: ['knoblauch']
};
@@ -183,7 +183,7 @@ describe('UrlParamsHelper', function() {
id: '<t-'
},
filter: {
- $href: '/api/filter/created_at'
+ href: '/api/filter/created_at'
},
values: ['5']
};
@@ -254,18 +254,18 @@ describe('UrlParamsHelper', function() {
id: '='
},
filter: {
- $href: '/api/filter/customField1'
+ href: '/api/filter/customField1'
},
values: [
{
_type: "CustomOption",
value: "cde",
- $href: "/api/v3/custom_options/2"
+ href: "/api/v3/custom_options/2"
},
{
_type: "CustomOption",
value: "abc",
- $href: "/api/v3/custom_options/7"
+ href: "/api/v3/custom_options/7"
}
]
};
diff --git a/frontend/src/app/components/wp-query/url-params-helper.ts b/frontend/src/app/components/wp-query/url-params-helper.ts
index 23458092fc3..ecff13e5795 100644
--- a/frontend/src/app/components/wp-query/url-params-helper.ts
+++ b/frontend/src/app/components/wp-query/url-params-helper.ts
@@ -295,8 +295,8 @@ export class UrlParamsHelperService {
return '';
} else if (value.id) {
return value.id.toString();
- } else if (value.$href) {
- return value.$href.split('/').pop().toString();
+ } else if (value.href) {
+ return value.href.split('/').pop().toString();
} else {
return value.toString();
}
@@ -340,7 +340,7 @@ export class UrlParamsHelperService {
}
public buildV3GetFilterIdFromFilter(filter:QueryFilterInstanceResource) {
- const href = filter.filter ? filter.filter.$href : filter._links.filter.href;
+ const href = filter.filter ? filter.filter.href : filter._links.filter.href;
return this.idFromHref(href);
}
diff --git a/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.html b/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.html
index 66253793a20..fdcf2064376 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.html
+++ b/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.html
@@ -79,7 +79,7 @@
<label class="option-label" *ngFor="let availableDirection of availableDirections">
<input type="radio"
[(ngModel)]="sort.direction"
- [value]="availableDirection.$href"
+ [value]="availableDirection.href"
[textContent]="availableDirection.name"
name="modal-sorting-attribute-{{index}}--sort-direction">
{{ availableDirection.name }}
diff --git a/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.ts b/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.ts
index ff3e776d170..aa256a7382c 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.ts
+++ b/frontend/src/app/components/wp-table/configuration-modal/tabs/sort-by-tab.component.ts
@@ -41,8 +41,8 @@ export class WpTableConfigurationSortByTab implements TabComponent {
};
readonly availableDirections = [
- { $href: QUERY_SORT_BY_ASC, name: this.I18n.t('js.label_ascending') },
- { $href: QUERY_SORT_BY_DESC, name: this.I18n.t('js.label_descending') }
+ { href: QUERY_SORT_BY_ASC, name: this.I18n.t('js.label_ascending') },
+ { href: QUERY_SORT_BY_DESC, name: this.I18n.t('js.label_descending') }
];
public availableColumns:SortColumn[] = [];
@@ -77,11 +77,11 @@ export class WpTableConfigurationSortByTab implements TabComponent {
.subscribe(() => {
const allColumns:SortColumn[] = this.wpTableSortBy.available.filter(
(sort:QuerySortByResource) => {
- return !sort.column.$href!.endsWith('/parent');
+ return !sort.column.href!.endsWith('/parent');
}
).map(
(sort:QuerySortByResource) => {
- return { name: sort.column.name, href: sort.column.$href };
+ return { name: sort.column.name, href: sort.column.href };
}
);
@@ -92,10 +92,10 @@ export class WpTableConfigurationSortByTab implements TabComponent {
this.getManualSortingOption();
_.each(this.wpTableSortBy.current, sort => {
- if (!sort.column.$href!.endsWith('/parent')) {
+ if (!sort.column.href!.endsWith('/parent')) {
this.sortationObjects.push(
- new SortModalObject({ name: sort.column.name, href: sort.column.$href },
- sort.direction.$href!)
+ new SortModalObject({ name: sort.column.name, href: sort.column.href },
+ sort.direction.href!)
);
if (sort.column.href === this.manualSortColumn.href) {
this.updateSortingMode('manual');
@@ -127,7 +127,7 @@ export class WpTableConfigurationSortByTab implements TabComponent {
private getMatchingSort(column:string, direction:string) {
return _.find(this.wpTableSortBy.available, sort => {
- return sort.column.$href === column && sort.direction.$href === direction;
+ return sort.column.href === column && sort.direction.href === direction;
});
}
diff --git a/frontend/src/app/components/wp-table/sort-header/sort-header.directive.ts b/frontend/src/app/components/wp-table/sort-header/sort-header.directive.ts
index 7583f003283..030414faf77 100644
--- a/frontend/src/app/components/wp-table/sort-header/sort-header.directive.ts
+++ b/frontend/src/app/components/wp-table/sort-header/sort-header.directive.ts
@@ -102,7 +102,7 @@ export class SortHeaderDirective extends UntilDestroyedMixin implements AfterVie
.subscribe(() => {
const latestSortElement = this.wpTableSortBy.current[0];
- if (!latestSortElement || this.headerColumn.$href !== latestSortElement.column.$href) {
+ if (!latestSortElement || this.headerColumn.href !== latestSortElement.column.href) {
this.currentSortDirection = null;
} else {
this.currentSortDirection = latestSortElement.direction;
@@ -200,7 +200,7 @@ export class SortHeaderDirective extends UntilDestroyedMixin implements AfterVie
return '';
}
- switch (this.currentSortDirection.$href) {
+ switch (this.currentSortDirection.href) {
case QUERY_SORT_BY_ASC:
return 'asc';
case QUERY_SORT_BY_DESC:
diff --git a/frontend/src/app/components/wp-table/wp-table-sums-row/wp-table-sums-row.directive.ts b/frontend/src/app/components/wp-table/wp-table-sums-row/wp-table-sums-row.directive.ts
index 7d23c594682..3e876a03848 100644
--- a/frontend/src/app/components/wp-table/wp-table-sums-row/wp-table-sums-row.directive.ts
+++ b/frontend/src/app/components/wp-table/wp-table-sums-row/wp-table-sums-row.directive.ts
@@ -90,7 +90,7 @@ export class WorkPackageTableSumsRowController implements AfterViewInit {
this.isHidden = !sum;
if (sum && resource.sumsSchema) {
this.schemaCache
- .ensureLoaded(resource.sumsSchema.$href!)
+ .ensureLoaded(resource.sumsSchema.href!)
.then((schema:SchemaResource) => {
this.refresh(columns, resource, schema);
});
diff --git a/frontend/src/app/modules/apiv3/endpoints/queries/apiv3-query-form.ts b/frontend/src/app/modules/apiv3/endpoints/queries/apiv3-query-form.ts
index fd492ee1133..045e73ccce5 100644
--- a/frontend/src/app/modules/apiv3/endpoints/queries/apiv3-query-form.ts
+++ b/frontend/src/app/modules/apiv3/endpoints/queries/apiv3-query-form.ts
@@ -53,7 +53,7 @@ export class Apiv3QueryForm extends APIv3FormResource<QueryFormResource> {
if (query.project) {
payload['_links'] = {
'project': {
- 'href': query.project.$href
+ 'href': query.project.href
}
};
}
diff --git a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
index df9f10a90be..d93481bd9cb 100644
--- a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
+++ b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
@@ -12,6 +12,7 @@
[clearSearchOnAdd]="false"
[appendTo]="appendTo"
[hideSelected]="hideSelected"
+ [compareWith]="compareByHref"
[id]="id"
(change)="changeModel($event)"
(open)="opened()"
@@ -23,7 +24,16 @@
</ng-template>
<ng-template ng-option-tmp let-item="item" let-search="searchTerm">
- <div [ngOptionHighlight]="search" class="ng-option-label ellipsis">{{ item.name }}</div>
+ <op-principal
+ *ngIf="isPrincipal(item)"
+ [hide-name]="true"
+ [principal]="item"
+ size="mini"
+ ></op-principal>
+ <span [ngOptionHighlight]="search"
+ [textContent]="item.name"
+ class="ng-option-label ellipsis">
+ </span>
</ng-template>
<ng-template ng-footer-tmp *ngIf="showAddNewButton">
diff --git a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
index 30d163f584f..51643366af1 100644
--- a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
+++ b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
@@ -47,10 +47,12 @@ import { AddTagFn } from "@ng-select/ng-select/lib/ng-select.component";
import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
import { Subject } from 'rxjs';
+import { PrincipalHelper } from "core-app/modules/principal/principal-helper";
+import { AngularTrackingHelpers } from "core-components/angular/tracking-functions";
export interface CreateAutocompleterValueOption {
name:string;
- $href:string|null;
+ href:string|null;
}
@Component({
@@ -87,6 +89,7 @@ export class CreateAutocompleterComponent extends UntilDestroyedMixin implements
@InjectField() readonly currentProject:CurrentProjectService;
@InjectField() readonly pathHelper:PathHelperService;
+ public compareByHref = AngularTrackingHelpers.compareByHref;
public text:{ [key:string]:string } = {};
public createAllowed:boolean|AddTagFn = false;
private _openDirectly = false;
@@ -164,4 +167,8 @@ export class CreateAutocompleterComponent extends UntilDestroyedMixin implements
public focusInputField() {
this.ngSelectComponent && this.ngSelectComponent.focus();
}
+
+ public isPrincipal(item:CreateAutocompleterValueOption) {
+ return item.href && PrincipalHelper.typeFromHref(item.href) !== null;
+ }
}
diff --git a/frontend/src/app/modules/autocompleter/user-autocompleter/user-autocompleter.component.ts b/frontend/src/app/modules/autocompleter/user-autocompleter/user-autocompleter.component.ts
index 13a12a74de8..874e6ba39d8 100644
--- a/frontend/src/app/modules/autocompleter/user-autocompleter/user-autocompleter.component.ts
+++ b/frontend/src/app/modules/autocompleter/user-autocompleter/user-autocompleter.component.ts
@@ -41,6 +41,13 @@ import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
export const usersAutocompleterSelector = 'user-autocompleter';
+export interface UserAutocompleteItem {
+ name:string;
+ id:string|null;
+ href:string|null;
+}
+
+
@Component({
templateUrl: './user-autocompleter.component.html',
selector: usersAutocompleterSelector
@@ -64,7 +71,7 @@ export class UserAutocompleterComponent implements OnInit {
private updateInputField:HTMLInputElement|undefined;
/** Keep a switchmap for search term and loading state */
- public requests = new DebouncedRequestSwitchmap<string, {[key:string]:string|null}>(
+ public requests = new DebouncedRequestSwitchmap<string, UserAutocompleteItem>(
(searchTerm:string) => this.getAvailableUsers(this.url, searchTerm),
errorNotificationHandler(this.halNotification)
);
@@ -141,7 +148,7 @@ export class UserAutocompleterComponent implements OnInit {
}
}
- protected getAvailableUsers(url:string, searchTerm:any):Observable<{[key:string]:string|null}[]> {
+ protected getAvailableUsers(url:string, searchTerm:any):Observable<UserAutocompleteItem[]> {
// Need to clone the filters to not add additional filters on every
// search term being processed.
const searchFilters = this.inputFilters.clone();
diff --git a/frontend/src/app/modules/boards/board/caused-updates/caused-updates.service.ts b/frontend/src/app/modules/boards/board/caused-updates/caused-updates.service.ts
index 3d24a683777..002a30013db 100644
--- a/frontend/src/app/modules/boards/board/caused-updates/caused-updates.service.ts
+++ b/frontend/src/app/modules/boards/board/caused-updates/caused-updates.service.ts
@@ -25,6 +25,6 @@ export class CausedUpdatesService {
}
private cacheValue(query:QueryResource) {
- return query.updatedAt + query.$href;
+ return query.updatedAt + query.href;
}
}
diff --git a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
index 8bfd51739aa..5fdfd3e77fd 100644
--- a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.ts
@@ -62,7 +62,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
private requestFocus = false;
ngOnInit() {
- this.nullOption = { name: this.text.placeholder, $href: null };
+ this.nullOption = { name: this.text.placeholder, href: null };
this.handler
.$onUserActivate
@@ -108,12 +108,12 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
public set selectedOption(val:ValueOption[]) {
this._selectedOption = val;
const mapper = (val:ValueOption) => {
- const option = _.find(this.availableOptions, o => o.$href === val.$href) || this.nullOption;
+ const option = _.find(this.availableOptions, o => o.href === val.href) || this.nullOption;
// Special case 'null' value, which angular
// only understands in ng-options as an empty string.
- if (option && option.$href === '') {
- option.$href = null;
+ if (option && option.href === '') {
+ option.href = null;
}
return option;
@@ -151,7 +151,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
let result;
if (option) {
- result = _.find(this.valueOptions, (valueOption) => valueOption.$href === option.$href)!;
+ result = _.find(this.valueOptions, (valueOption) => valueOption.href === option.href)!;
}
return result || this.nullOption;
@@ -168,7 +168,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
this.availableOptions = availableValues || [];
this.valueOptions = this.availableOptions.map(el => {
- return { name: el.name, $href: el.$href };
+ return { name: el.name, href: el.href };
});
this._selectedOption = this.buildSelectedOption();
this.checkCurrentValueValidity();
@@ -209,7 +209,7 @@ export class MultiSelectEditFieldComponent extends EditFieldComponent implements
// (If value AND)
// MultiSelect AND there is no value which href is not in the options hrefs
(!_.some(this.value, (value:HalResource) => {
- return _.some(this.availableOptions, (option) => (option.$href === value.$href));
+ return _.some(this.availableOptions, (option) => (option.href === value.href));
}))
);
} else {
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
index 9e14245a1f5..0e0984032c6 100644
--- a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
@@ -38,12 +38,12 @@ import { HalResourceNotificationService } from 'core-app/modules/hal/services/ha
import { InjectField } from 'core-app/helpers/angular/inject-field.decorator';
import { PermissionsService } from 'core-app/core/services/permissions/permissions.service';
import { CreateAutocompleterComponent } from "core-app/modules/autocompleter/create-autocompleter/create-autocompleter.component";
-import {EditFormComponent} from "core-app/modules/fields/edit/edit-form/edit-form.component";
-import {StateService} from "@uirouter/core";
+import { EditFormComponent } from "core-app/modules/fields/edit/edit-form/edit-form.component";
+import { StateService } from "@uirouter/core";
export interface ValueOption {
name:string;
- $href:string|null;
+ href:string|null;
}
@Component({
@@ -70,8 +70,8 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
onAfterViewInit: (component:CreateAutocompleterComponent) => this._autocompleterComponent = component
};
public get selectedOption() {
- const href = this.value ? this.value.$href : null;
- return _.find(this.valueOptions, o => o.$href === href)!;
+ const href = this.value ? this.value.href : null;
+ return _.find(this.valueOptions, o => o.href === href)!;
}
public set selectedOption(val:ValueOption|HalResource) {
// The InviteUserModal gives us a resource that is not in availableOptions yet,
@@ -82,12 +82,12 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
return;
}
- const option = _.find(this.availableOptions, o => o.$href === val.$href);
+ const option = _.find(this.availableOptions, o => o.href === val.href);
// Special case 'null' value, which angular
// only understands in ng-options as an empty string.
- if (option && option.$href === '') {
- option.$href = null;
+ if (option && option.href === '') {
+ option.href = null;
}
this.value = option;
@@ -213,12 +213,12 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
private addValue(val:HalResource) {
this.availableOptions.push(val);
- this.valueOptions.push({ name: val.name, $href: val.$href });
+ this.valueOptions.push({ name: val.name, href: val.href });
}
public get currentValueInvalid():boolean {
return !!(
- (this.value && !_.some(this.availableOptions, (option:HalResource) => (option.$href === this.value.$href)))
+ (this.value && !_.some(this.availableOptions, (option:HalResource) => (option.href === this.value.href)))
||
(!this.value && this.schema.required)
);
@@ -226,7 +226,7 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
public onCreate(newElement:HalResource) {
this.addValue(newElement);
- this.selectedOption = { name: newElement.name, $href: newElement.$href };
+ this.selectedOption = { name: newElement.name, href: newElement.href };
this.handler.handleUserSubmit();
}
@@ -267,7 +267,7 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
if (emptyOption === undefined) {
this.availableOptions.unshift({
name: this.text.placeholder,
- $href: ''
+ href: ''
});
}
}
@@ -281,7 +281,7 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
}
protected mapAllowedValue(value:HalResource):ValueOption {
- return { name: value.name, $href: value.$href };
+ return { name: value.name, href: value.href };
}
// Subclasses shall be able to override the filters with which the
diff --git a/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
index a76a4ecb189..8ed92b73c4e 100644
--- a/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/work-package-edit-field.component.ts
@@ -87,7 +87,7 @@ export class WorkPackageEditFieldComponent extends SelectEditFieldComponent {
return {
name: `${prefix}#${ (value as WorkPackageResource).id } ${suffix}`,
- $href: value.$href
+ href: value.href
};
} else {
return value;
diff --git a/frontend/src/app/modules/global_search/input/global-search-input.component.html b/frontend/src/app/modules/global_search/input/global-search-input.component.html
index f0e95fda53c..b1ce2e53e97 100644
--- a/frontend/src/app/modules/global_search/input/global-search-input.component.html
+++ b/frontend/src/app/modules/global_search/input/global-search-input.component.html
@@ -47,7 +47,7 @@
<op-principal
[hide-name]="true"
[principal]="item.author"
- class-list="avatar global-search-author-avatar hidden-for-mobile"
+ class="hidden-for-mobile"
></op-principal>
<span class="global-search--wp-subject">
diff --git a/frontend/src/app/modules/global_search/input/global-search-input.component.sass b/frontend/src/app/modules/global_search/input/global-search-input.component.sass
index 0a8c77a234d..e07856b3b78 100644
--- a/frontend/src/app/modules/global_search/input/global-search-input.component.sass
+++ b/frontend/src/app/modules/global_search/input/global-search-input.component.sass
@@ -140,9 +140,10 @@ $search-input-height: 30px
color: var(--body-font-color)
-.global-search-author-avatar
- margin-right: 5px
- float: left
+.global-search--option-wrapper
+ .op-avatar
+ margin-right: 5px
+ float: left
diff --git a/frontend/src/app/modules/global_search/input/global-search-input.component.ts b/frontend/src/app/modules/global_search/input/global-search-input.component.ts
index 76d0f4f546f..20acf4c4e61 100644
--- a/frontend/src/app/modules/global_search/input/global-search-input.component.ts
+++ b/frontend/src/app/modules/global_search/input/global-search-input.component.ts
@@ -62,7 +62,7 @@ interface SearchResultItem {
subject:string;
status:string;
statusId:string;
- $href:string;
+ href:string;
project:string;
author:HalResource;
}
@@ -302,7 +302,7 @@ export class GlobalSearchInputComponent implements OnInit, OnDestroy {
subject: wp.subject,
status: wp.status.name,
statusId: wp.status.idFromLink,
- $href: wp.$href,
+ href: wp.href,
project: wp.project.name,
author: wp.author
} as SearchResultItem;
diff --git a/frontend/src/app/modules/grids/widgets/news/news.component.html b/frontend/src/app/modules/grids/widgets/news/news.component.html
index 3d8367f4a74..04c214fd588 100644
--- a/frontend/src/app/modules/grids/widgets/news/news.component.html
+++ b/frontend/src/app/modules/grids/widgets/news/news.component.html
@@ -19,7 +19,7 @@
*ngIf="news.author"
[principal]="news.author"
[hide-name]="true"
- avatar-classes="avatar news-author-avatar hidden-for-mobile"
+ class="news-author-avatar hidden-for-mobile"
></op-principal>
<div>
<a [href]="newsProjectPath(news)"
diff --git a/frontend/src/app/modules/hal/resources/collection-resource.ts b/frontend/src/app/modules/hal/resources/collection-resource.ts
index 78a318d5168..2971287f724 100644
--- a/frontend/src/app/modules/hal/resources/collection-resource.ts
+++ b/frontend/src/app/modules/hal/resources/collection-resource.ts
@@ -40,7 +40,7 @@ export class CollectionResource<T = HalResource> extends HalResource {
* This is useful, as angular does not recognize update made by $load.
*/
public updateElements():Promise<unknown> {
- if (this.$href) {
+ if (this.href) {
return this.$load().then((collection:this) => this.elements = collection.elements);
} else {
return Promise.resolve();
diff --git a/frontend/src/app/modules/hal/resources/hal-resource.spec.ts b/frontend/src/app/modules/hal/resources/hal-resource.spec.ts
index 21ca6141998..411b328c4a3 100644
--- a/frontend/src/app/modules/hal/resources/hal-resource.spec.ts
+++ b/frontend/src/app/modules/hal/resources/hal-resource.spec.ts
@@ -68,7 +68,7 @@ describe('HalResource', () => {
it('should be instantiable using a default object', () => {
const resource = halResourceService.createHalResource({}, true);
- expect(resource.$href).toEqual(null);
+ expect(resource.href).toEqual(null);
});
describe('when updating a loaded resource using `$update()`', () => {
diff --git a/frontend/src/app/modules/hal/resources/hal-resource.ts b/frontend/src/app/modules/hal/resources/hal-resource.ts
index 5af355173c0..12d1bc5e08e 100644
--- a/frontend/src/app/modules/hal/resources/hal-resource.ts
+++ b/frontend/src/app/modules/hal/resources/hal-resource.ts
@@ -113,8 +113,8 @@ export class HalResource {
}
public get idFromLink():string {
- if (this.$href) {
- return HalResource.idFromLink(this.$href);
+ if (this.href) {
+ return HalResource.idFromLink(this.href);
}
return '';
@@ -130,8 +130,8 @@ export class HalResource {
* be printed nicely on console and in errors
*/
public toString() {
- if (this.$href) {
- return `[HalResource href=${this.$href}]`;
+ if (this.href) {
+ return `[HalResource href=${this.href}]`;
} else {
return `[HalResource id=${this.id}]`;
}
@@ -212,17 +212,10 @@ export class HalResource {
this._name = name;
}
- /**
- * Alias for $href.
- */
public get href():string|null {
return this.$link.href;
}
- public get $href():string|null {
- return this.$link.href;
- }
-
/**
* Return the associated state to this HAL resource, if any.
*/
diff --git a/frontend/src/app/modules/hal/resources/query-operator-resource.ts b/frontend/src/app/modules/hal/resources/query-operator-resource.ts
index 4f142637b6a..97981aa06e1 100644
--- a/frontend/src/app/modules/hal/resources/query-operator-resource.ts
+++ b/frontend/src/app/modules/hal/resources/query-operator-resource.ts
@@ -35,8 +35,8 @@ export class QueryOperatorResource extends HalResource {
}
public get idFromLink():string {
- if (this.$href) {
- const idPart = HalResource.idFromLink(this.$href);
+ if (this.href) {
+ const idPart = HalResource.idFromLink(this.href);
return decodeURIComponent(idPart);
}
diff --git a/frontend/src/app/modules/hal/resources/query-sort-by-resource.ts b/frontend/src/app/modules/hal/resources/query-sort-by-resource.ts
index 5ddc751c0da..757327e651d 100644
--- a/frontend/src/app/modules/hal/resources/query-sort-by-resource.ts
+++ b/frontend/src/app/modules/hal/resources/query-sort-by-resource.ts
@@ -48,6 +48,6 @@ export class QuerySortByResource extends HalResource {
*/
export class QuerySortByDirection extends HalResource {
public get id():string {
- return this.$href!.split('/').pop()!;
+ return this.href!.split('/').pop()!;
}
}
diff --git a/frontend/src/app/modules/hal/resources/relation-resource.ts b/frontend/src/app/modules/hal/resources/relation-resource.ts
index df7edd93d96..e1bce8d9cdf 100644
--- a/frontend/src/app/modules/hal/resources/relation-resource.ts
+++ b/frontend/src/app/modules/hal/resources/relation-resource.ts
@@ -92,7 +92,7 @@ export class RelationResource extends HalResource {
* @return {{id, href, relationType: string, workPackageType}}
*/
public denormalized(workPackage:WorkPackageResource):DenormalizedRelationData {
- const target = (this.to.href === workPackage.$href) ? 'from' : 'to';
+ const target = (this.to.href === workPackage.href) ? 'from' : 'to';
return {
target: this[target],
diff --git a/frontend/src/app/modules/hal/schemas/hal-payload.helper.ts b/frontend/src/app/modules/hal/schemas/hal-payload.helper.ts
index 4b760e350ff..912dbc0491c 100644
--- a/frontend/src/app/modules/hal/schemas/hal-payload.helper.ts
+++ b/frontend/src/app/modules/hal/schemas/hal-payload.helper.ts
@@ -69,11 +69,11 @@ export class HalPayloadHelper {
if (resource.$links[key]) {
if (Array.isArray(resource[key])) {
payload['_links'][key] = _.map(resource[key], element => {
- return { href: (element as HalResource).$href };
+ return { href: (element as HalResource).href };
});
} else {
payload['_links'][key] = {
- href: (resource[key] && resource[key].$href)
+ href: (resource[key] && resource[key].href)
};
}
} else {
diff --git a/frontend/src/app/modules/members/members-autocompleter.component.ts b/frontend/src/app/modules/members/members-autocompleter.component.ts
index cd184dc9ea0..0de318aab53 100644
--- a/frontend/src/app/modules/members/members-autocompleter.component.ts
+++ b/frontend/src/app/modules/members/members-autocompleter.component.ts
@@ -1,11 +1,13 @@
import { Observable } from "rxjs";
-import { map } from "rxjs/operators";
import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
import { HttpClient, HttpParams } from "@angular/common/http";
import { Component } from "@angular/core";
import { URLParamsEncoder } from "core-app/modules/hal/services/url-params-encoder";
import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
-import { UserAutocompleterComponent } from "core-app/modules/autocompleter/user-autocompleter/user-autocompleter.component";
+import {
+ UserAutocompleteItem,
+ UserAutocompleterComponent,
+} from "core-app/modules/autocompleter/user-autocompleter/user-autocompleter.component";
export const membersAutocompleterSelector = 'members-autocompleter';
@@ -17,22 +19,14 @@ export class MembersAutocompleterComponent extends UserAutocompleterComponent {
@InjectField() http:HttpClient;
@InjectField() pathHelper:PathHelperService;
- protected getAvailableUsers(url:string, searchTerm:any):Observable<{ [key:string]:string|null }[]> {
+ protected getAvailableUsers(url:string, searchTerm:any):Observable<UserAutocompleteItem[]> {
return this.http
- .get(url,
+ .get<UserAutocompleteItem[]>(url,
{
params: new HttpParams({ encoder: new URLParamsEncoder(), fromObject: { q: searchTerm } }),
responseType: 'json',
headers: { 'Content-Type': 'application/json; charset=utf-8' }
},
- )
- .pipe(
- map((res:any) => {
- return res.results.items.map((el:any) => {
- const href = /^\d+$/.test(el.id.toString()) ? this.pathHelper.userPath(el.id) : null;
- return { name: el.name, id: el.id, href: href };
- });
- })
);
}
}
diff --git a/frontend/src/app/modules/principal/principal-renderer.service.ts b/frontend/src/app/modules/principal/principal-renderer.service.ts
index b26c3a58121..41079dbc557 100644
--- a/frontend/src/app/modules/principal/principal-renderer.service.ts
+++ b/frontend/src/app/modules/principal/principal-renderer.service.ts
@@ -1,23 +1,22 @@
-import {Injectable} from "@angular/core";
-import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
-import {ColorsService} from "core-app/modules/common/colors/colors.service";
-import {APIV3Service} from "core-app/modules/apiv3/api-v3.service";
+import { Injectable } from "@angular/core";
+import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
+import { ColorsService } from "core-app/modules/common/colors/colors.service";
+import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
-import {PrincipalLike} from "./principal-types";
-import {PrincipalHelper} from "./principal-helper";
+import { PrincipalLike } from "./principal-types";
+import { PrincipalHelper } from "./principal-helper";
import PrincipalType = PrincipalHelper.PrincipalType;
export type AvatarSize = 'default'|'medium'|'mini';
export interface AvatarOptions {
- hide: boolean,
- size: AvatarSize,
- classes?: string,
+ hide:boolean;
+ size:AvatarSize;
}
export interface NameOptions {
- hide: boolean,
- link: boolean,
+ hide:boolean;
+ link:boolean;
}
@Injectable({ providedIn: 'root' })
@@ -29,17 +28,20 @@ export class PrincipalRendererService {
}
- renderMultiple(container:HTMLElement,
- users:PrincipalLike[],
- name: NameOptions = { hide: false, link: false },
- avatar:AvatarOptions = { hide: false, size: 'default' },
- multiLine:boolean = false) {
+ renderMultiple(
+ container:HTMLElement,
+ users:PrincipalLike[],
+ name:NameOptions = { hide: false, link: false },
+ avatar:AvatarOptions = { hide: false, size: 'default' },
+ multiLine:boolean = false,
+ ) {
+ container.classList.add('op-principal');
const list = document.createElement('span');
for (let i = 0; i < users.length; i++) {
const userElement = document.createElement('span');
if (multiLine) {
- userElement.classList.add('user-avatar--multi-line');
+ userElement.classList.add('op-principal--multi-line');
}
this.render(userElement, users[i], name, avatar);
@@ -59,11 +61,11 @@ export class PrincipalRendererService {
render(
container:HTMLElement,
principal:PrincipalLike,
- name: NameOptions = { hide: false, link: true },
+ name:NameOptions = { hide: false, link: true },
avatar:AvatarOptions = { hide: false, size: 'default' },
):void {
- const type = PrincipalHelper.typeFromHref(principal.href || '')!;
container.classList.add('op-principal');
+ const type = PrincipalHelper.typeFromHref(principal.href || '')!;
if (!avatar.hide) {
const el = this.renderAvatar(principal, avatar, type);
@@ -76,17 +78,19 @@ export class PrincipalRendererService {
}
}
- private renderAvatar(principal:PrincipalLike, options:AvatarOptions, type:PrincipalType) {
+ private renderAvatar(
+ principal:PrincipalLike,
+ options:AvatarOptions,
+ type:PrincipalType,
+ ) {
const userInitials = this.getInitials(principal.name);
const colorCode = this.colors.toHsl(principal.name);
- console.log('rendering avatar', options, userInitials);
-
- let fallback = document.createElement('div');
- fallback.className = options.classes || '';
- fallback.classList.add('avatar');
- fallback.classList.add(`avatar-${options.size}`);
- fallback.classList.add('avatar--fallback');
+ const fallback = document.createElement('div');
+ fallback.classList.add('op-avatar');
+ fallback.classList.add(`op-avatar_${options.size}`);
+ fallback.classList.add(`op-avatar_${type.replace('_', '-')}`);
+ fallback.classList.add('op-avatar--fallback');
fallback.textContent = userInitials;
fallback.style.background = colorCode;
@@ -100,9 +104,8 @@ export class PrincipalRendererService {
private renderUserAvatar(principal:PrincipalLike, fallback:HTMLElement, options:AvatarOptions) {
const image = new Image();
- image.className = options.classes || '';
- image.classList.add('avatar');
- image.classList.add(`avatar-${options.size}`);
+ image.classList.add('op-avatar');
+ image.classList.add(`op-avatar_${options.size}`);
image.src = this.apiV3Service.users.id(principal.id || '').avatar.toString();
image.title = principal.name;
image.alt = principal.name;
@@ -139,10 +142,10 @@ export class PrincipalRendererService {
}
private getInitials(name:string) {
- let characters = [...name];
- let lastSpace = name.lastIndexOf(' ');
- let first = characters[0]?.toUpperCase();
- let last = name[lastSpace + 1]?.toUpperCase();
+ const characters = [...name];
+ const lastSpace = name.lastIndexOf(' ');
+ const first = characters[0]?.toUpperCase();
+ const last = name[lastSpace + 1]?.toUpperCase();
return [first, last].join("");
}
diff --git a/frontend/src/app/modules/principal/principal.component.ts b/frontend/src/app/modules/principal/principal.component.ts
index 37426c56118..7813640686b 100644
--- a/frontend/src/app/modules/principal/principal.component.ts
+++ b/frontend/src/app/modules/principal/principal.component.ts
@@ -26,18 +26,15 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
-import {Component, ElementRef, Input, OnInit} from '@angular/core';
-import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
-import {PathHelperService} from 'core-app/modules/common/path-helper/path-helper.service';
-import {TimezoneService} from 'core-components/datetime/timezone.service';
-import {APIV3Service} from "core-app/modules/apiv3/api-v3.service";
+import { Component, ElementRef, Input, OnInit } from '@angular/core';
+import { I18nService } from 'core-app/modules/common/i18n/i18n.service';
+import { PathHelperService } from 'core-app/modules/common/path-helper/path-helper.service';
+import { TimezoneService } from 'core-components/datetime/timezone.service';
+import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
-import {
- PrincipalRendererService,
- AvatarSize,
-} from "./principal-renderer.service";
-import {PrincipalLike} from "./principal-types";
-import {PrincipalHelper} from "./principal-helper";
+import { AvatarSize, PrincipalRendererService } from "./principal-renderer.service";
+import { PrincipalLike } from "./principal-types";
+import { PrincipalHelper } from "./principal-helper";
import PrincipalPluralType = PrincipalHelper.PrincipalPluralType;
export const principalSelector = 'op-principal';
@@ -45,7 +42,6 @@ export const principalSelector = 'op-principal';
@Component({
template: '',
selector: principalSelector,
- host: {'class': 'op-principal'}
})
export class OpPrincipalComponent implements OnInit {
/** If coming from angular, pass a principal resource if available */
@@ -54,7 +50,6 @@ export class OpPrincipalComponent implements OnInit {
@Input('hide-name') hideName:boolean = false;
@Input() link:boolean = true;
@Input() size:AvatarSize = 'default';
- @Input('avatar-classes') avatarClasses:string = '';
public constructor(readonly elementRef:ElementRef,
readonly PathHelper:PathHelperService,
@@ -74,7 +69,6 @@ export class OpPrincipalComponent implements OnInit {
this.hideName = element.dataset.hideName === 'true';
this.link = element.dataset.link === 'true';
this.size = element.dataset.size ?? 'default';
- this.avatarClasses = element.dataset.avatarClasses ?? '';
}
this.principalRenderer.render(
@@ -86,8 +80,7 @@ export class OpPrincipalComponent implements OnInit {
},
{
hide: this.hideAvatar,
- size: this.size,
- classes: this.avatarClasses,
+ size: this.size
},
);
}
@@ -103,6 +96,6 @@ export class OpPrincipalComponent implements OnInit {
id,
name,
href,
- }
+ };
}
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
index d81d4a38178..5a675d84e8e 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
@@ -133,7 +133,7 @@ export class WorkPackageViewAdditionalElementsService {
if (results.sumsSchema) {
return this
.schemaCache
- .ensureLoaded(results.sumsSchema.$href!)
+ .ensureLoaded(results.sumsSchema.href!)
.then(() => []);
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
index 9d950275f92..7b03ac192fc 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service.ts
@@ -80,7 +80,7 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService<Q
public isSortable(column:QueryColumn):boolean {
return !!_.find(
this.available,
- (candidate) => candidate.column.$href === column.$href
+ (candidate) => candidate.column.href === column.href
);
}
@@ -103,14 +103,14 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService<Q
public findAvailableDirection(column:QueryColumn, direction:string):QuerySortByResource | undefined {
return _.find(
this.available,
- (candidate) => (candidate.column.$href === column.$href &&
- candidate.direction.$href === direction)
+ (candidate) => (candidate.column.href === column.href &&
+ candidate.direction.href === direction)
);
}
public add(sortBy:QuerySortByResource) {
const newValue = _
- .uniqBy([sortBy, ...this.current], sortBy => sortBy.column.$href)
+ .uniqBy([sortBy, ...this.current], sortBy => sortBy.column.href)
.slice(0, 3);
this.update(newValue);
@@ -159,7 +159,7 @@ export class WorkPackageViewSortByService extends WorkPackageQueryStateService<Q
private get manualSortObject() {
return _.find(this.available, sort => {
- return sort.column.$href!.endsWith('/manualSorting');
+ return sort.column.href!.endsWith('/manualSorting');
});
}
}
diff --git a/frontend/src/global_styles/content/_avatar.sass b/frontend/src/global_styles/content/_avatar.sass
new file mode 100644
index 00000000000..93697c5dc35
--- /dev/null
+++ b/frontend/src/global_styles/content/_avatar.sass
@@ -0,0 +1,47 @@
+.op-avatar
+ border-radius: var(--user-avatar-border-radius)
+ width: var(--user-avatar-width)
+ height: var(--user-avatar-height)
+ margin-right: 5px
+ color: white
+ display: inline-block
+ text-align: center
+ vertical-align: middle
+ cursor: inherit
+ user-select: none
+
+ // Fallback avatar if no img tag gets rendered
+ &--fallback
+ max-width: none
+
+ // Default size
+ line-height: 34px
+ font-size: 16px
+ background-color: var(--user-avatar-default-bg-color)
+
+ &_mini
+ border-radius: var(--user-avatar-mini-border-radius)
+ width: var(--user-avatar-mini-width)
+ height: var(--user-avatar-mini-height)
+ margin-right: 10px -5px
+ line-height: var(--user-avatar-mini-height)
+ font-size: 10px
+
+ &_medium
+ border-radius: var(--user-avatar-medium-border-radius)
+ width: var(--user-avatar-medium-width)
+ height: var(--user-avatar-medium-height)
+ line-height: var(--user-avatar-medium-height)
+ font-size: 13px
+ vertical-align: inherit
+
+
+ // Different border styling for placeholders
+ &_placeholder-user
+ border: 1px dashed
+ background: none
+
+ // Different border styling for groups
+ &_group
+ border: 1px solid white
+ box-shadow: 4px 0px 0px -1px #cccccc
\ No newline at end of file
diff --git a/frontend/src/global_styles/content/_index.sass b/frontend/src/global_styles/content/_index.sass
index aa8bb1ab1cc..39657b39705 100644
--- a/frontend/src/global_styles/content/_index.sass
+++ b/frontend/src/global_styles/content/_index.sass
@@ -1,5 +1,6 @@
@import accounts
@import accounts_mobile
+@import avatar
@import augmented
@import badges
@import blockquotes
@@ -44,6 +45,7 @@
@import user
@import journal
@import pagination
+@import principal
@import progress_bar
@import request_for_confirmation
@import form_error_messages
diff --git a/frontend/src/global_styles/content/_news.sass b/frontend/src/global_styles/content/_news.sass
index d8625e640ef..95caa437fb6 100644
--- a/frontend/src/global_styles/content/_news.sass
+++ b/frontend/src/global_styles/content/_news.sass
@@ -44,11 +44,11 @@
line-height: 1.25
.news-author-avatar
- margin-right: 5px
- float: left
-
-.news-project
line-height: 1
+ .op-avatar
+ margin-right: 5px
+ float: left
+
@media screen and (max-width: 679px)
.news-author
diff --git a/frontend/src/global_styles/content/_principal.sass b/frontend/src/global_styles/content/_principal.sass
new file mode 100644
index 00000000000..667c913203c
--- /dev/null
+++ b/frontend/src/global_styles/content/_principal.sass
@@ -0,0 +1,5 @@
+.op-principal
+ &--multi-line
+ display: block
+ margin-bottom: 2px
+
diff --git a/frontend/src/global_styles/content/_user.sass b/frontend/src/global_styles/content/_user.sass
index 0a9fcb8174b..f6107810ca9 100644
--- a/frontend/src/global_styles/content/_user.sass
+++ b/frontend/src/global_styles/content/_user.sass
@@ -26,38 +26,6 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
-.avatar, .gravatar
- border-radius: var(--user-avatar-border-radius)
- width: var(--user-avatar-width)
- height: var(--user-avatar-height)
- color: white
- display: inline-block
- text-align: center
- vertical-align: middle
- cursor: inherit
- user-select: none
-
- // Default size
- line-height: 34px
- font-size: 16px
- background-color: var(--user-avatar-default-bg-color)
-
-.avatar-mini
- border-radius: var(--user-avatar-mini-border-radius)
- width: var(--user-avatar-mini-width)
- height: var(--user-avatar-mini-height)
- margin-right: 10px -5px
- line-height: var(--user-avatar-mini-height)
- font-size: 10px
-
-.avatar-medium
- border-radius: var(--user-avatar-medium-border-radius)
- width: var(--user-avatar-medium-width)
- height: var(--user-avatar-medium-height)
- line-height: var(--user-avatar-medium-height)
- font-size: 13px
- vertical-align: inherit
-
h1, h2, h3, h4
op-principal
vertical-align: middle
diff --git a/frontend/src/global_styles/content/modules/_avatars.sass b/frontend/src/global_styles/content/modules/_avatars.sass
index 79b22a606af..6780b2147c3 100644
--- a/frontend/src/global_styles/content/modules/_avatars.sass
+++ b/frontend/src/global_styles/content/modules/_avatars.sass
@@ -18,14 +18,3 @@
.avatars--error-pane
color: var(--content-form-error-color)
font-weight: bold
-
-.avatar--fallback,
-.avatar-default
- margin-right: 5px
-
-.avatar--fallback
- max-width: none
-
-.user-avatar--multi-line
- display: block
- margin-bottom: 2px
\ No newline at end of file
diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb
index f406f488ac5..4d8838b3ce3 100644
--- a/lib/redmine/menu_manager/top_menu_helper.rb
+++ b/lib/redmine/menu_manager/top_menu_helper.rb
@@ -88,7 +88,7 @@ module Redmine::MenuManager::TopMenuHelper
end
def render_user_drop_down(items)
- avatar = avatar(User.current, class: 'op-app-header--avatar')
+ avatar = avatar User.current
render_menu_dropdown_with_items(
label: avatar.presence || '',
label_options: {
diff --git a/modules/avatars/app/views/avatars/users/_gravatars.html.erb b/modules/avatars/app/views/avatars/users/_gravatars.html.erb
index 17b77f69b9a..72156dccab7 100644
--- a/modules/avatars/app/views/avatars/users/_gravatars.html.erb
+++ b/modules/avatars/app/views/avatars/users/_gravatars.html.erb
@@ -4,7 +4,7 @@
<%= t 'avatars.text_your_current_gravatar' %>
</p>
<div class="avatars--current-gravatar">
- <%= build_gravatar_image_tag @user %>
+ <%= avatar @user %>
</div>
<% if @user == current_user %>
diff --git a/modules/avatars/lib/open_project/avatars/patches/avatar_helper_patch.rb b/modules/avatars/lib/open_project/avatars/patches/avatar_helper_patch.rb
index 8ca081dda5d..cc2bf7a314e 100644
--- a/modules/avatars/lib/open_project/avatars/patches/avatar_helper_patch.rb
+++ b/modules/avatars/lib/open_project/avatars/patches/avatar_helper_patch.rb
@@ -38,15 +38,7 @@ AvatarHelper.class_eval do
# Returns the avatar image tag for the given +user+ if avatars are enabled
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <[email protected]>')
def avatar(principal, options = {})
- return build_default_avatar_image_tag(principal, options) unless principal.is_a?(User)
-
- if local_avatar? principal
- local_avatar_image_tag principal, options
- elsif avatar_manager.gravatar_enabled?
- build_gravatar_image_tag principal, options
- else
- build_default_avatar_image_tag principal, options
- end
+ build_principal_avatar_tag principal, options
rescue StandardError => e
Rails.logger.error "Failed to create avatar for #{principal}: #{e}"
''.html_safe
@@ -54,7 +46,7 @@ AvatarHelper.class_eval do
def avatar_url(user, options = {})
if local_avatar? user
- local_avatar_image_url user
+ user_avatar_url(user.id)
elsif avatar_manager.gravatar_enabled?
build_gravatar_image_url user, options
else
@@ -65,10 +57,6 @@ AvatarHelper.class_eval do
''.html_safe
end
- def any_avatar?(user)
- avatar_manager.gravatar_enabled? || local_avatar?(user)
- end
-
def local_avatar?(user)
return false unless avatar_manager.local_avatars_enabled?
@@ -79,35 +67,12 @@ AvatarHelper.class_eval do
::OpenProject::Avatars::AvatarManager
end
- def build_gravatar_image_tag(user, options = {})
- mail = extract_email_address(user)
- raise ArgumentError.new('Invalid Mail') unless mail.present?
-
- opts = options.merge(gravatar: default_gravatar_options)
-
- tag_options = merge_image_options(user, opts)
- tag_options[:class] = [
- tag_options[:class],
- 'avatar--gravatar-image',
- 'avatar--fallback'
- ].reject(&:empty?).join(' ')
-
- content_tag 'op-principal',
- '',
- 'data-avatar-classes': tag_options[:class],
- 'data-size': tag_options[:size],
- 'data-principal-id': user.id,
- 'data-principal-name': user.name,
- 'data-principal-type': 'user',
- 'data-hide-name': 'true'
- end
-
def build_gravatar_image_url(user, options = {})
mail = extract_email_address(user)
raise ArgumentError.new('Invalid Mail') unless mail.present?
opts = options.merge(gravatar: default_gravatar_options)
- # gravatar_image_url expects grvatar options as second arg
+ # gravatar_image_url expects gravatar options as second arg
if opts[:gravatar]
opts.merge!(opts.delete(:gravatar))
end
@@ -115,28 +80,27 @@ AvatarHelper.class_eval do
gravatar_image_url(mail, opts)
end
- def local_avatar_image_url(user)
- user_avatar_url(user.id)
- end
-
- def local_avatar_image_tag(user, options = {})
- tag_options = merge_image_options(user, options)
+ def build_principal_avatar_tag(user, options = {})
+ tag_options = merge_default_avatar_options(user, options)
content_tag 'op-principal',
'',
- 'data-avatar-classes': tag_options[:class],
- 'data-principal-id': user.id,
- 'data-principal-name': user.name,
- 'data-principal-type': 'user',
- 'data-size': tag_options[:size],
- 'data-hide-name': 'true'
+ class: tag_options[:class],
+ data: {
+ 'principal-id': user.id,
+ 'principal-name': user.name,
+ 'principal-type': user.type.underscore,
+ 'size': tag_options[:size],
+ 'hide-name': tag_options[:hide_name]
+ }
end
- def merge_image_options(user, options)
+ def merge_default_avatar_options(user, options)
default_options = {
- class: '',
- size: 'default'
+ size: 'default',
+ hide_name: true
}
+
default_options[:title] = h(user.name) if user.respond_to?(:name)
options.reverse_merge(default_options)
@@ -154,24 +118,9 @@ AvatarHelper.class_eval do
def extract_email_address(object)
if object.respond_to?(:mail)
object.mail
- elsif object.to_s =~ %r{<(.+?)>}
- $1
end
end
end
- def build_default_avatar_image_tag(user, options = {})
- tag_options = merge_image_options(user, options)
-
- content_tag 'op-principal',
- '',
- 'data-avatar-classes': tag_options[:class],
- 'data-size': tag_options[:size],
- 'data-principal-name': user.name,
- 'data-principal-id': user.id,
- 'data-principal-type': 'user',
- 'data-hide-name': 'true'
- end
-
prepend InstanceMethods
end
diff --git a/modules/avatars/spec/helpers/avatar_helper_spec.rb b/modules/avatars/spec/helpers/avatar_helper_spec.rb
index fcf87e10fac..3f05e0a3818 100644
--- a/modules/avatars/spec/helpers/avatar_helper_spec.rb
+++ b/modules/avatars/spec/helpers/avatar_helper_spec.rb
@@ -27,7 +27,6 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
'data-principal-name': user.name,
'data-principal-type': 'user',
'data-hide-name': 'true',
- 'data-avatar-classes': '',
'data-size': 'default' }
content_tag 'op-principal', '', tag_options
@@ -42,31 +41,11 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
'data-principal-id': user.id,
'data-principal-name': user.name,
'data-principal-type': 'user',
- 'data-avatar-classes': '',
'data-size': 'default'}
content_tag 'op-principal', '', tag_options
end
- def gravatar_expected_user_avatar_tag(_digest, _options = {})
- tag_options = { 'data-principal-id': user.id,
- 'data-principal-name': user.name,
- 'data-hide-name': 'true',
- 'data-principal-type': 'user',
- 'data-size': 'default',
- 'data-avatar-classes': 'avatar--gravatar-image avatar--fallback' }
-
- content_tag 'op-principal', '', tag_options
- end
-
- def gravatar_expected_image_tag(digest, options = {})
- tag_options = options.reverse_merge(title: user.name,
- alt: 'Gravatar',
- class: 'avatar--gravatar-image avatar--fallback').delete_if { |key, value| value.nil? || key == :ssl }
-
- image_tag gravatar_expected_url(digest, options), tag_options
- end
-
def gravatar_expected_url(digest, options = {})
ssl = !!options[:ssl]
@@ -91,7 +70,7 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
it "should return the gravatar image if no image uploaded for the user" do
allow(user).to receive(:local_avatar_attachment).and_return nil
- expect(helper.avatar(user)).to be_html_eql(gravatar_expected_user_avatar_tag(mail_digest))
+ expect(helper.avatar(user)).to be_html_eql(default_expected_user_avatar_tag(user))
end
end
@@ -166,7 +145,7 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
context 'with http', with_settings: { protocol: 'http' } do
it 'should return a gravatar image tag if a user is provided' do
- expect(helper.avatar(user)).to be_html_eql(gravatar_expected_user_avatar_tag(mail_digest))
+ expect(helper.avatar(user)).to be_html_eql(default_expected_user_avatar_tag(user))
end
it 'should return a gravatar url if a user is provided' do
@@ -176,7 +155,7 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
context 'with https', with_settings: { protocol: 'https' } do
it 'should return a gravatar image tag with ssl if the request was ssl required' do
- expect(helper.avatar(user)).to be_html_eql(gravatar_expected_user_avatar_tag(mail_digest, ssl: true))
+ expect(helper.avatar(user)).to be_html_eql(default_expected_user_avatar_tag(user))
end
it 'should return a gravatar image tag with ssl if the request was ssl required' do
@@ -198,13 +177,6 @@ describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
expect(helper.avatar(mail)).to eq('')
end
- it 'should return a gravatar url if a parsable e-mail string is provided' do
- mail = '<[email protected]>'
- digest = Digest::MD5.hexdigest('[email protected]')
-
- expect(helper.avatar_url(mail)).to eq(gravatar_expected_url(digest))
- end
-
it 'should return an empty string if a non parsable (e-mail) string is provided' do
expect(helper.avatar_url('just the name')).to eq('')
end
diff --git a/modules/bim/app/cells/bim/ifc_models/row_cell.rb b/modules/bim/app/cells/bim/ifc_models/row_cell.rb
index 7b3a304f04b..b9f8766f454 100644
--- a/modules/bim/app/cells/bim/ifc_models/row_cell.rb
+++ b/modules/bim/app/cells/bim/ifc_models/row_cell.rb
@@ -25,7 +25,7 @@ module Bim
end
def uploader
- icon = avatar model.uploader, class: 'avatar-mini'
+ icon = avatar model.uploader, size: :mini
icon + model.uploader.name
end
diff --git a/modules/boards/spec/features/action_boards/assignee_board_spec.rb b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
index fd5a64ae34d..e812a73d743 100644
--- a/modules/boards/spec/features/action_boards/assignee_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/assignee_board_spec.rb
@@ -149,7 +149,7 @@ describe 'Assignee action board',
board_page.expect_card 'Bob Self', 'Some Task', present: false
# Expect to have changed the avatar
- expect(page).to have_selector('.wp-card--assignee .avatar-mini', text: 'FB', wait: 10)
+ expect(page).to have_selector('.wp-card--assignee .op-avatar_mini', text: 'FB', wait: 10)
work_package.reload
expect(work_package.assigned_to).to eq(foobar_user)
@@ -161,7 +161,7 @@ describe 'Assignee action board',
board_page.expect_card 'Bob Self', 'Some Task', present: false
# Expect to have changed the avatar
- expect(page).to have_selector('.wp-card--assignee .avatar-mini', text: 'GG', wait: 10)
+ expect(page).to have_selector('.wp-card--assignee .op-avatar_mini', text: 'GG', wait: 10)
work_package.reload
expect(work_package.assigned_to).to eq(group)
diff --git a/spec/features/members/invitation_spec.rb b/spec/features/members/invitation_spec.rb
index 2b65f9c9e75..b183eff6ea8 100644
--- a/spec/features/members/invitation_spec.rb
+++ b/spec/features/members/invitation_spec.rb
@@ -55,9 +55,9 @@ feature 'invite user via email', type: :feature, js: true do
click_on 'Add member'
members_page.search_and_select_principal! '[email protected]',
+ 'Send invite to [email protected]'
members_page.select_role! 'Developer'
- expect(members_page).to have_selected_new_principal('Invite [email protected]')
+ expect(members_page).to have_selected_new_principal('[email protected]')
click_on 'Add'
diff --git a/spec/features/members/membership_spec.rb b/spec/features/members/membership_spec.rb
index c983a75614a..5debfdb9c3e 100644
--- a/spec/features/members/membership_spec.rb
+++ b/spec/features/members/membership_spec.rb
@@ -118,6 +118,7 @@ feature 'Administrating memberships via the project settings', type: :feature, j
members_page.add_user! 'A-Team', as: 'Manager'
expect(members_page).to have_added_group('A-Team')
+ expect(page).to have_selector '.op-avatar_group'
SeleniumHubWaiter.wait
members_page.remove_group! 'A-Team'
@@ -129,6 +130,7 @@ feature 'Administrating memberships via the project settings', type: :feature, j
members_page.add_user! 'Hannibal Smith', as: 'Manager'
expect(members_page).to have_added_user 'Hannibal Smith'
+ expect(page).to have_selector '.op-avatar_user'
SeleniumHubWaiter.wait
members_page.remove_user! 'Hannibal Smith'
@@ -140,6 +142,7 @@ feature 'Administrating memberships via the project settings', type: :feature, j
members_page.add_user! developer_placeholder.name, as: developer.name
expect(members_page).to have_added_user developer_placeholder.name
+ expect(page).to have_selector '.op-avatar_placeholder-user'
SeleniumHubWaiter.wait
members_page.remove_user! developer_placeholder.name