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;
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<Party> parties = track.getParties();
parties.remove(party);
track.setParties(parties);
/* 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<Party> parties = track.getParties();
parties.add(party);
track.setParties(parties);
}
+ if ("true".equals(request.getServletRequest().getParameter("delete-artist"))) {
+ List<Artist> artists = track.getArtists();
+ artists.remove(artist);
+ track.setArtists(artists);
+ }
+
+ if ("true".equals(request.getServletRequest().getParameter("move-up"))) {
+ List<Artist> 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<Artist> 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<Artist> 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);
</form>
+<h2>Artists</h2>
+
+<%foreach track.artists artist>
+
+ <div>Artist: <a href="admin.edit-artist?id=<%artist.id|html>"><%artist.name|html></a></div>
+
+ <form action="admin.edit-track" method="post" accept-charset="utf-8">
+ <input type="hidden" name="id" value="<%track.id|html>"/>
+ <input type="hidden" name="artist" value="<%artist.id|html>"/>
+ <button type="submit" name="delete-artist" value="true">Delete Artist</button>
+ <%notfirst><button type="submit" name="move-up" value="true">Artist ↑</button><%/notfirst>
+ <%notlast><button type="submit" name="move-down" value="true">Artist ↓</button><%/notlast>
+ </form>
+
+<%/foreach>
+
+<h3>Add New Artist</h3>
+
+<form action="admin.edit-track" method="post" accept-charset="utf-8">
+
+ <input type="hidden" name="id" value="<%track.id|html>"/>
+
+ <div>
+ Add Artist:
+ <select name="artist">
+ <%foreach dataManager.allArtists artist|sort>
+ <option value="<%artist.id|html>"><%artist.name|html></option>
+ <%/foreach>
+ </select>
+ </div>
+
+ <button type="submit" name="add-artist" value="true">Add Artist</button>
+
+</form>
+
<h2>Parties</h2>
<%foreach track.parties party>