UX: Add title to user messages page.
This commit is contained in:
parent
d02e2cbcca
commit
c6cb7f6693
|
@ -5,6 +5,11 @@ export default (viewName, path, channel) => {
|
||||||
return UserTopicListRoute.extend({
|
return UserTopicListRoute.extend({
|
||||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||||
|
|
||||||
|
titleToken() {
|
||||||
|
const key = viewName === "index" ? "inbox" : viewName;
|
||||||
|
return [I18n.t(`user.messages.${key}`), I18n.t("user.private_messages")];
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
didTransition() {
|
didTransition() {
|
||||||
this.controllerFor("user-topics-list")._showFooter();
|
this.controllerFor("user-topics-list")._showFooter();
|
||||||
|
|
|
@ -1,27 +1,41 @@
|
||||||
import createPMRoute from "discourse/routes/build-private-messages-route";
|
import createPMRoute from "discourse/routes/build-private-messages-route";
|
||||||
|
|
||||||
export default createPMRoute('groups', 'private-messages-groups').extend({
|
export default createPMRoute('groups', 'private-messages-groups').extend({
|
||||||
model(params) {
|
groupName: null,
|
||||||
const username = this.modelFor("user").get("username_lower");
|
|
||||||
return this.store.findFiltered("topicList", {
|
|
||||||
filter: `topics/private-messages-group/${username}/${params.name}/archive`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
afterModel(model) {
|
titleToken() {
|
||||||
const split = model.get("filter").split('/');
|
const groupName = this.get('groupName');
|
||||||
const groupName = split[split.length-2];
|
|
||||||
const groups = this.modelFor("user").get("groups");
|
|
||||||
const group = _.first(groups.filterBy("name", groupName));
|
|
||||||
this.controllerFor("user-private-messages").set("group", group);
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController(controller, model) {
|
if (groupName) {
|
||||||
this._super.apply(this, arguments);
|
return [
|
||||||
const split = model.get("filter").split('/');
|
`${groupName.capitalize()} ${I18n.t('user.messages.archive')}`,
|
||||||
const group = split[split.length-2];
|
I18n.t("user.private_messages")
|
||||||
this.controllerFor("user-private-messages").set("groupFilter", group);
|
];
|
||||||
this.controllerFor("user-private-messages").set("archive", true);
|
};
|
||||||
this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}/archive`);
|
},
|
||||||
}
|
|
||||||
|
model(params) {
|
||||||
|
const username = this.modelFor("user").get("username_lower");
|
||||||
|
return this.store.findFiltered("topicList", {
|
||||||
|
filter: `topics/private-messages-group/${username}/${params.name}/archive`
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
afterModel(model) {
|
||||||
|
const split = model.get("filter").split('/');
|
||||||
|
const groupName = split[split.length-2];
|
||||||
|
this.set("groupName", groupName);
|
||||||
|
const groups = this.modelFor("user").get("groups");
|
||||||
|
const group = _.first(groups.filterBy("name", groupName));
|
||||||
|
this.controllerFor("user-private-messages").set("group", group);
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController(controller, model) {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
const split = model.get("filter").split('/');
|
||||||
|
const group = split[split.length-2];
|
||||||
|
this.controllerFor("user-private-messages").set("groupFilter", group);
|
||||||
|
this.controllerFor("user-private-messages").set("archive", true);
|
||||||
|
this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}/archive`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
import createPMRoute from "discourse/routes/build-private-messages-route";
|
import createPMRoute from "discourse/routes/build-private-messages-route";
|
||||||
|
|
||||||
export default createPMRoute('groups', 'private-messages-groups').extend({
|
export default createPMRoute('groups', 'private-messages-groups').extend({
|
||||||
model(params) {
|
groupName: null,
|
||||||
const username = this.modelFor("user").get("username_lower");
|
|
||||||
return this.store.findFiltered("topicList", {
|
|
||||||
filter: `topics/private-messages-group/${username}/${params.name}`
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
afterModel(model) {
|
titleToken() {
|
||||||
const groupName = _.last(model.get("filter").split('/'));
|
const groupName = this.get('groupName');
|
||||||
const groups = this.modelFor("user").get("groups");
|
if (groupName) return [groupName.capitalize(), I18n.t("user.private_messages")];
|
||||||
const group = _.first(groups.filterBy("name", groupName));
|
},
|
||||||
this.controllerFor("user-private-messages").set("group", group);
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController(controller, model) {
|
model(params) {
|
||||||
this._super.apply(this, arguments);
|
const username = this.modelFor("user").get("username_lower");
|
||||||
const group = _.last(model.get("filter").split('/'));
|
return this.store.findFiltered("topicList", {
|
||||||
this.controllerFor("user-private-messages").set("groupFilter", group);
|
filter: `topics/private-messages-group/${username}/${params.name}`
|
||||||
this.controllerFor("user-private-messages").set("archive", false);
|
});
|
||||||
this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}`);
|
},
|
||||||
}
|
|
||||||
|
afterModel(model) {
|
||||||
|
const groupName = _.last(model.get("filter").split('/'));
|
||||||
|
this.set("groupName", groupName);
|
||||||
|
const groups = this.modelFor("user").get("groups");
|
||||||
|
const group = _.first(groups.filterBy("name", groupName));
|
||||||
|
this.controllerFor("user-private-messages").set("group", group);
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController(controller, model) {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
const group = _.last(model.get("filter").split('/'));
|
||||||
|
this.controllerFor("user-private-messages").set("groupFilter", group);
|
||||||
|
this.controllerFor("user-private-messages").set("archive", false);
|
||||||
|
this.controllerFor("user-topics-list").subscribe(`/private-messages/group/${group}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue