From 1f30a1853e38c20a45722dbd6d38aaaec63839e8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Feb 2018 15:29:32 +0100 Subject: Add confirm when admin use custom js/css --- client/src/app/core/confirm/confirm.component.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'client/src/app/core/confirm/confirm.component.ts') diff --git a/client/src/app/core/confirm/confirm.component.ts b/client/src/app/core/confirm/confirm.component.ts index 0515d969a..8f81b7a98 100644 --- a/client/src/app/core/confirm/confirm.component.ts +++ b/client/src/app/core/confirm/confirm.component.ts @@ -4,21 +4,20 @@ import { ModalDirective } from 'ngx-bootstrap/modal' import { ConfirmService } from './confirm.service' -export interface ConfigChangedEvent { - columns: { [id: string]: { isDisplayed: boolean } } - config: { resultsPerPage: number } -} - @Component({ selector: 'my-confirm', templateUrl: './confirm.component.html', - styles: [ '.button { padding: 0 13px; }' ] + styleUrls: [ './confirm.component.scss' ] }) export class ConfirmComponent implements OnInit { @ViewChild('confirmModal') confirmModal: ModalDirective title = '' message = '' + expectedInputValue = '' + inputLabel = '' + + inputValue = '' constructor (private confirmService: ConfirmService) { // Empty @@ -31,10 +30,13 @@ export class ConfirmComponent implements OnInit { } this.confirmService.showConfirm.subscribe( - ({ title, message }) => { + ({ title, message, expectedInputValue, inputLabel }) => { this.title = title this.message = message + this.inputLabel = inputLabel + this.expectedInputValue = expectedInputValue + this.showModal() } ) @@ -52,6 +54,13 @@ export class ConfirmComponent implements OnInit { this.hideModal() } + isConfirmationDisabled () { + // No input validation + if (!this.inputLabel || !this.expectedInputValue) return false + + return this.expectedInputValue !== this.inputValue + } + showModal () { this.confirmModal.show() } -- cgit v1.2.3