FIX: correctly set values and defaults for group-form-interaction-fields (#9891)

FIX: correctly set values and defaults for group-form-interaction-fields (#9891)

diff --git a/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js b/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
index 9f20ed3..d241176 100644
--- a/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
+++ b/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
@@ -1,5 +1,6 @@
 import I18n from "I18n";
 import Component from "@ember/component";
+import { or } from "@ember/object/computed";
 import discourseComputed from "discourse-common/utils/decorators";
 
 export default Component.extend({
@@ -47,6 +48,21 @@ export default Component.extend({
     ];
   },
 
+  membersVisibilityLevel: or(
+    "model.members_visibility_level",
+    "visibilityLevelOptions.firstObject.value"
+  ),
+
+  messageableLevel: or(
+    "model.messageable_level",
+    "aliasLevelOptions.firstObject.value"
+  ),
+
+  mentionableLevel: or(
+    "model.mentionable_level",
+    "aliasLevelOptions.firstObject.value"
+  ),
+
   @discourseComputed(
     "siteSettings.email_in",
     "model.automatic",
diff --git a/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs b/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
index 1a2c473..07cf33c 100644
--- a/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
@@ -22,11 +22,12 @@
     <label for="visiblity">{{i18n "admin.groups.manage.interaction.members_visibility_levels.title"}}</label>
 
     {{combo-box name="alias"
-        valueProperty="value"
-        value=model.members_visibility_level
-        content=visibilityLevelOptions
-        castInteger=true
-        class="groups-form-members-visibility-level"}}
+      valueProperty="value"
+      value=membersVisibilityLevel
+      content=visibilityLevelOptions
+      class="groups-form-members-visibility-level"
+      onChange=(action (mut model.members_visibility_level))
+    }}
 
     <div class="control-instructions">
       {{i18n "admin.groups.manage.interaction.members_visibility_levels.description"}}
@@ -41,7 +42,7 @@
   {{combo-box
     name="alias"
     valueProperty="value"
-    value=model.mentionable_level
+    value=mentionableLevel
     content=aliasLevelOptions
     class="groups-form-mentionable-level"
     onChange=(action (mut model.mentionable_level))
@@ -54,7 +55,7 @@
   {{combo-box
     name="alias"
     valueProperty="value"
-    value=model.messageable_level
+    value=messageableLevel
     content=aliasLevelOptions
     class="groups-form-messageable-level"
     onChange=(action (mut model.messageable_level))

GitHub sha: f51093dd

This commit appears in #9891 which was merged by jjaffeux.