FIX: Fetch all groups for group-chooser in category settings (#48)

FIX: Fetch all groups for group-chooser in category settings (#48)

diff --git a/assets/javascripts/discourse/components/category-experts-settings.js b/assets/javascripts/discourse/components/category-experts-settings.js
index 9418af4..4881259 100644
--- a/assets/javascripts/discourse/components/category-experts-settings.js
+++ b/assets/javascripts/discourse/components/category-experts-settings.js
@@ -1,30 +1,25 @@
 import Component from "@ember/component";
+import Group from "discourse/models/group";
 import { action } from "@ember/object";
 import { ajax } from "discourse/lib/ajax";
 
 export default Component.extend({
   groupIds: null,
+  allGroups: null,
 
   init() {
     this._super(...arguments);
     this.set(
       "groupIds",
       this.category.custom_fields.category_expert_group_ids
-        ? this.category.custom_fields.category_expert_group_ids.split("|")
+        ? this.category.custom_fields.category_expert_group_ids
+            .split("|")
+            .map((id) => parseInt(id, 10))
         : []
     );
 
-    ajax("/groups.json").then((response) => {
-      const groupOptions = [];
-      response.groups.forEach((group) => {
-        if (!group.automatic) {
-          groupOptions.push({
-            name: group.name,
-            id: group.id.toString(),
-          });
-        }
-      });
-      this.set("groupOptions", groupOptions);
+    Group.findAll().then((groups) => {
+      this.set("allGroups", groups.filterBy("automatic", false));
     });
 
     ajax("/badges.json").then((response) => {
diff --git a/assets/javascripts/discourse/templates/components/category-experts-settings.hbs b/assets/javascripts/discourse/templates/components/category-experts-settings.hbs
index c0d2f9f..dc63074 100644
--- a/assets/javascripts/discourse/templates/components/category-experts-settings.hbs
+++ b/assets/javascripts/discourse/templates/components/category-experts-settings.hbs
@@ -5,10 +5,11 @@
       {{i18n "category_experts.group"}}
     </label>
     <div class="controls">
-      {{multi-select
+      {{group-chooser
+        content=allGroups
         value=groupIds
-        content=groupOptions
-        onSelect=(action onChangeGroupIds)
+        labelProperty="name"
+        onChange=(action "onChangeGroupIds")
       }}
     </div>
   </section>

GitHub sha: 7bd85435fcc41945394a8bca59e8800c44980452

This commit appears in #48 which was approved by eviltrout. It was merged by markvanlan.