Skip to content

Commit

Permalink
[DSC-472] Empty contextual menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufiyan Shaikh committed Mar 4, 2022
1 parent 7194349 commit c3f78de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/app/shared/context-menu/context-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<ng-container *ngFor="let entry of (getStandAloneMenuEntries() | async)">
<ng-container *ngComponentOutlet="entry; injector: objectInjector;"></ng-container>
</ng-container>
<div ngbDropdown #itemOptions="ngbDropdown" placement="bottom-right" class="d-inline-block float-right ml-1">
<div ngbDropdown #itemOptions="ngbDropdown" placement="bottom-right"
class="float-right ml-1" [ngClass]="optionCount === 0 ? 'd-none' : 'd-inline-block'">
<button class="btn btn-outline-primary" id="context-menu" ngbDropdownToggle>
<i class="fas fa-ellipsis-h" aria-hidden="true"></i>
</button>
Expand All @@ -11,9 +12,6 @@ <h6 class="dropdown-header">{{'context-menu.actions.label' | translate}}</h6>
<ng-container *ngFor="let entry of (getContextMenuEntries() | async)">
<ng-container *ngComponentOutlet="entry; injector: objectInjector;"></ng-container>
</ng-container>
<label class="dropdown-item" *ngIf="optionCount === 0">
{{'context-menu.actions.no-options-available' | translate}}
</label>
</div>
</div>

Expand Down
10 changes: 6 additions & 4 deletions src/app/shared/context-menu/context-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ export class ContextMenuComponent implements OnInit {

ngAfterViewChecked() {
// To check that Context-menu contains options or not
const el = Array.from(document.getElementById('itemOptionsDropdownMenu').getElementsByClassName('ng-star-inserted'));
const el = Array.from(document.getElementById('itemOptionsDropdownMenu')?.getElementsByClassName('ng-star-inserted'));
this.optionCount = 0;
el.forEach(element => {
this.optionCount += element.childElementCount;
});
if (el) {
el.forEach(element => {
this.optionCount += element.childElementCount;
});
}
}
}
2 changes: 0 additions & 2 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,6 @@

"context-menu.actions.label": "Options",

"context-menu.actions.no-options-available": "No Options Available",

"context-menu.actions.edit-item.btn.FULL": "Edit all the details",

"context-menu.actions.edit-item.btn.OWNER": "Edit",
Expand Down

0 comments on commit c3f78de

Please sign in to comment.