File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
assets/javascripts/discourse
templates/components/user-fields Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
import UserField from "admin/models/user-field" ;
2
+ import { withPluginApi } from 'discourse/lib/plugin-api' ;
2
3
import { i18n } from "discourse/lib/computed" ;
4
+ import { observes , on } from "ember-addons/ember-computed-decorators" ;
3
5
4
6
const UserFieldType = Ember . Object . extend ( {
5
7
name : i18n ( "id" , "admin.user_fields.field_types.%@" )
@@ -23,5 +25,23 @@ export default{
23
25
return this . _fieldTypes ;
24
26
} ,
25
27
} ) ;
28
+
29
+ withPluginApi ( '0.8.12' , api => {
30
+ api . modifyClass ( 'component:user-field' , {
31
+ values : [ ] ,
32
+
33
+ @on ( "init" )
34
+ init_values ( ) {
35
+ if ( this . field . field_type == "multiselect-dropdown" && this . get ( "value" ) ) {
36
+ this . set ( "values" , JSON . parse ( this . get ( "value" ) ) ) ;
37
+ }
38
+ } ,
39
+
40
+ @observes ( "values" )
41
+ setValue ( ) {
42
+ this . set ( "value" , JSON . stringify ( this . get ( "values" ) ) ) ;
43
+ } ,
44
+ } ) ;
45
+ } ) ;
26
46
}
27
47
}
Original file line number Diff line number Diff line change 1
1
<label class =" control-label" for =" {{ concat ' user-' elementId }} " >{{{ field.name }}} </label >
2
2
<div class =' controls' >
3
- {{ multi-select id = (concat ' user-' elementId ) content =field.options value =value none =noneLabel }}
3
+ {{ multi-select id = (concat ' user-' elementId ) content =field.options values =values none =noneLabel }}
4
+
4
5
{{ #if field.required }} <span class =' required' >*</span >{{ /if }}
5
6
<div class =" instructions" >{{{ field.description }}} </div >
6
7
</div >
You can’t perform that action at this time.
0 commit comments