Commit 72070f4e by Antti Tönkyrä

Tournament stuff

- Revert Game-ID to n/a on missing
- Better default action on enter in multiparticipate
- Delete buttons for tournament participants
1 parent e2be07d6
...@@ -234,10 +234,15 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -234,10 +234,15 @@ public class TournamentBean implements TournamentBeanLocal {
EventUser executor = permissionBean.getCurrentUser(); EventUser executor = permissionBean.getCurrentUser();
// Assert we have permission to remove participant // Assert we have permission to remove participant
if(permissionBean.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION) && tp.getParticipator().equals(executor)) { if(tp.getParticipator().equals(executor)) {
throw new Exception("tournaments.can_only_remove_own_participations"); // own participation, can we delete?
} else if(!tp.getParticipator().equals(executor) && permissionBean.hasPermission(TournamentPermission.MANAGE_ALL)) { if(!permissionBean.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION)) {
throw new Exception("tournaments.cannot_remove_others_participations"); throw new Exception("tournaments.can_only_remove_own_participations");
}
} else {
if(!permissionBean.hasPermission(TournamentPermission.MANAGE_ALL)) {
throw new Exception("tournaments.cannot_remove_others_participations");
}
} }
// Assert that tournament has not closed participation // Assert that tournament has not closed participation
......
...@@ -38,7 +38,18 @@ ...@@ -38,7 +38,18 @@
<h:outputText value="#{groupMembership.placeReservation.name}" />&nbsp; <h:outputText value="#{groupMembership.placeReservation.name}" />&nbsp;
</ui:repeat> </ui:repeat>
</p:column> </p:column>
</p:dataTable> <p:column>
<p:commandButton value="#{i18n['delete']}" actionListener="#{tournamentParticipantsView.deleteParticipation}" update="@form">
<p:confirm header="#{i18n['confirmdialog.header']}" message="#{i18n['confirmdialog.are_you_sure']}" icon="ui-icon-alert" />
<f:attribute name="participantid" value="#{participant.id}" />
</p:commandButton>
<p:confirmDialog global="true">
<p:commandButton value="#{i18n['confirmdialog.yes']}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="#{i18n['confirmdialog.no']}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form> </h:form>
......
...@@ -28,6 +28,16 @@ ...@@ -28,6 +28,16 @@
</f:facet> </f:facet>
<h:outputText value="#{participant.participator.nick}" /> <h:outputText value="#{participant.participator.nick}" />
</p:column> </p:column>
<p:column>
<p:commandButton value="#{i18n['delete']}" actionListener="#{tournamentParticipantsView.deleteParticipation}" update="@form">
<p:confirm header="#{i18n['confirmdialog.header']}" message="#{i18n['confirmdialog.are_you_sure']}" icon="ui-icon-alert" />
<f:attribute name="participantid" value="#{participant.id}" />
</p:commandButton>
<p:confirmDialog global="true">
<p:commandButton value="#{i18n['confirmdialog.yes']}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="#{i18n['confirmdialog.no']}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
</p:column>
<p:rowExpansion styleClass="inlineRow"> <p:rowExpansion styleClass="inlineRow">
<p:dataTable value="#{participant.teamMembers}" var="member"> <p:dataTable value="#{participant.teamMembers}" var="member">
<p:column> <p:column>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<h2>#{i18n['tournaments.participate_team_members']}</h2> <h2>#{i18n['tournaments.participate_team_members']}</h2>
<p:messages autoUpdate="true" redisplay="false"></p:messages> <p:messages autoUpdate="true" redisplay="false"></p:messages>
<h:form> <h:form>
<p:commandButton style="width: 0px; height: 0px;" value="" action="#{tournamentParticipateView.addMainPlayerToTeam}" update="@form"/>
<h3>#{i18n['tournaments.team_details']}</h3> <h3>#{i18n['tournaments.team_details']}</h3>
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputText value="#{i18n['tournament.team_name']}" /> <h:outputText value="#{i18n['tournament.team_name']}" />
...@@ -78,7 +79,7 @@ ...@@ -78,7 +79,7 @@
<h:panelGroup> <h:panelGroup>
#{i18n['tournaments.participate_backup_player_count']}: #{i18n['tournaments.participate_backup_player_count']}:
#{tournamentParticipateView.backupPlayerCount}/#{tournamentParticipateView.backupMax} #{tournamentParticipateView.backupPlayerCount}/#{tournamentParticipateView.backupMax}
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
<p:commandButton value="#{i18n['tournaments.cancel_participation']}" action="#{tournamentParticipateView.cancelParticipation}" onerror="location.reload(true);"/> <p:commandButton value="#{i18n['tournaments.cancel_participation']}" action="#{tournamentParticipateView.cancelParticipation}" onerror="location.reload(true);"/>
......
...@@ -4,6 +4,8 @@ import java.util.HashMap; ...@@ -4,6 +4,8 @@ import java.util.HashMap;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.inject.Named; import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal; import fi.codecrew.moya.beans.TournamentBeanLocal;
...@@ -12,6 +14,7 @@ import fi.codecrew.moya.model.GameID; ...@@ -12,6 +14,7 @@ import fi.codecrew.moya.model.GameID;
import fi.codecrew.moya.model.Tournament; import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentParticipant; import fi.codecrew.moya.model.TournamentParticipant;
import fi.codecrew.moya.model.TournamentTeamMember; import fi.codecrew.moya.model.TournamentTeamMember;
import fi.codecrew.moya.utilities.jsf.MessageHelper;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
...@@ -27,7 +30,7 @@ public class TournamentParticipantsView extends GenericCDIView { ...@@ -27,7 +30,7 @@ public class TournamentParticipantsView extends GenericCDIView {
public String showView(Integer tournamentId) { public String showView(Integer tournamentId) {
if(eventUserGameID == null) { if(eventUserGameID == null) {
this.setTournament(tournamentBean.getTournamentById(tournamentId)); this.tournament = tournamentBean.getTournamentById(tournamentId);
this.beginConversation(); this.beginConversation();
eventUserGameID = new HashMap<Integer, String>(); eventUserGameID = new HashMap<Integer, String>();
for(TournamentParticipant tp : tournament.getParticipants()) { for(TournamentParticipant tp : tournament.getParticipants()) {
...@@ -36,7 +39,7 @@ public class TournamentParticipantsView extends GenericCDIView { ...@@ -36,7 +39,7 @@ public class TournamentParticipantsView extends GenericCDIView {
if(gid != null) if(gid != null)
eventUserGameID.put(ttm.getEventUser().getId(), gid.getIdentifier()); eventUserGameID.put(ttm.getEventUser().getId(), gid.getIdentifier());
else else
eventUserGameID.put(ttm.getEventUser().getId(), ttm.getEventUser().getUser().getNick()); eventUserGameID.put(ttm.getEventUser().getId(), "n/a");
} }
} }
} }
...@@ -46,6 +49,17 @@ public class TournamentParticipantsView extends GenericCDIView { ...@@ -46,6 +49,17 @@ public class TournamentParticipantsView extends GenericCDIView {
return "/tournaments/admin/view_tournament_team.xhtml"; return "/tournaments/admin/view_tournament_team.xhtml";
} }
public void deleteParticipation(ActionEvent ae) {
try {
Integer id = (Integer)ae.getComponent().getAttributes().get("participantid");
tournamentBean.deleteParticipationById(id);
this.tournament = tournamentBean.getTournamentById(this.tournament.getId());
} catch(Exception e) {
MessageHelper.err(e.getMessage());
}
}
public String cancel() { public String cancel() {
this.endConversation(); this.endConversation();
return "/tournaments/admin/index.xhtml"; return "/tournaments/admin/index.xhtml";
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!