You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2021/11/26 14:31:11 UTC
[openmeetings] 01/02: [OPENMEETINGS-2488] bootstrap-confirmation used instead of dialog
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
commit 5cee9a554b36cafcb35bef26e69361810aa1c4ec
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Fri Nov 26 21:27:45 2021 +0700
[OPENMEETINGS-2488] bootstrap-confirmation used instead of dialog
---
.../common/confirmation/ConfirmableAjaxBorder.html | 26 --------
.../common/confirmation/ConfirmableAjaxBorder.java | 74 ---------------------
.../common/confirmation/ConfirmationDialog.java | 77 ----------------------
.../common/confirmation/ConfirmationHelper.java | 12 +---
.../web/common/tree/FileTreePanel.html | 23 ++-----
.../web/common/tree/FileTreePanel.java | 57 ++++++++--------
.../openmeetings/web/common/tree/filetree.js | 13 ++--
.../web/room/sidebar/{upload.js => room-upload.js} | 0
.../openmeetings/web/user/chat/ChatToolbar.java | 6 +-
9 files changed, 44 insertions(+), 244 deletions(-)
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.html
deleted file mode 100644
index 590405b..0000000
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
-
--->
-<!DOCTYPE html>
-<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-9.xsd">
-<wicket:border>
- <wicket:body/>
-</wicket:border>
-</html>
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.java
deleted file mode 100644
index a344fc5..0000000
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmableAjaxBorder.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.openmeetings.web.common.confirmation;
-
-import static org.apache.openmeetings.web.common.BasePanel.EVT_CLICK;
-
-import org.apache.wicket.ajax.AjaxEventBehavior;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.markup.html.border.Border;
-
-public abstract class ConfirmableAjaxBorder extends Border {
- private static final long serialVersionUID = 1L;
- private final ConfirmationDialog dialog;
-
- protected ConfirmableAjaxBorder(String id, ConfirmationDialog dialog) {
- super(id);
- this.dialog = dialog;
- setOutputMarkupId(true);
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
- add(new AjaxEventBehavior(EVT_CLICK) {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- ConfirmableAjaxBorder.this.updateAjaxAttributes(attributes);
- }
-
- @Override
- protected void onEvent(AjaxRequestTarget target) {
- if (isClickable()) {
- dialog.show(target);
- }
- }
- });
- }
-
- protected boolean isClickable() {
- return true;
- }
-
- /**
- * Gives a chance to the specializations to modify the attributes.
- *
- * @param attributes - attributes
- */
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- }
-
- protected void onEvent(AjaxRequestTarget target) {
- dialog.show(target);
- }
-}
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationDialog.java
deleted file mode 100644
index 7ded64f..0000000
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationDialog.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.openmeetings.web.common.confirmation;
-
-import org.apache.openmeetings.web.common.OmModalCloseButton;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.ResourceModel;
-
-import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.CssClassNameAppender;
-import de.agilecoders.wicket.core.markup.html.bootstrap.button.BootstrapAjaxLink;
-import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
-import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.TextContentModal;
-import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType;
-import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType;
-
-public abstract class ConfirmationDialog extends TextContentModal {
- private static final long serialVersionUID = 1L;
- private BootstrapAjaxLink<String> okButton;
-
- protected ConfirmationDialog(String id, IModel<String> title, IModel<String> model) {
- super(id, model);
- header(title);
- }
-
- private BootstrapAjaxLink<String> getOkButton() {
- if (okButton == null) {
- okButton = new BootstrapAjaxLink<>(BUTTON_MARKUP_ID, null, Buttons.Type.Outline_Danger, new ResourceModel("54")) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- close(target);
- onConfirm(target);
- }
- };
- okButton.setIconType(FontAwesome5IconType.exclamation_triangle_s);
- }
- return okButton;
- }
-
- public ConfirmationDialog withOkType(Buttons.Type type) {
- getOkButton().setType(type);
- return this;
- }
-
- public ConfirmationDialog withOkIcon(IconType icon) {
- getOkButton().setIconType(icon);
- return this;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
- add(new CssClassNameAppender("om-confirm-dialog"));
- addButton(getOkButton());
- addButton(OmModalCloseButton.of());
- }
-
- protected abstract void onConfirm(AjaxRequestTarget target);
-}
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationHelper.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationHelper.java
index 444452e..1cf1644 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationHelper.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/confirmation/ConfirmationHelper.java
@@ -18,8 +18,6 @@
*/
package org.apache.openmeetings.web.common.confirmation;
-import java.util.function.Consumer;
-
import org.apache.wicket.Component;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationBehavior;
@@ -31,17 +29,13 @@ public class ConfirmationHelper {
}
public static ConfirmationBehavior newOkCancelDangerConfirm(Component c, String title) {
- return newOkCancelDangerConfirm(c, title, null);
+ return new ConfirmationBehavior(newOkCancelDangerConfirmCfg(c, title));
}
- public static ConfirmationBehavior newOkCancelDangerConfirm(Component c, String title, Consumer<ConfirmationConfig> cfgCustomizer) {
- ConfirmationConfig cfg = newOkCancelConfirmCfg(c, title)
+ public static ConfirmationConfig newOkCancelDangerConfirmCfg(Component c, String title) {
+ return newOkCancelConfirmCfg(c, title)
.withBtnOkClass("btn btn-sm btn-danger")
.withBtnOkIconClass("fas fa-exclamation-triangle");
- if (cfgCustomizer != null) {
- cfgCustomizer.accept(cfg);
- }
- return new ConfirmationBehavior(cfg);
}
private static ConfirmationConfig newOkCancelConfirmCfg(Component c, String title) {
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.html
index 5bfa3c0..9bdb387 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.html
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.html
@@ -23,29 +23,15 @@
<wicket:panel>
<form wicket:id="form" class="h-100">
<div class="file-tree item drop area">
- <div class="icons clear trash-toolbar" wicket:id="trash-toolbar" wicket:message="title:705">
+ <div class="icons clear trash-toolbar" wicket:id="trash-toolbar"
+ data-btn-ok-class="btn btn-sm btn-danger"
+ data-btn-ok-icon-class="fas fa-exclamation-triangle"
+ wicket:message="title:705, data-btn-ok-label:54, data-btn-cancel-label:lbl.cancel, data-title:80, data-bs-content:713">
<span wicket:id="upload" wicket:message="title:702"></span>
<span wicket:id="create" wicket:message="title:703"></span>
<span wicket:id="refresh" class="refresh om-icon big align-left clickable" wicket:message="title:lbl.refresh"></span>
<span wicket:id="trash"></span>
<div class="clear"></div>
- <div id="om-js-trash-confirm" class="modal om-confirm-dialog" tabindex="-1" data-bs-backdrop="static" role="dialog" aria-labelledby="om-js-trash-confirm-header" aria-modal="true" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title" id="om-js-trash-confirm-header"><wicket:message key="80"/></h4>
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
- </div>
- <div class="modal-body"><wicket:message key="713"/></div>
- <div class="modal-footer">
- <button type="button" class="btn btn-outline-danger ok-btn">
- <i class="fas fa-exclamation-triangle"></i> <wicket:message key="54"/>
- </button>
- <button type="button" data-bs-dismiss="modal" class="btn btn-outline-secondary"><wicket:message key="lbl.cancel"/></button>
- </div>
- </div>
- </div>
- </div>
</div>
<div wicket:id="tree-container" class="trees">
<div id="tree-anchor"></div>
@@ -67,6 +53,5 @@
<div wicket:id="errors"></div>
</div>
</form>
- <div wicket:id="trash-confirm-dialog"></div>
</wicket:panel>
</html>
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java
index 8ea79c8..21aea80 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/FileTreePanel.java
@@ -28,6 +28,7 @@ import static org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_CLASS;
import static org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_TITLE;
import static org.apache.openmeetings.web.app.WebSession.getUserId;
import static org.apache.openmeetings.web.common.BasePanel.EVT_CLICK;
+import static org.apache.openmeetings.web.common.confirmation.ConfirmationHelper.newOkCancelDangerConfirmCfg;
import static org.apache.openmeetings.web.pages.BasePage.ALIGN_LEFT;
import static org.apache.openmeetings.web.pages.BasePage.ALIGN_RIGHT;
@@ -46,8 +47,6 @@ import org.apache.openmeetings.db.entity.file.FileItem;
import org.apache.openmeetings.db.entity.record.Recording;
import org.apache.openmeetings.util.OmFileHelper;
import org.apache.openmeetings.web.common.NameDialog;
-import org.apache.openmeetings.web.common.confirmation.ConfirmableAjaxBorder;
-import org.apache.openmeetings.web.common.confirmation.ConfirmationDialog;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
@@ -85,6 +84,7 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.button.ButtonBehavior;
import de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons;
import de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.SplitButton;
import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType;
+import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationBehavior;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType;
public abstract class FileTreePanel extends Panel {
@@ -125,7 +125,8 @@ public abstract class FileTreePanel extends Panel {
private final WebMarkupContainer buttons = new WebMarkupContainer("buttons");
private final Form<Void> form = new Form<>("form");
private final NameDialog addFolder;
- private ConfirmableAjaxBorder trashBorder;
+ private final WebMarkupContainer trash = new WebMarkupContainer("trash");
+ private ConfirmationBehavior trashConfirm;
private final Long roomId;
private boolean readOnly = true;
private final Component createDir = new WebMarkupContainer("create").add(new AjaxEventBehavior(EVT_CLICK) {
@@ -137,7 +138,6 @@ public abstract class FileTreePanel extends Panel {
}
});
private final Component upload = new WebMarkupContainer("upload");
- private ConfirmationDialog confirmTrashDialog;
@SpringBean
private RecordingDao recDao;
@@ -212,8 +212,25 @@ public abstract class FileTreePanel extends Panel {
update(target);
}
}));
- trashToolbar.add(getTrashBorder());
- add(confirmTrashDialog);
+ trashToolbar.add(trash.setOutputMarkupId(true));
+ trash.add(new AjaxEventBehavior("confirmed.bs.confirmation") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onEvent(AjaxRequestTarget target) {
+ deleteAll(target);
+ }
+ });
+
+ trashConfirm = new ConfirmationBehavior(newOkCancelDangerConfirmCfg(trashToolbar, getString("80")).withContent(getString("713"))) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean isEnabled(Component component) {
+ return !readOnly && !selected.isEmpty();
+ }
+ };
+ trash.add(trashConfirm);
form.add(trees.add(tree).setOutputMarkupId(true));
updateSizes();
@@ -313,28 +330,6 @@ public abstract class FileTreePanel extends Panel {
}));
}
- private ConfirmableAjaxBorder getTrashBorder() {
- if (trashBorder == null) {
- confirmTrashDialog = new ConfirmationDialog("trash-confirm-dialog", new ResourceModel("80"), new ResourceModel("713")) {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onConfirm(AjaxRequestTarget target) {
- deleteAll(target);
- }
- };
- trashBorder = new ConfirmableAjaxBorder("trash", confirmTrashDialog) {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected boolean isClickable() {
- return !readOnly && !selected.isEmpty();
- }
- };
- }
- return trashBorder;
- }
-
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
@@ -384,9 +379,9 @@ public abstract class FileTreePanel extends Panel {
createDir.add(AttributeModifier.replace(ATTR_CLASS, CREATE_DIR_CLASS + (readOnly ? DISABLED_CLASS : "")));
upload.setEnabled(!readOnly);
upload.add(AttributeModifier.replace(ATTR_CLASS, UPLOAD_CLASS + (readOnly ? DISABLED_CLASS : "")));
- trashBorder.add(AttributeModifier.replace(ATTR_CLASS, TRASH_CLASS + (readOnly ? DISABLED_CLASS : "")));
+ trash.add(AttributeModifier.replace(ATTR_CLASS, TRASH_CLASS + (readOnly ? DISABLED_CLASS : "")));
if (handler != null) {
- handler.add(createDir, upload, trashBorder);
+ handler.add(createDir, upload, trash);
update(handler);
}
}
@@ -509,7 +504,7 @@ public abstract class FileTreePanel extends Panel {
}
updateSelected(target); //all finally selected are in the update list
if (target != null) {
- target.add(trashBorder, buttons);
+ target.add(trash, buttons);
}
}
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/filetree.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/filetree.js
index 1d8584e..dbb426d 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/filetree.js
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/tree/filetree.js
@@ -15,13 +15,14 @@ var OmFileTree = (function() {
return !dropped || (!!dropped.context && $(dropped.context).hasClass('wb', 'room'));
}
, confirmTrash: function(drop, ui, callback) {
- const dlg = $('#om-js-trash-confirm');
- dlg.find('.ok-btn').off().click(function() {
- drop.append(ui.draggable);
- dlg.modal('hide');
- callback();
+ $('.trash-toolbar').confirmation({
+ trigger: 'manual'
+ , onConfirm: () => {
+ drop.append(ui.draggable);
+ callback();
+ }
});
- dlg.modal('show');
+ $('.trash-toolbar').confirmation('show');
}
}
})();
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/upload.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/room-upload.js
similarity index 100%
rename from openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/upload.js
rename to openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/room-upload.js
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.java
index 1273f7c..15501b5 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/chat/ChatToolbar.java
@@ -26,7 +26,7 @@ import static org.apache.openmeetings.web.app.WebSession.getDateFormat;
import static org.apache.openmeetings.web.app.WebSession.getRights;
import static org.apache.openmeetings.web.app.WebSession.getUserId;
import static org.apache.openmeetings.web.common.BasePanel.EVT_CLICK;
-import static org.apache.openmeetings.web.common.confirmation.ConfirmationHelper.newOkCancelDangerConfirm;
+import static org.apache.openmeetings.web.common.confirmation.ConfirmationHelper.newOkCancelDangerConfirmCfg;
import static org.apache.openmeetings.web.room.RoomPanel.isModerator;
import java.util.List;
@@ -56,6 +56,8 @@ import com.github.openjson.JSONObject;
import com.googlecode.wicket.jquery.core.IJQueryWidget.JQueryWidget;
import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar;
+import de.agilecoders.wicket.extensions.markup.html.bootstrap.confirmation.ConfirmationBehavior;
+
/**
* Provides a custom implementation for com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.IWysiwygToolbar suitable
* for chat}
@@ -209,7 +211,7 @@ public class ChatToolbar extends Panel implements IWysiwygToolbar {
});
}
};
- delBtn.add(newOkCancelDangerConfirm(this, getString("832"), cfg -> cfg.withCustomClass("chat-delete")));
+ delBtn.add(new ConfirmationBehavior(newOkCancelDangerConfirmCfg(this, getString("832")).withCustomClass("chat-delete")));
toolbar.add(delBtn.setVisible(hasAdminLevel(getRights())).setOutputMarkupId(true)
.setOutputMarkupPlaceholderTag(true));
toolbar.add(save.setVisible(hasAdminLevel(getRights())).setOutputMarkupId(true)