Skip to content

Show a currency #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions src/main/frontend/src/components/AddCatalogPriceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IMPORTANT:
// You must update ResourceUrl.RESOURCES_VERSION each time whenever you're modified this file!
//
// @todo #1342 AddCatalogPriceForm: show a currency
// @todo #1388 AddCatalogPriceForm: consider using a tooltip for currency

class AddCatalogPriceForm extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -33,6 +33,21 @@ class AddCatalogPriceForm extends React.Component {
});
}

getCurrencyByCatalogName(catalog) {
switch (catalog) {
case 'michel':
case 'yvert':
return ['\u20AC', 'EUR'];
case 'scott':
return ['$', 'USD'];
case 'gibbons':
return ['\u00A3', 'GBP'];
case 'solovyov':
case 'zagorski':
return ['\u20BD', 'RUB'];
}
}

handleSubmit(event) {
event.preventDefault();

Expand Down Expand Up @@ -86,6 +101,8 @@ class AddCatalogPriceForm extends React.Component {
}
render() {
const hasValidationErrors = this.state.validationErrors.length > 0;
const [currencySymbol, currencyName] = this.getCurrencyByCatalogName(this.state.catalog);

return (
<div className="col-sm-12 form-group">
<form className={`form-horizontal ${hasValidationErrors ? 'has-error' : ''}`} onSubmit={this.handleSubmit}>
Expand Down Expand Up @@ -129,17 +146,17 @@ class AddCatalogPriceForm extends React.Component {
<label className="control-label col-sm-3">
{ this.props.l10n['t_price'] || 'Price' }
</label>
<div className="col-sm-6">
<div className="row">
<div className="col-xs-6">
<input
className="form-control"
id="catalog-price"
type="text"
size="5"
required="required"
onChange={ this.handleChangePrice }/>
</div>
<div className="col-sm-3">
<div className="input-group">
<span className="input-group-addon">{ currencySymbol }</span>
<input
id="catalog-price"
type="text"
className="form-control"
size="5"
title={ currencyName }
required="required"
onChange={ this.handleChangePrice }/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class ResourceUrl {
public static final String STATIC_RESOURCES_URL = "https://stamps.filezz.ru";

// MUST be updated when any of our resources were modified
public static final String RESOURCES_VERSION = "v0.4.3.2";
public static final String RESOURCES_VERSION = "v0.4.3.3";

// CheckStyle: ignore LineLength for next 14 lines
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/CatalogUtils.min.js";
Expand Down