-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modal): modal service wip (#2047)
fixes #1998 fixes #1995 fixes #1830 fixes #1181 fixes #579 * feat(modal): modal service wip * feat(modal): wip, add close buttons attribute support, add ability to open modaol with component * feat(modal): add config, move creating of loader to constructor, add demo * fix(modal): fix service path * fix(modal): fix api-docs * fix(modal): fix scroll on modals created by service, add docs * feat(modal): wip, add BsModalService.show output obj * refactor(modal): change inner component getter * feat(modal): add BsModalRef and docs * feat(modal): remove data-attributes, return BsModalRef, update docs * feat(modal): add docs for BsModalService, BsModalRef, update demo * feat(modal): add bs4 support * feat(modal): keep focus inside a modal * chore(modals): small refactoring (#2128) * chore(modals): simplify service (#2130) * chore(modal): view container ref made optional for component loader (#2133) * fix(modal): fix backdrop flickering * fix(modal): fix backdrop click on the left/right sides, add class option * feat(modals): nested modals wip * fix(modal): fix multiple hide() call * fix(modal): fix multiple backdrop clicks, fix padding * fix(modal): fixed padding * fix(modal): fix page flickering * feat(modal): add isAnimated support, add service section to demo * fix(test): fix popover and tyepahead unit tests
- Loading branch information
1 parent
2fedac2
commit 2d02faa
Showing
25 changed files
with
758 additions
and
114 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
1 change: 1 addition & 0 deletions
1
demo/src/app/components/+modal/demos/service-component/service-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 @@ | ||
<button type="button" class="btn btn-primary" (click)="openModalWithComponent()">Create modal with component</button> |
40 changes: 40 additions & 0 deletions
40
demo/src/app/components/+modal/demos/service-component/service-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,40 @@ | ||
import { Component } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class'; | ||
|
||
@Component({ | ||
selector: 'demo-modal-service-component', | ||
templateUrl: './service-component.html' | ||
}) | ||
export class DemoModalServiceFromComponent { | ||
constructor(private modalService: BsModalService) {} | ||
|
||
public openModalWithComponent() { | ||
this.modalService.show(ModalContentComponent); | ||
} | ||
} | ||
|
||
/* This is a component which we pass in modal*/ | ||
|
||
@Component({ | ||
selector: 'modal-content', | ||
template: ` | ||
<div class="modal-header"> | ||
<h4 class="modal-title pull-left">{{title}}</h4> | ||
<button type="button" class="close pull-right" aria-label="Close" (click)="bsModalRef.hide()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
This is a modal with component inside. | ||
Click <b>×</b> to close modal. | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" (click)="bsModalRef.hide()">Close</button> | ||
</div> | ||
` | ||
}) | ||
export class ModalContentComponent { | ||
public title: string = 'Modal with component'; | ||
constructor(public bsModalRef: BsModalRef) {} | ||
} |
27 changes: 27 additions & 0 deletions
27
demo/src/app/components/+modal/demos/service-nested/service-nested.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,27 @@ | ||
<button type="button" class="btn btn-primary" (click)="openModal(template)">Open first modal</button> | ||
|
||
<template #template> | ||
<div class="modal-header"> | ||
<h4 class="modal-title pull-left">First modal</h4> | ||
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
This is a first modal | ||
<button type="button" class="btn btn-primary" (click)="openModal2(templateNested)">Open second modal</button> | ||
</div> | ||
</template> | ||
|
||
<template #templateNested> | ||
<div class="modal-header"> | ||
<h4 class="modal-title pull-left">Second modal</h4> | ||
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef2.hide()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
This is nested modal.<br> | ||
<button *ngIf="modalRef" type="button" class="btn btn-danger" (click)="closeFirstModal()">Close first modal</button> | ||
</div> | ||
</template> |
24 changes: 24 additions & 0 deletions
24
demo/src/app/components/+modal/demos/service-nested/service-nested.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,24 @@ | ||
import { Component, TemplateRef } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class'; | ||
|
||
@Component({ | ||
selector: 'demo-modal-service-nested', | ||
templateUrl: './service-nested.html' | ||
}) | ||
export class DemoModalServiceNestedComponent { | ||
public modalRef: BsModalRef; | ||
public modalRef2: BsModalRef; | ||
constructor(private modalService: BsModalService) {} | ||
|
||
public openModal(template: TemplateRef<any>) { | ||
this.modalRef = this.modalService.show(template, {class: 'modal-sm'}); | ||
} | ||
public openModal2(template: TemplateRef<any>) { | ||
this.modalRef2 = this.modalService.show(template, {class: 'second'}); | ||
} | ||
public closeFirstModal() { | ||
this.modalRef.hide(); | ||
this.modalRef = null; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
demo/src/app/components/+modal/demos/service-options/service-options.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,20 @@ | ||
<button type="button" class="btn btn-primary" (click)="openModal(template)">Open modal</button> | ||
<button type="button" class="btn btn-primary" (click)="openModalWithClass(template)">Open modal with custom css class</button> | ||
<br> | ||
<br> | ||
<button type="button" class="btn btn-primary btn-sm" (click)="config.animated = !config.animated">{{config.animated ? 'Disable' : 'Enable'}} animation</button> | ||
<button type="button" class="btn btn-primary btn-sm" (click)="config.keyboard = !config.keyboard">{{config.keyboard ? 'Disable' : 'Enable'}} Esc</button> | ||
<button type="button" class="btn btn-primary btn-sm" (click)="config.backdrop = !config.backdrop">{{config.backdrop ? 'Disable' : 'Enable'}} backdrop</button> | ||
<button type="button" class="btn btn-primary btn-sm" (click)="config.ignoreBackdropClick = !config.ignoreBackdropClick">{{!config.ignoreBackdropClick ? 'Disable' : 'Enable'}} backdrop click</button> | ||
|
||
<template #template> | ||
<div class="modal-header"> | ||
<h4 class="modal-title pull-left">Modal</h4> | ||
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
Just a modal with a bunch of words inside, nothing serious. | ||
</div> | ||
</template> |
27 changes: 27 additions & 0 deletions
27
demo/src/app/components/+modal/demos/service-options/service-options.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,27 @@ | ||
import { Component, TemplateRef } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class'; | ||
|
||
@Component({ | ||
selector: 'demo-modal-service-options', | ||
templateUrl: './service-options.html' | ||
}) | ||
export class DemoModalServiceOptionsComponent { | ||
public modalRef: BsModalRef; | ||
public config = { | ||
animated: true, | ||
keyboard: true, | ||
backdrop: true, | ||
ignoreBackdropClick: false | ||
}; | ||
constructor(private modalService: BsModalService) {} | ||
|
||
public openModal(template: TemplateRef<any>) { | ||
this.modalRef = this.modalService.show(template, this.config); | ||
} | ||
|
||
public openModalWithClass(template: TemplateRef<any>) { | ||
this.modalRef = this.modalService.show(template, Object.assign({}, this.config, {class: 'gray modal-lg'})); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
demo/src/app/components/+modal/demos/service-template/service-template.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,13 @@ | ||
<button type="button" class="btn btn-primary" (click)="openModal(template)">Create template modal</button> | ||
|
||
<template #template> | ||
<div class="modal-header"> | ||
<h4 class="modal-title pull-left">Modal</h4> | ||
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
This is a modal. | ||
</div> | ||
</template> |
16 changes: 16 additions & 0 deletions
16
demo/src/app/components/+modal/demos/service-template/service-template.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,16 @@ | ||
import { Component, TemplateRef } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class'; | ||
|
||
@Component({ | ||
selector: 'demo-modal-service-static', | ||
templateUrl: './service-template.html' | ||
}) | ||
export class DemoModalServiceStaticComponent { | ||
public modalRef: BsModalRef; | ||
constructor(private modalService: BsModalService) {} | ||
|
||
public openModal(template: TemplateRef<any>) { | ||
this.modalRef = this.modalService.show(template); | ||
} | ||
} |
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
Oops, something went wrong.