summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaben Amare <haben.amare@outlook.com>2020-05-25 14:59:32 +0000
committerHaben Amare <haben.amare@outlook.com>2020-05-25 22:02:51 +0000
commit3cf6ed916f4fd4c8e6e826ed4af1c2dd4c965110 (patch)
tree11b18e394d6cde20fbe8c69584ac0c87118a7940
parent351d9d0c9577c9d543d543bc12a51388b0141324 (diff)
downloadwekan-3cf6ed916f4fd4c8e6e826ed4af1c2dd4c965110.tar.gz
wekan-3cf6ed916f4fd4c8e6e826ed4af1c2dd4c965110.tar.bz2
wekan-3cf6ed916f4fd4c8e6e826ed4af1c2dd4c965110.zip
add the 'currency' custom field type
-rw-r--r--client/components/sidebar/sidebarCustomFields.jade11
-rw-r--r--client/components/sidebar/sidebarCustomFields.js37
-rw-r--r--i18n/en-GB.i18n.json2
-rw-r--r--i18n/en.i18n.json2
-rw-r--r--models/customFields.js6
5 files changed, 56 insertions, 2 deletions
diff --git a/client/components/sidebar/sidebarCustomFields.jade b/client/components/sidebar/sidebarCustomFields.jade
index 4d023f45..4cff73f4 100644
--- a/client/components/sidebar/sidebarCustomFields.jade
+++ b/client/components/sidebar/sidebarCustomFields.jade
@@ -33,6 +33,17 @@ template(name="createCustomFieldPopup")
option(value=value selected="selected") {{name}}
else
option(value=value) {{name}}
+
+ div.js-field-settings.js-field-settings-currency(class="{{#if isTypeNotSelected 'currency'}}hide{{/if}}")
+ label
+ | {{_ 'custom-field-currency-option'}}
+ select.js-field-currency
+ each getCurrencySymbols
+ if selected
+ option(value=value selected="selected") {{name}}
+ else
+ option(value=value) {{name}}
+
div.js-field-settings.js-field-settings-dropdown(class="{{#if isTypeNotSelected 'dropdown'}}hide{{/if}}")
label
| {{_ 'custom-field-dropdown-options'}}
diff --git a/client/components/sidebar/sidebarCustomFields.js b/client/components/sidebar/sidebarCustomFields.js
index 92e93641..41aecea4 100644
--- a/client/components/sidebar/sidebarCustomFields.js
+++ b/client/components/sidebar/sidebarCustomFields.js
@@ -16,12 +16,26 @@ BlazeComponent.extendComponent({
}).register('customFieldsSidebar');
const CreateCustomFieldPopup = BlazeComponent.extendComponent({
- _types: ['text', 'number', 'date', 'dropdown'],
+ _types: ['text', 'number', 'date', 'dropdown', 'currency'],
+
+ _defaultCurrencySymbols: [
+ { symbol: '$' },
+ { symbol: '€' },
+ { symbol: '£' },
+ { symbol: '¥' },
+ ],
onCreated() {
this.type = new ReactiveVar(
this.data().type ? this.data().type : this._types[0],
);
+
+ this.currencySymbol = new ReactiveVar(
+ this.data().settings && this.data().settings.currencySymbol
+ ? this.data().settings.currencySymbol
+ : this._defaultCurrencySymbols[0].symbol,
+ );
+
this.dropdownItems = new ReactiveVar(
this.data().settings && this.data().settings.dropdownItems
? this.data().settings.dropdownItems
@@ -44,6 +58,18 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
return this.type.get() !== type;
},
+ getCurrencySymbols() {
+ const currentSymbol = this.currencySymbol.get();
+
+ return this._defaultCurrencySymbols.map(({ symbol }) => {
+ return {
+ name: symbol,
+ value: symbol,
+ selected: symbol === currentSymbol,
+ };
+ });
+ },
+
getDropdownItems() {
const items = this.dropdownItems.get();
Array.from(this.findAll('.js-field-settings-dropdown input')).forEach(
@@ -62,6 +88,11 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
getSettings() {
const settings = {};
switch (this.type.get()) {
+ case 'currency': {
+ const currencySymbol = this.currencySymbol.get();
+ settings.currencySymbol = currencySymbol;
+ break;
+ }
case 'dropdown': {
const dropdownItems = this.getDropdownItems().filter(
item => !!item.name.trim(),
@@ -80,6 +111,10 @@ const CreateCustomFieldPopup = BlazeComponent.extendComponent({
const value = evt.target.value;
this.type.set(value);
},
+ 'change .js-field-currency'(evt) {
+ const value = evt.target.value;
+ this.currencySymbol.set(value);
+ },
'keydown .js-dropdown-item.last'(evt) {
if (evt.target.value.trim() && evt.keyCode === 13) {
const items = this.getDropdownItems();
diff --git a/i18n/en-GB.i18n.json b/i18n/en-GB.i18n.json
index 9049f7bf..57e8ad78 100644
--- a/i18n/en-GB.i18n.json
+++ b/i18n/en-GB.i18n.json
@@ -256,6 +256,8 @@
"current": "current",
"custom-field-delete-pop": "There is no undo. This will remove this custom field from all cards and destroy its history.",
"custom-field-checkbox": "Checkbox",
+ "custom-field-currency": "Currency",
+ "custom-field-currency-option": "Currency Symbol",
"custom-field-date": "Date",
"custom-field-dropdown": "Dropdown List",
"custom-field-dropdown-none": "(none)",
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index 991ea7c1..ffc6e77c 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -256,6 +256,8 @@
"current": "current",
"custom-field-delete-pop": "There is no undo. This will remove this custom field from all cards and destroy its history.",
"custom-field-checkbox": "Checkbox",
+ "custom-field-currency": "Currency",
+ "custom-field-currency-option": "Currency Symbol",
"custom-field-date": "Date",
"custom-field-dropdown": "Dropdown List",
"custom-field-dropdown-none": "(none)",
diff --git a/models/customFields.js b/models/customFields.js
index cc798b16..435ebabb 100644
--- a/models/customFields.js
+++ b/models/customFields.js
@@ -22,7 +22,7 @@ CustomFields.attachSchema(
* type of the custom field
*/
type: String,
- allowedValues: ['text', 'number', 'date', 'dropdown'],
+ allowedValues: ['text', 'number', 'date', 'dropdown', 'currency'],
},
settings: {
/**
@@ -30,6 +30,10 @@ CustomFields.attachSchema(
*/
type: Object,
},
+ 'settings.currencySymbol': {
+ type: String,
+ optional: true,
+ },
'settings.dropdownItems': {
/**
* list of drop down items objects