diff --git a/app/assets/javascripts/discourse/controllers/composer_controller.js.coffee b/app/assets/javascripts/discourse/controllers/composer_controller.js.coffee index ee697f3c0..5ad11c946 100644 --- a/app/assets/javascripts/discourse/controllers/composer_controller.js.coffee +++ b/app/assets/javascripts/discourse/controllers/composer_controller.js.coffee @@ -22,7 +22,12 @@ window.Discourse.ComposerController = Ember.Controller.extend Discourse.Presence .then (opts) => opts = opts || {} @close() - Discourse.set('currentUser.post_count', Discourse.get('currentUser.post_count') + 1) + + if composer.get('creatingTopic') + Discourse.set('currentUser.topic_count', Discourse.get('currentUser.topic_count') + 1) + else + Discourse.set('currentUser.reply_count', Discourse.get('currentUser.reply_count') + 1) + Discourse.routeTo(opts.post.get('url')) , (error) => composer.set('disableDrafts', false) diff --git a/app/assets/javascripts/discourse/templates/composer.js.handlebars b/app/assets/javascripts/discourse/templates/composer.js.handlebars index 72e7e1923..e1c6d5417 100644 --- a/app/assets/javascripts/discourse/templates/composer.js.handlebars +++ b/app/assets/javascripts/discourse/templates/composer.js.handlebars @@ -2,7 +2,7 @@ <div class='contents'> - <div id='new-user-education' {{bindAttr class="view.newUserEducationVisible"}}> + <div id='new-user-education' style='display: none'> <a href='#' {{action closeEducation target="view"}} class='close'>{{i18n ok}}</a> {{{view.educationContents}}} diff --git a/app/assets/javascripts/discourse/views/composer_view.js.coffee b/app/assets/javascripts/discourse/views/composer_view.js.coffee index c0897b575..7cef1fa4d 100644 --- a/app/assets/javascripts/discourse/views/composer_view.js.coffee +++ b/app/assets/javascripts/discourse/views/composer_view.js.coffee @@ -59,8 +59,11 @@ window.Discourse.ComposerView = window.Discourse.View.extend fetchNewUserEducation: (-> - if (Discourse.get('currentUser.post_count') >= Discourse.SiteSettings.educate_until_posts) + # If creating a topic, use topic_count, otherwise post_count + count = if @get('content.creatingTopic') then Discourse.get('currentUser.topic_count') else Discourse.get('currentUser.reply_count') + if (count >= Discourse.SiteSettings.educate_until_posts) @set('educationClosed', true) + @set('educationContents', '') return return unless @get('controller.hasReply') @@ -71,17 +74,25 @@ window.Discourse.ComposerView = window.Discourse.View.extend educationKey = if @get('content.creatingTopic') then 'new-topic' else 'new-reply' $.get("/education/#{educationKey}").then (result) => @set('educationContents', result) - ).observes('controller.hasReply', 'content.creatingTopic', 'Discourse.currentUser.post_count') + ).observes('controller.hasReply', 'content.creatingTopic', 'Discourse.currentUser.reply_count') newUserEducationVisible: (-> - return 'collapsed' unless @get('educationContents') - return 'collapsed' unless @get('content.composeState') is Discourse.Composer.OPEN - return 'collapsed' unless @present('content.reply') - return 'collapsed' if @get('educationClosed') + return false unless @get('educationContents') + return false unless @get('content.composeState') is Discourse.Composer.OPEN + return false unless @present('content.reply') + return false if @get('educationClosed') - return 'visible' + true ).property('content.composeState', 'content.reply', 'educationClosed', 'educationContents') + newUserEducationVisibilityChanged: (-> + $panel = $('#new-user-education') + if @get('newUserEducationVisible') + $panel.slideDown('fast') + else + $panel.slideUp('fast') + ).observes('newUserEducationVisible') + moveNewUserEducation: (sizePx) -> $('#new-user-education').css('bottom', sizePx) diff --git a/app/assets/stylesheets/application/compose.css.scss b/app/assets/stylesheets/application/compose.css.scss index dd4a438a6..07f421934 100644 --- a/app/assets/stylesheets/application/compose.css.scss +++ b/app/assets/stylesheets/application/compose.css.scss @@ -6,15 +6,7 @@ #new-user-education { - &.collapsed { - max-height: 0; - visibility: hidden; - } - - &.visible { - max-height: 1000px; - visibility: visible; - } + @include box-shadow(3px 3px 3px rgba($black, 0.14)); p { margin: 0 0 10px 0; diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rb index 018915d9d..48de537e1 100644 --- a/app/serializers/current_user_serializer.rb +++ b/app/serializers/current_user_serializer.rb @@ -7,7 +7,8 @@ class CurrentUserSerializer < BasicUserSerializer :notification_channel_position, :site_flagged_posts_count, :moderator?, - :post_count + :reply_count, + :topic_count # we probably want to move this into site, but that json is cached so hanging it off current user seems okish @@ -15,8 +16,12 @@ class CurrentUserSerializer < BasicUserSerializer object.admin end - def post_count - object.posts.count + def topic_count + object.topics.count + end + + def reply_count + object.posts.where("post_number > 1").count end def moderator? @@ -26,4 +31,5 @@ class CurrentUserSerializer < BasicUserSerializer def site_flagged_posts_count PostAction.flagged_posts_count end + end