http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ResetPasswordDialog.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ResetPasswordDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ResetPasswordDialog.java index 8346aa1..bb19049 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ResetPasswordDialog.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/pages/auth/ResetPasswordDialog.java @@ -1,157 +1,157 @@ -/* - * 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.pages.auth; - -import static org.apache.openmeetings.db.util.UserHelper.getMinPasswdLength; -import static org.apache.openmeetings.web.app.Application.getBean; -import static org.apache.wicket.validation.validator.StringValidator.minimumLength; - -import java.util.Arrays; -import java.util.List; - -import org.apache.openmeetings.db.dao.basic.ConfigurationDao; -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.web.app.Application; -import org.apache.openmeetings.web.util.NonClosableDialog; -import org.apache.openmeetings.web.util.NonClosableMessageDialog; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.Model; - -import com.googlecode.wicket.jquery.core.JQueryBehavior; -import com.googlecode.wicket.jquery.core.Options; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; -import com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog; -import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel; - -public class ResetPasswordDialog extends NonClosableDialog<String> { - private static final long serialVersionUID = 1L; - private DialogButton resetBtn = new DialogButton("reset", Application.getString(327)); - private Form<String> form; - private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true)); - private PasswordTextField password; - private final User user; - final MessageDialog confirmReset; - - public ResetPasswordDialog(String id, final User user) { - super(id, Application.getString(325)); - this.user = user; - add(form = new Form<String>("form") { - private static final long serialVersionUID = 1L; - private TextField<String> login; - private PasswordTextField confirmPassword; - { - add(feedback.setOutputMarkupId(true)); - add(login = new TextField<>("login", Model.of(user.getLogin()))); - login.setOutputMarkupId(true); - add(password = new PasswordTextField("password", new Model<String>())); - password.setOutputMarkupId(true); - password.setLabel(Model.of(Application.getString(328))); - ConfigurationDao cfgDao = getBean(ConfigurationDao.class); - password.setRequired(false).add(minimumLength(getMinPasswdLength(cfgDao))); - add(confirmPassword = new PasswordTextField("confirmPassword", new Model<String>())); - confirmPassword.setOutputMarkupId(true); - confirmPassword.setLabel(Model.of(Application.getString(329))); - confirmPassword.setRequired(true).add(minimumLength(getMinPasswdLength(cfgDao))); - - add(new AjaxButton("submit") { // FAKE button so "submit-on-enter" works as expected - private static final long serialVersionUID = 1L; - - @Override - protected void onSubmit(AjaxRequestTarget target) { - ResetPasswordDialog.this.onSubmit(target); - } - - @Override - protected void onError(AjaxRequestTarget target) { - ResetPasswordDialog.this.onError(target); - } - }); - } - - @Override - protected void onValidate() { - String pass = password.getConvertedInput(); - if (pass != null && !pass.isEmpty() && !pass.equals(confirmPassword.getConvertedInput())) { - error(Application.getString(232)); - } - super.onValidate(); - } - - }); - confirmReset = new NonClosableMessageDialog("confirmReset", Application.getString(325), Application.getString(332)) { - private static final long serialVersionUID = 1L; - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton button) { - setResponsePage(Application.get().getSignInPageClass()); - } - }; - add(confirmReset); - } - - @Override - public void onConfigure(JQueryBehavior behavior) { - super.onConfigure(behavior); - behavior.setOption("autoOpen", true); - } - - @Override - protected List<DialogButton> getButtons() { - return Arrays.asList(resetBtn); - } - - @Override - public DialogButton getSubmitButton() { - return resetBtn; - } - - @Override - public Form<?> getForm() { - return form; - } - - @Override - protected void onError(AjaxRequestTarget target) { - target.add(feedback); - } - - @Override - protected void onSubmit(AjaxRequestTarget target) { - try { - getBean(UserDao.class).resetPassword(user, password.getConvertedInput()); - } catch (Exception e) { - error(e.getMessage()); - } - } - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton button) { - if (resetBtn.equals(button)) { - confirmReset.open(handler); - } else { - setResponsePage(Application.get().getSignInPageClass()); - } - } -} +/* + * 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.pages.auth; + +import static org.apache.openmeetings.db.util.UserHelper.getMinPasswdLength; +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.wicket.validation.validator.StringValidator.minimumLength; + +import java.util.Arrays; +import java.util.List; + +import org.apache.openmeetings.db.dao.basic.ConfigurationDao; +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.entity.user.User; +import org.apache.openmeetings.web.app.Application; +import org.apache.openmeetings.web.util.NonClosableDialog; +import org.apache.openmeetings.web.util.NonClosableMessageDialog; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxButton; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.PasswordTextField; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.model.Model; + +import com.googlecode.wicket.jquery.core.JQueryBehavior; +import com.googlecode.wicket.jquery.core.Options; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; +import com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog; +import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel; + +public class ResetPasswordDialog extends NonClosableDialog<String> { + private static final long serialVersionUID = 1L; + private DialogButton resetBtn = new DialogButton("reset", Application.getString(327)); + private Form<String> form; + private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true)); + private PasswordTextField password; + private final User user; + final MessageDialog confirmReset; + + public ResetPasswordDialog(String id, final User user) { + super(id, Application.getString(325)); + this.user = user; + add(form = new Form<String>("form") { + private static final long serialVersionUID = 1L; + private TextField<String> login; + private PasswordTextField confirmPassword; + { + add(feedback.setOutputMarkupId(true)); + add(login = new TextField<>("login", Model.of(user.getLogin()))); + login.setOutputMarkupId(true); + add(password = new PasswordTextField("password", new Model<String>())); + password.setOutputMarkupId(true); + password.setLabel(Model.of(Application.getString(328))); + ConfigurationDao cfgDao = getBean(ConfigurationDao.class); + password.setRequired(false).add(minimumLength(getMinPasswdLength(cfgDao))); + add(confirmPassword = new PasswordTextField("confirmPassword", new Model<String>())); + confirmPassword.setOutputMarkupId(true); + confirmPassword.setLabel(Model.of(Application.getString(329))); + confirmPassword.setRequired(true).add(minimumLength(getMinPasswdLength(cfgDao))); + + add(new AjaxButton("submit") { // FAKE button so "submit-on-enter" works as expected + private static final long serialVersionUID = 1L; + + @Override + protected void onSubmit(AjaxRequestTarget target) { + ResetPasswordDialog.this.onSubmit(target); + } + + @Override + protected void onError(AjaxRequestTarget target) { + ResetPasswordDialog.this.onError(target); + } + }); + } + + @Override + protected void onValidate() { + String pass = password.getConvertedInput(); + if (pass != null && !pass.isEmpty() && !pass.equals(confirmPassword.getConvertedInput())) { + error(Application.getString(232)); + } + super.onValidate(); + } + + }); + confirmReset = new NonClosableMessageDialog("confirmReset", Application.getString(325), Application.getString(332)) { + private static final long serialVersionUID = 1L; + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton button) { + setResponsePage(Application.get().getSignInPageClass()); + } + }; + add(confirmReset); + } + + @Override + public void onConfigure(JQueryBehavior behavior) { + super.onConfigure(behavior); + behavior.setOption("autoOpen", true); + } + + @Override + protected List<DialogButton> getButtons() { + return Arrays.asList(resetBtn); + } + + @Override + public DialogButton getSubmitButton() { + return resetBtn; + } + + @Override + public Form<?> getForm() { + return form; + } + + @Override + protected void onError(AjaxRequestTarget target) { + target.add(feedback); + } + + @Override + protected void onSubmit(AjaxRequestTarget target) { + try { + getBean(UserDao.class).resetPassword(user, password.getConvertedInput()); + } catch (Exception e) { + error(e.getMessage()); + } + } + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton button) { + if (resetBtn.equals(button)) { + confirmReset.open(handler); + } else { + setResponsePage(Application.get().getSignInPageClass()); + } + } +}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.html ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.html index 9c025cb..a69db09 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.html +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.html @@ -1,42 +1,42 @@ -<?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. - ---> -<html xmlns:wicket="http://wicket.apache.org"> -<wicket:panel> - <table> - <tr> - <td><wicket:message key="1550" /></td> - <td wicket:id="name">[name]</td> - </tr> - <tr> - <td><wicket:message key="1551" /></td> - <td wicket:id="version">[version]</td> - </tr> - <tr> - <td><wicket:message key="1552" /></td> - <td wicket:id="revision">[revision]</td> - </tr> - <tr> - <td><wicket:message key="1553" /></td> - <td wicket:id="buildDate">[buildDate]</td> - </tr> - </table> -</wicket:panel> -</html> +<?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. + +--> +<html xmlns:wicket="http://wicket.apache.org"> +<wicket:panel> + <table> + <tr> + <td><wicket:message key="1550" /></td> + <td wicket:id="name">[name]</td> + </tr> + <tr> + <td><wicket:message key="1551" /></td> + <td wicket:id="version">[version]</td> + </tr> + <tr> + <td><wicket:message key="1552" /></td> + <td wicket:id="revision">[revision]</td> + </tr> + <tr> + <td><wicket:message key="1553" /></td> + <td wicket:id="buildDate">[buildDate]</td> + </tr> + </table> +</wicket:panel> +</html> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.java index 50718e4..ab92bbe 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/AboutDialog.java @@ -1,57 +1,57 @@ -/* - * 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.user; - -import static org.apache.openmeetings.util.Version.getBuildDate; -import static org.apache.openmeetings.util.Version.getRevision; -import static org.apache.openmeetings.util.Version.getVersion; -import static org.apache.openmeetings.web.app.Application.getBean; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.openmeetings.db.dao.basic.ConfigurationDao; -import org.apache.openmeetings.web.app.Application; -import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.markup.html.basic.Label; - -import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; - -public class AboutDialog extends AbstractDialog<String> { - private static final long serialVersionUID = 1L; - - public AboutDialog(String id) { - super(id, Application.getString(1549)); - - add(new Label("name", getBean(ConfigurationDao.class).getAppName())); - add(new Label("version", getVersion())); - add(new Label("revision", getRevision())); - add(new Label("buildDate", getBuildDate())); - } - - @Override - protected List<DialogButton> getButtons() { - return new ArrayList<>(); - } - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton arg1) { - } -} +/* + * 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.user; + +import static org.apache.openmeetings.util.Version.getBuildDate; +import static org.apache.openmeetings.util.Version.getRevision; +import static org.apache.openmeetings.util.Version.getVersion; +import static org.apache.openmeetings.web.app.Application.getBean; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.openmeetings.db.dao.basic.ConfigurationDao; +import org.apache.openmeetings.web.app.Application; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.html.basic.Label; + +import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; + +public class AboutDialog extends AbstractDialog<String> { + private static final long serialVersionUID = 1L; + + public AboutDialog(String id) { + super(id, Application.getString(1549)); + + add(new Label("name", getBean(ConfigurationDao.class).getAppName())); + add(new Label("version", getVersion())); + add(new Label("revision", getRevision())); + add(new Label("buildDate", getBuildDate())); + } + + @Override + protected List<DialogButton> getButtons() { + return new ArrayList<>(); + } + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton arg1) { + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.html ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.html index 42cd4b3..f450843 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.html +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.html @@ -1,27 +1,27 @@ -<?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. - ---> -<html xmlns:wicket="http://wicket.apache.org"> -<wicket:panel> - <div wicket:id="container"> - <div wicket:id="body"></div> - </div> -</wicket:panel> -</html> +<?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. + +--> +<html xmlns:wicket="http://wicket.apache.org"> +<wicket:panel> + <div wicket:id="container"> + <div wicket:id="body"></div> + </div> +</wicket:panel> +</html> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.java index 0cab471..50f3472 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/UserInfoDialog.java @@ -1,83 +1,83 @@ -/* - * 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.user; - -import static org.apache.openmeetings.web.app.Application.getBean; -import static org.apache.openmeetings.web.app.WebSession.getUserId; - -import java.util.Arrays; -import java.util.List; - -import org.apache.openmeetings.db.dao.user.UserContactDao; -import org.apache.openmeetings.web.app.Application; -import org.apache.openmeetings.web.user.profile.UserProfilePanel; -import org.apache.openmeetings.web.util.ContactsHelper; -import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.markup.html.WebMarkupContainer; - -import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; - -public class UserInfoDialog extends AbstractDialog<String> { - private static final long serialVersionUID = 1L; - private WebMarkupContainer container = new WebMarkupContainer("container"); - private DialogButton cancel = new DialogButton("cancel", Application.getString(61)); - private DialogButton message = new DialogButton("message", Application.getString(1253)); - private DialogButton contacts = new DialogButton("contacts", Application.getString(1186)); - private MessageDialog newMessage; - private long userId; - - public UserInfoDialog(String id, MessageDialog newMessage) { - super(id, Application.getString(1235)); - add(container.add(new WebMarkupContainer("body")).setOutputMarkupId(true)); - this.newMessage = newMessage; - } - - public void open(IPartialPageRequestHandler handler, long userId) { - this.userId = userId; - contacts.setVisible(userId != getUserId() && getBean(UserContactDao.class).get(userId, getUserId()) == null, handler); - message.setVisible(userId != getUserId(), handler); - container.replace(new UserProfilePanel("body", userId)); - handler.add(container); - open(handler); - } - - public WebMarkupContainer getContainer() { - return container; - } - - @Override - public int getWidth() { - return 600; - } - - @Override - protected List<DialogButton> getButtons() { - return Arrays.asList(contacts, message, cancel); - } - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton button) { - if (message.equals(button)) { - newMessage.reset(false).open(handler, userId); - } else if (contacts.equals(button)) { - ContactsHelper.addUserToContactList(userId); - } - } -} +/* + * 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.user; + +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.WebSession.getUserId; + +import java.util.Arrays; +import java.util.List; + +import org.apache.openmeetings.db.dao.user.UserContactDao; +import org.apache.openmeetings.web.app.Application; +import org.apache.openmeetings.web.user.profile.UserProfilePanel; +import org.apache.openmeetings.web.util.ContactsHelper; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.html.WebMarkupContainer; + +import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; + +public class UserInfoDialog extends AbstractDialog<String> { + private static final long serialVersionUID = 1L; + private WebMarkupContainer container = new WebMarkupContainer("container"); + private DialogButton cancel = new DialogButton("cancel", Application.getString(61)); + private DialogButton message = new DialogButton("message", Application.getString(1253)); + private DialogButton contacts = new DialogButton("contacts", Application.getString(1186)); + private MessageDialog newMessage; + private long userId; + + public UserInfoDialog(String id, MessageDialog newMessage) { + super(id, Application.getString(1235)); + add(container.add(new WebMarkupContainer("body")).setOutputMarkupId(true)); + this.newMessage = newMessage; + } + + public void open(IPartialPageRequestHandler handler, long userId) { + this.userId = userId; + contacts.setVisible(userId != getUserId() && getBean(UserContactDao.class).get(userId, getUserId()) == null, handler); + message.setVisible(userId != getUserId(), handler); + container.replace(new UserProfilePanel("body", userId)); + handler.add(container); + open(handler); + } + + public WebMarkupContainer getContainer() { + return container; + } + + @Override + public int getWidth() { + return 600; + } + + @Override + protected List<DialogButton> getButtons() { + return Arrays.asList(contacts, message, cancel); + } + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton button) { + if (message.equals(button)) { + newMessage.reset(false).open(handler, userId); + } else if (contacts.equals(button)) { + ContactsHelper.addUserToContactList(userId); + } + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.html ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.html b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.html index 2d5276e..6a69179 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.html +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.html @@ -1,121 +1,121 @@ -<?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. - ---> -<html xmlns:wicket="http://wicket.apache.org"> - <wicket:panel> - <form wicket:id="appForm" class="appointmentPopUp"> - <span wicket:id="feedback"></span> - <div id="tabs"> - <ul> - <li><a href="#tab1"><wicket:message key="appointment.tab.general"/></a></li> - <li><a href="#tab2"><wicket:message key="436"/></a></li> - <li><a href="#tab3"><wicket:message key="appointment.tab.advanced"/></a></li> - </ul> - <div id="tab1"> - <div class="table"> - <div> - <div class="column label"><wicket:message key="572" /></div> - <div class="column data"><input type="text" wicket:id="title" /></div> - </div> - <div> - <div class="column label"><wicket:message key="570" /></div> - <div class="column data"><span class="date time picker" wicket:id="start"></span></div> - </div> - <div> - <div class="column label"><wicket:message key="571" /></div> - <div class="column data"><span class="date time picker" wicket:id="end"></span></div> - </div> - <div wicket:id="owner-row"> - <div class="column label"><wicket:message key="1156" /></div> - <div class="column data"><span wicket:id="aowner"></span></div> - </div> - <div wicket:id="inviteeType"> - <div> - <div class="column label"><input type="radio" wicket:id="user"/><label wicket:for="user"><wicket:message key="803" /></label></div> - <div class="column data om-select2" wicket:message="title:1588"><select class="appointment attendees input" wicket:id="attendees"></select></div> - </div> - <div wicket:id="groupContainer"> - <div class="column label"><input type="radio" wicket:id="group"/><label wicket:for="group"><wicket:message key="126" /></label></div> - <div class="column data om-select2"><select wicket:id="groups" class="input invitees"></select></div> - </div> - </div> - <div> - <div class="column label"><wicket:message key="569" /></div> - <div class="column data"><input type="text" wicket:id="location" /></div> - </div> - <div> - <div class="column label"><wicket:message key="573" /></div> - <div class="column data"> - <div wicket:id="toolbarContainer"></div> - <div wicket:id="description"></div> - </div> - </div> - </div> - </div> - <div id="tab2"> - <div class="table"> - <div> - <input type="checkbox" wicket:id="createRoom" /><label wicket:for="createRoom"><wicket:message key="1509" /></label> - </div> - <div wicket:id="create-room-block"> - <div> - <div class="column label"><wicket:message key="619" /></div> - <div class="column data"><select wicket:id="type" ></select></div> - </div> - <div> - <div class="column label"><label wicket:for="moderated"><wicket:message key="640" /></label></div> - <div class="column data"><input type="checkbox" wicket:id="moderated" /></div> - </div> - </div> - <div> - <div class="column label"><wicket:message key="436" /></div> - <div class="column data"><select wicket:id="groom" ></select></div> - </div> - <div wicket:id="sip-container"> - <div class="column label"><wicket:message key="1003"/></div> - <div class="column data"><span wicket:id="room.confno"></span></div> - </div> - </div> - </div> - <div id="tab3"> - <div class="table"> - <div> - <div class="column label"><wicket:message key="565" /></div> - <div class="column data"><select wicket:id="reminder" ></select></div> - </div> - <div> - <input type="checkbox" wicket:id="passwordProtected" /><label wicket:for="passwordProtected"><wicket:message key="524" /></label> - </div> - <div> - <div class="column label"><wicket:message key="525" /></div> - <div class="column data"><input type="password" wicket:id="password" /></div> - </div> - <div><wicket:message key="1445" /></div> - <div> - <div class="column label"><wicket:message key="162" /></div> - <div class="column data"><select wicket:id="calendar"></select></div> - </div> - </div> - </div> - </div> - </form> - <div wicket:id="confirmDelete"></div> - </wicket:panel> -</html> +<?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. + +--> +<html xmlns:wicket="http://wicket.apache.org"> + <wicket:panel> + <form wicket:id="appForm" class="appointmentPopUp"> + <span wicket:id="feedback"></span> + <div id="tabs"> + <ul> + <li><a href="#tab1"><wicket:message key="appointment.tab.general"/></a></li> + <li><a href="#tab2"><wicket:message key="436"/></a></li> + <li><a href="#tab3"><wicket:message key="appointment.tab.advanced"/></a></li> + </ul> + <div id="tab1"> + <div class="table"> + <div> + <div class="column label"><wicket:message key="572" /></div> + <div class="column data"><input type="text" wicket:id="title" /></div> + </div> + <div> + <div class="column label"><wicket:message key="570" /></div> + <div class="column data"><span class="date time picker" wicket:id="start"></span></div> + </div> + <div> + <div class="column label"><wicket:message key="571" /></div> + <div class="column data"><span class="date time picker" wicket:id="end"></span></div> + </div> + <div wicket:id="owner-row"> + <div class="column label"><wicket:message key="1156" /></div> + <div class="column data"><span wicket:id="aowner"></span></div> + </div> + <div wicket:id="inviteeType"> + <div> + <div class="column label"><input type="radio" wicket:id="user"/><label wicket:for="user"><wicket:message key="803" /></label></div> + <div class="column data om-select2" wicket:message="title:1588"><select class="appointment attendees input" wicket:id="attendees"></select></div> + </div> + <div wicket:id="groupContainer"> + <div class="column label"><input type="radio" wicket:id="group"/><label wicket:for="group"><wicket:message key="126" /></label></div> + <div class="column data om-select2"><select wicket:id="groups" class="input invitees"></select></div> + </div> + </div> + <div> + <div class="column label"><wicket:message key="569" /></div> + <div class="column data"><input type="text" wicket:id="location" /></div> + </div> + <div> + <div class="column label"><wicket:message key="573" /></div> + <div class="column data"> + <div wicket:id="toolbarContainer"></div> + <div wicket:id="description"></div> + </div> + </div> + </div> + </div> + <div id="tab2"> + <div class="table"> + <div> + <input type="checkbox" wicket:id="createRoom" /><label wicket:for="createRoom"><wicket:message key="1509" /></label> + </div> + <div wicket:id="create-room-block"> + <div> + <div class="column label"><wicket:message key="619" /></div> + <div class="column data"><select wicket:id="type" ></select></div> + </div> + <div> + <div class="column label"><label wicket:for="moderated"><wicket:message key="640" /></label></div> + <div class="column data"><input type="checkbox" wicket:id="moderated" /></div> + </div> + </div> + <div> + <div class="column label"><wicket:message key="436" /></div> + <div class="column data"><select wicket:id="groom" ></select></div> + </div> + <div wicket:id="sip-container"> + <div class="column label"><wicket:message key="1003"/></div> + <div class="column data"><span wicket:id="room.confno"></span></div> + </div> + </div> + </div> + <div id="tab3"> + <div class="table"> + <div> + <div class="column label"><wicket:message key="565" /></div> + <div class="column data"><select wicket:id="reminder" ></select></div> + </div> + <div> + <input type="checkbox" wicket:id="passwordProtected" /><label wicket:for="passwordProtected"><wicket:message key="524" /></label> + </div> + <div> + <div class="column label"><wicket:message key="525" /></div> + <div class="column data"><input type="password" wicket:id="password" /></div> + </div> + <div><wicket:message key="1445" /></div> + <div> + <div class="column label"><wicket:message key="162" /></div> + <div class="column data"><select wicket:id="calendar"></select></div> + </div> + </div> + </div> + </div> + </form> + <div wicket:id="confirmDelete"></div> + </wicket:panel> +</html> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.java index e468e36..e721c0b 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentDialog.java @@ -1,510 +1,510 @@ -/* - * 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.user.calendar; - -import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; -import static org.apache.openmeetings.web.app.Application.getBean; -import static org.apache.openmeetings.web.app.WebSession.getRights; -import static org.apache.openmeetings.web.app.WebSession.getUserId; -import static org.apache.openmeetings.web.util.CalendarWebHelper.getDate; -import static org.apache.openmeetings.web.util.CalendarWebHelper.getDateTime; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.openmeetings.db.dao.calendar.AppointmentDao; -import org.apache.openmeetings.db.dao.room.RoomDao; -import org.apache.openmeetings.db.dao.user.GroupUserDao; -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.db.entity.calendar.Appointment.Reminder; -import org.apache.openmeetings.db.entity.calendar.MeetingMember; -import org.apache.openmeetings.db.entity.calendar.OmCalendar; -import org.apache.openmeetings.db.entity.room.Room; -import org.apache.openmeetings.db.entity.user.Group; -import org.apache.openmeetings.db.entity.user.GroupUser; -import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.db.util.AuthLevelUtil; -import org.apache.openmeetings.db.util.FormatHelper; -import org.apache.openmeetings.service.calendar.caldav.AppointmentManager; -import org.apache.openmeetings.web.app.Application; -import org.apache.openmeetings.web.app.WebSession; -import org.apache.openmeetings.web.common.GroupChoiceProvider; -import org.apache.openmeetings.web.common.OmDateTimePicker; -import org.apache.openmeetings.web.pages.MainPage; -import org.apache.openmeetings.web.user.rooms.RoomEnterBehavior; -import org.apache.openmeetings.web.util.RoomTypeDropDown; -import org.apache.openmeetings.web.util.UserMultiChoice; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; -import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.CheckBox; -import org.apache.wicket.markup.html.form.ChoiceRenderer; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.IChoiceRenderer; -import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.form.Radio; -import org.apache.wicket.markup.html.form.RadioGroup; -import org.apache.wicket.markup.html.form.RequiredTextField; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.util.CollectionModel; -import org.red5.logging.Red5LoggerFactory; -import org.slf4j.Logger; -import org.wicketstuff.select2.Select2MultiChoice; - -import com.googlecode.wicket.jquery.core.JQueryBehavior; -import com.googlecode.wicket.jquery.core.Options; -import com.googlecode.wicket.jquery.ui.JQueryUIBehavior; -import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor; -import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar; -import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; -import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButtons; -import com.googlecode.wicket.jquery.ui.widget.dialog.DialogIcon; -import com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog; -import com.googlecode.wicket.kendo.ui.form.datetime.local.DateTimePicker; -import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel; - -public class AppointmentDialog extends AbstractFormDialog<Appointment> { - private static final long serialVersionUID = 1L; - private static final Logger log = Red5LoggerFactory.getLogger(AppointmentDialog.class, webAppRootKey); - - private AppointmentForm form; - private DialogButton save = new DialogButton("save", Application.getString(813)); - private DialogButton cancel = new DialogButton("cancel", Application.getString(1130)); - private DialogButton delete = new DialogButton("delete", Application.getString(814)); - private DialogButton enterRoom = new DialogButton("enterRoom", Application.getString(1282)); - private final CalendarPanel calendarPanel; - private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true)); - final MessageDialog confirmDelete; - private final WebMarkupContainer sipContainer = new WebMarkupContainer("sip-container"); - //FIXME TODO need to be unified with RoomInvitationForm - private final RadioGroup<InviteeType> rdi = new RadioGroup<>("inviteeType", Model.of(InviteeType.user)); - private final Select2MultiChoice<Group> groups = new Select2MultiChoice<>("groups" - , new CollectionModel<Group>(new ArrayList<>()) - , new GroupChoiceProvider()); - private final UserMultiChoice attendees = new UserMultiChoice("attendees", new CollectionModel<User>(new ArrayList<>())); - private enum InviteeType { - user - , group - } - - @Override - public int getWidth() { - return 650; - } - - @Override - public void onConfigure(JQueryBehavior behavior) { - super.onConfigure(behavior); - behavior.setOption("classes", "{'ui-dialog': 'ui-corner-all appointment'}"); - } - - public void setModelObjectWithAjaxTarget(Appointment a, AjaxRequestTarget target) { - form.setModelObject(a); - form.start.setModelObject(getDateTime(a.getStart())); - form.end.setModelObject(getDateTime(a.getEnd())); - form.setEnabled(isOwner(a)); - log.debug(" -- setModelObjectWithAjaxTarget -- Current model " + a); - if (a.getId() != null) { - delete.setVisible(isOwner(a), target); - enterRoom.setVisible(a.getRoom() != null, target); - } else { - delete.setVisible(false, target); - enterRoom.setVisible(false, target); - } - if (a.getRoom() != null) { - target.add(sipContainer.replace(new Label("room.confno", a.getRoom().getConfno())).setVisible(a.getRoom().isSipEnabled())); - } - save.setVisible(isOwner(a), target); - super.setModelObject(a); - } - - public AppointmentDialog(String id, String title, CalendarPanel calendarPanel, CompoundPropertyModel<Appointment> model) { - super(id, title, model, true); - log.debug(" -- AppointmentDialog -- Current model " + getModel().getObject()); - this.calendarPanel = calendarPanel; - setOutputMarkupId(true); - form = new AppointmentForm("appForm", model); - add(form); - confirmDelete = new MessageDialog("confirmDelete", Application.getString(814), Application.getString(833), DialogButtons.OK_CANCEL, DialogIcon.WARN){ - private static final long serialVersionUID = 1L; - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton button) { - if (button != null && button.match(AbstractDialog.OK)){ - deleteAppointment(handler); - } - } - }; - add(confirmDelete); - } - - protected void deleteAppointment(IPartialPageRequestHandler handler) { - Appointment a = getModelObject(); - getBean(AppointmentDao.class).delete(a, getUserId()); - calendarPanel.refresh(handler); - if (a.getCalendar() != null && a.getHref() != null) { - calendarPanel.updatedeleteAppointment(handler, CalendarDialog.DIALOG_TYPE.DELETE_APPOINTMENT, a); - } - } - - @Override - protected List<DialogButton> getButtons() { - return Arrays.asList(enterRoom, save, delete, cancel); - } - - @Override - public DialogButton getSubmitButton() { - return save; - } - - @Override - public Form<?> getForm() { - return form; - } - - @Override - protected void onOpen(IPartialPageRequestHandler handler) { - handler.add(form.add(new JQueryUIBehavior("#tabs", "tabs"))); - } - - @Override - public void onClose(IPartialPageRequestHandler handler, DialogButton button) { - if (delete.equals(button)) { - confirmDelete.open(handler); - } else if (enterRoom.equals(button)) { - RoomEnterBehavior.roomEnter((MainPage)getPage(), handler, getModelObject().getRoom().getId()); - } - } - - @Override - protected void onError(AjaxRequestTarget target) { - target.add(feedback); - } - - @Override - protected void onSubmit(AjaxRequestTarget target) { - Appointment a = form.getModelObject(); - a.setRoom(form.createRoom ? form.appRoom : form.groom.getModelObject()); - final List<MeetingMember> mms = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers(); - Set<Long> currentIds = new HashSet<>(); - List<User> users = new ArrayList<>(); - if (InviteeType.group == rdi.getModelObject()) { - //lets iterate through all group users - for (Group g : groups.getModelObject()) { - for (GroupUser gu : getBean(GroupUserDao.class).get(g.getId(), 0, Integer.MAX_VALUE)) { - User u = gu.getUser(); - if (!currentIds.contains(u.getId())) { - users.add(u); - currentIds.add(u.getId()); - } - } - } - } else { - users = new ArrayList<>(attendees.getModelObject()); - for (User u : users) { - if (u.getId() != null) { - currentIds.add(u.getId()); - } - } - } - - //remove users - for (Iterator<MeetingMember> i = mms.iterator(); i.hasNext();) { - MeetingMember m = i.next(); - if (!currentIds.contains(m.getUser().getId())) { - i.remove(); - } - } - Set<Long> originalIds = new HashSet<>(); - for (MeetingMember m : mms) { - originalIds.add(m.getUser().getId()); - } - //add users - for (User u : users) { - if (u.getId() == null || !originalIds.contains(u.getId())) { - MeetingMember mm = new MeetingMember(); - mm.setUser(u); - mm.setDeleted(false); - mm.setInserted(a.getInserted()); - mm.setUpdated(a.getUpdated()); - mm.setAppointment(a); - mms.add(mm); - } - } - a.setMeetingMembers(mms); - a.setStart(getDate(form.start.getModelObject())); - a.setEnd(getDate(form.end.getModelObject())); - a.setCalendar(form.cals.getModelObject()); - getBean(AppointmentDao.class).update(a, getUserId()); - if (a.getCalendar() != null) { - calendarPanel.updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a); - } - target.add(feedback); - calendarPanel.refresh(target); - } - - public static boolean isOwner(Appointment object) { - return object.getOwner() != null && getUserId().equals(object.getOwner().getId()); - } - - private class AppointmentForm extends Form<Appointment> { - private static final long serialVersionUID = 1L; - private boolean createRoom = true; - private Room appRoom = null; - private final DateTimePicker start = new OmDateTimePicker("start", Model.of(LocalDateTime.now())); - private final DateTimePicker end = new OmDateTimePicker("end", Model.of(LocalDateTime.now())); - private final PasswordTextField pwd = new PasswordTextField("password"); - private final Label owner = new Label("aowner", Model.of("")); - private final WebMarkupContainer ownerPanel = new WebMarkupContainer("owner-row"); - private final WebMarkupContainer createRoomBlock = new WebMarkupContainer("create-room-block", new CompoundPropertyModel<>(appRoom)); - private final DropDownChoice<Room.Type> roomType = new RoomTypeDropDown("type"); - private final DropDownChoice<Room> groom = new DropDownChoice<>( - "groom" - , Model.of(new Room()) - , getRoomList() - , new ChoiceRenderer<Room>("name", "id")); - private DropDownChoice<OmCalendar> cals = new DropDownChoice<>( - "calendar", - new LoadableDetachableModel<List<? extends OmCalendar>>() { - private static final long serialVersionUID = 1L; - - @Override - protected List<? extends OmCalendar> load() { - return getCalendarList(); - } - }, - new ChoiceRenderer<OmCalendar>("title", "id") - ); - private final WebMarkupContainer groupContainer = new WebMarkupContainer("groupContainer"); - - private Room createAppRoom() { - Room r = new Room(); - r.setAppointment(true); - if (r.getType() == null) { - r.setType(Room.Type.conference); - } - return r; - } - - @Override - protected void onModelChanged() { - super.onModelChanged(); - - Appointment a = getModelObject(); - if (a.getReminder() == null) { - a.setReminder(Reminder.none); - } - if (a.getRoom() == null) { - a.setRoom(createAppRoom()); - } - createRoom = a.getRoom().isAppointment(); - if (createRoom) { - appRoom = a.getRoom(); - } else { - groom.setModelObject(a.getRoom()); - appRoom = createAppRoom(); - } - createRoomBlock.setDefaultModelObject(appRoom); - createRoomBlock.setEnabled(createRoom); - groom.setEnabled(!createRoom); - if (a.getId() == null) { - java.util.Calendar start = WebSession.getCalendar(); - start.setTime(a.getStart()); - java.util.Calendar end = WebSession.getCalendar(); - end.setTime(a.getEnd()); - - if (start.equals(end)) { - end.add(java.util.Calendar.HOUR_OF_DAY, 1); - a.setEnd(end.getTime()); - } - cals.setEnabled(true); - } else { - cals.setEnabled(false); - } - - rdi.setModelObject(InviteeType.user); - attendees.setModelObject(new ArrayList<>()); - if (a.getMeetingMembers() != null) { - for (MeetingMember mm : a.getMeetingMembers()) { - attendees.getModelObject().add(mm.getUser()); - } - } - pwd.setEnabled(a.isPasswordProtected()); - owner.setDefaultModel(Model.of(FormatHelper.formatUser(a.getOwner()))); - ownerPanel.setVisible(!isOwner(a)); - } - - public AppointmentForm(String id, CompoundPropertyModel<Appointment> model) { - super(id, model); - setOutputMarkupId(true); - - add(feedback.setOutputMarkupId(true)); - //General - add(new RequiredTextField<String>("title").setLabel(Model.of(Application.getString(572)))); - add(ownerPanel.add(owner)); - boolean showGroups = AuthLevelUtil.hasAdminLevel(getRights()); - add(rdi.add(new AjaxFormChoiceComponentUpdatingBehavior() { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - boolean groupsEnabled = InviteeType.group == rdi.getModelObject(); - target.add(groups.setEnabled(groupsEnabled), attendees.setEnabled(!groupsEnabled)); - } - })); - groupContainer.add( - groups.setLabel(Model.of(Application.getString(126))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true) - , new Radio<>("group", Model.of(InviteeType.group)) - ); - if (showGroups) { - groups.add(new AjaxFormComponentUpdatingBehavior("change") { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - // added to update model - } - }).setEnabled(false); - } - rdi.add(attendees.add(new AjaxFormComponentUpdatingBehavior("change") { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - // added to update model - } - }) - , groupContainer.setVisible(showGroups) - ); - rdi.add(new Radio<>("user", Model.of(InviteeType.user))); - - add(new TextField<String>("location")); - DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbarContainer"); - add(toolbar); - add(new WysiwygEditor("description", toolbar)); - - //room - add(new AjaxCheckBox("createRoom", new PropertyModel<Boolean>(this, "createRoom")) { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - createRoom = getConvertedInput(); - target.add(createRoomBlock.setEnabled(createRoom), groom.setEnabled(!createRoom)); - } - }); - add(createRoomBlock.add(roomType, new CheckBox("moderated")).setEnabled(createRoom).setOutputMarkupId(true)); - add(groom.setRequired(true).setLabel(Model.of(Application.getString(406))).setEnabled(!createRoom).setOutputMarkupId(true)); - add(sipContainer.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true)); - sipContainer.add(new Label("room.confno", "")).setVisible(false); - - //Advanced - add(new DropDownChoice<>( - "reminder" - , Arrays.asList(Reminder.values()) - , new IChoiceRenderer<Reminder>() { - private static final long serialVersionUID = 1L; - - @Override - public Object getDisplayValue(Reminder art) { - return getString("appointment.reminder." + art.name()); - } - - @Override - public String getIdValue(Reminder art, int index) { - return art.name(); - } - - @Override - public Reminder getObject(String id, IModel<? extends List<? extends Reminder>> choices) { - for (Reminder art : choices.getObject()) { - if (art.name().equals(id)) { - return art; - } - } - return null; - } - })); - add(new AjaxCheckBox("passwordProtected") { - private static final long serialVersionUID = 1L; - - @Override - protected void onUpdate(AjaxRequestTarget target) { - AppointmentForm.this.getModelObject().setPasswordProtected(getConvertedInput()); - pwd.setEnabled(AppointmentForm.this.getModelObject().isPasswordProtected()); - target.add(pwd); - } - }); - pwd.setEnabled(getModelObject().isPasswordProtected()); - pwd.setOutputMarkupId(true); - add(pwd); - add(cals.setNullValid(true).setLabel(Model.of("calendar")).setOutputMarkupId(true)); - } - - @Override - protected void onInitialize() { - super.onInitialize(); - add(start.setLabel(Model.of(getString("570"))).setRequired(true) - , end.setLabel(Model.of(getString("571"))).setRequired(true)); - } - - private List<Room> getRoomList() { - //FIXME need to be reviewed - List<Room> result = new ArrayList<>(); - RoomDao dao = getBean(RoomDao.class); - result.addAll(dao.getPublicRooms()); - for (GroupUser ou : getBean(UserDao.class).get(getUserId()).getGroupUsers()) { - result.addAll(dao.getGroupRooms(ou.getGroup().getId())); - } - if (getModelObject().getRoom() != null && getModelObject().getRoom().isAppointment()) { //FIXME review - result.add(getModelObject().getRoom()); - } - return result; - } - - private List<OmCalendar> getCalendarList(){ - return getBean(AppointmentManager.class).getCalendars(getUserId()); - } - - @Override - protected void onValidate() { - if (null != start.getConvertedInput() && null != end.getConvertedInput() && end.getConvertedInput().isBefore(start.getConvertedInput())) { - error(Application.getString(1592)); - } - } - } -} +/* + * 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.user.calendar; + +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.WebSession.getRights; +import static org.apache.openmeetings.web.app.WebSession.getUserId; +import static org.apache.openmeetings.web.util.CalendarWebHelper.getDate; +import static org.apache.openmeetings.web.util.CalendarWebHelper.getDateTime; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.openmeetings.db.dao.calendar.AppointmentDao; +import org.apache.openmeetings.db.dao.room.RoomDao; +import org.apache.openmeetings.db.dao.user.GroupUserDao; +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.entity.calendar.Appointment; +import org.apache.openmeetings.db.entity.calendar.Appointment.Reminder; +import org.apache.openmeetings.db.entity.calendar.MeetingMember; +import org.apache.openmeetings.db.entity.calendar.OmCalendar; +import org.apache.openmeetings.db.entity.room.Room; +import org.apache.openmeetings.db.entity.user.Group; +import org.apache.openmeetings.db.entity.user.GroupUser; +import org.apache.openmeetings.db.entity.user.User; +import org.apache.openmeetings.db.util.AuthLevelUtil; +import org.apache.openmeetings.db.util.FormatHelper; +import org.apache.openmeetings.service.calendar.caldav.AppointmentManager; +import org.apache.openmeetings.web.app.Application; +import org.apache.openmeetings.web.app.WebSession; +import org.apache.openmeetings.web.common.GroupChoiceProvider; +import org.apache.openmeetings.web.common.OmDateTimePicker; +import org.apache.openmeetings.web.pages.MainPage; +import org.apache.openmeetings.web.user.rooms.RoomEnterBehavior; +import org.apache.openmeetings.web.util.RoomTypeDropDown; +import org.apache.openmeetings.web.util.UserMultiChoice; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; +import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.ChoiceRenderer; +import org.apache.wicket.markup.html.form.DropDownChoice; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.IChoiceRenderer; +import org.apache.wicket.markup.html.form.PasswordTextField; +import org.apache.wicket.markup.html.form.Radio; +import org.apache.wicket.markup.html.form.RadioGroup; +import org.apache.wicket.markup.html.form.RequiredTextField; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.model.CompoundPropertyModel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.LoadableDetachableModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.model.util.CollectionModel; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; +import org.wicketstuff.select2.Select2MultiChoice; + +import com.googlecode.wicket.jquery.core.JQueryBehavior; +import com.googlecode.wicket.jquery.core.Options; +import com.googlecode.wicket.jquery.ui.JQueryUIBehavior; +import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor; +import com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar; +import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractDialog; +import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButtons; +import com.googlecode.wicket.jquery.ui.widget.dialog.DialogIcon; +import com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog; +import com.googlecode.wicket.kendo.ui.form.datetime.local.DateTimePicker; +import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel; + +public class AppointmentDialog extends AbstractFormDialog<Appointment> { + private static final long serialVersionUID = 1L; + private static final Logger log = Red5LoggerFactory.getLogger(AppointmentDialog.class, webAppRootKey); + + private AppointmentForm form; + private DialogButton save = new DialogButton("save", Application.getString(813)); + private DialogButton cancel = new DialogButton("cancel", Application.getString(1130)); + private DialogButton delete = new DialogButton("delete", Application.getString(814)); + private DialogButton enterRoom = new DialogButton("enterRoom", Application.getString(1282)); + private final CalendarPanel calendarPanel; + private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true)); + final MessageDialog confirmDelete; + private final WebMarkupContainer sipContainer = new WebMarkupContainer("sip-container"); + //FIXME TODO need to be unified with RoomInvitationForm + private final RadioGroup<InviteeType> rdi = new RadioGroup<>("inviteeType", Model.of(InviteeType.user)); + private final Select2MultiChoice<Group> groups = new Select2MultiChoice<>("groups" + , new CollectionModel<Group>(new ArrayList<>()) + , new GroupChoiceProvider()); + private final UserMultiChoice attendees = new UserMultiChoice("attendees", new CollectionModel<User>(new ArrayList<>())); + private enum InviteeType { + user + , group + } + + @Override + public int getWidth() { + return 650; + } + + @Override + public void onConfigure(JQueryBehavior behavior) { + super.onConfigure(behavior); + behavior.setOption("classes", "{'ui-dialog': 'ui-corner-all appointment'}"); + } + + public void setModelObjectWithAjaxTarget(Appointment a, AjaxRequestTarget target) { + form.setModelObject(a); + form.start.setModelObject(getDateTime(a.getStart())); + form.end.setModelObject(getDateTime(a.getEnd())); + form.setEnabled(isOwner(a)); + log.debug(" -- setModelObjectWithAjaxTarget -- Current model " + a); + if (a.getId() != null) { + delete.setVisible(isOwner(a), target); + enterRoom.setVisible(a.getRoom() != null, target); + } else { + delete.setVisible(false, target); + enterRoom.setVisible(false, target); + } + if (a.getRoom() != null) { + target.add(sipContainer.replace(new Label("room.confno", a.getRoom().getConfno())).setVisible(a.getRoom().isSipEnabled())); + } + save.setVisible(isOwner(a), target); + super.setModelObject(a); + } + + public AppointmentDialog(String id, String title, CalendarPanel calendarPanel, CompoundPropertyModel<Appointment> model) { + super(id, title, model, true); + log.debug(" -- AppointmentDialog -- Current model " + getModel().getObject()); + this.calendarPanel = calendarPanel; + setOutputMarkupId(true); + form = new AppointmentForm("appForm", model); + add(form); + confirmDelete = new MessageDialog("confirmDelete", Application.getString(814), Application.getString(833), DialogButtons.OK_CANCEL, DialogIcon.WARN){ + private static final long serialVersionUID = 1L; + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton button) { + if (button != null && button.match(AbstractDialog.OK)){ + deleteAppointment(handler); + } + } + }; + add(confirmDelete); + } + + protected void deleteAppointment(IPartialPageRequestHandler handler) { + Appointment a = getModelObject(); + getBean(AppointmentDao.class).delete(a, getUserId()); + calendarPanel.refresh(handler); + if (a.getCalendar() != null && a.getHref() != null) { + calendarPanel.updatedeleteAppointment(handler, CalendarDialog.DIALOG_TYPE.DELETE_APPOINTMENT, a); + } + } + + @Override + protected List<DialogButton> getButtons() { + return Arrays.asList(enterRoom, save, delete, cancel); + } + + @Override + public DialogButton getSubmitButton() { + return save; + } + + @Override + public Form<?> getForm() { + return form; + } + + @Override + protected void onOpen(IPartialPageRequestHandler handler) { + handler.add(form.add(new JQueryUIBehavior("#tabs", "tabs"))); + } + + @Override + public void onClose(IPartialPageRequestHandler handler, DialogButton button) { + if (delete.equals(button)) { + confirmDelete.open(handler); + } else if (enterRoom.equals(button)) { + RoomEnterBehavior.roomEnter((MainPage)getPage(), handler, getModelObject().getRoom().getId()); + } + } + + @Override + protected void onError(AjaxRequestTarget target) { + target.add(feedback); + } + + @Override + protected void onSubmit(AjaxRequestTarget target) { + Appointment a = form.getModelObject(); + a.setRoom(form.createRoom ? form.appRoom : form.groom.getModelObject()); + final List<MeetingMember> mms = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers(); + Set<Long> currentIds = new HashSet<>(); + List<User> users = new ArrayList<>(); + if (InviteeType.group == rdi.getModelObject()) { + //lets iterate through all group users + for (Group g : groups.getModelObject()) { + for (GroupUser gu : getBean(GroupUserDao.class).get(g.getId(), 0, Integer.MAX_VALUE)) { + User u = gu.getUser(); + if (!currentIds.contains(u.getId())) { + users.add(u); + currentIds.add(u.getId()); + } + } + } + } else { + users = new ArrayList<>(attendees.getModelObject()); + for (User u : users) { + if (u.getId() != null) { + currentIds.add(u.getId()); + } + } + } + + //remove users + for (Iterator<MeetingMember> i = mms.iterator(); i.hasNext();) { + MeetingMember m = i.next(); + if (!currentIds.contains(m.getUser().getId())) { + i.remove(); + } + } + Set<Long> originalIds = new HashSet<>(); + for (MeetingMember m : mms) { + originalIds.add(m.getUser().getId()); + } + //add users + for (User u : users) { + if (u.getId() == null || !originalIds.contains(u.getId())) { + MeetingMember mm = new MeetingMember(); + mm.setUser(u); + mm.setDeleted(false); + mm.setInserted(a.getInserted()); + mm.setUpdated(a.getUpdated()); + mm.setAppointment(a); + mms.add(mm); + } + } + a.setMeetingMembers(mms); + a.setStart(getDate(form.start.getModelObject())); + a.setEnd(getDate(form.end.getModelObject())); + a.setCalendar(form.cals.getModelObject()); + getBean(AppointmentDao.class).update(a, getUserId()); + if (a.getCalendar() != null) { + calendarPanel.updatedeleteAppointment(target, CalendarDialog.DIALOG_TYPE.UPDATE_APPOINTMENT, a); + } + target.add(feedback); + calendarPanel.refresh(target); + } + + public static boolean isOwner(Appointment object) { + return object.getOwner() != null && getUserId().equals(object.getOwner().getId()); + } + + private class AppointmentForm extends Form<Appointment> { + private static final long serialVersionUID = 1L; + private boolean createRoom = true; + private Room appRoom = null; + private final DateTimePicker start = new OmDateTimePicker("start", Model.of(LocalDateTime.now())); + private final DateTimePicker end = new OmDateTimePicker("end", Model.of(LocalDateTime.now())); + private final PasswordTextField pwd = new PasswordTextField("password"); + private final Label owner = new Label("aowner", Model.of("")); + private final WebMarkupContainer ownerPanel = new WebMarkupContainer("owner-row"); + private final WebMarkupContainer createRoomBlock = new WebMarkupContainer("create-room-block", new CompoundPropertyModel<>(appRoom)); + private final DropDownChoice<Room.Type> roomType = new RoomTypeDropDown("type"); + private final DropDownChoice<Room> groom = new DropDownChoice<>( + "groom" + , Model.of(new Room()) + , getRoomList() + , new ChoiceRenderer<Room>("name", "id")); + private DropDownChoice<OmCalendar> cals = new DropDownChoice<>( + "calendar", + new LoadableDetachableModel<List<? extends OmCalendar>>() { + private static final long serialVersionUID = 1L; + + @Override + protected List<? extends OmCalendar> load() { + return getCalendarList(); + } + }, + new ChoiceRenderer<OmCalendar>("title", "id") + ); + private final WebMarkupContainer groupContainer = new WebMarkupContainer("groupContainer"); + + private Room createAppRoom() { + Room r = new Room(); + r.setAppointment(true); + if (r.getType() == null) { + r.setType(Room.Type.conference); + } + return r; + } + + @Override + protected void onModelChanged() { + super.onModelChanged(); + + Appointment a = getModelObject(); + if (a.getReminder() == null) { + a.setReminder(Reminder.none); + } + if (a.getRoom() == null) { + a.setRoom(createAppRoom()); + } + createRoom = a.getRoom().isAppointment(); + if (createRoom) { + appRoom = a.getRoom(); + } else { + groom.setModelObject(a.getRoom()); + appRoom = createAppRoom(); + } + createRoomBlock.setDefaultModelObject(appRoom); + createRoomBlock.setEnabled(createRoom); + groom.setEnabled(!createRoom); + if (a.getId() == null) { + java.util.Calendar start = WebSession.getCalendar(); + start.setTime(a.getStart()); + java.util.Calendar end = WebSession.getCalendar(); + end.setTime(a.getEnd()); + + if (start.equals(end)) { + end.add(java.util.Calendar.HOUR_OF_DAY, 1); + a.setEnd(end.getTime()); + } + cals.setEnabled(true); + } else { + cals.setEnabled(false); + } + + rdi.setModelObject(InviteeType.user); + attendees.setModelObject(new ArrayList<>()); + if (a.getMeetingMembers() != null) { + for (MeetingMember mm : a.getMeetingMembers()) { + attendees.getModelObject().add(mm.getUser()); + } + } + pwd.setEnabled(a.isPasswordProtected()); + owner.setDefaultModel(Model.of(FormatHelper.formatUser(a.getOwner()))); + ownerPanel.setVisible(!isOwner(a)); + } + + public AppointmentForm(String id, CompoundPropertyModel<Appointment> model) { + super(id, model); + setOutputMarkupId(true); + + add(feedback.setOutputMarkupId(true)); + //General + add(new RequiredTextField<String>("title").setLabel(Model.of(Application.getString(572)))); + add(ownerPanel.add(owner)); + boolean showGroups = AuthLevelUtil.hasAdminLevel(getRights()); + add(rdi.add(new AjaxFormChoiceComponentUpdatingBehavior() { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + boolean groupsEnabled = InviteeType.group == rdi.getModelObject(); + target.add(groups.setEnabled(groupsEnabled), attendees.setEnabled(!groupsEnabled)); + } + })); + groupContainer.add( + groups.setLabel(Model.of(Application.getString(126))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true) + , new Radio<>("group", Model.of(InviteeType.group)) + ); + if (showGroups) { + groups.add(new AjaxFormComponentUpdatingBehavior("change") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + // added to update model + } + }).setEnabled(false); + } + rdi.add(attendees.add(new AjaxFormComponentUpdatingBehavior("change") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + // added to update model + } + }) + , groupContainer.setVisible(showGroups) + ); + rdi.add(new Radio<>("user", Model.of(InviteeType.user))); + + add(new TextField<String>("location")); + DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbarContainer"); + add(toolbar); + add(new WysiwygEditor("description", toolbar)); + + //room + add(new AjaxCheckBox("createRoom", new PropertyModel<Boolean>(this, "createRoom")) { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + createRoom = getConvertedInput(); + target.add(createRoomBlock.setEnabled(createRoom), groom.setEnabled(!createRoom)); + } + }); + add(createRoomBlock.add(roomType, new CheckBox("moderated")).setEnabled(createRoom).setOutputMarkupId(true)); + add(groom.setRequired(true).setLabel(Model.of(Application.getString(406))).setEnabled(!createRoom).setOutputMarkupId(true)); + add(sipContainer.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true)); + sipContainer.add(new Label("room.confno", "")).setVisible(false); + + //Advanced + add(new DropDownChoice<>( + "reminder" + , Arrays.asList(Reminder.values()) + , new IChoiceRenderer<Reminder>() { + private static final long serialVersionUID = 1L; + + @Override + public Object getDisplayValue(Reminder art) { + return getString("appointment.reminder." + art.name()); + } + + @Override + public String getIdValue(Reminder art, int index) { + return art.name(); + } + + @Override + public Reminder getObject(String id, IModel<? extends List<? extends Reminder>> choices) { + for (Reminder art : choices.getObject()) { + if (art.name().equals(id)) { + return art; + } + } + return null; + } + })); + add(new AjaxCheckBox("passwordProtected") { + private static final long serialVersionUID = 1L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + AppointmentForm.this.getModelObject().setPasswordProtected(getConvertedInput()); + pwd.setEnabled(AppointmentForm.this.getModelObject().isPasswordProtected()); + target.add(pwd); + } + }); + pwd.setEnabled(getModelObject().isPasswordProtected()); + pwd.setOutputMarkupId(true); + add(pwd); + add(cals.setNullValid(true).setLabel(Model.of("calendar")).setOutputMarkupId(true)); + } + + @Override + protected void onInitialize() { + super.onInitialize(); + add(start.setLabel(Model.of(getString("570"))).setRequired(true) + , end.setLabel(Model.of(getString("571"))).setRequired(true)); + } + + private List<Room> getRoomList() { + //FIXME need to be reviewed + List<Room> result = new ArrayList<>(); + RoomDao dao = getBean(RoomDao.class); + result.addAll(dao.getPublicRooms()); + for (GroupUser ou : getBean(UserDao.class).get(getUserId()).getGroupUsers()) { + result.addAll(dao.getGroupRooms(ou.getGroup().getId())); + } + if (getModelObject().getRoom() != null && getModelObject().getRoom().isAppointment()) { //FIXME review + result.add(getModelObject().getRoom()); + } + return result; + } + + private List<OmCalendar> getCalendarList(){ + return getBean(AppointmentManager.class).getCalendars(getUserId()); + } + + @Override + protected void onValidate() { + if (null != start.getConvertedInput() && null != end.getConvertedInput() && end.getConvertedInput().isBefore(start.getConvertedInput())) { + error(Application.getString(1592)); + } + } + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentModel.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentModel.java b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentModel.java index 3e5cc63..5819d24 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentModel.java +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/calendar/AppointmentModel.java @@ -1,51 +1,51 @@ -/* - * 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.user.calendar; - -import static org.apache.openmeetings.web.app.Application.getBean; -import static org.apache.openmeetings.web.app.WebSession.getUserId; -import static org.apache.openmeetings.web.util.CalendarWebHelper.getDate; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.openmeetings.db.dao.calendar.AppointmentDao; -import org.apache.openmeetings.db.entity.calendar.Appointment; - -import com.googlecode.wicket.jquery.ui.calendar.CalendarEvent; -import com.googlecode.wicket.jquery.ui.calendar.CalendarModel; -import com.googlecode.wicket.jquery.ui.calendar.ICalendarVisitor; - -public class AppointmentModel extends CalendarModel implements ICalendarVisitor { - private static final long serialVersionUID = 1L; - - @Override - public void visit(CalendarEvent event) { - //every event can be customized - } - - @Override - protected List<? extends CalendarEvent> load() { - List<CalendarEvent> list = new ArrayList<>(); - for (Appointment a : getBean(AppointmentDao.class).getInRange(getUserId(), getDate(getStart()), getDate(getEnd()))) { - list.add(new OmCalendarEvent(a)); - } - return list; - } -} +/* + * 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.user.calendar; + +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.WebSession.getUserId; +import static org.apache.openmeetings.web.util.CalendarWebHelper.getDate; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.openmeetings.db.dao.calendar.AppointmentDao; +import org.apache.openmeetings.db.entity.calendar.Appointment; + +import com.googlecode.wicket.jquery.ui.calendar.CalendarEvent; +import com.googlecode.wicket.jquery.ui.calendar.CalendarModel; +import com.googlecode.wicket.jquery.ui.calendar.ICalendarVisitor; + +public class AppointmentModel extends CalendarModel implements ICalendarVisitor { + private static final long serialVersionUID = 1L; + + @Override + public void visit(CalendarEvent event) { + //every event can be customized + } + + @Override + protected List<? extends CalendarEvent> load() { + List<CalendarEvent> list = new ArrayList<>(); + for (Appointment a : getBean(AppointmentDao.class).getInRange(getUserId(), getDate(getStart()), getDate(getEnd()))) { + list.add(new OmCalendarEvent(a)); + } + return list; + } +}
