Fixed a regression based on the ServiceType toString implementation.
The DB code relied on the ServiceType toString matching the enum name. Moved the displayable value to a dedicated field and reference it in the UI.
This commit is contained in:
		@@ -3,9 +3,9 @@ package com.jdbernard.nlsongs.model;
 | 
			
		||||
public enum ServiceType {
 | 
			
		||||
    SUN_AM("Sunday AM"), SUN_PM("Sunday PM"), WED("Wednesday");
 | 
			
		||||
    
 | 
			
		||||
    private String displayName;
 | 
			
		||||
    private final String displayName;
 | 
			
		||||
 | 
			
		||||
    ServiceType(String displayName) { this.displayName = displayName; }
 | 
			
		||||
 | 
			
		||||
    @Override public String toString() { return this.displayName; }
 | 
			
		||||
    public String getDisplayName() { return this.displayName; }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ if (!service) { response.sendError(response.SC_NOT_FOUND); return }
 | 
			
		||||
        <link rel="shortcut icon" href="../images/favicon.ico">
 | 
			
		||||
 | 
			
		||||
        <title><%= service.@date.toString("yyyy-MM-dd")
 | 
			
		||||
           %> (<%= service.serviceType%>) - New Life Songs Database</title>
 | 
			
		||||
           %> (<%= service.serviceType.displayName %>) - New Life Songs Database</title>
 | 
			
		||||
        <script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
 | 
			
		||||
        <!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>-->
 | 
			
		||||
        <!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>-->
 | 
			
		||||
@@ -34,9 +34,9 @@ if (!service) { response.sendError(response.SC_NOT_FOUND); return }
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <header>
 | 
			
		||||
            <h1>New Life Songs</h1>
 | 
			
		||||
            <h2><%= service.@date.toString("yyyy-MM-dd") %> (<%=
 | 
			
		||||
                    service.serviceType %>)</h2>
 | 
			
		||||
            <h1><a href="../">New Life Songs</a></h1>
 | 
			
		||||
            <h2 class=service-date><%= service.@date.toString("yyyy-MM-dd") %> (<%=
 | 
			
		||||
                    service.serviceType.displayName %>)</h2>
 | 
			
		||||
 | 
			
		||||
            <nav><ul>
 | 
			
		||||
                <li><a href="../admin/">Admin</a></li>
 | 
			
		||||
 
 | 
			
		||||
@@ -41,13 +41,9 @@ songsDB = NLSongsContext.songsDB
 | 
			
		||||
                </tr></thead>
 | 
			
		||||
                <tbody>
 | 
			
		||||
                <% songsDB.findAllServices().sort { it.date }.reverse().each { service -> %>
 | 
			
		||||
                    <tr><td><a href="../service/<%= service.id %>"><%=
 | 
			
		||||
                    <tr><td class=date><a href="../service/<%= service.id %>"><%=
 | 
			
		||||
                            service.@date.toString("yyyy-MM-dd") %></a></td>
 | 
			
		||||
                        <td><% switch (service.serviceType) {
 | 
			
		||||
                            case SUN_PM: out.print("Sunday PM"); break
 | 
			
		||||
                            case SUN_AM: out.print("Sunday AM"); break
 | 
			
		||||
                            case WED: out.print("Wednesday"); break }
 | 
			
		||||
                            %></td></tr><% } %>
 | 
			
		||||
                        <td class=service-type><%= service.serviceType.displayName %></td></tr><% } %>
 | 
			
		||||
                </tbody>
 | 
			
		||||
                <tfoot><tr>
 | 
			
		||||
                        <th class="dt-left">Date</th>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user