CCM NG/ccm-core: Some more work for the Vaadin Prototype
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4715 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
3778e92584
commit
1050a6fc63
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.admin.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||||
|
|
||||||
|
import com.vaadin.ui.Button;
|
||||||
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
|
import com.vaadin.ui.Label;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
import com.vaadin.ui.Window;
|
||||||
|
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ConfirmDiscardDialog extends Window {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7270363517221672796L;
|
||||||
|
|
||||||
|
public ConfirmDiscardDialog(final Window window,
|
||||||
|
final String message) {
|
||||||
|
|
||||||
|
if (window == this) {
|
||||||
|
throw new IllegalArgumentException("ConfirmDiscardDialog can't be "
|
||||||
|
+ "used with itself.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final Label label = new Label(message);
|
||||||
|
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
|
final Button yesButton = new Button(bundle.getString("ui.admin.yes"));
|
||||||
|
yesButton.addClickListener(event -> {
|
||||||
|
close();
|
||||||
|
UI.getCurrent().removeWindow(window);
|
||||||
|
});
|
||||||
|
|
||||||
|
final Button noButton = new Button(bundle.getString("ui.admin.no"));
|
||||||
|
noButton.addClickListener(event -> close());
|
||||||
|
|
||||||
|
final HorizontalLayout buttonsLayout = new HorizontalLayout(yesButton,
|
||||||
|
noButton);
|
||||||
|
final VerticalLayout layout = new VerticalLayout(label,
|
||||||
|
buttonsLayout);
|
||||||
|
|
||||||
|
setContent(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -34,6 +34,7 @@ import com.vaadin.ui.TextField;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
|
import org.libreccm.admin.ui.ConfirmDiscardDialog;
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
import org.libreccm.security.User;
|
import org.libreccm.security.User;
|
||||||
import org.libreccm.security.UserManager;
|
import org.libreccm.security.UserManager;
|
||||||
|
|
@ -72,9 +73,11 @@ public class UserEditor extends Window {
|
||||||
private CheckBox passwordResetRequired;
|
private CheckBox passwordResetRequired;
|
||||||
private CheckBox banned;
|
private CheckBox banned;
|
||||||
|
|
||||||
public UserEditor(final UserRepository userRepo,
|
public UserEditor(final UserRepository userRepo,
|
||||||
final UserManager userManager) {
|
final UserManager userManager) {
|
||||||
|
|
||||||
|
super("Create new user");
|
||||||
|
|
||||||
user = null;
|
user = null;
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
|
|
@ -86,6 +89,8 @@ public class UserEditor extends Window {
|
||||||
final UserRepository userRepo,
|
final UserRepository userRepo,
|
||||||
final UserManager userManager) {
|
final UserManager userManager) {
|
||||||
|
|
||||||
|
super(String.format("Edit user %s", user.getName()));
|
||||||
|
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
|
|
@ -98,7 +103,7 @@ public class UserEditor extends Window {
|
||||||
final ResourceBundle bundle = ResourceBundle
|
final ResourceBundle bundle = ResourceBundle
|
||||||
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||||
UI.getCurrent().getLocale());
|
UI.getCurrent().getLocale());
|
||||||
|
|
||||||
userName = new TextField(bundle
|
userName = new TextField(bundle
|
||||||
.getString("ui.admin.user_edit.username.label"));
|
.getString("ui.admin.user_edit.username.label"));
|
||||||
userName.setRequiredIndicatorVisible(true);
|
userName.setRequiredIndicatorVisible(true);
|
||||||
|
|
@ -188,7 +193,7 @@ public class UserEditor extends Window {
|
||||||
|
|
||||||
banned = new CheckBox(bundle
|
banned = new CheckBox(bundle
|
||||||
.getString("ui.admin.user_edit.banned.label"));
|
.getString("ui.admin.user_edit.banned.label"));
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
banned.setVisible(false);
|
banned.setVisible(false);
|
||||||
banned.setEnabled(false);
|
banned.setEnabled(false);
|
||||||
|
|
@ -203,6 +208,7 @@ public class UserEditor extends Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Button cancel = new Button(bundle.getString("ui.admin.cancel"));
|
final Button cancel = new Button(bundle.getString("ui.admin.cancel"));
|
||||||
|
cancel.addClickListener(event -> close());
|
||||||
|
|
||||||
final HorizontalLayout buttons = new HorizontalLayout(submit, cancel);
|
final HorizontalLayout buttons = new HorizontalLayout(submit, cancel);
|
||||||
|
|
||||||
|
|
@ -229,5 +235,15 @@ public class UserEditor extends Window {
|
||||||
|
|
||||||
setContent(panel);
|
setContent(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
final ConfirmDiscardDialog dialog = new ConfirmDiscardDialog(
|
||||||
|
this, "Are you sure to discard the changes made this user?");
|
||||||
|
dialog.setModal(true);
|
||||||
|
UI.getCurrent().addWindow(dialog);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -572,3 +572,5 @@ ui.admin.users.table.filter.screenname.description=Filter users by user name
|
||||||
ui.admin.user_set_password_confirm.label=Confirm password
|
ui.admin.user_set_password_confirm.label=Confirm password
|
||||||
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
||||||
ui.admin.user_edit.password_options.set=Set password
|
ui.admin.user_edit.password_options.set=Set password
|
||||||
|
ui.admin.yes=Yes
|
||||||
|
ui.admin.no=No
|
||||||
|
|
|
||||||
|
|
@ -576,3 +576,5 @@ ui.admin.users.table.filter.screenname.description=Filter users by user name
|
||||||
ui.admin.user_set_password_confirm.label=Passwort best\u00e4tigen
|
ui.admin.user_set_password_confirm.label=Passwort best\u00e4tigen
|
||||||
ui.admin.user_edit.password_options.generate_and_send=Generieren und an Benutzer senden
|
ui.admin.user_edit.password_options.generate_and_send=Generieren und an Benutzer senden
|
||||||
ui.admin.user_edit.password_options.set=Passwort setzen
|
ui.admin.user_edit.password_options.set=Passwort setzen
|
||||||
|
ui.admin.yes=Ja
|
||||||
|
ui.admin.no=Nein
|
||||||
|
|
|
||||||
|
|
@ -569,3 +569,5 @@ ui.admin.users.table.filter.screenname.description=Filter users by user name
|
||||||
ui.admin.user_set_password_confirm.label=Confirm password
|
ui.admin.user_set_password_confirm.label=Confirm password
|
||||||
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
||||||
ui.admin.user_edit.password_options.set=Set password
|
ui.admin.user_edit.password_options.set=Set password
|
||||||
|
ui.admin.yes=Yes
|
||||||
|
ui.admin.no=No
|
||||||
|
|
|
||||||
|
|
@ -560,3 +560,5 @@ ui.admin.users.table.filter.screenname.description=Filter users by user name
|
||||||
ui.admin.user_set_password_confirm.label=Confirm password
|
ui.admin.user_set_password_confirm.label=Confirm password
|
||||||
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
ui.admin.user_edit.password_options.generate_and_send=Generate and send to user
|
||||||
ui.admin.user_edit.password_options.set=Set password
|
ui.admin.user_edit.password_options.set=Set password
|
||||||
|
ui.admin.yes=Yes
|
||||||
|
ui.admin.no=No
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue