Compare commits
5 Commits
main
...
a-template
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ede1f4bf6f | ||
|
|
436cee1ad2 | ||
|
|
190d858edb | ||
|
|
7e50e76892 | ||
|
|
83a7a95686 |
@ -0,0 +1,39 @@
|
||||
<DSection @bodyClass={{this.bodyClass}} @class="container">
|
||||
<WatchRead @action={{action "markFaqRead"}} @path={{@model.path}}>
|
||||
<div class="contents clearfix body-page">
|
||||
<PluginOutlet
|
||||
@name="above-static"
|
||||
@tagName="span"
|
||||
@connectorTagName="div"
|
||||
/>
|
||||
|
||||
{{html-safe @model.html}}
|
||||
|
||||
<PluginOutlet
|
||||
@name="below-static"
|
||||
@connectorTagName="div"
|
||||
/>
|
||||
|
||||
{{#if this.anyButtons}}
|
||||
<div class="body-page-button-container">
|
||||
{{#if this.showSignupButton}}
|
||||
<DButton
|
||||
@action={{route-action "showCreateAccount"}}
|
||||
@class="btn-primary sign-up-button"
|
||||
@label="sign_up"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showLoginButton}}
|
||||
<DButton
|
||||
@action={{route-action "showLogin"}}
|
||||
@class="btn-primary login-button"
|
||||
@icon="user"
|
||||
@label="log_in"
|
||||
/>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</WatchRead>
|
||||
</DSection>
|
||||
@ -0,0 +1,28 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { equal, or } from "@ember/object/computed";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
|
||||
export default class StaticPage extends Component {
|
||||
@equal("model.path", "login") showLoginButton;
|
||||
@or("showLoginButton", "showSignupButton") anyButtons;
|
||||
|
||||
get bodyClass() {
|
||||
return `static-${this.args.model.path}`;
|
||||
}
|
||||
|
||||
get showSignupButton() {
|
||||
const application = getOwner(this).lookup("controller:application");
|
||||
return this.args.model.path === "login" && application.canSignUp;
|
||||
}
|
||||
|
||||
@action
|
||||
async markFaqRead() {
|
||||
if (this.currentUser) {
|
||||
await ajax(userPath("read-faq"), { type: "POST" });
|
||||
this.currentUser.set("read_faq", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { equal, or } from "@ember/object/computed";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
|
||||
export default Controller.extend({
|
||||
application: controller(),
|
||||
|
||||
showLoginButton: equal("model.path", "login"),
|
||||
anyButtons: or("showLoginButton", "showSignupButton"),
|
||||
|
||||
@discourseComputed("model.path")
|
||||
bodyClass: (path) => `static-${path}`,
|
||||
|
||||
@discourseComputed("model.path")
|
||||
showSignupButton() {
|
||||
return (
|
||||
this.get("model.path") === "login" && this.get("application.canSignUp")
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
markFaqRead() {
|
||||
const currentUser = this.currentUser;
|
||||
if (currentUser) {
|
||||
ajax(userPath("read-faq"), { type: "POST" }).then(() => {
|
||||
currentUser.set("read_faq", true);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -11,9 +11,8 @@ const configs = {
|
||||
|
||||
export default function (page) {
|
||||
return DiscourseRoute.extend({
|
||||
renderTemplate() {
|
||||
this.render("static");
|
||||
},
|
||||
templateName: "static",
|
||||
controllerName: "static",
|
||||
|
||||
beforeModel(transition) {
|
||||
const configKey = configs[page];
|
||||
|
||||
@ -5,11 +5,7 @@ import { action } from "@ember/object";
|
||||
|
||||
export default function (filter) {
|
||||
return DiscourseRoute.extend({
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-posts")._showFooter();
|
||||
return true;
|
||||
},
|
||||
templateName: "user/posts",
|
||||
|
||||
model() {
|
||||
return this.modelFor("user").get("postsStream");
|
||||
@ -32,8 +28,10 @@ export default function (filter) {
|
||||
this.controllerFor("user-posts").set("model", model);
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("user/posts");
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-posts")._showFooter();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -2,18 +2,11 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||
import StaticPage from "discourse/models/static-page";
|
||||
|
||||
export default function (pageName) {
|
||||
const route = {
|
||||
return DiscourseRoute.extend({
|
||||
templateName: "static",
|
||||
|
||||
model() {
|
||||
return StaticPage.find(pageName);
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("static");
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
this.controllerFor("static").set("model", model);
|
||||
},
|
||||
};
|
||||
return DiscourseRoute.extend(route);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import UnknownRoute from "discourse/routes/unknown";
|
||||
|
||||
export default UnknownRoute.extend({
|
||||
renderTemplate() {
|
||||
this.render("unknown");
|
||||
},
|
||||
templateName: "unknown",
|
||||
});
|
||||
|
||||
@ -5,6 +5,7 @@ import { action, get } from "@ember/object";
|
||||
export function buildGroupPage(type) {
|
||||
return DiscourseRoute.extend({
|
||||
type,
|
||||
templateName: "group-activity-posts",
|
||||
|
||||
titleToken() {
|
||||
return I18n.t(`groups.${type}`);
|
||||
@ -25,10 +26,6 @@ export function buildGroupPage(type) {
|
||||
this.controllerFor("application").set("showFooter", loadedAll);
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("group-activity-posts");
|
||||
},
|
||||
|
||||
@action
|
||||
didTransition() {
|
||||
return true;
|
||||
|
||||
@ -4,6 +4,8 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
templateName: "user_bookmarks",
|
||||
|
||||
queryParams: {
|
||||
acting_username: { refreshModel: true },
|
||||
q: { refreshModel: true },
|
||||
@ -46,10 +48,6 @@ export default DiscourseRoute.extend({
|
||||
.finally(() => controller.set("loading", false));
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("user_bookmarks");
|
||||
},
|
||||
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("user-activity")._showFooter();
|
||||
|
||||
@ -3,6 +3,8 @@ import I18n from "I18n";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
templateName: "user_stream",
|
||||
|
||||
model() {
|
||||
const user = this.modelFor("user");
|
||||
const draftsStream = user.get("userDraftsStream");
|
||||
@ -16,10 +18,6 @@ export default DiscourseRoute.extend({
|
||||
});
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("user_stream");
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
},
|
||||
|
||||
@ -4,6 +4,8 @@ import { action } from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend(ViewingActionType, {
|
||||
templateName: "user_stream",
|
||||
|
||||
queryParams: {
|
||||
acting_username: { refreshModel: true },
|
||||
},
|
||||
@ -29,10 +31,6 @@ export default DiscourseRoute.extend(ViewingActionType, {
|
||||
});
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("user_stream");
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
this.viewingActionType(this.userActionType);
|
||||
|
||||
@ -4,6 +4,8 @@ import ViewingActionType from "discourse/mixins/viewing-action-type";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend(ViewingActionType, {
|
||||
templateName: "user/badges",
|
||||
|
||||
model() {
|
||||
return UserBadge.findByUsername(
|
||||
this.modelFor("user").get("username_lower"),
|
||||
@ -16,10 +18,6 @@ export default DiscourseRoute.extend(ViewingActionType, {
|
||||
controller.set("model", model);
|
||||
},
|
||||
|
||||
renderTemplate() {
|
||||
this.render("user/badges");
|
||||
},
|
||||
|
||||
@action
|
||||
didTransition() {
|
||||
this.controllerFor("application").set("showFooter", true);
|
||||
|
||||
@ -2,9 +2,7 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
controllerName: "user-notifications",
|
||||
renderTemplate() {
|
||||
this.render("user/notifications-index");
|
||||
},
|
||||
templateName: "user/notifications-index",
|
||||
|
||||
afterModel(model) {
|
||||
if (!model) {
|
||||
|
||||
@ -4,9 +4,7 @@ import Draft from "discourse/models/draft";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
renderTemplate() {
|
||||
this.render("user/messages");
|
||||
},
|
||||
templateName: "user/messages",
|
||||
|
||||
model() {
|
||||
return this.modelFor("user");
|
||||
|
||||
@ -3,9 +3,8 @@ import ViewingActionType from "discourse/mixins/viewing-action-type";
|
||||
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||
|
||||
export default DiscourseRoute.extend(ViewingActionType, {
|
||||
renderTemplate() {
|
||||
this.render("user-topics-list");
|
||||
},
|
||||
templateName: "user-topics-list",
|
||||
controllerName: "user-topics-list",
|
||||
|
||||
setupController(controller, model) {
|
||||
setTopicList(model);
|
||||
|
||||
@ -1,24 +1 @@
|
||||
<DSection @bodyClass={{this.bodyClass}} @class="container">
|
||||
<WatchRead @action={{action "markFaqRead"}} @path={{this.model.path}}>
|
||||
<div class="contents clearfix body-page">
|
||||
|
||||
<PluginOutlet @name="above-static" @tagName="span" @connectorTagName="div" />
|
||||
|
||||
{{html-safe this.model.html}}
|
||||
|
||||
<PluginOutlet @name="below-static" @connectorTagName="div" />
|
||||
|
||||
{{#if this.anyButtons}}
|
||||
<div class="body-page-button-container">
|
||||
{{#if this.showSignupButton}}
|
||||
<DButton @action={{route-action "showCreateAccount"}} @class="btn-primary sign-up-button" @label="sign_up" />
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showLoginButton}}
|
||||
<DButton @action={{route-action "showLogin"}} @class="btn-primary login-button" @icon="user" @label="log_in" />
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</WatchRead>
|
||||
</DSection>
|
||||
<StaticPage @model={{this.model}} />
|
||||
|
||||
Reference in New Issue
Block a user