Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/frontend/app/components/user-profile.gjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';
import ManageUsersSummary from 'frontend/components/manage-users-summary';
import t from 'ember-intl/helpers/t';
Expand All @@ -8,7 +7,6 @@ import UserStatus from 'ilios-common/components/user-status';
import PendingSingleUserUpdate from 'frontend/components/pending-single-user-update';
import ToggleButtons from 'ilios-common/components/toggle-buttons';
import not from 'ember-truth-helpers/helpers/not';
import toggle from 'ilios-common/helpers/toggle';
import UserProfileCalendar from 'frontend/components/user-profile-calendar';
import UserProfileBio from 'frontend/components/user-profile-bio';
import UserProfileRoles from 'frontend/components/user-profile-roles';
Expand All @@ -20,7 +18,6 @@ import LearnerGroups from 'frontend/components/user-profile/learner-groups';

export default class UserProfileComponent extends Component {
@service currentUser;
@tracked showCalendar = false;

get userIsTheCurrentUser() {
return Number(this.currentUser.currentUserId) === Number(this.args.user.id);
Expand All @@ -44,14 +41,14 @@ export default class UserProfileComponent extends Component {
<PendingSingleUserUpdate @user={{@user}} @canUpdate={{@canUpdate}} />
<div class="user-profile-actions" data-test-user-profile-actions>
<ToggleButtons
@firstOptionSelected={{not this.showCalendar}}
@firstOptionSelected={{not @showCalendar}}
@firstLabel={{t "general.hideCalendar"}}
@secondLabel={{t "general.showCalendar"}}
@toggle={{toggle "showCalendar" this}}
@toggle={{@setShowCalendar}}
/>
</div>
<div class="blocks">
{{#if this.showCalendar}}
{{#if @showCalendar}}
<UserProfileCalendar @user={{@user}} />
{{/if}}
<UserProfileBio
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/app/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class UserController extends Controller {
@service iliosConfig;

queryParams = [
'showCalendar',
'isManagingBio',
'isManagingRoles',
'isManagingCohorts',
Expand All @@ -18,6 +19,7 @@ export default class UserController extends Controller {
'permissionsSchool',
'permissionsYear',
];
@tracked showCalendar = false;
@tracked isManagingBio = false;
@tracked isManagingRoles = false;
@tracked isManagingCohorts = false;
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/app/templates/user.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import pageTitle from 'ember-page-title/helpers/page-title';
import t from 'ember-intl/helpers/t';
import UserProfile from 'frontend/components/user-profile';
import set from 'ember-set-helper/helpers/set';
import toggle from 'ilios-common/helpers/toggle';
<template>
{{pageTitle (t "general.admin") " | " (t "general.users") " | " @model.fullName}}
<UserProfile
@user={{@model}}
@canUpdate={{@controller.canUpdate}}
@canCreate={{@controller.canCreate}}
@showCalendar={{@controller.showCalendar}}
@setShowCalendar={{toggle "showCalendar" @controller}}
@isManagingBio={{@controller.isManagingBio}}
@setIsManagingBio={{set @controller "isManagingBio"}}
@isManagingRoles={{@controller.isManagingRoles}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,19 @@ module('Integration | Component | user-profile', function (hooks) {
const user = this.server.create('user');
const userModel = await this.owner.lookup('service:store').findRecord('user', user.id);
this.set('user', userModel);
this.set('showCalendar', false);
this.set('setShowCalendar', () => {
this.set('showCalendar', !this.showCalendar);
});

await render(
<template>
<UserProfile
@user={{this.user}}
@canUpdate={{false}}
@canCreate={{false}}
@showCalendar={{this.showCalendar}}
@setShowCalendar={{this.setShowCalendar}}
@isManagingBio={{false}}
@setIsManagingBio={{(noop)}}
@isManagingRoles={{false}}
Expand All @@ -125,14 +131,28 @@ module('Integration | Component | user-profile', function (hooks) {
</template>,
);

assert.notOk(component.calendar.isVisible);
assert.strictEqual(component.actions.calendarToggle.firstLabel.text, 'Hide Calendar');
assert.ok(component.actions.calendarToggle.firstButton.isChecked);
assert.strictEqual(component.actions.calendarToggle.secondLabel.text, 'Show Calendar');
assert.notOk(component.actions.calendarToggle.secondButton.isChecked);
assert.notOk(component.calendar.isVisible, 'calendar is not visible');
assert.strictEqual(
component.actions.calendarToggle.firstLabel.text,
'Hide Calendar',
'first toggle button label is correct',
);
assert.ok(
component.actions.calendarToggle.firstButton.isChecked,
'first toggle button is checked',
);
assert.strictEqual(
component.actions.calendarToggle.secondLabel.text,
'Show Calendar',
'second toggle button label is correct',
);
assert.notOk(
component.actions.calendarToggle.secondButton.isChecked,
'second toggle button is not checked',
);
await component.actions.calendarToggle.secondButton.click();
assert.ok(component.calendar.isVisible);
assert.ok(component.calendar.isVisible, 'calendar is visible after toggle');
await component.actions.calendarToggle.firstButton.click();
assert.notOk(component.calendar.isVisible);
assert.notOk(component.calendar.isVisible, 'calendar is not visible after toggle');
});
});