From 131a437f679d57b7b5842c7205617926d0d077fc Mon Sep 17 00:00:00 2001 From: Leonard Martin Date: Thu, 3 Jan 2019 16:35:31 +0000 Subject: [PATCH 1/3] Add global profile page Adds an empty page that allows asru users to see the profile of any user within the system, irrespective of establishment affiliations. --- lib/app.js | 2 ++ lib/urls.js | 3 +++ pages/profile/content/index.js | 1 + pages/profile/index.js | 22 ++++++++++++++++++++++ pages/profile/views/index.jsx | 13 +++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 pages/profile/content/index.js create mode 100644 pages/profile/index.js create mode 100644 pages/profile/views/index.jsx diff --git a/lib/app.js b/lib/app.js index b96fca61..c4ce5cc8 100644 --- a/lib/app.js +++ b/lib/app.js @@ -12,6 +12,7 @@ const { const dashboard = require('../pages/dashboard'); const search = require('../pages/search'); +const globalProfile = require('../pages/profile'); const urls = require('./urls'); @@ -42,6 +43,7 @@ module.exports = settings => { app.use(urls.dashboard, dashboard(settings)); app.use(urls.search, search(settings)); + app.use(urls.global.profile, globalProfile()); app.use((req, res, next) => { req.breadcrumb('dashboard'); diff --git a/lib/urls.js b/lib/urls.js index 83d5e528..e955680c 100644 --- a/lib/urls.js +++ b/lib/urls.js @@ -1,6 +1,9 @@ module.exports = { dashboard: '/', search: '/search(/:searchType)?', + global: { + profile: '/profile/:profileId' + }, account: { menu: '/account', edit: '/account/edit' diff --git a/pages/profile/content/index.js b/pages/profile/content/index.js new file mode 100644 index 00000000..f053ebf7 --- /dev/null +++ b/pages/profile/content/index.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/pages/profile/index.js b/pages/profile/index.js new file mode 100644 index 00000000..5971106d --- /dev/null +++ b/pages/profile/index.js @@ -0,0 +1,22 @@ +const { page } = require('@asl/service/ui'); + +module.exports = settings => { + const app = page({ + ...settings, + root: __dirname + }); + + app.get('/', (req, res, next) => { + req.breadcrumb('profile.view'); + return req.api(`/profile/${req.profileId}`) + .then(({ json: { data, meta } }) => { + res.locals.model = data; + }) + .then(() => next()) + .catch(next); + }); + + app.get('/', (req, res) => res.sendResponse()); + + return app; +}; diff --git a/pages/profile/views/index.jsx b/pages/profile/views/index.jsx new file mode 100644 index 00000000..f3914630 --- /dev/null +++ b/pages/profile/views/index.jsx @@ -0,0 +1,13 @@ +import React, { Fragment } from 'react'; +import { connect } from 'react-redux'; +import { Header } from '@asl/components'; + +const Index = ({ model }) => ( + +
+ +); + +const mapStateToProps = ({ model }) => ({ model }); + +export default connect(mapStateToProps)(Index); From ca4b343ebcad5cea5b5f3e9b0bd4776cb7d35507 Mon Sep 17 00:00:00 2001 From: Leonard Martin Date: Fri, 4 Jan 2019 09:50:31 +0000 Subject: [PATCH 2/3] Add link to profile page from people search results --- pages/search/views/index.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pages/search/views/index.jsx b/pages/search/views/index.jsx index 7d41384b..739130b7 100644 --- a/pages/search/views/index.jsx +++ b/pages/search/views/index.jsx @@ -6,15 +6,23 @@ import SearchPanel from '../../components/search-panel'; const formatters = { establishments: { name: { - format: (name, establishment) => + format: (name, establishment) => { + return ; + } } }, profiles: { lastName: { - format: (lastName, profile) => `${profile.firstName} ${lastName}` + format: (lastName, profile) => { + return ; + } }, establishments: { - format: establishments => establishments.map(establishment => establishment.name).join(', ') + format: establishments => establishments.map((establishment, i) => [ + // separate links with line breaks #hack + i > 0 &&
, + + ]) } }, projects: {} From 982e6c5c1291a0fbcbb45cf5dda7f156b83fbc2d Mon Sep 17 00:00:00 2001 From: Leonard Martin Date: Fri, 4 Jan 2019 11:21:46 +0000 Subject: [PATCH 3/3] Fix dashboard breadcrumb Need to ensure that the homepage breadcrumb appears on all pages, so need to sit above any other mounted pages. --- lib/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/app.js b/lib/app.js index c4ce5cc8..05a92c12 100644 --- a/lib/app.js +++ b/lib/app.js @@ -42,14 +42,15 @@ module.exports = settings => { }); app.use(urls.dashboard, dashboard(settings)); - app.use(urls.search, search(settings)); - app.use(urls.global.profile, globalProfile()); app.use((req, res, next) => { req.breadcrumb('dashboard'); next(); }); + app.use(urls.search, search(settings)); + app.use(urls.global.profile, globalProfile()); + app.use(urls.account.menu, user()); app.use(urls.feedback, feedback(settings));