Skip to content

Commit

Permalink
todo comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jflamy committed Feb 5, 2025
1 parent bf9fc41 commit 5502a0c
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Button createDownloadButton() {
* @return
*/
// @Deprecated
// TODO remove use of createImmediateDownloadButton
// CODEREVIEW remove use of createImmediateDownloadButton
public Anchor createImmediateDownloadButton(String... tooltipText) {
this.xlsWriter = this.streamSourceSupplier.get();
Supplier<String> supplier = () -> getTargetFileName();
Expand Down
2 changes: 0 additions & 2 deletions owlcms/src/main/java/app/owlcms/data/athlete/Athlete.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,6 @@ public int getCategoryScoreRank() {
@Transient
@JsonIgnore
public String getCategorySortCode() {
// TODO: something that reflects age boundaries then weight, considering no-age and no-weight score based.
// maybe championship age-low age-high body-low body-high
Category sortCategory = getMainRankings().getCategory();
String sortCode = sortCategory != null ? sortCategory.getSortCode() : "-";
// logger.debug("a {} category {} sortCode {}", getAbbreviatedName(), getCategory(), sortCategory.getSortCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static List<Athlete> doFindFiltered(EntityManager em, String lastName, Gr
if (group != null && group.getName() == "*") {
group = null;
}
// REVIEW this does not appear to work with ageDivision/Championship
// CODEREVIEW this does not appear to work with ageDivision/Championship
String qlString = "select a from Athlete a"
+ filteringSelection(lastName, group, category, ageGroup, ageDivision, gender, weighedIn, team)
+ " order by a.category";
Expand Down
18 changes: 18 additions & 0 deletions owlcms/src/main/java/app/owlcms/data/competition/Competition.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public static void splitPTeamMembersByGender(List<Athlete> athletes, List<Athlet
private String currentRecordsTemplateFileName;
@Column(columnDefinition = "boolean default false")
private boolean masters20kg = false;
private String technicalOfficialsTemplateFileName;

public Competition() {
this.medalsByGroup = new HashMap<>();
Expand Down Expand Up @@ -750,6 +751,15 @@ public String getComputedTeamsListTemplateFileName() {
return this.teamsListTemplateFileName;
}

@Transient
@JsonIgnore
public String getComputedTechnicalOfficialsTemplateFileName() {
if (this.technicalOfficialsTemplateFileName == null) {
return "technicalOfficials.xlsx";
}
return this.technicalOfficialsTemplateFileName;
}

public String getCurrentRecordsTemplateFileName() {
return this.currentRecordsTemplateFileName;
}
Expand Down Expand Up @@ -1026,6 +1036,10 @@ public String getTeamsListTemplateFileName() {
return this.teamsListTemplateFileName;
}

public String getTechnicalOfficialsTemplateFileName() {
return this.technicalOfficialsTemplateFileName;
}

public String getTranslatedScoringSystemName() {
String translate = Translator.translateOrElseNull("Ranking." + getScoringSystem(), OwlcmsSession.getLocale());
return translate != null ? translate : Translator.translate("Score");
Expand Down Expand Up @@ -1524,6 +1538,10 @@ public void setTeamsListTemplateFileName(String teamsListTemplateFileName) {
this.teamsListTemplateFileName = teamsListTemplateFileName;
}

public void setTechnicalOfficialsTemplateFileName(String technicalOfficialsTemplateFileName) {
this.technicalOfficialsTemplateFileName = technicalOfficialsTemplateFileName;
}

/**
* Sets the use birth year.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ private void medalsInit() {
setId("medals-" + fop.getName());
setWideTeamNames(false);
this.getElement().setProperty("competitionName", Competition.getCurrent().getCompetitionName());
// FIXME: confusing
// CODEREVIEW: confusing
// this.setGroup(fop.getVideoGroup());
// this.setCategory(fop.getVideoCategory());
this.setGroup(fop.getGroup());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* This shows an overlay when competition events such as a record attempt or jury deliberation take place.
*
*/
// TODO: show record attempt and new record for a limited duration.
// CODEREVIEW: show record attempt and new record for a limited duration.

@SuppressWarnings({ "serial", "deprecation" })
@Tag("eventmonitor-template")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void doClose(boolean noAction) {
this.close();
return;
}
// REVIEW: this should be done after processing the JuryEvent in FieldOfPlay
// CODEREVIEW: this should be done after processing the JuryEvent in FieldOfPlay
resumeLifting(noAction);

this.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
import org.vaadin.crudui.crud.CrudListener;
import org.vaadin.crudui.crud.impl.GridCrud;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.NativeLabel;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.FlexLayout;
import com.vaadin.flow.router.Route;

import app.owlcms.apputils.queryparameters.BaseContent;
import app.owlcms.components.JXLSDownloader;
import app.owlcms.data.competition.Competition;
import app.owlcms.data.technicalofficial.TechnicalOfficial;
import app.owlcms.data.technicalofficial.TechnicalOfficialRepository;
import app.owlcms.i18n.Translator;
Expand All @@ -25,6 +34,7 @@
import app.owlcms.nui.crudui.OwlcmsGridLayout;
import app.owlcms.nui.shared.OwlcmsContent;
import app.owlcms.nui.shared.OwlcmsLayout;
import app.owlcms.spreadsheet.JXLSExportRecords;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;

Expand All @@ -43,6 +53,7 @@ public class TechnicalOfficialContent extends BaseContent implements CrudListene
}
private OwlcmsCrudFormFactory<TechnicalOfficial> editingFormFactory;
private OwlcmsLayout routerLayout;
private FlexLayout topBar;

/**
* Instantiates the TechnicalOfficial crudGrid.
Expand All @@ -60,8 +71,55 @@ public TechnicalOfficial add(TechnicalOfficial domainObjectToAdd) {
}

@Override
// public FlexLayout createMenuArea() {
// return new FlexLayout();
// }

public FlexLayout createMenuArea() {
return new FlexLayout();
this.topBar = new FlexLayout();

Button uploadCustom = new Button(Translator.translate("TechnicalOfficials.Upload"),
new Icon(VaadinIcon.UPLOAD_ALT),
buttonClickEvent -> {
AgeGroupsFileUploadDialog ageGroupsFileUploadDialog = new AgeGroupsFileUploadDialog();
ageGroupsFileUploadDialog.setCallback(() -> loadOfficials());
ageGroupsFileUploadDialog.open();
});

var recordsWriter1 = new JXLSExportRecords(UI.getCurrent(), true, true);
JXLSDownloader dd1 = new JXLSDownloader(
() -> {
return recordsWriter1;
},
"/templates/records",
Competition::getComputedTechnicalOfficialsTemplateFileName,
Competition::setTechnicalOfficialsTemplateFileName,
Translator.translate("Records.exportCurrentRecordsTitle"),
Translator.translate("Download"));
Div allRecords1 = new Div();
Button downloadButton = dd1.createDownloadButton();
downloadButton.setWidthFull();
allRecords1.add(downloadButton);

FlexLayout buttons = new FlexLayout(
new NativeLabel(Translator.translate("AgeGroups.Custom")),
allRecords1, uploadCustom);
buttons.getStyle().set("flex-wrap", "wrap");
buttons.getStyle().set("gap", "1ex");
buttons.getStyle().set("margin-left", "5em");
buttons.setAlignItems(FlexComponent.Alignment.BASELINE);

this.topBar.getStyle().set("flex", "100 1");
this.topBar.add(buttons);
this.topBar.setJustifyContentMode(FlexComponent.JustifyContentMode.START);
this.topBar.setAlignItems(FlexComponent.Alignment.CENTER);

return this.topBar;
}

private Object loadOfficials() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'loadOfficials'");
}

@Override
Expand Down Expand Up @@ -113,7 +171,7 @@ public TechnicalOfficial update(TechnicalOfficial domainObjectToUpdate) {
* @param crudFormFactory the factory that will create the form using this information
*/
protected void createFormLayout(OwlcmsCrudFormFactory<TechnicalOfficial> crudFormFactory) {
((TechnicalOfficialEditingFormFactory)crudFormFactory).technicalOfficialLayout();
((TechnicalOfficialEditingFormFactory) crudFormFactory).technicalOfficialLayout();
}

/**
Expand Down Expand Up @@ -144,20 +202,20 @@ protected GridCrud<TechnicalOfficial> createGrid(OwlcmsCrudFormFactory<Technical
* @return the form factory that will create the actual form on demand
*/
private OwlcmsCrudFormFactory<TechnicalOfficial> createFormFactory() {
this.editingFormFactory = new TechnicalOfficialEditingFormFactory(TechnicalOfficial.class);
this.editingFormFactory = new TechnicalOfficialEditingFormFactory(TechnicalOfficial.class);
return this.editingFormFactory;
}

// private <T extends Component & HasUrlParameter<String>> String getWindowOpenerFromClass(Class<T> targetClass,
// String parameter) {
// return "window.open('" + URLUtils.getUrlFromTargetClass(targetClass) + "?fop=" + parameter
// + "','" + targetClass.getSimpleName() + "')";
// String parameter) {
// return "window.open('" + URLUtils.getUrlFromTargetClass(targetClass) + "?fop=" + parameter
// + "','" + targetClass.getSimpleName() + "')";
// }

// private <T extends Component & HasUrlParameter<String>> Button openInNewTab(Class<T> targetClass,
// String label, String parameter) {
// Button button = new Button(label);
// button.getElement().setAttribute("onClick", getWindowOpenerFromClass(targetClass, parameter));
// return button;
// String label, String parameter) {
// Button button = new Button(label);
// button.getElement().setAttribute("onClick", getWindowOpenerFromClass(targetClass, parameter));
// return button;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package app.owlcms.nui.preparation;

import java.io.OutputStream;

import app.owlcms.spreadsheet.XLSXWorkbookStreamSource;

@SuppressWarnings("serial")
public class XLSXTechnicalOfficialsExport extends XLSXWorkbookStreamSource {

@Override
protected void writeStream(OutputStream stream) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'writeStream'");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public Component buildNewForm(CrudOperation operation, Athlete aFromList, boolea
if (this.getCurrentGroup() != null && !this.getCurrentGroup().getName().equals("*")) {
aFromList.setGroup(getCurrentGroup());
}
this.binder.readBean(aFromList); // REVIEW should be getEditedAthlete() ?
this.binder.readBean(aFromList); // CODEREVIEW should be getEditedAthlete() ?

// binder has read bean.
filterCategories(getEditedAthlete().getCategory(), operation != CrudOperation.ADD);
Expand Down
Loading

0 comments on commit 5502a0c

Please sign in to comment.