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 20d0e1fe62e7906213a4eaec5f7ca906bc055929
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Sun Apr 15 20:49:08 2018 +0700

    [OPENMEETINGS-1864] restore is implemented
---
 .../openmeetings/web/admin/AdminBaseForm.java      | 58 +++++++++-----------
 .../openmeetings/web/admin/AdminSavePanel.html     |  8 +--
 .../openmeetings/web/admin/AdminSavePanel.java     | 63 +++++++++++++++++++---
 .../openmeetings/web/admin/groups/GroupForm.java   | 11 ++--
 .../openmeetings/web/admin/labels/LangPanel.html   | 46 ++++++++--------
 .../openmeetings/web/admin/users/UserForm.java     | 11 +++-
 .../web/app/Application.properties.xml             |  2 +
 .../web/common/FormSaveRefreshPanel.java           | 17 ++----
 openmeetings-web/src/main/webapp/css/general.css   | 11 ----
 9 files changed, 128 insertions(+), 99 deletions(-)

diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminBaseForm.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminBaseForm.java
index c6f300c..9fb1dc2 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminBaseForm.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminBaseForm.java
@@ -51,8 +51,8 @@ public abstract class AdminBaseForm<T> extends Form<T> {
                        }
 
                        @Override
-                       protected void onSaveError(AjaxRequestTarget target, 
Form<?> form) {
-                               AdminBaseForm.this.onSaveError(target, form);
+                       protected void onError(AjaxRequestTarget target, 
Form<?> form) {
+                               AdminBaseForm.this.onError(target, form);
                        }
 
                        @Override
@@ -61,28 +61,23 @@ public abstract class AdminBaseForm<T> extends Form<T> {
                        }
 
                        @Override
-                       protected void onNewError(AjaxRequestTarget target, 
Form<?> form) {
-                               AdminBaseForm.this.onNewError(target, form);
-                       }
-
-                       @Override
                        protected void onRefreshSubmit(AjaxRequestTarget 
target, Form<?> form) {
                                AdminBaseForm.this.onRefreshSubmit(target, 
form);
                        }
 
                        @Override
-                       protected void onRefreshError(AjaxRequestTarget target, 
Form<?> form) {
-                               AdminBaseForm.this.onRefreshError(target, form);
+                       protected void onDeleteSubmit(AjaxRequestTarget target, 
Form<?> form) {
+                               AdminBaseForm.this.onDeleteSubmit(target, form);
                        }
 
                        @Override
-                       protected void onDeleteSubmit(AjaxRequestTarget target, 
Form<?> form) {
-                               AdminBaseForm.this.onDeleteSubmit(target, form);
+                       protected void onPurgeSubmit(AjaxRequestTarget target, 
Form<?> form) {
+                               AdminBaseForm.this.onPurgeSubmit(target, form);
                        }
 
                        @Override
-                       protected void onDeleteError(AjaxRequestTarget target, 
Form<?> form) {
-                               AdminBaseForm.this.onDeleteError(target, form);
+                       protected void onRestoreSubmit(AjaxRequestTarget 
target, Form<?> form) {
+                               AdminBaseForm.this.onRestoreSubmit(target, 
form);
                        }
                };
                add(savePanel);
@@ -109,9 +104,14 @@ public abstract class AdminBaseForm<T> extends Form<T> {
                savePanel.setSaveVisible(visible);
        }
 
-       protected boolean isDelBtnVisible() {
-               return true;
+       public void setPurgeVisible(boolean visible) {
+               savePanel.setPurgeVisible(visible);
        }
+
+       public void setRestoreVisible(boolean visible) {
+               savePanel.setRestoreVisible(visible);
+       }
+
        /**
         * invoked when user press save button
         *
@@ -126,7 +126,7 @@ public abstract class AdminBaseForm<T> extends Form<T> {
         * @param target - ajax target to update form component
         * @param form - Form being processed
         */
-       protected void onSaveError(AjaxRequestTarget target, Form<?> form) {
+       protected void onError(AjaxRequestTarget target, Form<?> form) {
                //no-op
        }
 
@@ -139,16 +139,6 @@ public abstract class AdminBaseForm<T> extends Form<T> {
        protected abstract void onNewSubmit(AjaxRequestTarget target, Form<?> 
form);
 
        /**
-        * invoked if new has error
-        *
-        * @param target - ajax target to update form component
-        * @param form - Form being processed
-        */
-       protected void onNewError(AjaxRequestTarget target, Form<?> form) {
-               //no-op
-       }
-
-       /**
         * invoked when refresh button is pressed
         *
         * @param target - ajax target to update form component
@@ -157,30 +147,30 @@ public abstract class AdminBaseForm<T> extends Form<T> {
        protected abstract void onRefreshSubmit(AjaxRequestTarget target, 
Form<?> form);
 
        /**
-        * invoked when refresh has error
+        * invoked when delete button is pressed
         *
         * @param target - ajax target to update form component
         * @param form - Form being processed
         */
-       protected void onRefreshError(AjaxRequestTarget target, Form<?> form) {
-               //no-op
-       }
+       protected abstract void onDeleteSubmit(AjaxRequestTarget target, 
Form<?> form);
 
        /**
-        * invoked when delete button is pressed
+        * invoked when purge button is pressed
         *
         * @param target - ajax target to update form component
         * @param form - Form being processed
         */
-       protected abstract void onDeleteSubmit(AjaxRequestTarget target, 
Form<?> form);
+       protected void onPurgeSubmit(AjaxRequestTarget target, Form<?> form) {
+               //no-op
+       }
 
        /**
-        * invoked when delete has error
+        * invoked when restore button is pressed
         *
         * @param target - ajax target to update form component
         * @param form - Form being processed
         */
-       protected void onDeleteError(AjaxRequestTarget target, Form<?> form) {
+       protected void onRestoreSubmit(AjaxRequestTarget target, Form<?> form) {
                //no-op
        }
 
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.html
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.html
index 6f79aca..a930582 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.html
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.html
@@ -20,16 +20,16 @@
 -->
 <html xmlns:wicket="http://wicket.apache.org";>
        <wicket:extend>
-               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only" wicket:id="ajax-new-button" wicket:message="title:155">
+               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only" wicket:id="btn-new" wicket:message="title:155">
                        <span class="ui-button-icon ui-icon 
ui-icon-plusthick"></span>&nbsp;
                </div>
-               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-highlight" wicket:id="ajax-cancel-button" 
wicket:message="title:157">
+               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-highlight" wicket:id="btn-delete" 
wicket:message="title:157">
                        <span class="ui-button-icon ui-icon 
ui-icon-closethick"></span>&nbsp;
                </div>
-               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-error">
+               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-error" wicket:id="btn-purge" 
wicket:message="title:admin.purge">
                        <span class="ui-button-icon ui-icon 
ui-icon-trash"></span>&nbsp;
                </div>
-               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only">
+               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only" wicket:id="btn-restore" 
wicket:message="title:admin.restore">
                        <span class="ui-button-icon ui-icon 
ui-icon-circle-check"></span>&nbsp;
                </div>
                <span wicket:id="newRecord"></span>
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.java
index 867a06c..21eaf7e 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/AdminSavePanel.java
@@ -31,6 +31,8 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
        private final Label newRecord = new Label("newRecord", Model.of(""));
        private final Form<T> form;
        private ConfirmableAjaxBorder delBtn;
+       private AjaxButton purgeBtn;
+       private AjaxButton restoreBtn;
 
        public AdminSavePanel(String id, final Form<T> form) {
                super(id, form);
@@ -42,7 +44,7 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
                newRecord.setDefaultModelObject(getString("155"));
                add(newRecord.setVisible(false).setOutputMarkupId(true));
 
-               final AjaxButton newBtn = new AjaxButton("ajax-new-button", 
form) {
+               final AjaxButton newBtn = new AjaxButton("btn-new", form) {
                        private static final long serialVersionUID = 1L;
 
                        @Override
@@ -58,14 +60,14 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
                        protected void onError(AjaxRequestTarget target) {
                                // repaint the feedback panel so errors are 
shown
                                target.add(feedback);
-                               onNewError(target, form);
+                               AdminSavePanel.this.onError(target, form);
                        }
                };
                // add a cancel button that can be used to submit the form via 
ajax
                final Form<?> cForm = new Form<>("form");
                cForm.setMultiPart(form.isMultiPart());
                add(cForm);
-               delBtn = new ConfirmableAjaxBorder("ajax-cancel-button", 
getString("80"), getString("833"), cForm) {
+               delBtn = new ConfirmableAjaxBorder("btn-delete", 
getString("80"), getString("833"), cForm) {
                        private static final long serialVersionUID = 1L;
 
                        @Override
@@ -73,7 +75,7 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
                                // repaint the feedback panel so errors are 
shown
                                target.add(feedback);
                                setNewVisible(false);
-                               onDeleteError(target, form);
+                               AdminSavePanel.this.onError(target, form);
                        }
 
                        @Override
@@ -84,7 +86,45 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
                                onDeleteSubmit(target, form);
                        }
                };
-               add(newBtn, delBtn);
+               purgeBtn = new AjaxButton("btn-purge", form) {
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       protected void onSubmit(AjaxRequestTarget target) {
+                               // repaint the feedback panel so that it is 
hidden
+                               target.add(feedback);
+                               setNewVisible(false);
+                               onPurgeSubmit(target, form);
+                       }
+
+                       @Override
+                       protected void onError(AjaxRequestTarget target) {
+                               // repaint the feedback panel so errors are 
shown
+                               target.add(feedback);
+                               AdminSavePanel.this.onError(target, form);
+                       }
+               };
+               restoreBtn = new AjaxButton("btn-restore", form) {
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       protected void onSubmit(AjaxRequestTarget target) {
+                               // repaint the feedback panel so that it is 
hidden
+                               target.add(feedback);
+                               setNewVisible(false);
+                               onRestoreSubmit(target, form);
+                       }
+
+                       @Override
+                       protected void onError(AjaxRequestTarget target) {
+                               // repaint the feedback panel so errors are 
shown
+                               target.add(feedback);
+                               AdminSavePanel.this.onError(target, form);
+                       }
+               };
+               add(newBtn, delBtn
+                               , 
purgeBtn.setOutputMarkupPlaceholderTag(true).setVisible(false)
+                               , 
restoreBtn.setOutputMarkupPlaceholderTag(true).setVisible(false));
                super.onInitialize();
        }
 
@@ -97,9 +137,16 @@ public abstract class AdminSavePanel<T> extends 
FormSaveRefreshPanel<T> {
                delBtn.setVisible(visible);
        }
 
-       protected abstract void onNewSubmit(AjaxRequestTarget target, Form<?> 
form);
-       protected abstract void onNewError(AjaxRequestTarget target, Form<?> 
form);
+       public void setPurgeVisible(boolean visible) {
+               purgeBtn.setVisible(visible);
+       }
+
+       public void setRestoreVisible(boolean visible) {
+               restoreBtn.setVisible(visible);
+       }
 
+       protected abstract void onNewSubmit(AjaxRequestTarget target, Form<?> 
form);
        protected abstract void onDeleteSubmit(AjaxRequestTarget target, 
Form<?> form);
-       protected abstract void onDeleteError(AjaxRequestTarget target, Form<?> 
form);
+       protected abstract void onPurgeSubmit(AjaxRequestTarget target, Form<?> 
form);
+       protected abstract void onRestoreSubmit(AjaxRequestTarget target, 
Form<?> form);
 }
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/groups/GroupForm.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/groups/GroupForm.java
index 4cc8aae..b1531d6 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/groups/GroupForm.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/groups/GroupForm.java
@@ -137,11 +137,6 @@ public class GroupForm extends AdminBaseForm<Group> {
        }
 
        @Override
-       protected boolean isDelBtnVisible() {
-               return !hasGroupAdminLevel(getRights());
-       }
-
-       @Override
        protected void onInitialize() {
                super.onInitialize();
                final boolean isGroupAdmin = hasGroupAdminLevel(getRights());
@@ -172,6 +167,12 @@ public class GroupForm extends AdminBaseForm<Group> {
                
add(reminderDays.setLabel(Model.of(getString("admin.group.form.reminderDays"))).setEnabled(false).setOutputMarkupId(true));
        }
 
+       @Override
+       protected void onConfigure() {
+               super.onConfigure();
+               setDelVisible(!hasGroupAdminLevel(getRights()));
+       }
+
        public void updateView(AjaxRequestTarget target) {
                userToadd.setModelObject(null);
                usersPanel.update(getGroupId());
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/labels/LangPanel.html
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/labels/LangPanel.html
index 78af381..ec40691 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/labels/LangPanel.html
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/labels/LangPanel.html
@@ -34,28 +34,30 @@
        <div wicket:id="feedback"></div>
        <div class="adminPanelColumnTable">
                <div>
-               <div wicket:id="addLangBtn" class="addButton" 
wicket:message="title:362" ></div>
-               <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-error" wicket:id="deleteLangBtn" 
wicket:message="title:363">
-                       <span class="ui-button-icon ui-icon 
ui-icon-closethick"></span>&nbsp;
-               </div>
-               <form wicket:id="langForm" class="addLanguagePanel">
-                       <table>
-                               <tr>
-                                       <td>
-                                               <select 
wicket:id="language"></select>
-                                       </td>
-                                       <td>
-                                               <span wicket:id="export" 
class="btn"><wicket:message key="360"/></span>
-                                       </td>
-                                       <td>
-                                               <div class="fileupload 
fileupload-new" data-provides="fileupload" style="margin: 0;">
-                                                       <span class="btn 
btn-file ui-button ui-widget ui-state-default ui-corner-all 
ui-button-text-only"><span class="ui-button-text"><wicket:message 
key="387"/></span><input type="file" accept="text/xml" 
wicket:id="fileInput"/></span>
-                                               </div>
-                                               <span 
wicket:id="progress">[progressbar]</span>
-                                       </td>
-                               </tr>
-                       </table>
-               </form>
+                       <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only" style="margin-top: -1.5em;" wicket:id="addLangBtn" 
wicket:message="title:362">
+                               <span class="ui-button-icon ui-icon 
ui-icon-plusthick"></span>&nbsp;
+                       </div>
+                       <div class="ui-button ui-widget ui-corner-all 
ui-button-icon-only ui-state-error" style="margin-top: -1.5em;" 
wicket:id="deleteLangBtn" wicket:message="title:363">
+                               <span class="ui-button-icon ui-icon 
ui-icon-closethick"></span>&nbsp;
+                       </div>
+                       <form wicket:id="langForm" class="addLanguagePanel">
+                               <table>
+                                       <tr>
+                                               <td>
+                                                       <select 
wicket:id="language"></select>
+                                               </td>
+                                               <td>
+                                                       <span 
wicket:id="export" class="btn"><wicket:message key="360"/></span>
+                                               </td>
+                                               <td>
+                                                       <div class="fileupload 
fileupload-new" data-provides="fileupload" style="margin: 0;">
+                                                               <span 
class="btn btn-file ui-button ui-widget ui-state-default ui-corner-all 
ui-button-text-only"><span class="ui-button-text"><wicket:message 
key="387"/></span><input type="file" accept="text/xml" 
wicket:id="fileInput"/></span>
+                                                       </div>
+                                                       <span 
wicket:id="progress">[progressbar]</span>
+                                               </td>
+                                       </tr>
+                               </table>
+                       </form>
                </div>
                <span wicket:id="navigator">[dataview navigator]</span>
                <table class="adminListTable">
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java
index adcdbaf..2083660 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/users/UserForm.java
@@ -182,15 +182,24 @@ public class UserForm extends AdminBaseForm<User> {
        protected void onModelChanged() {
                super.onModelChanged();
                boolean nd = !getModelObject().isDeleted();
+               boolean isNew = getModelObject().getId() == null;
                mainContainer.setEnabled(nd);
                setSaveVisible(nd);
-               setDelVisible(nd && getModelObject().getId() != null);
+               setDelVisible(nd && !isNew);
+               setRestoreVisible(!nd);
+               setPurgeVisible(!isNew);
                password.setModelObject(null);
                generalForm.updateModelObject(getModelObject(), true);
                passValidator.setUser(getModelObject());
        }
 
        @Override
+       protected void onRestoreSubmit(AjaxRequestTarget target, Form<?> form) {
+               getModelObject().setDeleted(false);
+               onSaveSubmit(target, form);
+       }
+
+       @Override
        protected void onSaveSubmit(AjaxRequestTarget target, Form<?> form) {
                if (isAdminPassRequired()) {
                        
adminPass.setAction((SerializableConsumer<AjaxRequestTarget>)t -> saveUser(t, 
password.getModelObject()));
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
index 07b2a68..56bfff2 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
@@ -1009,4 +1009,6 @@ see http://openmeetings.apache.org/LanguageEditor.html 
for Details
        <entry key="menu.polls"><![CDATA[Polls]]></entry>
        <entry key="menu.polls.quick.title"><![CDATA[Create Quick 
Poll]]></entry>
        <entry key="menu.polls.quick.descr"><![CDATA[Gather feedback without 
creating a poll]]></entry>
+       <entry key="admin.restore"><![CDATA[Restore]]></entry>
+       <entry key="admin.purge"><![CDATA[Purge]]></entry>
 </properties>
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/FormSaveRefreshPanel.java
 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/FormSaveRefreshPanel.java
index 1719e41..cca36cf 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/FormSaveRefreshPanel.java
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/FormSaveRefreshPanel.java
@@ -57,7 +57,7 @@ public abstract class FormSaveRefreshPanel<T> extends Panel {
                        protected void onError(AjaxRequestTarget target) {
                                // repaint the feedback panel so errors are 
shown
                                target.add(feedback);
-                               onSaveError(target, form);
+                               FormSaveRefreshPanel.this.onError(target, form);
                        }
                });
 
@@ -78,7 +78,7 @@ public abstract class FormSaveRefreshPanel<T> extends Panel {
                                // repaint the feedback panel so errors are 
shown
                                target.add(feedback);
                                setNewVisible(false);
-                               onRefreshError(target, form);
+                               FormSaveRefreshPanel.this.onError(target, form);
                        }
                });
                super.onInitialize();
@@ -105,20 +105,9 @@ public abstract class FormSaveRefreshPanel<T> extends 
Panel {
         * @param target Ajax target
         * @param form form object
         */
-       protected void onSaveError(AjaxRequestTarget target, Form<?> form) {
+       protected void onError(AjaxRequestTarget target, Form<?> form) {
                //no-op
        }
 
        protected abstract void onRefreshSubmit(AjaxRequestTarget target, 
Form<?> form);
-
-
-       /**
-        * Refresh error handler
-        *
-        * @param target Ajax target
-        * @param form form object
-        */
-       protected void onRefreshError(AjaxRequestTarget target, Form<?> form) {
-               //no-op
-       }
 }
diff --git a/openmeetings-web/src/main/webapp/css/general.css 
b/openmeetings-web/src/main/webapp/css/general.css
index 4dd9632..c1c4afe 100644
--- a/openmeetings-web/src/main/webapp/css/general.css
+++ b/openmeetings-web/src/main/webapp/css/general.css
@@ -568,17 +568,6 @@ form .input {
 div.formSaveBar {
        height: 35px;
 }
-.addButton {
-       display: inline-block;
-       cursor: pointer;
-       width: 18px;
-       height: 18px;
-       border: none;
-       margin-left: 2px;
-       margin-top: 2px;
-       vertical-align: super;
-       background: url(images/plus_icon.png) no-repeat;
-}
 .hash-panel-main {
        width: 100%;
        height: 100%;

-- 
To stop receiving notification emails like this one, please contact
solo...@apache.org.

Reply via email to