[33452] Show multi-select badge of custom field in wp table (#8462)

* Show multi-select badge of custom field in wp table

* Add custom-option class around user-multi-select values
pull/8475/head
Inga Mai 4 years ago committed by GitHub
parent 3fda238c70
commit 317850cdd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      frontend/src/app/modules/fields/display/field-types/multiple-user-display-field.module.ts

@ -30,6 +30,7 @@ import {ResourcesDisplayField} from "./resources-display-field.module";
import {UserResource} from "core-app/modules/hal/resources/user-resource";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
import {UserAvatarRendererService} from "core-components/user/user-avatar/user-avatar-renderer.service";
import {cssClassCustomOption} from "core-app/modules/fields/display/display-field.module";
export class MultipleUserFieldModule extends ResourcesDisplayField {
@InjectField() avatarRenderer:UserAvatarRendererService;
@ -52,13 +53,16 @@ export class MultipleUserFieldModule extends ResourcesDisplayField {
*/
protected renderValues(values:UserResource[], element:HTMLElement) {
const content = document.createDocumentFragment();
const divContainer = document.createElement('div');
divContainer.classList.add(cssClassCustomOption);
content.appendChild(divContainer);
this.renderAbridgedValues(element, values);
this.renderAbridgedValues(divContainer, values);
if (values.length > 2) {
const dots = document.createElement('span');
dots.innerHTML = '... ';
content.appendChild(dots);
divContainer.appendChild(dots);
const badge = this.optionDiv(values.length.toString(), 'badge', '-secondary');
content.appendChild(badge);

Loading…
Cancel
Save