Commit 9971f67a authored by Elias Englmeier's avatar Elias Englmeier
Browse files

added categories table and editing of ideas

parent ae9542d5
......@@ -13,6 +13,6 @@
##
build.namespace=ANALYSIS
build.number=12
build.date=1511193637994
build.number=23
build.date=1511964638794
build.auto.upgrade=true
\ No newline at end of file
......@@ -13,6 +13,6 @@
##
build.namespace=GB
build.number=33
build.date=1511193642506
build.number=44
build.date=1511964643116
build.auto.upgrade=true
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>
.gradle/
build/
target/
/bin/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ideaBoard</name>
<comment>Project ideaBoard created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.liferay.ide.core.liferayNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
#Thu Sep 21 11:55:56 CEST 2017
connection.arguments=
containers=org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/
connection.jvm.arguments=
build.commands=org.eclipse.jdt.core.javabuilder
connection.project.dir=../..
natures=org.eclipse.jdt.core.javanature
eclipse.preferences.version=1
connection.java.home=null
derived.resources=.gradle,build
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
project.path=\:modules\:ideaBoard
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %><%@
taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %><%@
taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %><%@
taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<liferay-theme:defineObjects />
<portlet:defineObjects />
<%@ include file="/init.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<portlet:defineObjects />
<portlet:actionURL var="submitNewIdea" windowState="normal" name="insertNewIdea"></portlet:actionURL>
<aui:form action="<%=submitNewIdea%>" method="post" name="myForm" id="myForm">
<aui:input type="text" name="title"/>
<aui:input type="text" name="short description"/>
<aui:input type="text" name="description"/>
<aui:button type="button" class = "btn btn-primary" id="next" value="done" onClick="submitForm()"/>
</aui:form>
<script>
function submitForm(e){
var myForm = $('#<portlet:namespace/>myForm');
myForm.submit();
}
</script>
\ No newline at end of file
<%@ include file="/init.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<%@ page import="com.liferay.portal.kernel.util.PortalUtil"%>
<portlet:defineObjects />
<portlet:actionURL var="navigateToInputForm" windowState="normal" name="getNavigationToInputForm">
</portlet:actionURL>
<style>
#bottomHr {
width: 100%;
height: 1px;
margin: 5px;
color: blue;
background: black;
}
#ideas_tab{
width : 85%;
}
.yui3-widget.tab{
background-color:rgba(0, 0, 0, 0.25);
margin-left : -5px;
}
.yui3-widget.tab.active.tab-selected{
background-color:rgba(204, 0, 0, 0.5);
transform: scale(1.1);
}
.tab-pane.active{
transform : scale (0.1);
}
.tab-content{
width : 75%;
display: inline-grid;
}
.nav.nav-stacked{
float:left;
display: inline-grid;
}
.nav{
padding-left:0;
padding-right:5%;
margin-bottom: 20px;
}
.nav-stacked > li + li{
margin-top: 4px;
}
</style>
<div id="main">
<aui:button type="button"class = "btn btn-primary" id="newBtn" style="float:right;" value="New Idea" onClick="<%=navigateToInputForm.toString()%>"/>
<script type="text/javascript">
$(document).ready(function() {
Liferay.on('refreshIdeaBoard',
function(event) {
var refresh = event.refresh;
if(refresh){
location.reload(true);
}
});
});
var ideasJsonArray = JSON.parse('${allIdeas}')
var tabViewChildren = ideasArrayToTabViewChildren(ideasJsonArray);
YUI().use('aui-tabview', function(Y){
new Y.TabView(
{
children : tabViewChildren,
srcNode : '#ideas_tab',
stacked : true
}).render();
});
function ideasArrayToTabViewChildren(arr){
var result = new Array();
for (var i = 0; i < arr.length; i++){
var obj = arr[i];
var child = {
content: '<br><h3>' + obj.shortdescription + '</h3><br><p>' + obj.description + '</p>',
id : obj.id,
label: ''+obj.title
}
result.push(child);
}
return result;
}
</script>
<div id="ideas_tab"></div>
<br/><hr id="bottomHr"/><br/>
<portlet:actionURL var="submitNewComment" windowState="normal" name="insertNewComment"></portlet:actionURL>
<aui:form action="<%=submitNewComment%>" method="post" name="commentForm" id="commentForm">
<aui:input type="text" name="Comment"></aui:input>
<aui:input type="hidden" name="IdeaId" value="0"/>
<aui:button type="button" class = "btn btn-primary" id="next" value="Submit" onClick="submitForm()"/>
</aui:form>
<script>
function submitForm(e){
var myForm = $('#<portlet:namespace/>commentForm');
var IdOfSelectedIdea = $('.yui3-widget.tab.active.tab-selected').attr('id');
document.getElementById('_IdeaBoard_INSTANCE_J6vRLVcyJ4mj_IdeaId').value = IdOfSelectedIdea;
myForm.submit();
}
</script>
</div>
javax.portlet.display-name.ideaBoard=ideaBoard JSP
javax.portlet.keywords.ideaBoard=ideaBoard,jsp
javax.portlet.short-title.ideaBoard=ideaBoard JSP
javax.portlet.title.ideaBoard=ideaBoard JSP Portlet
ideaBoard.caption=Hello from ideaBoard JSP!
\ No newline at end of file
Bundle-Name: ideaBoard
Bundle-SymbolicName: ideaBoard
Bundle-Version: 1.0.0
Export-Package: ideaBoard.constants
\ No newline at end of file
dependencies {
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
compileOnly group: "jstl", name: "jstl", version: "1.2"
compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
compile project (":modules:ideaService:ideaService-api")
}
\ No newline at end of file
package ideaBoard.constants;
/**
* @author englmeier
*/
public class IdeaBoardPortletKeys {
public static final String IdeaBoard = "IdeaBoard";
}
\ No newline at end of file
package ideaBoard.portlet;
import ideaBoard.constants.IdeaBoardPortletKeys;
import ideaService.model.Comment;
import ideaService.model.Ideas;
import ideaService.service.CommentLocalServiceUtil;
import ideaService.service.IdeasLocalServiceUtil;
import ideaService.service.IdeasService;
import ideaService.service.persistence.IdeasUtil;
import com.liferay.counter.kernel.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextFactory;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.WebKeys;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.Portlet;
import javax.portlet.PortletException;
import javax.portlet.ProcessAction;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.osgi.service.component.annotations.Component;
/**
* @author englmeier
*/
@Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=category.sample",
"com.liferay.portlet.instanceable=true",
"javax.portlet.display-name=ideaBoard Portlet",
"javax.portlet.init-param.template-path=/",
"javax.portlet.init-param.view-template=/view.jsp",
"javax.portlet.name=" + IdeaBoardPortletKeys.IdeaBoard,
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=power-user,user"
},
service = Portlet.class
)
public class IdeaBoardPortlet extends MVCPortlet {
@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException{
//System.out.println("Loaded the IdeaBoard.");
super.doView(renderRequest, renderResponse);
}
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException{
renderRequest.setAttribute("allIdeas", JSONFactoryUtil.looseSerializeDeep(IdeasLocalServiceUtil.getAllIdeas()));
super.render(renderRequest, renderResponse);
}
public void getNavigationToInputForm(ActionRequest request, ActionResponse response)
throws PortalException, SystemException {
response.setRenderParameter("mvcPath","/inputIdea.jsp");
}
public void insertNewIdea(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, SystemException, IOException {
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Ideas.class.getName(), actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
String title = ParamUtil.getString(actionRequest, "title");
String description = ParamUtil.getString(actionRequest, "description");
String shortDescription = ParamUtil.getString(actionRequest, "short description");
Ideas nextIdea = IdeasLocalServiceUtil.creadeIdeasWithAutomatedDbId(title, serviceContext.getUserId(),serviceContext.getScopeGroupId(),
null, null, shortDescription, description, 0.0, 0.0, true, false,0,themeDisplay.getLayout().getPrimaryKey(),0L,"",0L);
IdeasLocalServiceUtil.persistIdeasAndPerformTypeChecks(nextIdea);
//Redirect to avoid duplicate submissions
actionResponse.sendRedirect(PortalUtil.getLayoutURL(themeDisplay.getLayout(),themeDisplay));
}
public void insertNewComment(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, IOException {
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Comment.class.getName(), actionRequest);
String commentBody = ParamUtil.getString(actionRequest, "Comment");
String id = ParamUtil.getString(actionRequest, "IdeaId");
Comment nextComment = CommentLocalServiceUtil.createCommentWithAutomatedDbId(id,commentBody,serviceContext.getUserId());
CommentLocalServiceUtil.persistCommentAndPerformTypeChecks(nextComment);
//Redirect to avoid duplicate submissions
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
actionResponse.sendRedirect(PortalUtil.getLayoutURL(themeDisplay.getLayout(),themeDisplay));
}
}
\ No newline at end of file
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %><%@
taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %><%@
taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %><%@
taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<liferay-theme:defineObjects />
<portlet:defineObjects />
<%@ include file="/init.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<portlet:defineObjects />
<portlet:actionURL var="submitNewIdea" windowState="normal" name="insertNewIdea"></portlet:actionURL>
<aui:form action="<%=submitNewIdea%>" method="post" name="myForm" id="myForm">
<aui:input type="text" name="title"/>
<aui:input type="text" name="short description"/>
<aui:input type="text" name="description"/>
<aui:button type="button" class = "btn btn-primary" id="next" value="done" onClick="submitForm()"/>
</aui:form>
<script>
function submitForm(e){
var myForm = $('#<portlet:namespace/>myForm');
myForm.submit();
}
</script>
\ No newline at end of file
<%@ include file="/init.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<%@ page import="com.liferay.portal.kernel.util.PortalUtil"%>
<portlet:defineObjects />
<portlet:actionURL var="navigateToInputForm" windowState="normal" name="getNavigationToInputForm">
</portlet:actionURL>
<style>
#bottomHr {
width: 100%;
height: 1px;
margin: 5px;
color: blue;
background: black;
}
#ideas_tab{
width : 85%;
}
.yui3-widget.tab{
background-color:rgba(0, 0, 0, 0.25);
margin-left : -5px;
}
.yui3-widget.tab.active.tab-selected{
background-color:rgba(204, 0, 0, 0.5);
transform: scale(1.1);
}
.tab-pane.active{
transform : scale (0.1);
}
.tab-content{
width : 75%;
display: inline-grid;
}
.nav.nav-stacked{
float:left;
display: inline-grid;
}
.nav{
padding-left:0;
padding-right:5%;
margin-bottom: 20px;
}
.nav-stacked > li + li{
margin-top: 4px;
}
</style>
<div id="main">
<aui:button type="button"class = "btn btn-primary" id="newBtn" style="float:right;" value="New Idea" onClick="<%=navigateToInputForm.toString()%>"/>
<script type="text/javascript">
$(document).ready(function() {
Liferay.on('refreshIdeaBoard',
function(event) {
var refresh = event.refresh;
if(refresh){
location.reload(true);
}
});
});
var ideasJsonArray = JSON.parse('${allIdeas}')
var tabViewChildren = ideasArrayToTabViewChildren(ideasJsonArray);
YUI().use('aui-tabview', function(Y){
new Y.TabView(
{
children : tabViewChildren,
srcNode : '#ideas_tab',
stacked : true
}).render();
});
function ideasArrayToTabViewChildren(arr){
var result = new Array();
for (var i = 0; i < arr.length; i++){
var obj = arr[i];
var child = {
content: '<br><h3>' + obj.shortdescription + '</h3><br><p>' + obj.description + '</p>',
id : obj.id,
label: ''+obj.title
}
result.push(child);
}
return result;
}
</script>
<div id="ideas_tab"></div>
<br/><hr id="bottomHr"/><br/>
<portlet:actionURL var="submitNewComment" windowState="normal" name="insertNewComment"></portlet:actionURL>
<aui:form action="<%=submitNewComment%>" method="post" name="commentForm" id="commentForm">
<aui:input type="text" name="Comment"></aui:input>
<aui:input type="hidden" name="IdeaId" value="0"/>
<aui:button type="button" class = "btn btn-primary" id="next" value="Submit" onClick="submitForm()"/>
</aui:form>
<script>
function submitForm(e){
var myForm = $('#<portlet:namespace/>commentForm');
var IdOfSelectedIdea = $('.yui3-widget.tab.active.tab-selected').attr('id');
document.getElementById('_IdeaBoard_INSTANCE_J6vRLVcyJ4mj_IdeaId').value = IdOfSelectedIdea;
myForm.submit();
}
</script>
</div>
javax.portlet.display-name.ideaBoard=ideaBoard JSP
javax.portlet.keywords.ideaBoard=ideaBoard,jsp
javax.portlet.short-title.ideaBoard=ideaBoard JSP
javax.portlet.title.ideaBoard=ideaBoard JSP Portlet
ideaBoard.caption=Hello from ideaBoard JSP!
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment