mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
Animate in new user education. Track replies separately from posts.
This commit is contained in:
@ -22,7 +22,12 @@ window.Discourse.ComposerController = Ember.Controller.extend Discourse.Presence
|
|||||||
.then (opts) =>
|
.then (opts) =>
|
||||||
opts = opts || {}
|
opts = opts || {}
|
||||||
@close()
|
@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'))
|
Discourse.routeTo(opts.post.get('url'))
|
||||||
, (error) =>
|
, (error) =>
|
||||||
composer.set('disableDrafts', false)
|
composer.set('disableDrafts', false)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<div class='contents'>
|
<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>
|
<a href='#' {{action closeEducation target="view"}} class='close'>{{i18n ok}}</a>
|
||||||
|
|
||||||
{{{view.educationContents}}}
|
{{{view.educationContents}}}
|
||||||
|
@ -59,8 +59,11 @@ window.Discourse.ComposerView = window.Discourse.View.extend
|
|||||||
|
|
||||||
fetchNewUserEducation: (->
|
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('educationClosed', true)
|
||||||
|
@set('educationContents', '')
|
||||||
return
|
return
|
||||||
|
|
||||||
return unless @get('controller.hasReply')
|
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'
|
educationKey = if @get('content.creatingTopic') then 'new-topic' else 'new-reply'
|
||||||
$.get("/education/#{educationKey}").then (result) => @set('educationContents', result)
|
$.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: (->
|
newUserEducationVisible: (->
|
||||||
return 'collapsed' unless @get('educationContents')
|
return false unless @get('educationContents')
|
||||||
return 'collapsed' unless @get('content.composeState') is Discourse.Composer.OPEN
|
return false unless @get('content.composeState') is Discourse.Composer.OPEN
|
||||||
return 'collapsed' unless @present('content.reply')
|
return false unless @present('content.reply')
|
||||||
return 'collapsed' if @get('educationClosed')
|
return false if @get('educationClosed')
|
||||||
|
|
||||||
return 'visible'
|
true
|
||||||
).property('content.composeState', 'content.reply', 'educationClosed', 'educationContents')
|
).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) ->
|
moveNewUserEducation: (sizePx) ->
|
||||||
$('#new-user-education').css('bottom', sizePx)
|
$('#new-user-education').css('bottom', sizePx)
|
||||||
|
|
||||||
|
@ -6,15 +6,7 @@
|
|||||||
|
|
||||||
#new-user-education {
|
#new-user-education {
|
||||||
|
|
||||||
&.collapsed {
|
@include box-shadow(3px 3px 3px rgba($black, 0.14));
|
||||||
max-height: 0;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.visible {
|
|
||||||
max-height: 1000px;
|
|
||||||
visibility: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0 0 10px 0;
|
margin: 0 0 10px 0;
|
||||||
|
@ -7,7 +7,8 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||||||
:notification_channel_position,
|
:notification_channel_position,
|
||||||
:site_flagged_posts_count,
|
:site_flagged_posts_count,
|
||||||
:moderator?,
|
: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
|
# 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
|
object.admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_count
|
def topic_count
|
||||||
object.posts.count
|
object.topics.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def reply_count
|
||||||
|
object.posts.where("post_number > 1").count
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator?
|
def moderator?
|
||||||
@ -26,4 +31,5 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||||||
def site_flagged_posts_count
|
def site_flagged_posts_count
|
||||||
PostAction.flagged_posts_count
|
PostAction.flagged_posts_count
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user