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 {
});
dbUpdates.add(new String[] {
"ALTER TABLE help_texts DROP COLUMN title;"
});
}
public BootstrapBean() {
......
......@@ -19,6 +19,8 @@
package fi.codecrew.moya.beans;
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.HelpTextFacade;
import fi.codecrew.moya.facade.HelpTextHistoryFacade;
......@@ -26,6 +28,7 @@ import fi.codecrew.moya.model.Help;
import fi.codecrew.moya.model.HelpText;
import fi.codecrew.moya.model.HelpTextHistory;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
......@@ -92,6 +95,7 @@ public class HelpBean implements HelpBeanLocal {
}
@Override
@RolesAllowed(UserPermission.S_EDIT_HELP)
public HelpText saveOrCreate(HelpText help) {
help.setLastEdited(Calendar.getInstance().getTime());
......
......@@ -39,9 +39,6 @@ public class HelpText extends GenericEntity implements Cloneable {
private static final long serialVersionUID = 1L;
@Column(name = "title")
private String title;
@Column(name = "description")
private String text;
......@@ -69,13 +66,6 @@ public class HelpText extends GenericEntity implements Cloneable {
public HelpText() {
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getText() {
return text;
......
......@@ -65,7 +65,6 @@ public class HelpTextHistory extends GenericEntity implements Cloneable {
* @param parent
*/
public HelpTextHistory(HelpText parent) {
this.title = parent.getTitle();
this.text = parent.getText();
this.edited = parent.getLastEdited();
this.editor = parent.getLastEditor();
......
......@@ -43,6 +43,7 @@ public enum UserPermission implements IAppPermission {
MODIFY_OWN_GAMEIDS,
VIEW_ALL_GAMEIDS,
HELPPAGE,
EDIT_HELP,
;
public static final String S_VIEW_ALL = "USER/VIEW_ALL";
......@@ -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_VIEW_ALL_GAMEIDS = "USER/VIEW_ALL_GAMEIDS";
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 key;
......
......@@ -6,6 +6,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
>
<composite:interface>
......@@ -14,14 +15,49 @@
<composite:implementation>
<b><h:outputText value="#{helpView.helpTitle}" escape="false" /></b><br />
<h:outputText value="#{helpView.helpText}" escape="false" /><br />
<h:form>
<h:form>
<p:inputText value="#{helpView.helpTitle}" /><br />
<p:inputTextarea value="#{helpView.helpText}" /><br />
<p:commandButton actionListener="#{helpView.saveHelpText}" />
<p:commandButton rendered="#{helpView.helpAvailable or helpView.permissionToEdit}" icon="ui-icon-help" title="#{i18n['help.title']}" onclick="PF('showHelpDialog').show()" />
<!-- 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>
......
......@@ -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"
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:pe="http://primefaces.org/ui/extensions"
>
<f:view contentType="text/html" locale="#{sessionHandler.locale}">
<h:head>
<pe:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><h:outputText value="#{layoutView.getHeader()}" /></title>
......@@ -38,7 +39,7 @@
}
</h:outputStylesheet>
</h:head>
</pe:head>
<h:body>
......@@ -181,18 +182,24 @@
<p:layoutUnit position="center">
<div class="container top">
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" immediate="true" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
<p:ajax update="@all" event="change" />
</p:selectOneButton>
</h:form>
<div style="float: left;">
<h:form id="selectLanguage">
<p:selectOneButton id="langselect" styleClass="languageSelector" value="#{sessionStore.locale}" immediate="true" converter="#{localeConverter}">
<f:selectItems value="#{localeSelectorView.availableLocales}" var="loc" itemValue="#{loc.locale}" itemLabel="#{loc.locale.displayName}" />
<p:ajax update="@all" event="change" />
</p:selectOneButton>
</h:form>
<h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}:top" />
</h:link>
<h:link rendered="#{layoutView.manageContent}" styleClass="editorlink" value="#{i18n['layout.editTop']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}:top" />
</h:link>
</div>
<div style="float: right;">
<help:helptool />
</div>
<div style="clear: both;"> </div>
</div>
......@@ -221,10 +228,6 @@
</p:layoutUnit>
<p:layoutUnit position="east" resizable="true">
<help:helptool />
</p:layoutUnit>
<p:layoutUnit position="south" size="30">
<footer class="bgColor1">
<h:outputText id="cdiloop" value="#{conversationKeepaliveView.date}">
......@@ -241,8 +244,6 @@
<h:form>
<!-- <p:growl id="growl" showDetail="true" sticky="true" autoUpdate="true" /> -->
<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="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
......
......@@ -30,6 +30,16 @@
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</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>
<groupId>org.primefaces.themes</groupId>
......
......@@ -19,7 +19,9 @@
package fi.codecrew.moya.web.cdiview.help;
import fi.codecrew.moya.beans.HelpBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.enums.ValidLocale;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.handler.SessionStore;
import fi.codecrew.moya.model.Help;
import fi.codecrew.moya.model.HelpText;
......@@ -48,9 +50,12 @@ public class HelpView {
@EJB
HelpBeanLocal helpBean;
String helpTitle = null;
@EJB
PermissionBeanLocal permissionBean;
String helpText = null;
@Inject
private transient SessionStore sessionstore;
......@@ -59,9 +64,8 @@ public class HelpView {
HelpText help = helpBean.getHelpForPage(layoutView.getPagepath(), sessionstore.getLocale());
if(help == null) {
helpTitle = helpText = "";
helpText = "";
} else {
helpTitle = help.getTitle();
helpText = help.getText();
}
......@@ -81,21 +85,14 @@ public class HelpView {
}
help.setText(getHelpText());
help.setTitle(getHelpTitle());
helpBean.saveOrCreate(help);
}
public String getHelpTitle() {
if(helpTitle == null) {
populateHelpText();
}
return helpTitle;
}
public void setHelpTitle(String helpTitle) {
this.helpTitle = helpTitle;
public boolean isHelpAvailable() {
return !getHelpText().isEmpty();
}
public void setHelpText(String helpText) {
......@@ -103,8 +100,16 @@ public class HelpView {
}
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!
global.notauthorized = You don't have enough rights to enter this site.
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.hostname = Hostname
httpsession.id = ID
......@@ -1548,3 +1555,6 @@ voting.create.voteEnd = Voting close
voting.create.voteStart = Voting start
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!
global.notauthorized = You don't have enough rights to enter this site.
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.hostname = Hostname
httpsession.id = ID
......@@ -1821,3 +1828,6 @@ voting.create.voteEnd = Voting close
voting.create.voteStart = Voting start
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
global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle sivulle.
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.hostname = Hostname
httpsession.id = ID
......@@ -1808,3 +1815,6 @@ voting.create.voteEnd = \u00C4\u00E4nestys kiinni
voting.create.voteStart = \u00C4\u00E4nestys auki
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!