@itfin/components 2.0.11 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -17,8 +17,8 @@
17
17
  <div v-if="currencySelect" class="itf-money-field__currency">
18
18
  <span>{{ selectedCurrencyCode }}<itf-icon v-if="!currencyDisabled && currenciesList.length > 1" name="chevron_down" /></span>
19
19
  <select v-if="!disabled && !currencyDisabled" :value="currencyId" @input="onCurrencyChanged">
20
- <option v-for="currency in currenciesList" :key="currency.Id" :value="currency.Id" :selected="currencyId === currency.Id">
21
- {{ currency.Symbol }}, {{ currency.Code }} - {{ currency.Title }}
20
+ <option v-for="currency in currenciesList" :key="currency[itemKey]" :value="currency[itemKey]" :selected="currencyId === currency[itemKey]">
21
+ {{ currency[symbolKey] }}, {{ currency[codeKey] }} - {{ currency[titleKey] }}
22
22
  </option>
23
23
  </select>
24
24
  </div>
@@ -106,6 +106,11 @@ class itfMoneyField extends Vue {
106
106
  @Prop({ type: Boolean, default: true }) currencySelect;
107
107
  @Prop({ type: Array, default: () => ([]) }) currencies;
108
108
  @Prop({ type: Boolean, default: false }) currencyDisabled;
109
+ @Prop({ type: String, default: 'Id' }) itemKey;
110
+ @Prop({ type: String, default: 'Code' }) codeKey;
111
+ @Prop({ type: String, default: 'Symbol' }) symbolKey;
112
+ @Prop({ type: String, default: 'Title' }) titleKey;
113
+ @Prop({ type: String, default: 'Precision' }) precisionKey;
109
114
  @Prop({ type: Number, default: -1000000000}) minValue;
110
115
  @Prop({ type: Number, default: 1000000000}) maxValue;
111
116
 
@@ -140,31 +145,31 @@ class itfMoneyField extends Vue {
140
145
  }
141
146
 
142
147
  onCurrencyChanged(e) {
143
- const currency = this.currenciesList.find((c) => c.Id === parseInt(e.target.value));
148
+ const currency = this.currenciesList.find((c) => c[this.itemKey] === parseInt(e.target.value));
144
149
  this.$emit('update:currency', currency)
145
150
  }
146
151
 
147
152
  get precition() {
148
- return this.selectedCurrency ? this.selectedCurrency.Precision : 2;
153
+ return this.selectedCurrency ? this.selectedCurrency[this.precisionKey] : 2;
149
154
  }
150
155
 
151
156
  get selectedCurrencySymbol() {
152
- return this.selectedCurrency ? this.selectedCurrency.Symbol : '#';
157
+ return this.selectedCurrency ? this.selectedCurrency[this.symbolKey] : '#';
153
158
  }
154
159
 
155
160
  get selectedCurrencyCode() {
156
- return this.selectedCurrency ? this.selectedCurrency.Code : '###';
161
+ return this.selectedCurrency ? this.selectedCurrency[this.codeKey] : '###';
157
162
  }
158
163
 
159
164
  get currencyId() {
160
- return this.selectedCurrency && this.selectedCurrency.Id;
165
+ return this.selectedCurrency && this.selectedCurrency[this.itemKey];
161
166
  }
162
167
 
163
168
  get selectedCurrency() {
164
169
  if (!this.currency || !this.currenciesList) {
165
170
  return this.currenciesList.find(({ IsDefault }) => IsDefault) || null;
166
171
  }
167
- return this.currenciesList.find(({ Id }) => this.currency.Id === Id);
172
+ return this.currenciesList.find((itm) => this.currency[this.itemKey] === itm[this.itemKey]);
168
173
  }
169
174
 
170
175
  setValue (val) {