Skip to content

Commit

Permalink
option to disable number localization in numeric interface
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Apr 6, 2017
1 parent fc11790 commit 1174eaa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api/locales/en.json
Expand Up @@ -234,6 +234,8 @@
"o2m_result_limit_comment": "Maximum number of results to fetch",
"add_new_x_item": "Add New %{table} Item",

"numeric_localized_comment": "Whether or not to localized the numeric value, eg: currency format",

"directus_files": "Directus Files",
"file_upload": "Upload",
"drag_and_drop": "Drag and drop",
Expand Down
25 changes: 21 additions & 4 deletions app/core/uis/numeric.js
Expand Up @@ -6,7 +6,13 @@
// For all details and documentation:
// http://www.getdirectus.com

define(['app', 'core/UIComponent', 'core/UIView', 'core/t'], function(app, UIComponent, UIView, __t) {
define([
'app',
'underscore',
'core/UIComponent',
'core/UIView',
'core/t'
], function(app, _, UIComponent, UIView, __t) {

'use strict';

Expand Down Expand Up @@ -73,7 +79,8 @@ define(['app', 'core/UIComponent', 'core/UIView', 'core/t'], function(app, UICom
variables: [
{id: 'size', type: 'String', default_value: 'large', ui: 'select', options: {options: {'large':__t('size_large'),'medium':__t('size_medium'),'small':__t('size_small')} }},
{id: 'placeholder_text', type: 'String', default_value: '', ui: 'textinput', char_length:200},
{id: 'allow_null', type: 'Boolean', default_value: false, ui: 'checkbox'}
{id: 'allow_null', type: 'Boolean', default_value: false, ui: 'checkbox'},
{id: 'localized', type: 'Boolean', default_value: true, ui: 'checkbox', comment: __t('numeric_localized_comment')}
],
Input: Input,
validate: function(value, options) {
Expand All @@ -82,10 +89,20 @@ define(['app', 'core/UIComponent', 'core/UIView', 'core/t'], function(app, UICom
return __t('this_field_is_required');
}
},
list: function(options) {
list: function (options) {
var value = options.value;

return _.isNumber(value) ? Number(value).toLocaleString() : '<span class="silver">--</span>';
if (_.isNumber(value)) {
value = Number(value);

if (options.settings.get('localized')) {
value = value.toLocaleString();
}
} else {
value = '<span class="silver">--</span>';
}

return value;
}
});

Expand Down

0 comments on commit 1174eaa

Please sign in to comment.