UX: Add title to user messages page.

This commit is contained in:
Guo Xiang Tan 2018-03-07 15:24:11 +08:00
parent d02e2cbcca
commit c6cb7f6693
3 changed files with 67 additions and 40 deletions

View File

@ -5,6 +5,11 @@ export default (viewName, path, channel) => {
return UserTopicListRoute.extend({
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: {
didTransition() {
this.controllerFor("user-topics-list")._showFooter();

View File

@ -1,27 +1,41 @@
import createPMRoute from "discourse/routes/build-private-messages-route";
export default createPMRoute('groups', 'private-messages-groups').extend({
model(params) {
const username = this.modelFor("user").get("username_lower");
return this.store.findFiltered("topicList", {
filter: `topics/private-messages-group/${username}/${params.name}/archive`
});
},
groupName: null,
afterModel(model) {
const split = model.get("filter").split('/');
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);
},
titleToken() {
const groupName = this.get('groupName');
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`);
}
if (groupName) {
return [
`${groupName.capitalize()} ${I18n.t('user.messages.archive')}`,
I18n.t("user.private_messages")
];
};
},
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`);
}
});

View File

@ -1,25 +1,33 @@
import createPMRoute from "discourse/routes/build-private-messages-route";
export default createPMRoute('groups', 'private-messages-groups').extend({
model(params) {
const username = this.modelFor("user").get("username_lower");
return this.store.findFiltered("topicList", {
filter: `topics/private-messages-group/${username}/${params.name}`
});
},
groupName: null,
afterModel(model) {
const groupName = _.last(model.get("filter").split('/'));
const groups = this.modelFor("user").get("groups");
const group = _.first(groups.filterBy("name", groupName));
this.controllerFor("user-private-messages").set("group", group);
},
titleToken() {
const groupName = this.get('groupName');
if (groupName) return [groupName.capitalize(), I18n.t("user.private_messages")];
},
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}`);
}
model(params) {
const username = this.modelFor("user").get("username_lower");
return this.store.findFiltered("topicList", {
filter: `topics/private-messages-group/${username}/${params.name}`
});
},
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}`);
}
});