Skip to content

Commit

Permalink
Added LetterSound
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatesh2k3 committed Jul 25, 2024
1 parent 24995ae commit 987f412
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
38 changes: 28 additions & 10 deletions src/main/java/ai/elimu/web/content/letter/LetterEditController.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package ai.elimu.web.content.letter;

import java.util.Calendar;
import javax.validation.Valid;
import java.util.List;

import org.apache.logging.log4j.Logger;
import ai.elimu.dao.LetterContributionEventDao;
import ai.elimu.dao.LetterDao;
import ai.elimu.model.content.Letter;
import ai.elimu.model.contributor.Contributor;
import ai.elimu.model.contributor.LetterContributionEvent;
import ai.elimu.util.DiscordHelper;
import ai.elimu.web.context.EnvironmentContextLoaderListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;

import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
Expand All @@ -23,6 +18,16 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import ai.elimu.dao.LetterContributionEventDao;
import ai.elimu.dao.LetterDao;
import ai.elimu.dao.LetterSoundDao;
import ai.elimu.model.content.Letter;
import ai.elimu.model.content.LetterSoundCorrespondence;
import ai.elimu.model.contributor.Contributor;
import ai.elimu.model.contributor.LetterContributionEvent;
import ai.elimu.util.DiscordHelper;
import ai.elimu.web.context.EnvironmentContextLoaderListener;

@Controller
@RequestMapping("/content/letter/edit")
public class LetterEditController {
Expand All @@ -32,6 +37,9 @@ public class LetterEditController {
@Autowired
private LetterDao letterDao;

@Autowired
private LetterSoundDao letterSoundDao;

@Autowired
private LetterContributionEventDao letterContributionEventDao;

Expand All @@ -46,7 +54,17 @@ public String handleRequest(
model.addAttribute("timeStart", System.currentTimeMillis());

model.addAttribute("letterContributionEvents", letterContributionEventDao.readAll(letter));


List<LetterSoundCorrespondence> letterSounds = letterSoundDao.readAllOrderedByUsage();
model.addAttribute("letterSounds", letterSounds);

int maxUsageCount = 0;
for (LetterSoundCorrespondence letterSound : letterSounds) {
if (letterSound.getUsageCount() > maxUsageCount) {
maxUsageCount = letterSound.getUsageCount();
}
}
model.addAttribute("maxUsageCount", maxUsageCount);
return "content/letter/edit";
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@
</ol>
</div>

<h5 class="center"><fmt:message key="letter.sound.correspondences" /></h5>
<h5 class="center"><fmt:message key="letter.sound.correspondences" /> (${fn:length(letterSounds)})</h5>
<div class="card-panel">
<c:if test="${not empty letterSounds}"></c:if>
<c:if test="${not empty letterSounds}">
<table class="bordered highlight">
<thead>
<tr>
Expand Down Expand Up @@ -222,6 +222,7 @@
</c:forEach>
</tbody>
</table>
</c:if>
</div>
</content:aside>

0 comments on commit 987f412

Please sign in to comment.