mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:52:45 +08:00
Animate in new user education. Track replies separately from posts.
This commit is contained in:
parent
37b0c168bf
commit
6f4882659a
|
@ -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)
|
||||
|
|
|
@ -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}}}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user