REFACTOR: removes display invitees option (#28)

REFACTOR: removes display invitees option (#28)

diff --git a/app/controllers/discourse_post_event/events_controller.rb b/app/controllers/discourse_post_event/events_controller.rb
index 9924625..b2d50fe 100644
--- a/app/controllers/discourse_post_event/events_controller.rb
+++ b/app/controllers/discourse_post_event/events_controller.rb
@@ -104,7 +104,6 @@ module DiscoursePostEvent
           :starts_at,
           :ends_at,
           :status,
-          :display_invitees,
           raw_invitees: []
         )
     end
diff --git a/app/models/discourse_post_event/event.rb b/app/models/discourse_post_event/event.rb
index e747fc7..0d21753 100644
--- a/app/models/discourse_post_event/event.rb
+++ b/app/models/discourse_post_event/event.rb
@@ -98,10 +98,6 @@ module DiscoursePostEvent
       @statuses ||= Enum.new(standalone: 0, public: 1, private: 2)
     end
 
-    def self.display_invitees_options
-      @display_invitees_options ||= Enum.new(everyone: 0, invitees_only: 1, none: 2)
-    end
-
     def most_likely_going(current_user, limit = SiteSetting.displayed_invitees_limit)
       most_likely = []
 
@@ -175,21 +171,5 @@ module DiscoursePostEvent
     def is_expired?
       Time.now > (self.ends_at || self.starts_at || Time.now)
     end
-
-    def display_invitees?(current_user)
-      !self.is_expired? &&
-      self.status != Event.statuses[:standalone] &&
-      (
-        self.display_invitees == Event.display_invitees_options[:everyone] ||
-        (
-          self.display_invitees == Event.display_invitees_options[:invitees_only] &&
-          self.invitees.exists?(user_id: current_user.id)
-        ) ||
-        (
-          self.display_invitees == Event.display_invitees_options[:none] &&
-          self.post.user == current_user
-        )
-      )
-    end
   end
 end
diff --git a/app/serializers/discourse_post_event/event_serializer.rb b/app/serializers/discourse_post_event/event_serializer.rb
index d36f25a..e9e69f2 100644
--- a/app/serializers/discourse_post_event/event_serializer.rb
+++ b/app/serializers/discourse_post_event/event_serializer.rb
@@ -11,9 +11,7 @@ module DiscoursePostEvent
     attributes :stats
     attributes :status
     attributes :raw_invitees
-    attributes :display_invitees
     attributes :post
-    attributes :should_display_invitees
     attributes :name
     attributes :can_act_on_event
     attributes :can_update_attendance
@@ -45,18 +43,10 @@ module DiscoursePostEvent
       }
     end
 
-    def should_display_invitees
-      object.display_invitees?(scope.current_user)
-    end
-
     def can_update_attendance
       object.can_user_update_attendance(scope.current_user)
     end
 
-    def display_invitees
-      Event.display_invitees_options[object.display_invitees]
-    end
-
     def creator
       BasicUserSerializer.new(object.post.user, embed: :objects, root: false)
     end
@@ -97,10 +87,6 @@ module DiscoursePostEvent
       end
     end
 
-    def include_sample_invitees?
-      object.display_invitees?(scope.current_user)
-    end
-
     def sample_invitees
       invitees = object.most_likely_going(scope.current_user)
       ActiveModel::ArraySerializer.new(invitees, each_serializer: InviteeSerializer)
diff --git a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6 b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
index d34e1d2..f63c93f 100644
--- a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
+++ b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
@@ -36,37 +36,6 @@ export default Controller.extend(ModalFunctionality, {
   publicEvent: equal("model.eventModel.status", "public"),
   privateEvent: equal("model.eventModel.status", "private"),
 
-  inviteesOptions: computed("model.eventModel.status", function() {
-    const options = [];
-
-    if (!this.standaloneEvent) {
-      options.push({
-        label: I18n.t(
-          "discourse_post_event.models.event.display_invitees.everyone"
-        ),
-        value: "everyone"
-      });
-
-      if (this.privateEvent) {
-        options.push({
-          label: I18n.t(
-            "discourse_post_event.models.event.display_invitees.invitees_only"
-          ),
-          value: "invitees_only"
-        });
-      }
-
-      options.push({
-        label: I18n.t(
-          "discourse_post_event.models.event.display_invitees.none"
-        ),
-        value: "none"
-      });
-    }
-
-    return options;
-  }),
-
   @action
   onChangeDates(changes) {
     this.model.eventModel.setProperties({
diff --git a/assets/javascripts/discourse/models/discourse-post-event-event.js.es6 b/assets/javascripts/discourse/models/discourse-post-event-event.js.es6
index 2572034..c3f4f07 100644
--- a/assets/javascripts/discourse/models/discourse-post-event-event.js.es6
+++ b/assets/javascripts/discourse/models/discourse-post-event-event.js.es6
@@ -6,11 +6,6 @@ const ATTRIBUTES = {
   starts_at: {},
   ends_at: {},
   raw_invitees: {},
-  display_invitees: {
-    transform(value) {
-      return DISPLAY_INVITEES_OPTIONS[value];
-    }
-  },
   status: {
     transform(value) {
       return STATUSES[value];
@@ -18,12 +13,6 @@ const ATTRIBUTES = {
   }
 };
 
-const DISPLAY_INVITEES_OPTIONS = {
-  everyone: 0,
-  invitees_only: 1,
-  none: 2
-};
-
 const STATUSES = {
   standalone: 0,
   public: 1,
diff --git a/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs b/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
index ef688c4..a080115 100644
--- a/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
+++ b/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
@@ -74,24 +74,6 @@
         excludeCurrentUser=true
       }}
     {{/event-field}}
-
-    {{#if inviteesOptions.length}}
-      {{#event-field label="discourse_post_event.builder_modal.display_invitees.label"}}
-        {{#each inviteesOptions as |option|}}
-          <label class="radio-label">
-            {{radio-button
-              name="display_invitees"
-              value=option.value
-              selection=model.eventModel.display_invitees
-              onChange=(action (mut model.eventModel.display_invitees))
-            }}
-            <span class="message">
-              {{option.label}}
-             </span>
-          </label>
-        {{/each}}
-      {{/event-field}}
-    {{/if}}
   </form>
   {{/conditional-loading-section}}
 {{/d-modal-body}}
diff --git a/assets/javascripts/discourse/widgets/discourse-post-event-invitees.js.es6 b/assets/javascripts/discourse/widgets/discourse-post-event-invitees.js.es6
index 80bf81b..8e8b209 100644
--- a/assets/javascripts/discourse/widgets/discourse-post-event-invitees.js.es6
+++ b/assets/javascripts/discourse/widgets/discourse-post-event-invitees.js.es6
@@ -7,9 +7,7 @@ export default createWidget("discourse-post-event-invitees", {
   transform(attrs) {
     return {
       isPrivateEvent: attrs.eventModel.status === "private",
-      showAll:
-        attrs.eventModel.should_display_invitees &&
-        attrs.eventModel.stats.invited > 10
+      showAll: attrs.eventModel.stats.invited > 10
     };
   },
 
diff --git a/assets/javascripts/discourse/widgets/discourse-post-event.js.es6 b/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
index 793be7f..0c9437e 100644
--- a/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
+++ b/assets/javascripts/discourse/widgets/discourse-post-event.js.es6
@@ -194,12 +194,11 @@ export default createWidget("discourse-post-event", {
         )
       }}
 
-      {{#if state.eventModel.should_display_invitees}}
-        <hr />
-        {{attach widget="discourse-post-event-invitees"
-          attrs=(hash eventModel=state.eventModel)
-        }}
-      {{/if}}
+      <hr />
+      
+      {{attach widget="discourse-post-event-invitees"
+        attrs=(hash eventModel=state.eventModel)
+      }}
 

[... diff too long, it was truncated ...]

GitHub sha: 31dfaf45

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