Commit dd17005a by Tuukka Kivilahti

help thingy, now there can be global help on every page

1 parent 27d59c15
...@@ -391,6 +391,10 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -391,6 +391,10 @@ public class BootstrapBean implements BootstrapBeanLocal {
}); });
dbUpdates.add(new String[] {
"ALTER TABLE help_texts DROP COLUMN title;"
});
} }
public BootstrapBean() { public BootstrapBean() {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import fi.codecrew.moya.enums.ValidLocale; import fi.codecrew.moya.enums.ValidLocale;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.HelpFacade; import fi.codecrew.moya.facade.HelpFacade;
import fi.codecrew.moya.facade.HelpTextFacade; import fi.codecrew.moya.facade.HelpTextFacade;
import fi.codecrew.moya.facade.HelpTextHistoryFacade; import fi.codecrew.moya.facade.HelpTextHistoryFacade;
...@@ -26,6 +28,7 @@ import fi.codecrew.moya.model.Help; ...@@ -26,6 +28,7 @@ import fi.codecrew.moya.model.Help;
import fi.codecrew.moya.model.HelpText; import fi.codecrew.moya.model.HelpText;
import fi.codecrew.moya.model.HelpTextHistory; import fi.codecrew.moya.model.HelpTextHistory;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -92,6 +95,7 @@ public class HelpBean implements HelpBeanLocal { ...@@ -92,6 +95,7 @@ public class HelpBean implements HelpBeanLocal {
} }
@Override @Override
@RolesAllowed(UserPermission.S_EDIT_HELP)
public HelpText saveOrCreate(HelpText help) { public HelpText saveOrCreate(HelpText help) {
help.setLastEdited(Calendar.getInstance().getTime()); help.setLastEdited(Calendar.getInstance().getTime());
......
...@@ -39,9 +39,6 @@ public class HelpText extends GenericEntity implements Cloneable { ...@@ -39,9 +39,6 @@ public class HelpText extends GenericEntity implements Cloneable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "title")
private String title;
@Column(name = "description") @Column(name = "description")
private String text; private String text;
...@@ -69,13 +66,6 @@ public class HelpText extends GenericEntity implements Cloneable { ...@@ -69,13 +66,6 @@ public class HelpText extends GenericEntity implements Cloneable {
public HelpText() { public HelpText() {
} }
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getText() { public String getText() {
return text; return text;
......
...@@ -65,7 +65,6 @@ public class HelpTextHistory extends GenericEntity implements Cloneable { ...@@ -65,7 +65,6 @@ public class HelpTextHistory extends GenericEntity implements Cloneable {
* @param parent * @param parent
*/ */
public HelpTextHistory(HelpText parent) { public HelpTextHistory(HelpText parent) {
this.title = parent.getTitle();
this.text = parent.getText(); this.text = parent.getText();
this.edited = parent.getLastEdited(); this.edited = parent.getLastEdited();
this.editor = parent.getLastEditor(); this.editor = parent.getLastEditor();
......
...@@ -43,6 +43,7 @@ public enum UserPermission implements IAppPermission { ...@@ -43,6 +43,7 @@ public enum UserPermission implements IAppPermission {
MODIFY_OWN_GAMEIDS, MODIFY_OWN_GAMEIDS,
VIEW_ALL_GAMEIDS, VIEW_ALL_GAMEIDS,
HELPPAGE, HELPPAGE,
EDIT_HELP,
; ;
public static final String S_VIEW_ALL = "USER/VIEW_ALL"; public static final String S_VIEW_ALL = "USER/VIEW_ALL";
...@@ -66,6 +67,7 @@ public enum UserPermission implements IAppPermission { ...@@ -66,6 +67,7 @@ public enum UserPermission implements IAppPermission {
public static final String S_MODIFY_OWN_GAMEIDS = "USER/MODIFY_OWN_GAMEIDS"; public static final String S_MODIFY_OWN_GAMEIDS = "USER/MODIFY_OWN_GAMEIDS";
public static final String S_VIEW_ALL_GAMEIDS = "USER/VIEW_ALL_GAMEIDS"; public static final String S_VIEW_ALL_GAMEIDS = "USER/VIEW_ALL_GAMEIDS";
public static final String S_HELPPAGE = "USER/HELPPAGE"; public static final String S_HELPPAGE = "USER/HELPPAGE";
public static final String S_EDIT_HELP = "USER/EDIT_HELP";
private final String fullName; private final String fullName;
private final String key; private final String key;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:p="http://primefaces.org/ui" xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
> >
<composite:interface> <composite:interface>
...@@ -14,14 +15,49 @@ ...@@ -14,14 +15,49 @@
<composite:implementation> <composite:implementation>
<b><h:outputText value="#{helpView.helpTitle}" escape="false" /></b><br /> <h:form>
<h:outputText value="#{helpView.helpText}" escape="false" /><br />
<h:form> <p:commandButton rendered="#{helpView.helpAvailable or helpView.permissionToEdit}" icon="ui-icon-help" title="#{i18n['help.title']}" onclick="PF('showHelpDialog').show()" />
<p:inputText value="#{helpView.helpTitle}" /><br />
<p:inputTextarea value="#{helpView.helpText}" /><br />
<p:commandButton actionListener="#{helpView.saveHelpText}" /> <!-- Sorry abt. this dialog mess, I was too lazy to find working way to do inline -editing with ckEditor -TK -->
<p:dialog widgetVar="showHelpDialog" header="#{i18n['help.title']}" >
<p:outputPanel id="helpPanel">
<p:outputPanel rendered="#{helpView.helpAvailable}" >
<h:outputText value="#{helpView.helpText}" escape="false" />
<br /><br />
<p:commandButton rendered="#{helpView.permissionToEdit}" value="#{i18n['help.edit']}" onclick="PF('editHelpDialog').show();PF('showHelpDialog').hide();" />
</p:outputPanel>
<p:outputPanel rendered="#{not helpView.helpAvailable and helpView.permissionToEdit}" id="helpPanelPlaceholder" >
<h2><h:outputText value="#{i18n['help.placeholder.title']}" /></h2>
<br />
<p:commandButton value="#{i18n['help.add']}" onclick="PF('editHelpDialog').show();PF('showHelpDialog').hide();" />
</p:outputPanel>
</p:outputPanel>
</p:dialog>
<p:dialog widgetVar="editHelpDialog" header="#{i18n['help.dialog.header']}" >
<p:outputPanel>
<pe:ckEditor id="editors" value="#{helpView.helpText}" toolbar="
[['Bold','Italic','Underline','Strike','TextColor'],
['NumberedList','BulletedList','Outdent', 'Indent'],
['Image','Table','HorizontalRule','Iframe'],
['Format','FontSize'],
['RemoveFormat', 'Save']]">
<p:ajax event="save" listener="#{helpView.saveHelpText}" update="helpPanel" oncomplete="PF('showHelpDialog').show();PF('editHelpDialog').hide();"/>
</pe:ckEditor>
</p:outputPanel>
<span class="error"><h:outputText value="#{i18n['help.globalWarning']}" /></span>
</p:dialog>
</h:form> </h:form>
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:ui="http://java.sun.com/jsf/facelets" <html class="no-js" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui"
xmlns:help="http://java.sun.com/jsf/composite/cditools/help" xmlns:help="http://java.sun.com/jsf/composite/cditools/help"
xmlns:pe="http://primefaces.org/ui/extensions"
> >
<f:view contentType="text/html" locale="#{sessionHandler.locale}"> <f:view contentType="text/html" locale="#{sessionHandler.locale}">
<h:head> <pe:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><h:outputText value="#{layoutView.getHeader()}" /></title> <title><h:outputText value="#{layoutView.getHeader()}" /></title>
...@@ -38,7 +39,7 @@ ...@@ -38,7 +39,7 @@
} }
</h:outputStylesheet> </h:outputStylesheet>
</h:head> </pe:head>
<h:body> <h:body>
...@@ -181,18 +182,24 @@ ...@@ -181,18 +182,24 @@
<p:layoutUnit position="center"> <p:layoutUnit position="center">
<div class="container top"> <div class="container top">
<h:form id="selectLanguage"> <div style="float: left;">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" immediate="true" converter="#{localeConverter}"> <h:form id="selectLanguage">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" /> <p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" immediate="true" converter="#{localeConverter}">
<p:ajax update="@all" event="change" /> <f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
</p:selectOneButton> <p:ajax update="@all" event="change" />
</h:form> </p:selectOneButton>
</h:form>
<h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage"> <h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}:top" /> <f:param name="pagename" value="#{layoutView.pagepath}:top" />
</h:link> </h:link>
</div>
<div style="float: right;">
<help:helptool />
</div>
<div style="clear: both;"> </div>
</div> </div>
...@@ -221,10 +228,6 @@ ...@@ -221,10 +228,6 @@
</p:layoutUnit> </p:layoutUnit>
<p:layoutUnit position="east" resizable="true">
<help:helptool />
</p:layoutUnit>
<p:layoutUnit position="south" size="30"> <p:layoutUnit position="south" size="30">
<footer class="bgColor1"> <footer class="bgColor1">
<h:outputText id="cdiloop" value="#{conversationKeepaliveView.date}"> <h:outputText id="cdiloop" value="#{conversationKeepaliveView.date}">
...@@ -241,8 +244,6 @@ ...@@ -241,8 +244,6 @@
<h:form> <h:form>
<!-- <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="true" /> -->
<p:confirmDialog global="true" showEffect="fade" hideEffect="explode"> <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" /> <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" /> <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
......
...@@ -30,6 +30,16 @@ ...@@ -30,6 +30,16 @@
<artifactId>primefaces</artifactId> <artifactId>primefaces</artifactId>
<version>${primefaces.version}</version> <version>${primefaces.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>resources-ckeditor</artifactId>
<version>4.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.primefaces.themes</groupId> <groupId>org.primefaces.themes</groupId>
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
package fi.codecrew.moya.web.cdiview.help; package fi.codecrew.moya.web.cdiview.help;
import fi.codecrew.moya.beans.HelpBeanLocal; import fi.codecrew.moya.beans.HelpBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.enums.ValidLocale; import fi.codecrew.moya.enums.ValidLocale;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.handler.SessionStore; import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.model.Help; import fi.codecrew.moya.model.Help;
import fi.codecrew.moya.model.HelpText; import fi.codecrew.moya.model.HelpText;
...@@ -48,9 +50,12 @@ public class HelpView { ...@@ -48,9 +50,12 @@ public class HelpView {
@EJB @EJB
HelpBeanLocal helpBean; HelpBeanLocal helpBean;
String helpTitle = null; @EJB
PermissionBeanLocal permissionBean;
String helpText = null; String helpText = null;
@Inject @Inject
private transient SessionStore sessionstore; private transient SessionStore sessionstore;
...@@ -59,9 +64,8 @@ public class HelpView { ...@@ -59,9 +64,8 @@ public class HelpView {
HelpText help = helpBean.getHelpForPage(layoutView.getPagepath(), sessionstore.getLocale()); HelpText help = helpBean.getHelpForPage(layoutView.getPagepath(), sessionstore.getLocale());
if(help == null) { if(help == null) {
helpTitle = helpText = ""; helpText = "";
} else { } else {
helpTitle = help.getTitle();
helpText = help.getText(); helpText = help.getText();
} }
...@@ -81,21 +85,14 @@ public class HelpView { ...@@ -81,21 +85,14 @@ public class HelpView {
} }
help.setText(getHelpText()); help.setText(getHelpText());
help.setTitle(getHelpTitle());
helpBean.saveOrCreate(help); helpBean.saveOrCreate(help);
} }
public String getHelpTitle() {
if(helpTitle == null) {
populateHelpText();
}
return helpTitle;
}
public void setHelpTitle(String helpTitle) { public boolean isHelpAvailable() {
this.helpTitle = helpTitle; return !getHelpText().isEmpty();
} }
public void setHelpText(String helpText) { public void setHelpText(String helpText) {
...@@ -103,8 +100,16 @@ public class HelpView { ...@@ -103,8 +100,16 @@ public class HelpView {
} }
public String getHelpText() { public String getHelpText() {
return this.helpText;
if(helpText == null) {
populateHelpText();
}
return helpText;
} }
public boolean isPermissionToEdit() {
return permissionBean.hasPermission(UserPermission.EDIT_HELP);
}
} }
...@@ -335,6 +335,13 @@ global.notAuthorizedExecute = You are not authorized to do that! ...@@ -335,6 +335,13 @@ global.notAuthorizedExecute = You are not authorized to do that!
global.notauthorized = You don't have enough rights to enter this site. global.notauthorized = You don't have enough rights to enter this site.
global.save = Save global.save = Save
help.edit=Edit help
help.placeholder.content=help.add=Create help for page
help.content=Help content
help.dialog.header=Edit page help
You can add help by pressing button under this text.
help.placeholder.title=No help for page
help.title=Help for page
httpsession.creationTime = Created httpsession.creationTime = Created
httpsession.hostname = Hostname httpsession.hostname = Hostname
httpsession.id = ID httpsession.id = ID
...@@ -1548,3 +1555,6 @@ voting.create.voteEnd = Voting close ...@@ -1548,3 +1555,6 @@ voting.create.voteEnd = Voting close
voting.create.voteStart = Voting start voting.create.voteStart = Voting start
yes = Yes yes = Yes
help.globalWarning=Helptexts are globals, and shared between every events\!
bortalApplication.user.HELPPAGE=Can see help page
bortalApplication.user.EDIT_HELP=Can edit help texts
...@@ -548,6 +548,13 @@ global.notAuthorizedExecute = You are not authorized to do that! ...@@ -548,6 +548,13 @@ global.notAuthorizedExecute = You are not authorized to do that!
global.notauthorized = You don't have enough rights to enter this site. global.notauthorized = You don't have enough rights to enter this site.
global.save = Save global.save = Save
help.add=Create help for page
help.content=Help content
help.dialog.header=Edit page help
help.edit=Edit help
help.placeholder.content=You can add help by pressing button under this text.
help.placeholder.title=No help for page
help.title=Help for page
httpsession.creationTime = Created httpsession.creationTime = Created
httpsession.hostname = Hostname httpsession.hostname = Hostname
httpsession.id = ID httpsession.id = ID
...@@ -1821,3 +1828,6 @@ voting.create.voteEnd = Voting close ...@@ -1821,3 +1828,6 @@ voting.create.voteEnd = Voting close
voting.create.voteStart = Voting start voting.create.voteStart = Voting start
yes = Yes yes = Yes
help.globalWarning=Helptexts are globals, and shared between every events\!
bortalApplication.user.HELPPAGE=Can see help page
bortalApplication.user.EDIT_HELP=Can edit help texts
...@@ -549,6 +549,13 @@ global.notAuthorizedExecute = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia suo ...@@ -549,6 +549,13 @@ global.notAuthorizedExecute = Sinulla ei ole riitt\u00E4v\u00E4sti oikeuksia suo
global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle sivulle. global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle sivulle.
global.save = Tallenna global.save = Tallenna
help.add=Luo ohje sivulle
help.content=Ohjeen sis\u00E4lt\u00F6
help.dialog.header=Muokkaa sivun ohjetta
help.edit=Muokkaa ohjetta
help.placeholder.content=Voit lis\u00E4t\u00E4 ohjeen allaolevalla napilla.
help.placeholder.title=Ei ohjetta sivulle
help.title=Ohje sivulle
httpsession.creationTime = Luotu httpsession.creationTime = Luotu
httpsession.hostname = Hostname httpsession.hostname = Hostname
httpsession.id = ID httpsession.id = ID
...@@ -1808,3 +1815,6 @@ voting.create.voteEnd = \u00C4\u00E4nestys kiinni ...@@ -1808,3 +1815,6 @@ voting.create.voteEnd = \u00C4\u00E4nestys kiinni
voting.create.voteStart = \u00C4\u00E4nestys auki voting.create.voteStart = \u00C4\u00E4nestys auki
yes = Kyll\u00E4 yes = Kyll\u00E4
help.globalWarning=Ohjeet ovat universaaleja ja ne n\u00E4kyv\u00E4t kaikissa moya-lippukaupoissa\!
bortalApplication.user.HELPPAGE=N\u00E4kee ohjesivun
bortalApplication.user.EDIT_HELP=Voi muokata ohjeita
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!