File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -261,4 +261,24 @@ describe('vue-numeric', () => {
261261 done ( )
262262 } )
263263 } )
264+
265+ it ( 'updates value with suffix currency symbol' , done => {
266+ const vm = new Vue ( {
267+ el,
268+ data ( ) {
269+ return {
270+ total : 0
271+ }
272+ } ,
273+ template : '<div><vue-numeric v-model="total" currency="CZK" currencySymbolPosition="suffix" precision=2 separator="."></vue-numeric></div>' ,
274+ components : { VueNumeric }
275+ } ) . $mount ( )
276+
277+ vm . total = 3000
278+
279+ Vue . nextTick ( ( ) => {
280+ expect ( vm . $el . firstChild . value . trim ( ) ) . toEqual ( '3.000,00 CZK' )
281+ done ( )
282+ } )
283+ } )
264284} )
Original file line number Diff line number Diff line change @@ -106,6 +106,16 @@ export default {
106106 default: ' ' ,
107107 required: false ,
108108 type: String
109+ },
110+
111+ /**
112+ * Position of currency symbol
113+ * Symbol position props accept either 'sufix' or 'prefix' (default).
114+ */
115+ currencySymbolPosition: {
116+ default: ' prefix' ,
117+ required: false ,
118+ type: String
109119 }
110120 },
111121
@@ -164,6 +174,14 @@ export default {
164174 thousandSeparator () {
165175 if (this .separator === ' .' ) return ' .'
166176 return ' ,'
177+ },
178+
179+ /**
180+ * Define format for currency symbol and value.
181+ * @return {String} format
182+ */
183+ formatString () {
184+ return this .currencySymbolPosition === ' suffix' ? ' %v %s' : ' %s %v'
167185 }
168186 },
169187
@@ -237,7 +255,8 @@ export default {
237255 */
238256 formatValue () {
239257 this .amount = accounting .formatMoney (this .numberValue , {
240- symbol: this .currency + ' ' ,
258+ symbol: this .currency ,
259+ format: this .formatString ,
241260 precision: Number (this .precision ),
242261 decimal: this .decimalSeparator ,
243262 thousand: this .thousandSeparator
You can’t perform that action at this time.
0 commit comments