Skip to content

Commit

Permalink
Merge pull request #1719 from jrjohnson/980-userprofile
Browse files Browse the repository at this point in the history
Add user profile screen
  • Loading branch information
stopfstedt committed May 26, 2016
2 parents 8e0b5ea + 0d44e61 commit 139c393
Show file tree
Hide file tree
Showing 28 changed files with 478 additions and 143 deletions.
7 changes: 2 additions & 5 deletions app/components/ilios-header.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import Ember from 'ember';

const { Component, computed, inject } = Ember;
const { oneWay, equal } = computed;
const { service } = inject;

export default Component.extend({
session: service(),
currentUser: Ember.inject.service(),
i18n: Ember.inject.service(),
userName: oneWay('currentUser.model.fullName'),
inEnglish: equal('i18n.locale', 'en'),
inSpanish: equal('i18n.locale', 'es'),
inFrench: equal('i18n.locale', 'fr'),
classNames: ['ilios-header'],
tagName: 'header',
locales: computed('i18n.locales', 'i18n.locale', function() {
return this.get('i18n.locales').map(locale => {
return { id: locale, text: this.get('i18n').t('language.select.' + locale) };
Expand Down
17 changes: 17 additions & 0 deletions app/components/my-profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Ember from 'ember';

const { computed, RSVP } = Ember;
const { Promise } = RSVP;

export default Ember.Component.extend({
classNames: ['my-profile'],
user: null,
roles: computed('user.roles.[]', function(){
const user = this.get('user');
return new Promise(resolve => {
user.get('roles').then(roles => {
resolve(roles.mapBy('title'));
});
})
}),
});
23 changes: 3 additions & 20 deletions app/components/user-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import ValidationErrorDisplay from 'ilios/mixins/validation-error-display';
import { task } from 'ember-concurrency';

const { computed, Component, inject, RSVP } = Ember;
const { PromiseObject, PromiseArray } = DS;
const { PromiseObject } = DS;
const { service } = inject;
const { sort } = computed;
const { sort, reads } = computed;

const Validations = buildValidations({
firstName: [
Expand Down Expand Up @@ -112,24 +112,7 @@ export default Component.extend(ValidationErrorDisplay, Validations, {
}
}).readOnly(),

secondaryCohorts: computed('user.primaryCohort', 'user.cohorts.[]', {
get() {
const user = this.get('user');

let promise = user.get('cohorts').then((cohorts) => {
return user.get('primaryCohort').then((primaryCohort) => {
if (!primaryCohort) {
return cohorts;
}
return cohorts.filter(cohort => {
return cohort.get('id') !== primaryCohort.get('id');
});
});
});

return PromiseArray.create({ promise });
}
}).readOnly(),
secondaryCohorts: reads('user.secondaryCohorts'),

cohortSorting: [
'programYear.program.school.title:asc',
Expand Down
1 change: 1 addition & 0 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export default {
'saved': 'New User Saved Successfully',
'username': 'Username',
'password': 'Password',
'myProfile': 'My Profile',
},
'language': {
'select': {
Expand Down
1 change: 1 addition & 0 deletions app/locales/es/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export default {
'saved': 'Nuevo Usuario Salvó con Éxito',
'username': 'Nombre de Usuario',
'password': 'Contraseña',
'myProfile': 'Mi Perfil',
},
'language': {
'select': {
Expand Down
1 change: 1 addition & 0 deletions app/locales/fr/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export default {
'saved': 'Nouvel utilisateur enregistré avec succès',
'username': 'Nom d’utilisateur',
'password': 'Mot de passe',
'myProfile': 'Mon profil',
},
'language': {
'select': {
Expand Down
11 changes: 10 additions & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,16 @@ var User = DS.Model.extend({
});

});
}
},
secondaryCohorts: computed('primaryCohort', 'cohorts.[]', function(){
return new Promise(resolve => {
this.get('cohorts').then((cohorts) => {
this.get('primaryCohort').then((primaryCohort) => {
resolve(cohorts.filter(cohort => cohort !== primaryCohort));
});
});
});
})
});

export default User;
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Router.map(function() {
this.route('schools');
this.route('school', { path: 'schools/:school_id'});
this.route('assign-students', {path: '/admin/assignstudents'});
this.route('myprofile');
});

export default Router;
11 changes: 11 additions & 0 deletions app/routes/myprofile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

const { service } = Ember.inject;

export default Ember.Route.extend(AuthenticatedRouteMixin, {
currentUser: service(),
model(){
return this.get('currentUser').get('model');
}
});
1 change: 0 additions & 1 deletion app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@import 'components/reset';
@import 'components/global';
@import 'components/action-menu';
@import 'components/header';
@import 'components/navigation';
@import 'components/table';
@import 'components/searchbox';
Expand Down
15 changes: 0 additions & 15 deletions app/styles/components/_action-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ $dropdown-distance-from-menu: $dropdown-padding * 2;
}
}

&.user-menu .button {
background-color: transparent;
border: 0;
border-radius: $base-border-radius;
color: $white;
font-weight: normal;
padding: .5em 2em .5em 1em;
vertical-align: middle;

&:hover {
background-color: $white;
color: $ilios-orange;
}
}

.dropdown-menu {
@include transition (all .2s ease-in-out);
background-color: $white;
Expand Down
71 changes: 0 additions & 71 deletions app/styles/components/_header.scss

This file was deleted.

2 changes: 2 additions & 0 deletions app/styles/mixins.scss
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
@import 'mixins/ilios-form';
@import 'mixins/profile';
@import 'mixins/header';
84 changes: 84 additions & 0 deletions app/styles/mixins/header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@mixin header () {
$header-height: 60px;

background-color: $ilios-orange;
border-bottom: 1px solid darken($ilios-orange, 10);
height: $header-height;
min-width: 250px;
text-align: center;
vertical-align: bottom;
width: 100%;
z-index: 100;

.logo {
float: left;
max-height: $header-height;
padding-left: 1em;

.image {
background-image: url('images/ilios-logo.png');
background-repeat: no-repeat;
display: block;
height: 42px;
padding: .8em 0;
width: 84px;
}
}

h1 {
color: $white;
display: inline-block;
font-size: $base-font-size * .75;
margin-top: 2em;

@include media($medium-screen) {
font-size: $base-font-size * 1.5;
margin: .5em;
}
}

// Elements on the far right
.tools {
background: transparent;
display: block;
float: right;
padding-left: .5em;
padding-right: 1em;

.user,
.locales {
color: $ilios-orange;
display: inline;
float: left;
font-size: $base-font-size * .8;
font-weight: 800;
margin-top: 1.2em;
padding: .4em .5em;

.button {
background-color: transparent;
border: 0;
border-radius: $base-border-radius;
color: $white;
font-weight: normal;
padding: .5em 2em .5em 1em;
vertical-align: middle;

span {
display: none;

@include media($medium-screen) {
display: inline;
}
}

&:hover {
background-color: $white;
color: $ilios-orange;
}


}
}
}
}
Loading

0 comments on commit 139c393

Please sign in to comment.