diff --git a/.gitignore b/.gitignore index ddcbebf..b209f25 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,5 @@ webpack.generated.js ### Maven ### **/target -/target \ No newline at end of file +/target +.flattened-pom.xml \ No newline at end of file diff --git a/acrarium/frontend/elements/dialog-content.js b/acrarium/frontend/elements/dialog-content.js new file mode 100644 index 0000000..242daf0 --- /dev/null +++ b/acrarium/frontend/elements/dialog-content.js @@ -0,0 +1,40 @@ +import {html, PolymerElement} from '@polymer/polymer/polymer-element.js'; +import '@vaadin/vaadin-dialog/vaadin-dialog.js'; +import '@vaadin/vaadin-button/vaadin-button.js'; + +class AcrariumDialogContent extends PolymerElement { + static get template() { + // language=HTML + return html` + +
+ +
+ + + ` + } +} + +customElements.define("acrarium-dialog-content", AcrariumDialogContent); \ No newline at end of file diff --git a/acrarium/src/main/java/com/faendir/acra/ui/base/ReportList.java b/acrarium/src/main/java/com/faendir/acra/ui/base/ReportList.java index 7b8f230..9a30dfc 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/base/ReportList.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/base/ReportList.java @@ -24,7 +24,7 @@ import com.faendir.acra.model.QReport; import com.faendir.acra.model.Report; import com.faendir.acra.security.SecurityUtils; import com.faendir.acra.service.AvatarService; -import com.faendir.acra.ui.base.popup.Popup; +import com.faendir.acra.ui.component.dialog.FluentDialog; import com.faendir.acra.ui.view.report.ReportView; import com.faendir.acra.util.TimeSpanRenderer; import com.vaadin.flow.component.button.Button; @@ -54,10 +54,10 @@ public class ReportList extends MyGrid{ addColumn(report -> report.getStacktrace().getStacktrace().split("\n", 2)[0], QReport.report.stacktrace.stacktrace, Messages.STACKTRACE).setAutoWidth(false).setFlexGrow(1); if (SecurityUtils.hasPermission(app, Permission.Level.EDIT)) { addColumn(new ComponentRenderer<>(report -> new Button(new Icon(VaadinIcon.TRASH), - event -> new Popup().setTitle(Messages.DELETE_REPORT_CONFIRM).addYesNoButtons(p -> { + event -> new FluentDialog().addText(Messages.DELETE_REPORT_CONFIRM).addConfirmButtons(p -> { reportDeleter.accept(report); getDataProvider().refreshAll(); - }, true).show()))); + }).show()))); } addOnClickNavigation(ReportView.class, Report::getId); } diff --git a/acrarium/src/main/java/com/faendir/acra/ui/component/CardDialog.java b/acrarium/src/main/java/com/faendir/acra/ui/component/CardDialog.java deleted file mode 100644 index 09f4a19..0000000 --- a/acrarium/src/main/java/com/faendir/acra/ui/component/CardDialog.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * (C) Copyright 2019 Lukas Morawietz (https://github.com/F43nd1r) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.faendir.acra.ui.component; - -import com.vaadin.flow.component.Component; -import com.vaadin.flow.component.dialog.Dialog; -import com.vaadin.flow.component.html.Div; - -/** - * @author lukas - * @since 24.04.19 - */ -public class CardDialog extends Dialog implements HasSize, HasStyle { - private final Div header; - private final Div content; - - public CardDialog() { - header = new Div(); - header.getStyle().set("padding", "1rem"); - header.getStyle().set("box-sizing", "border-box"); - header.getStyle().set("background-color", "var(--lumo-contrast-5pct)"); - header.getStyle().set("display", "inline-block"); - header.setWidth("100%"); - content = new Div(); - content.getStyle().set("padding", "1rem"); - content.getStyle().set("box-sizing", "border-box"); - content.getStyle().set("display", "inline-block"); - content.setSizeFull(); - super.add(header, content); - } - - public CardDialog(Component... components) { - this(); - add(components); - } - - public void removeAll() { - content.removeAll(); - } - - public void addComponentAtIndex(int index, Component component) { - content.addComponentAtIndex(index, component); - } - - public void addComponentAsFirst(Component component) { - content.addComponentAsFirst(component); - } - - public void add(Component... components) { - content.add(components); - } - - public void remove(Component... components) { - content.remove(components); - } - - public void setHeader(Component... components) { - header.removeAll(); - header.add(components); - } - - public void setHeaderColor(String textColor, String backgroundColor) { - header.getStyle().set("color",textColor); - header.getStyle().set("background-color", backgroundColor); - } -} diff --git a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java index db0bf09..3925c18 100644 --- a/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java +++ b/acrarium/src/main/java/com/faendir/acra/ui/component/Translatable.java @@ -30,6 +30,7 @@ import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.checkbox.Checkbox; import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.html.Div; +import com.vaadin.flow.component.html.H3; import com.vaadin.flow.component.html.Image; import com.vaadin.flow.component.select.Select; import com.vaadin.flow.component.textfield.NumberField; @@ -148,6 +149,10 @@ public class Translatable extends Composite implements L return create(new Label(), captionId, params); } + public static Translatable

createH3(@NonNull String captionId, @NonNull Object... params) { + return create(new H3(), captionId, params); + } + public static Translatable createImage(@NonNull String src, @NonNull String captionId, @NonNull Object... params) { return new Translatable<>(new Image(src, ""), image -> image.setAlt(image.getTranslation(captionId, params))); } diff --git a/acrarium/src/main/java/com/faendir/acra/ui/component/dialog/AcrariumDialog.java b/acrarium/src/main/java/com/faendir/acra/ui/component/dialog/AcrariumDialog.java new file mode 100644 index 0000000..d3e1d8f --- /dev/null +++ b/acrarium/src/main/java/com/faendir/acra/ui/component/dialog/AcrariumDialog.java @@ -0,0 +1,84 @@ +package com.faendir.acra.ui.component.dialog; + +import com.faendir.acra.ui.component.Translatable; +import com.vaadin.flow.component.ClickEvent; +import com.vaadin.flow.component.Component; +import com.vaadin.flow.component.ComponentEventListener; +import com.vaadin.flow.component.button.Button; +import com.vaadin.flow.component.button.ButtonVariant; +import com.vaadin.flow.component.dialog.Dialog; +import com.vaadin.flow.dom.Element; + +import java.util.Optional; + +public class AcrariumDialog extends Dialog { + private final DialogContent content; + + public AcrariumDialog() { + this.content = new DialogContent(); + super.add(content); + } + + public void setHeader(String captionId, Object... params) { + content.setHeader(Translatable.createH3(captionId, params)); + } + + public void setPositive(ComponentEventListener> clickListener, String captionId, Object... params) { + Translatable