Skip to content

Commit 6c09710

Browse files
committed
prototype: part 2
1 parent ae96840 commit 6c09710

File tree

3 files changed

+62
-22
lines changed

3 files changed

+62
-22
lines changed

src/main/java/ru/mystamps/web/feature/site/ResourceUrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class ResourceUrl {
3131
public static final String STATIC_RESOURCES_URL = "https://stamps.filezz.ru";
3232

3333
// MUST be updated when any of our resources were modified
34-
public static final String RESOURCES_VERSION = "v0.4.7.0";
34+
public static final String RESOURCES_VERSION = "v0.4.7.1";
3535

3636
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/utils/CatalogUtils.min.js";
3737
private static final String COLLECTION_INFO_JS = "/public/js/" + RESOURCES_VERSION + "/collection/info.min.js";

src/main/javascript/series/info.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,18 @@ function populateTransactionDateWithTodayDate() {
77
var today = DateUtils.formatDateToDdMmYyyy(new Date());
88
$('#date').val(today);
99
}
10+
11+
function getCurrencyByCatalogName(catalog) {
12+
switch (catalog) {
13+
case 'MICHEL':
14+
case 'YVERT':
15+
return [ '\u20AC', 'EUR' ];
16+
case 'SCOTT':
17+
return [ '$', 'USD' ];
18+
case 'GIBBONS':
19+
return [ '\u00A3', 'GBP' ];
20+
case 'SOLOVYOV':
21+
case 'ZAGORSKI':
22+
return [ '\u20BD', 'RUB' ];
23+
}
24+
}

src/main/webapp/WEB-INF/views/series/info.html

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -411,52 +411,53 @@ <h5 th:text="#{t_hidden_images}">Hidden images</h5>
411411

412412
<div id="add-catalog-price" sec:authorize="hasAuthority('CREATE_SERIES')">
413413
<div class="col-sm-12 form-group">
414-
<form id="add-catalog-price-form" class={ `form-horizontal ${hasValidationErrors ? 'has-error' : ''}` }>
414+
<form id="add-catalog-price-form" class="form-horizontal has-error">
415415
<div id="add-catalog-price-failed-msg"
416-
class={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
417-
{ l10n['t_server_error'] || 'Server error' }
416+
class="alert alert-danger text-center col-sm-8 col-sm-offset-2"
417+
th:text="#{t_server_error}">
418+
Server error
418419
</div>
419420
<div class="form-group form-group-sm">
420-
<label for="price-catalog-name" class="control-label col-sm-3">
421-
{ l10n['t_catalog'] || 'Catalog' }
421+
<label for="price-catalog-name" class="control-label col-sm-3" th:text="#{t_catalog}">
422+
Catalog
422423
</label>
423424
<div class="col-sm-6">
424425
<select id="price-catalog-name" name="catalogName" class="form-control">
425-
<option value="michel">{ l10n['t_michel'] || 'Michel' }</option>
426-
<option value="scott">{ l10n['t_scott'] || 'Scott' }</option>
427-
<option value="yvert">{ l10n['t_yvert'] || 'Yvert et Tellier' }</option>
428-
<option value="gibbons">{ l10n['t_sg'] || 'Stanley Gibbons' }</option>
429-
<option value="solovyov">{ l10n['t_solovyov'] || 'Solovyov' }</option>
430-
<option value="zagorski">{ l10n['t_zagorski'] || 'Zagorski' }</option>
426+
<option value="MICHEL" th:text="#{t_michel}">Michel</option>
427+
<option value="SCOTT" th:text="#{t_scott}">Scott</option>
428+
<option value="YVERT" th:text="#{t_yvert}">Yvert et Tellier</option>
429+
<option value="GIBBONS" th:text="#{t_sg}">Stanley Gibbons</option>
430+
<option value="SOLOVYOV" th:text="#{t_solovyov}">Solovyov</option>
431+
<option value="ZAGORSKI" th:text="#{t_zagorski}">Zagorski</option>
431432
</select>
432433
</div>
433434
</div>
434435
<div class="form-group form-group-sm">
435-
<label for="catalog-price" class="control-label col-sm-3 required-field">
436-
{ l10n['t_price'] || 'Price' }
436+
<label for="catalog-price" class="control-label col-sm-3 required-field" th:text="#{t_price}">
437+
Price
437438
</label>
438439
<div class="col-sm-3">
439440
<div class="input-group">
440-
<span class="input-group-addon">{ currencySymbol }</span>
441+
<span class="input-group-addon" id="js-catalog-price-symbol" >&euro;</span>
441442
<input id="catalog-price"
442443
type="text"
443444
class="form-control"
444445
size="5"
445-
title={ currencyName }
446+
title="EUR"
446447
required="required" />
447448
</div>
448449
</div>
449450
</div>
450451
<div class="col-sm-offset-3 col-sm-4">
451-
<span id="catalog-price.errors"
452-
class={ `help-block ${hasValidationErrors ? '' : 'hidden'}` }>
453-
{ validationErrors.join(', ') }
452+
<span id="catalog-price.errors" class="help-block">
453+
Invalid value
454454
</span>
455455
<button
456456
type="submit"
457457
class="btn btn-primary btn-sm"
458-
disabled={ isDisabled }>
459-
{ l10n['t_add'] || 'Add' }
458+
disabled
459+
th:text="#{t_add}">
460+
Add
460461
</button>
461462
</div>
462463
</form>
@@ -1079,10 +1080,34 @@ <h5 th:text="#{t_add_info_who_selling_series}">Add info about selling/buying thi
10791080
src="../../../../../../target/classes/js/utils/DateUtils.min.js"
10801081
th:src="${DATE_UTILS_JS}"></script>
10811082

1082-
<script sec:authorize="hasAuthority('VIEW_SERIES_SALES')"
1083+
<script sec:authorize="hasAnyAuthority('VIEW_SERIES_SALES', 'CREATE_SERIES')"
10831084
src="../../../../javascript/series/info.js"
10841085
th:src="${SERIES_INFO_JS}"></script>
10851086

1087+
<script sec:authorize="hasAuthority('CREATE_SERIES')">
1088+
window.addEventListener('DOMContentLoaded', function initPage() {
1089+
var catalogNameElem = document.getElementById('price-catalog-name');
1090+
if (catalogNameElem == null) {
1091+
console.error("Couldn't initialize catalog name selector: element not found");
1092+
return;
1093+
}
1094+
catalogNameElem.addEventListener('change', function changeCatalogCurrency(elem) {
1095+
var name = this.value;
1096+
var info = getCurrencyByCatalogName(this.value);
1097+
var symbolElem = document.getElementById('js-catalog-price-symbol');
1098+
if (symbolElem == null) {
1099+
console.error("Couldn't change currency symbol: element not found");
1100+
}
1101+
var titleElem = document.getElementById('catalog-price');
1102+
if (titleElem == null) {
1103+
console.error("Couldn't change currency title: element not found");
1104+
}
1105+
symbolElem.innerText = info[0];
1106+
titleElem.title = info[1];
1107+
});
1108+
});
1109+
</script>
1110+
10861111
<!--/*/
10871112
<th:block sec:authorize="hasAnyAuthority('IMPORT_SERIES_SALES', 'MARK_SIMILAR_SERIES', 'CREATE_SERIES', 'ADD_COMMENTS_TO_SERIES', 'HIDE_IMAGE')">
10881113
/*/-->

0 commit comments

Comments
 (0)