Skip to content

Commit

Permalink
Hide empty space if three dot menu is not shown (#3590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator authored May 22, 2024
1 parent 1d13674 commit 8d86099
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,21 @@ <h2>{{ 'Participants' | translate }}</h2>
</div>

<!-- Menu -->
<div *osScrollingTableCell="'menu'; row as user; config: { width: 40 }" class="cell-slot fill">
<div
*osScrollingTableCell="
'menu';
row as user;
config: { width: 40 };
isHidden: !canSeeItemMenu() && viewport.isMobileSubject
"
class="cell-slot"
>
<button
mat-icon-button
[disabled]="isMultiSelect"
[matMenuTriggerFor]="singleItemMenu"
(click)="$event.stopPropagation()"
[matMenuTriggerData]="{ user: user }"
*ngIf="canSeeSingleItemMenu(user) || (viewport.isMobileSubject | async)"
>
<mat-icon>more_vert</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ export class ParticipantListComponent extends BaseMeetingListViewComponent<ViewU
public canChangePassword(user: ViewUser): boolean {
const userOML = user?.organization_management_level;
const sufficientOML = userOML ? this.operator.hasOrganizationPermissions(userOML as OML) : true;
return (
!user?.saml_id &&
this.userService.isAllowed(`changePassword`, user.id === this.operator.user.id) &&
sufficientOML
);
return !user?.saml_id && this.userService.isAllowed(`changePassword`, false) && sufficientOML;
}

public isUserPresent(user: ViewUser): boolean {
Expand Down Expand Up @@ -458,8 +454,8 @@ export class ParticipantListComponent extends BaseMeetingListViewComponent<ViewU
await this.repo.removeUsersFromMeeting([user]);
}

public canSeeSingleItemMenu(user: ViewUser): boolean {
return this.operator.hasPerms(Permission.userCanUpdate) || this.canChangePassword(user);
public canSeeItemMenu(): boolean {
return this.operator.hasPerms(Permission.userCanUpdate);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TemplatePortal } from '@angular/cdk/portal';
import { Directive, Input, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
import { Directive, Input, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
import { Observable, Subscription } from 'rxjs';

import { ScrollingTableManageService } from '../services';
import { ScrollingTableCellDefConfig } from './scrolling-table-cell-config';
Expand All @@ -9,7 +10,7 @@ import { ScrollingTableCellPosition } from './scrolling-table-cell-position';
@Directive({
selector: `[osScrollingTableCell]`
})
export class ScrollingTableCellDirective implements OnInit, ScrollingTableCellDefinition {
export class ScrollingTableCellDirective implements OnInit, OnDestroy, ScrollingTableCellDefinition {
@Input()
public set osScrollingTableCell(property: string) {
this._property = property;
Expand All @@ -22,8 +23,18 @@ export class ScrollingTableCellDirective implements OnInit, ScrollingTableCellDe
}

@Input()
public set osScrollingTableCellIsHidden(isHidden: boolean) {
this._isHidden = isHidden;
public set osScrollingTableCellIsHidden(isHidden: boolean | Observable<boolean>) {
if (this.isHiddenSubscription) {
this.isHiddenSubscription.unsubscribe();
}
if (typeof isHidden == `boolean`) {
this.isHiddenSubscription = null;
this._isHidden = isHidden;
} else {
isHidden.subscribe(isMobileView => {
this._isHidden = !isMobileView;
});
}
}

@Input()
Expand Down Expand Up @@ -81,6 +92,7 @@ export class ScrollingTableCellDirective implements OnInit, ScrollingTableCellDe
private _property = ``;
private _labelString = ``;
private _isDefault = false;
private isHiddenSubscription: Subscription | null = null;

public constructor(
public readonly template: TemplateRef<any>,
Expand All @@ -96,6 +108,12 @@ export class ScrollingTableCellDirective implements OnInit, ScrollingTableCellDe
}
}

public ngOnDestroy(): void {
if (this.isHiddenSubscription) {
this.isHiddenSubscription.unsubscribe();
}
}

private render(): void {
const { width, minWidth, maxWidth } = this._config;
if (width) {
Expand Down

0 comments on commit 8d86099

Please sign in to comment.