mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Show FAQ at top of the hamburger until the user reads it
This commit is contained in:
@ -3,8 +3,11 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
markFaqRead() {
|
markFaqRead() {
|
||||||
if (this.currentUser) {
|
const currentUser = this.currentUser;
|
||||||
Discourse.ajax("/users/read-faq", { method: "POST" });
|
if (currentUser) {
|
||||||
|
Discourse.ajax("/users/read-faq", { method: "POST" }).then(() => {
|
||||||
|
currentUser.set('read_faq', true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
{{#menu-panel visible=visible}}
|
{{#menu-panel visible=visible}}
|
||||||
|
{{#unless currentUser.read_faq}}
|
||||||
|
{{#menu-links}}
|
||||||
|
<li>
|
||||||
|
{{#d-link path=faqUrl class="faq-link"}}
|
||||||
|
{{i18n "faq"}}
|
||||||
|
<span class='new'>{{i18n "new_item"}}</span>
|
||||||
|
{{/d-link}}
|
||||||
|
</li>
|
||||||
|
{{/menu-links}}
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
{{#if currentUser.staff}}
|
{{#if currentUser.staff}}
|
||||||
{{#menu-links class="columned"}}
|
{{#menu-links}}
|
||||||
<li>{{d-link route="admin" class="admin-link" icon="wrench" label="admin_title"}}</li>
|
<li>{{d-link route="admin" class="admin-link" icon="wrench" label="admin_title"}}</li>
|
||||||
<li>
|
<li>
|
||||||
{{#d-link route="adminFlags" class="flagged-posts-link"}}
|
{{#d-link route="adminFlags" class="flagged-posts-link"}}
|
||||||
@ -70,7 +81,9 @@
|
|||||||
|
|
||||||
{{#menu-links omitRule="true"}}
|
{{#menu-links omitRule="true"}}
|
||||||
<li>{{d-link route="about" class="about-link" label="about.simple_title"}}</li>
|
<li>{{d-link route="about" class="about-link" label="about.simple_title"}}</li>
|
||||||
<li>{{d-link path=faqUrl class="faq-link" label="faq"}}</li>
|
{{#if currentUser.read_faq}}
|
||||||
|
<li>{{d-link path=faqUrl class="faq-link" label="faq"}}</li>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if showKeyboardShortcuts}}
|
{{#if showKeyboardShortcuts}}
|
||||||
<li>{{d-link action="keyboardShortcuts" class="keyboard-shortcuts-link" label="keyboard_shortcuts_help.title"}}</li>
|
<li>{{d-link action="keyboardShortcuts" class="keyboard-shortcuts-link" label="keyboard_shortcuts_help.title"}}</li>
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||||
|
import { on } from 'ember-addons/ember-computed-decorators';
|
||||||
var readFaq = false;
|
|
||||||
|
|
||||||
export default Ember.View.extend(ScrollTop, {
|
export default Ember.View.extend(ScrollTop, {
|
||||||
|
|
||||||
_checkRead: function() {
|
@on('didInsertElement')
|
||||||
const path = this.get('controller.model.path');
|
_checkRead() {
|
||||||
if (path === "faq" || path === "guidelines") {
|
const currentUser = this.get('controller.currentUser');
|
||||||
const controller = this.get('controller');
|
if (currentUser) {
|
||||||
$(window).on('load.faq resize.faq scroll.faq', function() {
|
const path = this.get('controller.model.path');
|
||||||
if (!readFaq && isElementInViewport($(".contents p").last())) {
|
if (path === "faq" || path === "guidelines") {
|
||||||
readFaq = true;
|
const controller = this.get('controller');
|
||||||
controller.send('markFaqRead');
|
$(window).on('load.faq resize.faq scroll.faq', function() {
|
||||||
}
|
const faqUnread = !currentUser.get('read_faq');
|
||||||
});
|
if (faqUnread && isElementInViewport($(".contents p").last())) {
|
||||||
|
controller.send('markFaqRead');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.on('didInsertElement'),
|
},
|
||||||
|
|
||||||
_stopChecking: function(){
|
@on('willDestroyElement')
|
||||||
|
_stopChecking() {
|
||||||
$(window).off('load.faq resize.faq scroll.faq');
|
$(window).off('load.faq resize.faq scroll.faq');
|
||||||
}.on('willDestroyElement')
|
}
|
||||||
});
|
});
|
||||||
|
@ -62,6 +62,13 @@
|
|||||||
background-color: dark-light-diff($highlight, $secondary, 50%, -55%);
|
background-color: dark-light-diff($highlight, $secondary, 50%, -55%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new {
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-left: 0.5em;
|
||||||
|
color: dark-light-choose(scale-color($primary, $lightness: 50%), scale-color($secondary, $lightness: 50%));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
li.category-link {
|
li.category-link {
|
||||||
|
@ -572,7 +572,7 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def read_faq
|
def read_faq
|
||||||
if(user = current_user)
|
if user = current_user
|
||||||
user.user_stat.read_faq = 1.second.ago
|
user.user_stat.read_faq = 1.second.ago
|
||||||
user.user_stat.save
|
user.user_stat.save
|
||||||
end
|
end
|
||||||
|
@ -30,12 +30,17 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||||||
:dismissed_banner_key,
|
:dismissed_banner_key,
|
||||||
:is_anonymous,
|
:is_anonymous,
|
||||||
:post_queue_new_count,
|
:post_queue_new_count,
|
||||||
:show_queued_posts
|
:show_queued_posts,
|
||||||
|
:read_faq
|
||||||
|
|
||||||
def include_site_flagged_posts_count?
|
def include_site_flagged_posts_count?
|
||||||
object.staff?
|
object.staff?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_faq
|
||||||
|
object.user_stat.read_faq?
|
||||||
|
end
|
||||||
|
|
||||||
def topic_count
|
def topic_count
|
||||||
object.topics.count
|
object.topics.count
|
||||||
end
|
end
|
||||||
|
@ -952,6 +952,7 @@ en:
|
|||||||
private_messages: "Search messages"
|
private_messages: "Search messages"
|
||||||
|
|
||||||
hamburger_menu: "go to another topic list or category"
|
hamburger_menu: "go to another topic list or category"
|
||||||
|
new_item: "New!"
|
||||||
go_back: 'go back'
|
go_back: 'go back'
|
||||||
not_logged_in_user: 'user page with summary of current activity and preferences'
|
not_logged_in_user: 'user page with summary of current activity and preferences'
|
||||||
current_user: 'go to your user page'
|
current_user: 'go to your user page'
|
||||||
|
Reference in New Issue
Block a user