UX: Hide group tab when there are no assignments, add everyone count (#83)

UX: Hide group tab when there are no assignments, add everyone count (#83)

diff --git a/assets/javascripts/discourse-assign/controllers/group-assignments.js.es6 b/assets/javascripts/discourse-assign/controllers/group-assignments.js.es6
index 1ecbd4a..23df1b8 100644
--- a/assets/javascripts/discourse-assign/controllers/group-assignments.js.es6
+++ b/assets/javascripts/discourse-assign/controllers/group-assignments.js.es6
@@ -21,7 +21,7 @@ export default Controller.extend({
     if (this.model.members.length >= this.offset + 50) {
       this.set("loading", true);
       this.set("offset", this.offset + 50);
-      ajax(`/assign/members/${this.groupName}?offset=${this.offset}`).then(
+      ajax(`/assign/members/${this.group.name}?offset=${this.offset}`).then(
         result => {
           this.members.pushObjects(result.members);
           this.set("loading", false);
diff --git a/assets/javascripts/discourse-assign/routes/group-assignments.js.es6 b/assets/javascripts/discourse-assign/routes/group-assignments.js.es6
index fd90774..5c5b854 100644
--- a/assets/javascripts/discourse-assign/routes/group-assignments.js.es6
+++ b/assets/javascripts/discourse-assign/routes/group-assignments.js.es6
@@ -1,7 +1,7 @@
-import Route from "@ember/routing/route";
+import DiscourseRoute from "discourse/routes/discourse";
 import { ajax } from "discourse/lib/ajax";
 
-export default Route.extend({
+export default DiscourseRoute.extend({
   model() {
     return ajax(`/assign/members/${this.modelFor("group").get("name")}`);
   },
@@ -10,7 +10,7 @@ export default Route.extend({
     controller.setProperties({
       model,
       members: [],
-      groupName: this.modelFor("group").get("name")
+      group: this.modelFor("group")
     });
 
     controller.findMembers(true);
diff --git a/assets/javascripts/discourse/components/group-assignments-menu-item.js.es6 b/assets/javascripts/discourse/components/group-assignments-menu-item.js.es6
index b6c2801..188c08d 100644
--- a/assets/javascripts/discourse/components/group-assignments-menu-item.js.es6
+++ b/assets/javascripts/discourse/components/group-assignments-menu-item.js.es6
@@ -3,6 +3,11 @@ export default Ember.Component.extend({
 
   init() {
     this._super(...arguments);
-    this.set("canAssign", this.currentUser && this.currentUser.can_assign);
+    this.set(
+      "displayAssignTab",
+      this.currentUser &&
+        this.currentUser.can_assign &&
+        this.group.assignment_count > 0
+    );
   }
 });
diff --git a/assets/javascripts/discourse/templates/components/group-assignments-filter.hbs b/assets/javascripts/discourse/templates/components/group-assignments-filter.hbs
index be45773..35fa403 100644
--- a/assets/javascripts/discourse/templates/components/group-assignments-filter.hbs
+++ b/assets/javascripts/discourse/templates/components/group-assignments-filter.hbs
@@ -4,6 +4,6 @@
   {{/link-to}}
 {{else}}
   {{#link-to "group.assignments.show" filter}}
-    {{i18n 'discourse_assign.group_everyone'}}
+    {{i18n 'discourse_assign.group_everyone'}} ({{assignment_count}})
   {{/link-to}}
 {{/if}}
diff --git a/assets/javascripts/discourse/templates/components/group-assignments-menu-item.hbs b/assets/javascripts/discourse/templates/components/group-assignments-menu-item.hbs
index 0d1b27e..6d3395c 100644
--- a/assets/javascripts/discourse/templates/components/group-assignments-menu-item.hbs
+++ b/assets/javascripts/discourse/templates/components/group-assignments-menu-item.hbs
@@ -1,8 +1,8 @@
-{{#if canAssign}}
+{{#if displayAssignTab}}
   <ul class ='nav-pills'>
     <li>
-      {{#link-to 'group.assignments' group}}
-        {{d-icon "user-plus" class="glyph"}}{{i18n 'discourse_assign.group_assignments'}}{{concat ' (' group.assignment_count concat ')'}}
+      {{#link-to "group.assignments"}}
+        {{d-icon "user-plus" class="glyph"}}{{i18n 'discourse_assign.group_assignments'}} ({{group.assignment_count}})
       {{/link-to}}
     </li>
   </ul>
diff --git a/assets/javascripts/discourse/templates/group/assignments.hbs b/assets/javascripts/discourse/templates/group/assignments.hbs
index ff29d89..743f33a 100644
--- a/assets/javascripts/discourse/templates/group/assignments.hbs
+++ b/assets/javascripts/discourse/templates/group/assignments.hbs
@@ -1,7 +1,7 @@
 <section class="user-secondary-navigation">
   {{#mobile-nav class="activity-nav" desktopClass="action-list activity-list nav-stacked" currentPath=router._router.currentPath}}
     {{#load-more selector=".activity-nav li" action=(action "loadMore")}}
-      {{group-assignments-filter show-avatar=false filter="everyone" routeType=route_type}}
+      {{group-assignments-filter show-avatar=false filter="everyone" routeType=route_type assignment_count=group.assignment_count}}
       {{#each members as |member|}}
         {{group-assignments-filter show-avatar=true filter=member routeType=route_type}}
       {{/each}}

GitHub sha: cd3e5763

This commit appears in #83 which was merged by davidtaylorhq.