Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into feature/turbo-yarn
- Loading branch information
Showing
13 changed files
with
220 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* COPYRIGHT (c) Siemens AG 2018-2022 ALL RIGHTS RESERVED. | ||
*/ | ||
import { Component, TemplateRef, ViewChild } from '@angular/core'; | ||
import { ModalService } from '@siemens/ix-angular/dist'; | ||
|
||
@Component({ | ||
selector: 'app-modal', | ||
template: ` | ||
<div> | ||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy | ||
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam | ||
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet | ||
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit | ||
amet. | ||
</div> | ||
<ix-button (click)="test()">Show Modal</ix-button> | ||
<ng-template #customModal let-modal> | ||
<div> | ||
<div class="modal-header"> | ||
Message headline | ||
<ix-icon-button | ||
ghost | ||
icon="close" | ||
class="dismiss-modal" | ||
(click)="modal.dismiss('dismiss')" | ||
></ix-icon-button> | ||
</div> | ||
<div class="modal-body">Message text lorem ipsum</div> | ||
<div class="modal-footer"> | ||
<ix-button | ||
outline | ||
class="dismiss-modal" | ||
(click)="modal.dismiss('dismiss')" | ||
> | ||
Cancel | ||
</ix-button> | ||
<ix-button class="close-modal" (click)="modal.close('okay')" | ||
>OK</ix-button | ||
> | ||
</div> | ||
</div> | ||
</ng-template> | ||
`, | ||
}) | ||
export class Modal { | ||
@ViewChild('customModal', { read: TemplateRef }) | ||
customModalRef!: TemplateRef<any>; | ||
|
||
constructor(private readonly modalService: ModalService) {} | ||
|
||
async test() { | ||
const instance = await this.modalService.open({ | ||
content: this.customModalRef, | ||
title: '', | ||
}); | ||
|
||
instance.onClose.on((a) => { | ||
console.log(a); | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
export * from '@siemens/ix'; | ||
export * from './components'; | ||
export * from './modal'; | ||
export * from './module'; |
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,4 @@ | ||
/* | ||
* COPYRIGHT (c) Siemens AG 2018-2022 ALL RIGHTS RESERVED. | ||
*/ | ||
export * from './modal.service'; |
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,8 @@ | ||
/* | ||
* COPYRIGHT (c) Siemens AG 2018-2022 ALL RIGHTS RESERVED. | ||
*/ | ||
import { TemplateRef } from '@angular/core'; | ||
|
||
export type ModalConfig = { | ||
content: TemplateRef<any>; | ||
}; |
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,58 @@ | ||
/* | ||
* COPYRIGHT (c) Siemens AG 2018-2022 ALL RIGHTS RESERVED. | ||
*/ | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
closeModal, | ||
dismissModal, | ||
modal, | ||
ModalConfig as IxModalConfig, | ||
} from '@siemens/ix'; | ||
import { ModalConfig } from './modal.config'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ModalService { | ||
constructor() {} | ||
|
||
async open(config: Omit<IxModalConfig, 'content'> & ModalConfig) { | ||
const context: { | ||
close: ((result: any) => void) | null; | ||
dismiss: ((result?: any) => void) | null; | ||
} = { | ||
close: null, | ||
dismiss: null, | ||
}; | ||
const embeddedView = config.content.createEmbeddedView({ | ||
$implicit: context, | ||
}); | ||
|
||
const node = embeddedView.rootNodes[0]; | ||
|
||
context.close = (result: any) => { | ||
closeModal(node, result); | ||
}; | ||
|
||
context.dismiss = (result?: any) => { | ||
dismissModal(node, result); | ||
}; | ||
|
||
embeddedView.detectChanges(); | ||
|
||
const modalInstance = await modal({ | ||
title: '', | ||
content: node, | ||
}); | ||
|
||
modalInstance.onClose.once(() => { | ||
embeddedView.destroy(); | ||
}); | ||
|
||
modalInstance.onDismiss.once(() => { | ||
embeddedView.destroy(); | ||
}); | ||
|
||
return modalInstance; | ||
} | ||
} |
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