From: David ‘Bombe’ Roden Date: Mon, 30 Jul 2012 13:58:27 +0000 (+0200) Subject: Add artist management to track. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=99b3017a74e73fb1496909c3540f9f122e74bcf9;p=demoscenemusic.git Add artist management to track. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java index c8a9be2..05bf3d0 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/admin/EditTrackPage.java @@ -18,8 +18,10 @@ package net.pterodactylus.demoscenemusic.page.admin; import java.util.Collection; +import java.util.List; import net.pterodactylus.demoscenemusic.core.Core; +import net.pterodactylus.demoscenemusic.data.Artist; import net.pterodactylus.demoscenemusic.data.Party; import net.pterodactylus.demoscenemusic.data.Track; import net.pterodactylus.demoscenemusic.page.ServletRequest; @@ -72,10 +74,14 @@ public class EditTrackPage extends AdminBasePage { templateContext.set("track", track); if (request.getMethod() == Method.POST) { + String partyId = request.getServletRequest().getParameter("party"); + Party party = getCore().getDataManager().getPartyById(partyId); + + String artistId = request.getServletRequest().getParameter("artist"); + Artist artist = getCore().getDataManager().getArtistById(artistId); + /* check if a party should be removed. */ if ("true".equals(request.getServletRequest().getParameter("delete-party"))) { - String partyId = request.getServletRequest().getParameter("party"); - Party party = getCore().getDataManager().getPartyById(partyId); Collection parties = track.getParties(); parties.remove(party); track.setParties(parties); @@ -83,13 +89,43 @@ public class EditTrackPage extends AdminBasePage { /* check if a party should be added. */ if ("true".equals(request.getServletRequest().getParameter("add-party"))) { - String partyId = request.getServletRequest().getParameter("party"); - Party party = getCore().getDataManager().getPartyById(partyId); Collection parties = track.getParties(); parties.add(party); track.setParties(parties); } + if ("true".equals(request.getServletRequest().getParameter("delete-artist"))) { + List artists = track.getArtists(); + artists.remove(artist); + track.setArtists(artists); + } + + if ("true".equals(request.getServletRequest().getParameter("move-up"))) { + List artists = track.getArtists(); + int index = artists.indexOf(artist); + if (index > 0) { + artists.remove(artist); + artists.add(index - 1, artist); + } + track.setArtists(artists); + } + + if ("true".equals(request.getServletRequest().getParameter("move-down"))) { + List artists = track.getArtists(); + int index = artists.indexOf(artist); + if (index < (artists.size() - 1)) { + artists.remove(artist); + artists.add(index + 1, artist); + } + track.setArtists(artists); + } + + if ("true".equals(request.getServletRequest().getParameter("add-artist"))) { + List artists = track.getArtists(); + artists.add(artist); + track.setArtists(artists); + } + String name = request.getServletRequest().getParameter("name"); if ((name != null) && (name.trim().length() > 0)) { track.setName(name); diff --git a/src/main/resources/templates/admin.edit-track b/src/main/resources/templates/admin.edit-track index cc535b9..bfc3355 100644 --- a/src/main/resources/templates/admin.edit-track +++ b/src/main/resources/templates/admin.edit-track @@ -37,6 +37,41 @@ +

Artists

+ +<%foreach track.artists artist> + + + +
+ + + + <%notfirst><%/notfirst> + <%notlast><%/notlast> +
+ +<%/foreach> + +

Add New Artist

+ +
+ + + +
+ Add Artist: + +
+ + + +
+

Parties

<%foreach track.parties party>