Skip to content

Commit

Permalink
feat(buttons): allow hiding of the confirm / cancel buttons
Browse files Browse the repository at this point in the history
Closes #10
  • Loading branch information
Matt Lewis committed May 7, 2016
1 parent 39f9d92 commit 540b965
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Set to either `confirm` or `cancel` to focus the confirm or cancel button. If om
#### isDisabled
Whether to disable showing the popover. Default `false`.

#### hideConfirmButton
Whether to hide the confirm button. Default `false`.

#### hideCancelButton
Whether to hide the cancel button. Default `false`.

## Development

### Prepare your environment
Expand Down
6 changes: 5 additions & 1 deletion src/confirm.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class Confirm implements OnDestroy, OnChanges, OnInit {
@Input() confirmButtonType: string;
@Input() cancelButtonType: string;
@Input() focusButton: string;
@Input() hideConfirmButton: boolean = false;
@Input() hideCancelButton: boolean = false;
@Input() isOpen: boolean = false;
@Input() isDisabled: boolean = false;
@Output() isOpenChange: EventEmitter<any> = new EventEmitter();
Expand Down Expand Up @@ -94,7 +96,9 @@ export class Confirm implements OnDestroy, OnChanges, OnInit {
'placement',
'confirmButtonType',
'cancelButtonType',
'focusButton'
'focusButton',
'hideConfirmButton',
'hideCancelButton'
];
optionalParams.forEach(param => {
if (this[param]) {
Expand Down
2 changes: 2 additions & 0 deletions src/confirmOptions.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class ConfirmOptions {
public cancelButtonType: string = 'default';
public placement: string = 'top';
public focusButton: string;
public hideConfirmButton: boolean = false;
public hideCancelButton: boolean = false;

public constructor(options: Object = {}) {
Object.assign(this, options);
Expand Down
10 changes: 8 additions & 2 deletions src/confirmPopover.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ interface Coords {
<div class="popover-content">
<p [innerHTML]="options.message"></p>
<div class="row">
<div class="col-xs-6">
<div
class="col-xs-6"
[class.col-xs-offset-3]="options.hideCancelButton"
*ngIf="!options.hideConfirmButton">
<button
#confirmButton
[class]="'btn btn-block btn-' + options.confirmButtonType"
(click)="options.onConfirm()"
[innerHtml]="options.confirmText">
</button>
</div>
<div class="col-xs-6">
<div
class="col-xs-6"
[class.col-xs-offset-3]="options.hideConfirmButton"
*ngIf="!options.hideCancelButton">
<button
#cancelButton
[class]="'btn btn-block btn-' + options.cancelButtonType"
Expand Down

0 comments on commit 540b965

Please sign in to comment.