Commit 620e1532 by Tuukka Kivilahti

calendars are quite nice

1 parent 0699436d
...@@ -117,7 +117,9 @@ public class LectureBean implements LectureBeanLocal { ...@@ -117,7 +117,9 @@ public class LectureBean implements LectureBeanLocal {
lectureloop: for (Lecture l : lectureGroup.getLectures()) { lectureloop: for (Lecture l : lectureGroup.getLectures()) {
for (Role r : l.getOpenForRoles()) { for (Role r : l.getOpenForRoles()) {
if (userRoles.contains(r)) { if (userRoles.contains(r)) {
lectures.add(l); if(!user.getLectures().contains(l)) {
lectures.add(l);
}
continue lectureloop; continue lectureloop;
} }
} }
...@@ -214,4 +216,9 @@ public class LectureBean implements LectureBeanLocal { ...@@ -214,4 +216,9 @@ public class LectureBean implements LectureBeanLocal {
return false; return false;
} }
@Override
public Lecture getFirstLecture() {
return lectureFacade.findFirstLecture();
}
} }
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.beans.EventBean;
import fi.codecrew.moya.model.Lecture; import fi.codecrew.moya.model.Lecture;
import fi.codecrew.moya.model.LectureGroup_;
import fi.codecrew.moya.model.Lecture_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -12,4 +18,20 @@ public class LectureFacade extends IntegerPkGenericFacade<Lecture> { ...@@ -12,4 +18,20 @@ public class LectureFacade extends IntegerPkGenericFacade<Lecture> {
public LectureFacade() { public LectureFacade() {
super(Lecture.class); super(Lecture.class);
} }
@EJB
EventBean eventbean;
public Lecture findFirstLecture() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Lecture> cq = cb.createQuery(Lecture.class);
Root<Lecture> root = cq.from(Lecture.class);
cq.where(cb.equal(root.get(Lecture_.lectureGroup).get(LectureGroup_.event), eventbean.getCurrentEvent()));
cq.orderBy(cb.asc(root.get(Lecture_.startTime)));
return getSingleNullableResult(getEm().createQuery(cq).setMaxResults(1));
}
} }
...@@ -34,4 +34,6 @@ public interface LectureBeanLocal { ...@@ -34,4 +34,6 @@ public interface LectureBeanLocal {
public int userLectureSelects(LectureGroup group, EventUser user); public int userLectureSelects(LectureGroup group, EventUser user);
public boolean isUserCanParticipate(EventUser user); public boolean isUserCanParticipate(EventUser user);
public Lecture getFirstLecture();
} }
...@@ -145,20 +145,22 @@ public class Lecture extends GenericEntity { ...@@ -145,20 +145,22 @@ public class Lecture extends GenericEntity {
this.startTime = startTime; this.startTime = startTime;
} }
/*
@Transient @Transient
public Calendar getEndTime() { public Date getEndTime() {
if (getStartTime() == null || getHours() == null) if (getStartTime() == null || getHours() == null)
return getStartTime(); return getStartTime();
Calendar endTime = (Calendar) getStartTime().clone(); Calendar endTime = Calendar.getInstance();
endTime.setTime((Date) getStartTime().clone());
endTime.add(Calendar.MINUTE, getHours().multiply(new BigDecimal(60)).intValue()); endTime.add(Calendar.MINUTE, getHours().multiply(new BigDecimal(60)).intValue());
return endTime; return endTime.getTime();
} }
/*
@Transient @Transient
public void setEndTime(Calendar endTime) { public void setEndTime(Calendar endTime) {
......
...@@ -7,16 +7,18 @@ ...@@ -7,16 +7,18 @@
<f:event type="preRenderView" listener="#{lectureUserView.initView()}" /> <f:event type="preRenderView" listener="#{lectureUserView.initView()}" />
</f:metadata> </f:metadata>
<ui:define rendered="#{lectureUserView.lectureGroupsVisible}" name="title"> <ui:define rendered="#{lectureUserView.lectureGroupsVisible}" name="title">
<h1>#{i18n['viewlectures.title']}</h1> <h1>#{i18n['viewlectures.title']}</h1>
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<h:form id="viewlecturesform"> <h:form id="viewlecturesform">
<p:outputPanel styleClass="messagebox" rendered="#{!lectureUserView.participateActive}"> <p:outputPanel styleClass="messagebox" rendered="#{!lectureUserView.participateActive}">
<h2><p:outputLabel value="#{i18n['lecture.participateNotActive.title']}" /></h2> <h2>
<p:outputLabel value="#{i18n['lecture.participateNotActive.title']}" />
</h2>
<p:outputLabel value="#{i18n['lecture.participateNotActive.message']}" /> <p:outputLabel value="#{i18n['lecture.participateNotActive.message']}" />
</p:outputPanel> </p:outputPanel>
...@@ -32,13 +34,13 @@ ...@@ -32,13 +34,13 @@
<h:outputText value="#{lectureGroup.selectCount}" /> <h:outputText value="#{lectureGroup.selectCount}" />
</p:column> </p:column>
<p:column> <p:column>
<p:commandButton value="#{i18n['lectureGroup.view']}" actionListener="#{lectureUserView.selectCurrentLectureGroup}" update=":viewlecturesform:participatedLectures :viewlecturesform:availableLectures :viewlecturesform:title" onerror="location.reload(true)" /> <p:commandButton value="#{i18n['lectureGroup.view']}" actionListener="#{lectureUserView.selectCurrentLectureGroup}" update=":viewlecturesform:availableLectures:lecturelist :viewlecturesform:availableLectures:schedule :viewlecturesform:participatedLectures :viewlecturesform:title" onerror="location.reload(true)" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</p:fieldset> </p:fieldset>
<h1> <h1>
<h:outputText id="title" value="#{lectureUserView.currentLectureGroup.name}" /> <h:outputText id="title" value="#{lectureUserView.currentLectureGroup.name}" />
</h1> </h1>
...@@ -62,39 +64,94 @@ ...@@ -62,39 +64,94 @@
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" /> <h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column> </p:column>
<p:column style="width:110px"> <p:column style="width:110px">
<p:commandButton value="#{i18n['lecture.unparticipate']}" actionListener="#{lectureUserView.unParticipateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" /> <p:commandButton value="#{i18n['lecture.unparticipate']}" actionListener="#{lectureUserView.unParticipateCurrent}" update=":viewlecturesform:availableLectures:lecturelist :viewlecturesform:availableLectures:schedule :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
</p:column>
</p:dataTable>
</p:fieldset>
<br /><br />
<p:fieldset id="availableLectures" legend="#{i18n['lecture.availableLectures']}" >
<p:dataTable value="#{lectureUserView.lectures}" var="lecture">
<p:column headerText="#{i18n['lecture.name']}" sortBy="#{lecture.name}" style="width:125px">
<h:outputText value="#{lecture.name}" />
</p:column>
<p:column headerText="#{i18n['lecture.description']}" sortBy="#{lecture.description}">
<h:outputText value="#{lecture.description}" />
</p:column>
<p:column headerText="#{i18n['lecture.hours']}" sortBy="#{lecture.hours}" style="width:110px">
<h:outputText value="#{lecture.hours}" />
</p:column>
<p:column headerText="#{i18n['lecture.startTime']}" sortBy="#{lecture.startTime}" style="width:110px">
<h:outputText value="#{lecture.startTime}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['lecture.participants']}" sortBy="#{lecture.participantsCount}" style="width:110px">
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column>
<p:column style="width:80px">
<p:commandButton value="#{i18n['lecture.participate']}" rendered="#{!lectureUserView.currentGroupFull and !lecture.full and lectureUserView.participateActive}" actionListener="#{lectureUserView.participateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
<h:outputText value="#{i18n['lecture.full']}" rendered="#{lecture.full}" />
<h:outputText value="#{i18n['lecture.groupFull']}" rendered="#{lectureUserView.currentGroupFull}" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</p:fieldset> </p:fieldset>
<br />
<br />
<h2>#{i18n['lecture.availableLectures']}</h2>
<p:tabView id="availableLectures">
<p:tab title="#{i18n['lecture.availableLecturesList']}">
<p:dataTable id="lecturelist" value="#{lectureUserView.lectures}" var="lecture">
<p:column headerText="#{i18n['lecture.name']}" sortBy="#{lecture.name}" style="width:125px">
<h:outputText value="#{lecture.name}" />
</p:column>
<p:column headerText="#{i18n['lecture.description']}" sortBy="#{lecture.description}">
<h:outputText value="#{lecture.description}" />
</p:column>
<p:column headerText="#{i18n['lecture.hours']}" sortBy="#{lecture.hours}" style="width:110px">
<h:outputText value="#{lecture.hours}" />
</p:column>
<p:column headerText="#{i18n['lecture.startTime']}" sortBy="#{lecture.startTime}" style="width:110px">
<h:outputText value="#{lecture.startTime}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['lecture.participants']}" sortBy="#{lecture.participantsCount}" style="width:110px">
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column>
<p:column style="width:80px">
<p:commandButton value="#{i18n['lecture.participate']}" rendered="#{!lectureUserView.currentGroupFull and !lecture.full and lectureUserView.participateActive}" actionListener="#{lectureUserView.participateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
<h:outputText value="#{i18n['lecture.full']}" rendered="#{lecture.full}" />&nbsp;
<h:outputText value="#{i18n['lecture.groupFull']}" rendered="#{lectureUserView.currentGroupFull}" />
</p:column>
</p:dataTable>
</p:tab>
<p:tab title="#{i18n['lecture.availableLecturesCalendar']}">
<p:schedule id="schedule" axisFormat="H:mm" timeFormat="H:mm" timeZone="#{sessionHandler.timezone}" initialDate="#{lectureUserView.scheduleInitDate}" value="#{lectureUserView.coursesCalendar}" locale="#{sessionHandler.locale}" tooltip="true" draggable="false" resizable="false" view="agendaDay" allDaySlot="false">
<p:ajax event="eventSelect" listener="#{lectureUserView.onLecureCalendarEventSelect}" update=":viewlecturesform:participatedLectures :viewlecturesform:availableLectures:schedule" />
</p:schedule>
</p:tab>
</p:tabView>
</h:form> </h:form>
<script type="text/javascript">
PrimeFaces.locales['fi'] = {
closeText : 'Sulje',
prevText : 'Edellinen',
nextText : 'Seuraava',
currentText : 'Tänään',
monthNames : [ 'Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu', 'Joulukuu' ],
monthNamesShort : [ 'Tammikuu', 'Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],
dayNames : [ 'Sunnuntai','Maanantai','Tiistain','Keskiviikko','Torstai','Perjantai','Lauantai' ],
dayNamesShort : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
dayNamesMin : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
weekHeader : 'vk',
firstDay : 1,
isRTL : false,
showMonthAfterYear : false,
yearSuffix : '',
month : 'Kuukausi',
week : 'Viikko',
day : 'Päivä',
allDayText : 'Koko päivä'
};
PrimeFaces.locales['und'] = {
closeText : 'Sulje',
prevText : 'Edellinen',
nextText : 'Seuraava',
currentText : 'Tänään',
monthNames : [ 'Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu', 'Joulukuu' ],
monthNamesShort : [ 'Tammikuu', 'Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],
dayNames : [ 'Sunnuntai','Maanantai','Tiistain','Keskiviikko','Torstai','Perjantai','Lauantai' ],
dayNamesShort : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
dayNamesMin : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
weekHeader : 'vk',
firstDay : 1,
isRTL : false,
showMonthAfterYear : false,
yearSuffix : '',
month : 'Kuukausi',
week : 'Viikko',
day : 'Päivä',
allDayText : 'Koko päivä'
};
</script>
</ui:define> </ui:define>
......
...@@ -115,4 +115,24 @@ ...@@ -115,4 +115,24 @@
.success { .success {
color: #006600; color: #006600;
} }
\ No newline at end of file
.lectureCalendar,
.lectureCalendarParticipating,
.lectureCalendarDisabled {
border: 1px solid black;
padding: 3px;
font-size: 11px;
}
.lectureCalendarParticipating {
background-color: green;
}
.lectureCalendarDisabled {
background-color: gray;
}
...@@ -218,3 +218,4 @@ th, td { ...@@ -218,3 +218,4 @@ th, td {
padding-right: 20px; padding-right: 20px;
padding-bottom: 20px; padding-bottom: 20px;
} }
...@@ -202,6 +202,8 @@ lanEventProperty.save = Save ...@@ -202,6 +202,8 @@ lanEventProperty.save = Save
lanEventProperty.textValue = Text value lanEventProperty.textValue = Text value
lecture.availableLectures = Aihealueen kurssit ja luennot lecture.availableLectures = Aihealueen kurssit ja luennot
lecture.availableLecturesCalendar = Kalenterina
lecture.availableLecturesList = Listana
lecture.createLecture = Uuden tiedot lecture.createLecture = Uuden tiedot
lecture.createNew = Luo uusi lecture.createNew = Luo uusi
lecture.description = Kuvaus lecture.description = Kuvaus
...@@ -216,6 +218,7 @@ lecture.participate = Ilmoittaudu ...@@ -216,6 +218,7 @@ lecture.participate = Ilmoittaudu
lecture.participateNotActive.message = Voit ilmoittautua kursseille kun olet ostanut lipun tapahtumaan lecture.participateNotActive.message = Voit ilmoittautua kursseille kun olet ostanut lipun tapahtumaan
lecture.participateNotActive.title = Osta ensiksi p\u00E4\u00E4sylippu lecture.participateNotActive.title = Osta ensiksi p\u00E4\u00E4sylippu
lecture.participatedLectures = Kurssi-ilmoittautumisesi lecture.participatedLectures = Kurssi-ilmoittautumisesi
lecture.participating = Osallistumassa
lecture.roles = Roolit lecture.roles = Roolit
lecture.saveLecture = Muokkaa lecture.saveLecture = Muokkaa
lecture.selectgroup = Valitse aihealue lecture.selectgroup = Valitse aihealue
......
...@@ -554,6 +554,8 @@ layout.editContent = Edit center ...@@ -554,6 +554,8 @@ layout.editContent = Edit center
layout.editTop = Edit topcontent layout.editTop = Edit topcontent
lecture.availableLectures = available lectures lecture.availableLectures = available lectures
lecture.availableLecturesCalendar = In calendar
lecture.availableLecturesList = In list
lecture.createLecture = New lecture lecture.createLecture = New lecture
lecture.createNew = Create new lecture.createNew = Create new
lecture.description = Description lecture.description = Description
...@@ -568,6 +570,7 @@ lecture.participate = Participate ...@@ -568,6 +570,7 @@ lecture.participate = Participate
lecture.participateNotActive.message = You can participate to lectures when you have bought a ticket to event. lecture.participateNotActive.message = You can participate to lectures when you have bought a ticket to event.
lecture.participateNotActive.title = Buy tickets before participating lecture.participateNotActive.title = Buy tickets before participating
lecture.participatedLectures = Your lectures lecture.participatedLectures = Your lectures
lecture.participating = Participating
lecture.roles = Roles lecture.roles = Roles
lecture.saveLecture = Edit lecture.saveLecture = Edit
lecture.selectgroup = Select lecturegroup lecture.selectgroup = Select lecturegroup
......
...@@ -564,6 +564,8 @@ layout.editContent = Muokkaa sis\u00E4lt\u00F6\u00E4 ...@@ -564,6 +564,8 @@ layout.editContent = Muokkaa sis\u00E4lt\u00F6\u00E4
layout.editTop = Muokkaa yl\u00E4sis\u00E4lt\u00F6\u00E4 layout.editTop = Muokkaa yl\u00E4sis\u00E4lt\u00F6\u00E4
lecture.availableLectures = Aihealueen kurssit ja luennot lecture.availableLectures = Aihealueen kurssit ja luennot
lecture.availableLecturesCalendar = Kalenterina
lecture.availableLecturesList = Listana
lecture.createLecture = Uuden tiedot lecture.createLecture = Uuden tiedot
lecture.createNew = Luo uusi lecture.createNew = Luo uusi
lecture.description = Kuvaus lecture.description = Kuvaus
...@@ -578,6 +580,7 @@ lecture.participate = Ilmoittaudu ...@@ -578,6 +580,7 @@ lecture.participate = Ilmoittaudu
lecture.participateNotActive.message = Voit ilmoittautua kursseille vasta kun olet ostanut lipun tapahtumaan. Osta lippu valitsemalla vasemmalta Kauppa -> Osta tuotteita. lecture.participateNotActive.message = Voit ilmoittautua kursseille vasta kun olet ostanut lipun tapahtumaan. Osta lippu valitsemalla vasemmalta Kauppa -> Osta tuotteita.
lecture.participateNotActive.title = Aloita ostamalla lippu tapahtumaan lecture.participateNotActive.title = Aloita ostamalla lippu tapahtumaan
lecture.participatedLectures = Ilmoittautumisesi lecture.participatedLectures = Ilmoittautumisesi
lecture.participating = Osallistumassa
lecture.roles = Roolit lecture.roles = Roolit
lecture.saveLecture = Muokkaa lecture.saveLecture = Muokkaa
lecture.selectgroup = Valitse aihealue lecture.selectgroup = Valitse aihealue
......
package fi.codecrew.moya.web.lecture; package fi.codecrew.moya.web.lecture;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -8,12 +9,17 @@ import javax.faces.model.ListDataModel; ...@@ -8,12 +9,17 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.DefaultScheduleEvent;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.ScheduleModel;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LectureBeanLocal; import fi.codecrew.moya.beans.LectureBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.LecturePermission; import fi.codecrew.moya.enums.apps.LecturePermission;
import fi.codecrew.moya.model.Lecture; import fi.codecrew.moya.model.Lecture;
import fi.codecrew.moya.model.LectureGroup; import fi.codecrew.moya.model.LectureGroup;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
...@@ -32,26 +38,28 @@ public class LectureUserView extends GenericCDIView { ...@@ -32,26 +38,28 @@ public class LectureUserView extends GenericCDIView {
@EJB @EJB
EventBeanLocal eventBean; EventBeanLocal eventBean;
ListDataModel<LectureGroup> lectureGroups = null; ListDataModel<LectureGroup> lectureGroups = null;
ListDataModel<Lecture> lectures = null; ListDataModel<Lecture> lectures = null;
ListDataModel<Lecture> participatedLectures = null; ListDataModel<Lecture> participatedLectures = null;
LectureGroup currentLectureGroup; LectureGroup currentLectureGroup;
ScheduleModel coursesCalendar = null;
Date curDate = null;
public void initView() { public void initView() {
if (super.requirePermissions(LecturePermission.VIEW)) { if (super.requirePermissions(LecturePermission.VIEW)) {
super.beginConversation(); super.beginConversation();
} }
} }
public boolean isLectureGroupsVisible() { public boolean isLectureGroupsVisible() {
if(lectureBean.getLectureGroups().size() <= 1) if (lectureBean.getLectureGroups().size() <= 1)
return false; return false;
return true; return true;
} }
public boolean isParticipateActive() { public boolean isParticipateActive() {
return lectureBean.isUserCanParticipate(userView.getCurrentUser()); return lectureBean.isUserCanParticipate(userView.getCurrentUser());
} }
...@@ -84,7 +92,7 @@ public class LectureUserView extends GenericCDIView { ...@@ -84,7 +92,7 @@ public class LectureUserView extends GenericCDIView {
if (currentLectureGroup == null) if (currentLectureGroup == null)
return new ListDataModel<Lecture>(); return new ListDataModel<Lecture>();
if(lectures == null) if (lectures == null)
lectures = new ListDataModel<Lecture>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser())); lectures = new ListDataModel<Lecture>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser()));
return lectures; return lectures;
...@@ -96,21 +104,91 @@ public class LectureUserView extends GenericCDIView { ...@@ -96,21 +104,91 @@ public class LectureUserView extends GenericCDIView {
return participatedLectures; return participatedLectures;
} }
public ScheduleModel getCoursesCalendar() {
if (coursesCalendar == null) {
coursesCalendar = new DefaultScheduleModel();
for (Lecture lecture : lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser())) {
String altinfo = "\n" + lecture.getDescription() + "\n";
if (lecture.isFull())
altinfo += "\n" + I18n.get("lecture.full");
if (isCurrentGroupFull())
altinfo += "\n" + I18n.get("lecture.groupFull");
DefaultScheduleEvent event = new DefaultScheduleEvent(lecture.getName() + altinfo, lecture.getStartTime(), lecture.getEndTime(), lecture);
event.setDescription(lecture.getDescription());
if (lecture.isFull() || isCurrentGroupFull()) {
event.setStyleClass("lectureCalendarDisabled");
} else {
event.setStyleClass("lectureCalendar");
}
coursesCalendar.addEvent(event);
}
for (Lecture lecture : lectureBean.getParticipatedLectures(userView.getCurrentUser())) {
String altinfo = "\n" + lecture.getDescription() + "\n\n" + I18n.get("lecture.participating");
DefaultScheduleEvent event = new DefaultScheduleEvent(lecture.getName() + altinfo, lecture.getStartTime(), lecture.getEndTime(), lecture);
event.setDescription(lecture.getDescription());
event.setStyleClass("lectureCalendarParticipating");
coursesCalendar.addEvent(event);
}
}
return coursesCalendar;
}
public void onLecureCalendarEventSelect(SelectEvent selectEvent) {
Lecture lecture = (Lecture) ((DefaultScheduleEvent) selectEvent.getObject()).getData();
lectureBean.participate(userView.getCurrentUser(), lecture);
// super.addFaceMessage("lecture.participated");
curDate = lecture.getStartTime();
this.lectures = null;
this.coursesCalendar = null;
}
public void onLecureCalendarDateSelect(SelectEvent selectEvent) {
}
public Date getScheduleInitDate() {
if (curDate != null)
return curDate;
Lecture lecture = lectureBean.getFirstLecture();
if (lecture == null)
return null;
return lecture.getStartTime();
}
public void participateCurrent() { public void participateCurrent() {
if(!isParticipateActive()) { if (!isParticipateActive()) {
return; return;
} }
if (lectures != null && lectures.isRowAvailable()) { if (lectures != null && lectures.isRowAvailable()) {
Lecture lecture = lectures.getRowData(); Lecture lecture = lectures.getRowData();
lectureBean.participate(userView.getCurrentUser(), lecture); lectureBean.participate(userView.getCurrentUser(), lecture);
super.addFaceMessage("lecture.participated"); super.addFaceMessage("lecture.participated");
this.lectures = null; this.lectures = null;
this.coursesCalendar = null;
} }
} }
...@@ -118,20 +196,20 @@ public class LectureUserView extends GenericCDIView { ...@@ -118,20 +196,20 @@ public class LectureUserView extends GenericCDIView {
if (participatedLectures != null && participatedLectures.isRowAvailable()) { if (participatedLectures != null && participatedLectures.isRowAvailable()) {
Lecture lecture = participatedLectures.getRowData(); Lecture lecture = participatedLectures.getRowData();
lectureBean.unparticipate(userView.getCurrentUser(), lecture); lectureBean.unparticipate(userView.getCurrentUser(), lecture);
super.addFaceMessage("lecture.unparticipated"); super.addFaceMessage("lecture.unparticipated");
this.lectures = null; this.lectures = null;
this.coursesCalendar = null;
} }
} }
public boolean isCurrentGroupFull() { public boolean isCurrentGroupFull() {
return (lectureBean.userLectureSelectsLeft(getCurrentLectureGroup(), userView.getCurrentUser()) <= 0); return (lectureBean.userLectureSelectsLeft(getCurrentLectureGroup(), userView.getCurrentUser()) <= 0);
} }
public int getCurrentGroupParticipateCount() { public int getCurrentGroupParticipateCount() {
return lectureBean.userLectureSelects(getCurrentLectureGroup(), userView.getCurrentUser()); return lectureBean.userLectureSelects(getCurrentLectureGroup(), userView.getCurrentUser());
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!