@@ -59,6 +59,7 @@ export default {
5959 options: [],
6060 selectedCountries: [],
6161 isLoading: false ,
62+ valueMap: {},
6263 };
6364 },
6465 watch: {
@@ -72,14 +73,29 @@ export default {
7273 checkAndSendData () {
7374 if (this .selected ) {
7475 if (this .selected .includes (' Other' )) {
75- if (this .multipleAllowed ) {
76- this .$emit (' valueChanged' , [... this .selected .slice (0 , - 1 ), this .otherInput ]);
76+ if (! _ .isEmpty (this .valueMap )) {
77+ this .valueMap [" Other" ] = this .otherInput ;
78+ }
79+ }
80+ let out = null ;
81+ if (this .multipleAllowed ) {
82+ if (! _ .isEmpty (this .valueMap )) {
83+ out = _ .map (this .selected , v => this .valueMap [v]);
84+ } else if (this .selected .includes (' Other' )) {
85+ out = [... this .selected .slice (0 , - 1 ), this .otherInput ];
7786 } else {
78- this . $emit ( ' valueChanged ' , this .otherInput );
87+ out = [ ... this .selected ]
7988 }
8089 } else {
81- this .$emit (' valueChanged' , this .selected );
90+ if (! _ .isEmpty (this .valueMap )) {
91+ out = this .valueMap [this .selected ];
92+ } else if (this .selected === ' Other' ) {
93+ out = this .otherInput ;
94+ } else {
95+ out = this .selected ;
96+ }
8297 }
98+ this .$emit (' valueChanged' , out);
8399 }
84100 },
85101 limitText (count ) {
@@ -99,6 +115,9 @@ export default {
99115 const activeValueChoices = _ .filter (v[' http://schema.org/name' ], ac => ac[' @language' ] === this .selected_language );
100116 return (activeValueChoices[0 ][' @value' ]);
101117 });
118+ this .options .forEach ((key , index ) => {
119+ this .valueMap [key] = this .constraints [' http://schema.repronim.org/choices' ][index][' http://schema.repronim.org/value' ][0 ][' @value' ];
120+ });
102121 } else if (this .constraints [' http://schema.repronim.org/choices' ].length === 1 ) { // choice list defined in external file
103122 axios .get (this .constraints [' http://schema.repronim.org/choices' ][0 ][' @value' ])
104123 .then ((resp ) => {
@@ -120,7 +139,11 @@ export default {
120139 },
121140 checkOther () {
122141 if (this .selected ) {
123- return this .selected .includes (' Other' );
142+ if (this .multipleAllowed ) {
143+ return this .selected .includes (' Other' );
144+ } else {
145+ return this .selected === ' Other' ;
146+ }
124147 }
125148 return false ;
126149 },
0 commit comments