Skip to content
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

Deprecate currency setting, fixes #4060 #4132

Merged
merged 1 commit into from
Feb 25, 2018
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
12 changes: 3 additions & 9 deletions fields/types/money/MoneyType.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ var util = require('util');
* @api public
*/
function money (list, path, options) {
this.currency = options.currency;
if (options.currency) {
throw new Error('The currency option from money has been deprecated. Provide a formatString instead');
}
this._nativeType = Number;
this._underscoreMethods = ['format'];
this._properties = ['currency'];
Expand All @@ -36,14 +38,6 @@ money.prototype.addFilterToQuery = NumberType.prototype.addFilterToQuery;
* Formats the field value
*/
money.prototype.format = function (item, format) {
if (this.currency) {
try {
numeral.language(this.currency, require('numeral/languages/' + this.currency));
numeral.language(this.currency);
} catch (err) {
throw new Error('FieldType.Money: options.currency failed to load.');
}
}
if (format || this._formatString) {
return (typeof item.get(this.path) === 'number') ? numeral(item.get(this.path)).format(format || this._formatString) : '';
} else {
Expand Down
6 changes: 0 additions & 6 deletions fields/types/money/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ Input should either be a valid `Number`, or a string that can be converted to a
{ type: Types.Money, format: '$0,0.00' }
```

`currency` `String` - loads a predefined object of settings for a specific language, the language must exist as a .js in numeral/languages folder.

```js
{ type: Types.Money, currency: 'en-gb' }
```

## Underscore Methods

`format(string)` - formats the stored value using [numeraljs](http://numeraljs.com/). Set to `false` to disable automatic formatting.
Expand Down