-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move tooltip panel directive to a more reusable and functional archit…
…ecture and small fine tunings and improvements
- Loading branch information
Pop John
committed
Oct 24, 2024
1 parent
d37bf12
commit e18c5ef
Showing
33 changed files
with
751 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
frontend/src/app/modules/core/components/ms-drawer/models/drawer.constants.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...rc/app/modules/core/components/ms-popover/components/ms-popover/ms-popover.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!-- Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 --> | ||
|
||
<div class="tooltip-container" [ngClass]="data.position" [ngStyle]="data.width | iconPanelSizeStyles: data.height"> | ||
<div class="tooltip-arrow"></div> | ||
|
||
<div class="popover-content"> | ||
<ng-content></ng-content> | ||
</div> | ||
|
||
<div class="close-button"> | ||
<button mat-icon-button (click)="onClose()"> | ||
<mat-icon fontSet="ms" fontIcon="icon-X" class="mat-error size-20"></mat-icon> | ||
</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
.../src/app/modules/core/components/ms-popover/components/ms-popover/ms-popover.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2024 Cisco Systems, Inc. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { Component, EventEmitter, HostListener, Inject, Input, Output, TemplateRef } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { PopoverStatus } from '../../models/enums/popover-status.enum'; | ||
import { PopoverConfig } from '../../models/interfaces/popover-config.interface'; | ||
import { PopoverSizeStylesPipe } from '../../pipes/popover-size-style.pipe'; | ||
import { PopoverRef } from '../../popover.ref'; | ||
import { POPOVER_DATA } from '../../popover.tokens'; | ||
|
||
@UntilDestroy() | ||
@Component({ | ||
selector: 'ms-popover', | ||
standalone: true, | ||
imports: [CommonModule, MatIconModule, MatButtonModule, PopoverSizeStylesPipe], | ||
templateUrl: './ms-popover.component.html', | ||
styleUrl: './ms-popover.component.scss' | ||
}) | ||
export class MsPopoverComponent { | ||
@Input() contentTemplate?: TemplateRef<any>; | ||
@Output() actionEvent: EventEmitter<PopoverStatus> = new EventEmitter<PopoverStatus>(); | ||
|
||
constructor( | ||
private popoverRef: PopoverRef, | ||
@Inject(POPOVER_DATA) public data: PopoverConfig | ||
) { | ||
this.closeDrawerOnBackdropClick(); | ||
} | ||
|
||
onClose(): void { | ||
this.actionEvent.emit(PopoverStatus.CLOSE); | ||
this.popoverRef.close({ status: PopoverStatus.CLOSE }); | ||
} | ||
|
||
onSave(): void { | ||
this.actionEvent.emit(PopoverStatus.SAVE); | ||
} | ||
|
||
onDismiss(): void { | ||
this.actionEvent.emit(PopoverStatus.DISMISS); | ||
this.popoverRef.close({ status: PopoverStatus.DISMISS }); | ||
} | ||
|
||
private closeDrawerOnBackdropClick(): void { | ||
if (!this.data.closePopoverOnBackdropClick) { | ||
return; | ||
} | ||
|
||
this.popoverRef | ||
.backdropClick() | ||
.pipe(untilDestroyed(this)) | ||
.subscribe(() => { | ||
this.onDismiss(); | ||
}); | ||
} | ||
|
||
@HostListener('window:keyup.esc') onEscKeyDown(): void { | ||
if (!this.data.closePopoverOnEscKeyUp) { | ||
return; | ||
} | ||
this.onDismiss(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
frontend/src/app/modules/core/components/ms-popover/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2024 Cisco Systems, Inc. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export * from './models/enums/popover-status.enum'; | ||
export * from './models/interfaces/popover-config.interface'; | ||
export * from './popover.ref'; | ||
export * from './popover.tokens'; |
22 changes: 22 additions & 0 deletions
22
frontend/src/app/modules/core/components/ms-popover/models/constants/popover.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2024 Cisco Systems, Inc. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { PopoverCSSSize } from '../types/popover-css-size.type'; | ||
|
||
export const DEFAUlT_POPOVER_WIDTH: PopoverCSSSize = '200px'; | ||
export const DEFAUlT_POPOVER_HEIGHT: PopoverCSSSize = '80px'; | ||
|
||
export const DEFAULT_POPOVER_POSITION_VALUE = 'top'; |
21 changes: 21 additions & 0 deletions
21
frontend/src/app/modules/core/components/ms-popover/models/enums/popover-action-type.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Cisco Systems, Inc. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export enum PopoverActionTypeEnum { | ||
ADD = 'add', | ||
EDIT = 'edit', | ||
VIEW = 'view' | ||
} |
22 changes: 22 additions & 0 deletions
22
frontend/src/app/modules/core/components/ms-popover/models/enums/popover-status.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2024 Cisco Systems, Inc. | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
|
||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export enum PopoverStatus { | ||
OPEN = 'open', | ||
DISMISS = 'dismiss', | ||
SAVE = 'save', | ||
CLOSE = 'close' | ||
} |
Oops, something went wrong.