Skip to content

Commit

Permalink
fix selecting negative offset duration autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Nov 19, 2024
1 parent 998b05c commit 5ca4ace
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

public abstract class DurationConverterBase implements Converter {

protected abstract boolean isSigned();

@Override
public String getAsString(FacesContext facesContext, UIComponent component, Object value) {
if (value == null) {
Expand All @@ -27,7 +29,8 @@ public String getAsString(FacesContext facesContext, UIComponent component, Obje
}
}
} else if (value instanceof SelectItem) {
return DateUtil.getDurationString((Integer) ((SelectItem) value).getValue(), DurationUnitOfTime.SECONDS, DurationUnitOfTime.SECONDS, 0);
Integer seconds = (Integer) ((SelectItem) value).getValue();
return (isSigned() ? DateUtil.getSignSymbol(seconds) : "") + DateUtil.getDurationString(seconds, DurationUnitOfTime.SECONDS, DurationUnitOfTime.SECONDS, 0);
} else {
return CommonUtil.NO_SELECTION_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public Object getAsObject(FacesContext context, UIComponent component, String va
return null;
}
}

@Override
protected boolean isSigned() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public Object getAsObject(FacesContext context, UIComponent component, String va
return null;
}
}

@Override
protected boolean isSigned() {
return true;
}
}

0 comments on commit 5ca4ace

Please sign in to comment.