Skip to content

Commit

Permalink
Merge pull request #526 from frank-weinberg/bugfix/525
Browse files Browse the repository at this point in the history
Fix various bugs/feature requests
  • Loading branch information
frank-weinberg authored Aug 12, 2022
2 parents 461098d + e23a3b0 commit 7f24b36
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion html/components/lt-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function prepareLtSheetTable(element, gameId, teamId, mode) {
} else if (k.field === 'CurrentBoxSymbols') {
element.find('#upcoming .Box.Box' + k.Position).text(v);
} else if (k.field === 'Annotation') {
element.find('#upcoming .Skater.' + k.Position).toggleClass('hasAnnotation', v !== '');
element.find('#upcoming .Skater.' + k.Position).toggleClass('hasAnnotation', v != null && v !== '');
}
}
);
Expand Down
2 changes: 2 additions & 0 deletions html/components/plt-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ function preparePltInputTable(element, gameId, teamId, mode, statsbookPeriod, al
var p = $('<tr>').addClass('Skater Penalty').attr('id', id).attr('number', number).attr('role', role);
var j = $('<tr>').addClass('Skater Jam').attr('id', id);

p.toggleClass('Captain', WS.state['ScoreBoard.Game(' + gameId + ').Team(' + t + ').Skater(' + id + ').Flags'] === 'C');

if (mode === 'lt' || mode === 'plt') {
var benchCell = $('<td>')
.addClass('Role Bench')
Expand Down
11 changes: 6 additions & 5 deletions html/components/sk-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ function prepareSkSheetTable(element, gameId, teamId, mode) {
case 'NoInitial':
var trip1Score = WS.state[prefix + 'ScoringTrip(1).Score'];
var trip1AfterSP = isTrue(WS.state[prefix + 'ScoringTrip(1).AfterSP']);
var trip1HasAnnotation = WS.state[prefix + 'ScoringTrip(1).Annotation'] !== '';
var trip1HasAnnotation = (WS.state[prefix + 'ScoringTrip(1).Annotation'] || '') !== '';
var trip2Score = WS.state[prefix + 'ScoringTrip(2).Score'];
var trip2Current = isTrue(WS.state[prefix + 'ScoringTrip(2).Current']);
var trip2AfterSP = isTrue(WS.state[prefix + 'ScoringTrip(2).AfterSP']);
var trip2HasAnnotation = trip2Score != null && WS.state[prefix + 'ScoringTrip(2).Annotation'] !== '';
var trip2HasAnnotation = trip2Score != null && (WS.state[prefix + 'ScoringTrip(2).Annotation'] || '') !== '';
var noInitial = isTrue(WS.state[prefix + 'NoInitial']);
var scoreText = '';
var otherScoreText = '';
Expand Down Expand Up @@ -235,7 +235,7 @@ function prepareSkSheetTable(element, gameId, teamId, mode) {
}
var score = WS.state[prefix + 'ScoringTrip(' + trip + ').Score'];
var current = isTrue(WS.state[prefix + 'ScoringTrip(' + trip + ').Current']);
var hasAnnotation = WS.state[prefix + 'ScoringTrip(' + trip + ').Annotation'] !== '';
var hasAnnotation = (WS.state[prefix + 'ScoringTrip(' + trip + ').Annotation'] || '') !== '';
row
.find('.Trip' + trip)
.toggleClass('hasAnnotation', hasAnnotation)
Expand All @@ -257,10 +257,10 @@ function prepareSkSheetTable(element, gameId, teamId, mode) {
}
if (isTrue(WS.state[prefix + 'ScoringTrip(' + t + ').AfterSP'])) {
scoreAfterSP = scoreAfterSP === '' ? tripScore : scoreAfterSP + ' + ' + tripScore;
annotationAfterSP = annotationAfterSP || WS.state[prefix + 'ScoringTrip(' + t + ').Annotation'] !== '';
annotationAfterSP = annotationAfterSP || (WS.state[prefix + 'ScoringTrip(' + t + ').Annotation'] || '') !== '';
} else {
scoreBeforeSP = scoreBeforeSP === '' ? tripScore : scoreBeforeSP + ' + ' + tripScore;
annotationBeforeSP = annotationBeforeSP || WS.state[prefix + 'ScoringTrip(' + t + ').Annotation'] !== '';
annotationBeforeSP = annotationBeforeSP || (WS.state[prefix + 'ScoringTrip(' + t + ').Annotation'] || '') !== '';
}
t++;
}
Expand Down Expand Up @@ -507,6 +507,7 @@ function prepareTripEditor() {
.button()
.on('click', function () {
tripEditor.find('#annotation').val('');
WS.Set(tripEditor.data('prefix') + 'Annotation', '');
})
)
)
Expand Down
5 changes: 3 additions & 2 deletions html/components/team-time-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ function createTeamTable(gameId) {
colorA.toggleClass('AlternateName', v != null);
});

var names = nameA.add(altNameA);
var names = nameA.add(colorA).add(altNameA);
WS.Register(prefix + '.Color(*)', function (k, v) {
v = v || '';
switch (k.Color) {
Expand Down Expand Up @@ -1600,12 +1600,13 @@ function createTimeoutDialog(gameId) {
row.remove();
return;
}
if (k.field === 'PrecedingJamNumber') {
if (k.field === 'PrecedingJam') {
row.remove();
row = [];
}
if (v != null && row.length === 0) {
var jam = Number(WS.state[prefix + '.PrecedingJamNumber']);
processJamNumber(k, jam);
var dur = isTrue(WS.state[prefix + '.Running']) ? 'Running' : _timeConversions.msToMinSec(WS.state[prefix + '.Duration'], true);
var pc = _timeConversions.msToMinSec(
isTrue(WS.state[prefix + '.Running'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ protected void valueChanged(Value<?> prop, Object value, Object last, Source sou
Game g = (Game) value;
if (g.get(Game.EVENT_INFO, Game.INFO_START_TIME) != null &&
!"".equals(g.get(Game.EVENT_INFO, Game.INFO_START_TIME).getValue())) {
LocalTime time = LocalTime.parse(g.get(Game.EVENT_INFO, Game.INFO_START_TIME).getValue());
LocalDate date = "".equals(g.get(Game.EVENT_INFO, Game.INFO_DATE).getValue())
? LocalDate.now()
: LocalDate.parse(g.get(Game.EVENT_INFO, Game.INFO_DATE).getValue());
long timeToStart = ChronoUnit.MILLIS.between(LocalDateTime.now(), LocalDateTime.of(date, time));
if (timeToStart > 0) {
Clock ic = g.getClock(Clock.ID_INTERMISSION);
ic.setMaximumTime(timeToStart);
ic.resetTime();
ic.start();
}
try {
LocalTime time = LocalTime.parse(g.get(Game.EVENT_INFO, Game.INFO_START_TIME).getValue());
LocalDate date = "".equals(g.get(Game.EVENT_INFO, Game.INFO_DATE).getValue())
? LocalDate.now()
: LocalDate.parse(g.get(Game.EVENT_INFO, Game.INFO_DATE).getValue());
long timeToStart = ChronoUnit.MILLIS.between(LocalDateTime.now(), LocalDateTime.of(date, time));
if (timeToStart > 0) {
Clock ic = g.getClock(Clock.ID_INTERMISSION);
ic.setMaximumTime(timeToStart);
ic.resetTime();
ic.start();
}
} catch (Exception e) {} // if parsing fails just set no time to derby
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ private void initReferences(Ruleset rs) {
snapshot = null;
replacePending = false;

setRuleset(scoreBoard.getRulesets().getRuleset(Rulesets.ROOT_ID));

setLabel(Button.START, ACTION_START_JAM);
setLabel(Button.STOP, ACTION_LINEUP);
setLabel(Button.TIMEOUT, ACTION_TIMEOUT);
Expand Down Expand Up @@ -245,8 +243,8 @@ protected Object computeValue(Value<?> prop, Object value, Object last, Source s
return source.isFile() ? value : last;
}
String date = get(EVENT_INFO, INFO_DATE) == null ? "0000-00-00" : get(EVENT_INFO, INFO_DATE).getValue();
String team1 = getTeam(Team.ID_1).get(Team.FILE_NAME).replace(" ", "");
String team2 = getTeam(Team.ID_2).get(Team.FILE_NAME).replace(" ", "");
String team1 = getTeam(Team.ID_1).get(Team.FILE_NAME).replaceAll("\\W+", "");
String team2 = getTeam(Team.ID_2).get(Team.FILE_NAME).replaceAll("\\W+", "");
String newName = "STATS-" + date + "_" + team1 + "_vs_" + team2;
if (newName.equals(last)) {
return newName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ private void fillIgrfAndPenalties() {

Sheet penalties = wb.getSheet("Penalties");
Sheet clock = wb.getSheet("Game Clock");
Sheet box = wb.getSheet("Penalty Box");

fillTeamData(igrf, clock, Team.ID_1);
fillTeamData(igrf, clock, Team.ID_2);
fillPenaltiesHead(penalties);
fillBoxHead(box);

for (Team t : game.getAll(Game.TEAM)) {
List<Skater> skaters = new ArrayList<>(t.getAll(Team.SKATER));
Expand Down Expand Up @@ -175,14 +177,12 @@ private void fillIgrfHead(Sheet igrf) {
setEventInfoCell(row, 1, Game.INFO_TOURNAMENT);
setEventInfoCell(row, 8, Game.INFO_HOST);
row = igrf.getRow(6);
if (game.get(Game.EVENT_INFO, Game.INFO_DATE) != null) {
try {
LocalDate date = LocalDate.parse(game.get(Game.EVENT_INFO, Game.INFO_DATE).getValue());
row.getCell(1).setCellValue(date);
if (game.get(Game.EVENT_INFO, Game.INFO_START_TIME) != null) {
LocalTime time = LocalTime.parse(game.get(Game.EVENT_INFO, Game.INFO_START_TIME).getValue());
row.getCell(8).setCellValue(LocalDateTime.of(date, time));
}
}
LocalTime time = LocalTime.parse(game.get(Game.EVENT_INFO, Game.INFO_START_TIME).getValue());
row.getCell(8).setCellValue(LocalDateTime.of(date, time));
} catch (Exception e) {} // when parsing fails just leave them empty
}

private void fillExpulsionSuspensionInfo(Sheet igrf) {
Expand Down Expand Up @@ -251,6 +251,12 @@ public int compare(Official o1, Official o2) {
lt[1][o.get(Official.SWAP) ? 1 - tId : tId] = name;
}
break;
case Official.ROLE_PBT:
if (tId >= 0) {
pbt[0][tId] = name;
pbt[1][o.get(Official.SWAP) ? 1 - tId : tId] = name;
}
break;
default: break;
}

Expand Down Expand Up @@ -311,6 +317,15 @@ private void fillPenaltiesHead(Sheet penalties) {
setCell(row, 41, pt);
}

private void fillBoxHead(Sheet box) {
Row row = box.getRow(0);
setCell(row, 11, pbt[0][0]);
setCell(row, 28, pbt[0][1]);
row = box.getRow(43);
setCell(row, 11, pbt[1][0]);
setCell(row, 28, pbt[1][1]);
}

private void fillSkater(Row row, Skater s, Sheet clock) {
String teamId = s.getTeam().getProviderId();
String flags = s.getFlags();
Expand Down Expand Up @@ -676,6 +691,7 @@ private void createCellStyles(Sheet igrf) {
private String[][] sk = {{"", ""}, {"", ""}};
private String[][] jr = {{"", ""}, {"", ""}};
private String[][] lt = {{"", ""}, {"", ""}};
private String[][] pbt = {{"", ""}, {"", ""}};

private List<String> injuries;

Expand Down

0 comments on commit 7f24b36

Please sign in to comment.