Skip to content

Commit

Permalink
grouped formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Alletkla committed Sep 26, 2022
1 parent 0cfa259 commit 8cc5379
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
24 changes: 22 additions & 2 deletions src/main/java/sqltoregex/controller/SqlToRegexController.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,29 @@ private SettingsForm addSettingsFormFields(Model model) {
})));
model.addAttribute("timeFormats",
getSynonymSetOf(DateAndTimeFormatSynonymGenerator.class, SettingsOption.TIMESYNONYMS,
SettingsType.ALL));
SettingsType.ALL).stream().collect(Collectors.groupingBy(el -> {
String patternString = el.toPattern();
Pattern pattern = Pattern.compile("[^a-zA-Z]");
Matcher matcher = pattern.matcher(patternString);

if (matcher.find()) {
return patternString.charAt(matcher.start());
} else {
return " ";
}
})));
model.addAttribute("dateTimeFormats", getSynonymSetOf(DateAndTimeFormatSynonymGenerator.class,
SettingsOption.DATETIMESYNONYMS, SettingsType.ALL));
SettingsOption.DATETIMESYNONYMS, SettingsType.ALL).stream().collect(Collectors.groupingBy(el -> {
String patternString = el.toPattern();
Pattern pattern = Pattern.compile("[^a-zA-Z]");
Matcher matcher = pattern.matcher(patternString);

if (matcher.find()) {
return patternString.charAt(matcher.start());
} else {
return " ";
}
})));
//special preprocessing to render comfortably on frontend
Map<String, Set<String>> aggregateFunctionSynonymsMap = settingsManager.getSettingBySettingsOption(
SettingsOption.AGGREGATEFUNCTIONLANG, StringSynonymGenerator.class, SettingsType.ALL)
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/static/config/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<value>yy/M/d</value>
<value>yy|M|d</value>
<value>yyyyMMdd</value>
<value>yyMMdd</value>
</datesynonyms>
<timesynonyms>
<settingstype>ALL;DEFAULT_SCHOOL</settingstype>
Expand All @@ -81,16 +82,19 @@
<value>H:m:s</value>
<value>H/m/s</value>
<value>H|m|s</value>
<value>H-m-s</value>
<value>HH:mm</value>
<value>HH/mm</value>
<value>HH|mm</value>
<value>HH-mm</value>
<value>H:m</value>
<value>H/m</value>
<value>H|m</value>
<value>H-m</value>
</timesynonyms>
<datetimesynonyms>
<settingstype>ALL;DEFAULT_SCHOOL</settingstype>
<value>yyyyMMddhhmmss</value>
<value>yyyy-MM-dd hh:mm:ss</value>
<value>yyyy.MM.dd hh:mm:ss</value>
<value>yyyy|MM|dd hh|mm|ss</value>
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/templates/assets/settingsform/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@
</div>

<hr>
<div class="row">
<div class="row" th:each="timeFormatsEntry : ${timeFormats}">
<div class="col-sm"
th:each="setting : ${timeFormats}">
th:each="setting : ${timeFormatsEntry.getValue()}">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" onchange="updateSingleUserSetting(this, document.getElementById('converterForm'))" th:id="'dateAndTime_' + ${setting.toPattern()}" th:value="${setting.toPattern()}" th:name="timeFormats" th:checked="${settingsForm.timeFormats.contains(setting)}">
<input class="form-check-input" type="checkbox" onchange="updateSingleUserSetting(this, document.getElementById('converterForm'))" th:id="'dateAndTime_' + ${setting.toPattern()}" th:value="${setting.toPattern()}" th:name="timeFormats" th:checked="${#sets.contains(settingsForm.getTimeFormats(), setting)}">
<label class="form-check-label" style="min-width: 100px" th:for="'timeFormats_' + ${setting.toPattern()}" th:text="${setting.toPattern()}">Enable format: "hh:MM:ss"</label>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="row" th:each="dateTimeFormatsEntry : ${dateTimeFormats}">
<div class="col-sm"
th:each="setting : ${dateTimeFormats}">
th:each="setting : ${dateTimeFormatsEntry.getValue()}">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" onchange="updateSingleUserSetting(this, document.getElementById('converterForm'))" th:id="'dateAndTime_' + ${setting.toPattern()}" th:value="${setting.toPattern()}" th:name="dateTimeFormats" th:checked="${settingsForm.dateTimeFormats.contains(setting)}">
<input class="form-check-input" type="checkbox" onchange="updateSingleUserSetting(this, document.getElementById('converterForm'))" th:id="'dateAndTime_' + ${setting.toPattern()}" th:value="${setting.toPattern()}" th:name="dateTimeFormats" th:checked="${#sets.contains(settingsForm.getDateTimeFormats(), setting)}">
<label class="form-check-label" style="min-width: 200px" th:for="'dateTimeFormats_' + ${setting.toPattern()}" th:text="${setting.toPattern()}">Enable format: "yyyy-MM-dd"</label>
</div>
</div>
Expand Down

0 comments on commit 8cc5379

Please sign in to comment.