From 6197053872ae809a423287cf74f3b568c98f1ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=BCleyman=20=C3=96ZEV?= Date: Sat, 1 May 2021 09:58:18 +0300 Subject: [PATCH] Added feature for confirm cancel button text customizing --- .gitignore | 3 ++- readme.md | 1 + resources/js/components/DetailField.vue | 2 +- resources/js/components/IndexField.vue | 2 +- src/Button.php | 7 ++++++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b5a6533..af14f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.vscode /vendor/ -/node_modules \ No newline at end of file +/node_modules +/.idea/* \ No newline at end of file diff --git a/readme.md b/readme.md index ecaabbd..bed6b0a 100644 --- a/readme.md +++ b/readme.md @@ -110,6 +110,7 @@ You can require a confirmation for descructive actions ```php Button::make('Cancel Account')->confirm('Are you sure?'), Button::make('Cancel Account')->confirm('title', 'content'), +Button::make('Cancel Account')->confirm('title', 'content', 'Cancel'), ``` ### Button state diff --git a/resources/js/components/DetailField.vue b/resources/js/components/DetailField.vue index 2921679..ab9b552 100644 --- a/resources/js/components/DetailField.vue +++ b/resources/js/components/DetailField.vue @@ -28,7 +28,7 @@ Cancel + @click.prevent="openModal = false" v-text="field.confirm.cancelButtonText"> diff --git a/resources/js/components/IndexField.vue b/resources/js/components/IndexField.vue index 9842664..42582dc 100644 --- a/resources/js/components/IndexField.vue +++ b/resources/js/components/IndexField.vue @@ -24,7 +24,7 @@ Cancel + class="cursor-pointer btn text-80 font-normal px-3 mr-3 btn-link" v-text="field.confirm.cancelButtonText"> confirm = [ 'title' => __('Confirmation'), 'body' => null, + 'cancelButtonText' => __('Cancel'), ]; if ($message1 && $message2 == null) { @@ -150,6 +151,10 @@ public function confirm($message1 = null, $message2 = null) $this->confirm['body'] = $message2; } + if ($cancelButtonText) { + $this->confirm['cancelButtonText'] = $cancelButtonText; + } + return $this; }