Skip to content

Commit

Permalink
Replace custom ConfirmationDialog with ConfirmDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mvysny committed Dec 3, 2024
1 parent 5d99f9b commit abdcf30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 103 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import com.github.mvysny.karibudsl.v10.beanValidationBinder
import com.github.mvysny.karibudsl.v10.bind
import com.github.mvysny.karibudsl.v10.textField
import com.github.mvysny.karibudsl.v10.trimmingConverter
import com.vaadin.flow.component.confirmdialog.ConfirmDialog
import com.vaadin.flow.component.formlayout.FormLayout
import com.vaadin.flow.component.notification.Notification
import com.vaadin.flow.data.binder.Binder
import com.vaadin.flow.data.validator.StringLengthValidator
import com.vaadin.starter.beveragebuddy.backend.Category
import com.vaadin.starter.beveragebuddy.backend.Review
import com.vaadin.starter.beveragebuddy.ui.ConfirmationDialog
import com.vaadin.starter.beveragebuddy.ui.EditorForm
import com.vaadin.starter.beveragebuddy.ui.EditorDialogFrame

Expand Down Expand Up @@ -65,15 +65,13 @@ class CategoryEditorDialog(private val onCategoriesChanged: (Category) -> Unit)
if (reviewCount == 0) {
delete(frame, item)
} else {
ConfirmationDialog().open(
ConfirmDialog(
"Delete Category “${item.name}”?",
"There are $reviewCount reviews associated with this category.",
"Deleting the category will mark the associated reviews as “undefined”. You may link the reviews to other categories on the edit page.",
"Delete",
true
"There are $reviewCount reviews associated with this category.\nDeleting the category will mark the associated reviews as “undefined”. You may link the reviews to other categories on the edit page.",
"Delete"
) {
delete(frame, item)
}
} .open()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package com.vaadin.starter.beveragebuddy.ui.reviews

import com.github.mvysny.karibudsl.v10.*
import com.vaadin.flow.component.confirmdialog.ConfirmDialog
import com.vaadin.flow.component.formlayout.FormLayout
import com.vaadin.flow.component.notification.Notification
import com.vaadin.flow.data.binder.Binder
import com.vaadin.starter.beveragebuddy.backend.Category
import com.vaadin.starter.beveragebuddy.backend.Review
import com.vaadin.starter.beveragebuddy.ui.ConfirmationDialog
import com.vaadin.starter.beveragebuddy.ui.EditorDialogFrame
import com.vaadin.starter.beveragebuddy.ui.EditorForm
import eu.vaadinonkotlin.vaadin.vokdb.dataProvider
Expand Down Expand Up @@ -90,18 +90,16 @@ class ReviewEditorDialog(private val onReviewsChanged: (Review) -> Unit) {
}

private fun maybeDelete(frame: EditorDialogFrame<Review>, item: Review) {
ConfirmationDialog().open(
ConfirmDialog(
"Delete beverage",
"Are you sure you want to delete beverage '${item.name}'?",
"",
"Delete",
true
"Delete"
) {
item.delete()
Notification.show("Beverage successfully deleted.", 3000, Notification.Position.BOTTOM_START)
frame.close()
onReviewsChanged(item)
}
} .open()
}

fun edit(review: Review) {
Expand Down

0 comments on commit abdcf30

Please sign in to comment.