From 641f252aa7825dbb48aed22c91543929ed9a2175 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Fri, 6 Dec 2024 15:13:02 -0800 Subject: [PATCH] wip versions of new UserProfileBioDetails and UserProfileBioManager components --- .../components/user-profile-bio-details.hbs | 135 ++++++++ .../components/user-profile-bio-details.js | 35 +++ .../components/user-profile-bio-manager.hbs | 289 ++++++++++++++++++ .../components/user-profile-bio-manager.js | 36 +++ 4 files changed, 495 insertions(+) create mode 100644 packages/frontend/app/components/user-profile-bio-details.hbs create mode 100644 packages/frontend/app/components/user-profile-bio-details.js create mode 100644 packages/frontend/app/components/user-profile-bio-manager.hbs create mode 100644 packages/frontend/app/components/user-profile-bio-manager.js diff --git a/packages/frontend/app/components/user-profile-bio-details.hbs b/packages/frontend/app/components/user-profile-bio-details.hbs new file mode 100644 index 0000000000..5ba2fcea34 --- /dev/null +++ b/packages/frontend/app/components/user-profile-bio-details.hbs @@ -0,0 +1,135 @@ +{{#let (unique-id) as |templateId|}} +
+
+ + + {{@user.firstName}} + +
+
+ + + {{@user.middleName}} + +
+
+ + + {{@user.lastName}} + +
+
+ + + {{@user.campusId}} + +
+
+ + + {{@user.otherId}} + +
+
+ + + {{@user.email}} + +
+
+ + + {{@user.displayName}} + +
+
+ + + {{@user.pronouns}} + +
+
+ + + {{@user.preferredEmail}} + +
+
+ + + {{@user.phone}} + +
+
+ + + {{this.userAuthentication.username}} + +
+ {{#if this.canEditUsernameAndPassword}} +
+ + + {{#if this.userAuthentication.username}} + ********* + {{/if}} + +
+ {{/if}} +
+{{/let}} \ No newline at end of file diff --git a/packages/frontend/app/components/user-profile-bio-details.js b/packages/frontend/app/components/user-profile-bio-details.js new file mode 100644 index 0000000000..6590ef33df --- /dev/null +++ b/packages/frontend/app/components/user-profile-bio-details.js @@ -0,0 +1,35 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +// import { action } from '@ember/object'; +// import { service } from '@ember/service'; +// import { TrackedAsyncData } from 'ember-async-data'; + +export default class UserProfileBioDetailsComponent extends Component { + @tracked firstName; + @tracked middleName; + @tracked lastName; + @tracked campusId; + @tracked otherId; + @tracked email; + @tracked displayName; + @tracked pronouns; + @tracked preferredEmail; + @tracked phone; + @tracked username; + @tracked password; + + constructor() { + super(...arguments); + + this.firstName = this.args.user.firstName; + this.middleName = this.args.user.middleName; + this.lastName = this.args.user.lastName; + this.campusId = this.args.user.campusId; + this.otherId = this.args.user.otherId; + this.email = this.args.user.email; + this.displayName = this.args.user.displayName; + this.pronouns = this.args.user.pronouns; + this.preferredEmail = this.args.user.preferredEmail; + this.phone = this.args.user.phone; + } +} diff --git a/packages/frontend/app/components/user-profile-bio-manager.hbs b/packages/frontend/app/components/user-profile-bio-manager.hbs new file mode 100644 index 0000000000..c6da654af0 --- /dev/null +++ b/packages/frontend/app/components/user-profile-bio-manager.hbs @@ -0,0 +1,289 @@ +{{#let (unique-id) as |templateId|}} +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+ + {{#unless this.canEditUsernameAndPassword}} + + {{/unless}} + +
+ {{#if this.showSyncErrorMessage}} + + {{t "general.unableToSyncUser"}} + + {{/if}} +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + + {{#if this.showUsernameTakenErrorMessage}} + + {{t "errors.duplicateUsername"}} + + {{/if}} +
+ {{#if this.canEditUsernameAndPassword}} +
+ + {{#if this.changeUserPassword}} + + {{#if this.hasErrorForPassword}} + + {{else if (gt this.password.length 0)}} + + {{#if (eq this.passwordStrengthScore 0)}} + {{t "general.tryHarder"}} + {{else if (eq this.passwordStrengthScore 1)}} + {{t "general.bad"}} + {{else if (eq this.passwordStrengthScore 2)}} + {{t "general.weak"}} + {{else if (eq this.passwordStrengthScore 3)}} + {{t "general.good"}} + {{else if (eq this.passwordStrengthScore 4)}} + {{t "general.strong"}} + {{/if}} + + + {{/if}} + + {{else}} + + {{/if}} +
+ {{/if}} +
+{{/let}} \ No newline at end of file diff --git a/packages/frontend/app/components/user-profile-bio-manager.js b/packages/frontend/app/components/user-profile-bio-manager.js new file mode 100644 index 0000000000..e6a403e80d --- /dev/null +++ b/packages/frontend/app/components/user-profile-bio-manager.js @@ -0,0 +1,36 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +// import { action } from '@ember/object'; +// import { service } from '@ember/service'; +// import { TrackedAsyncData } from 'ember-async-data'; +import { ValidateIf } from 'class-validator'; +import { validatable, IsEmail, NotBlank, Length } from 'ilios-common/decorators/validation'; + +@validatable +export default class UserProfileBioManagerComponent extends Component { + @tracked @Length(1, 50) @NotBlank() firstName; + @tracked @Length(0, 20) middleName; + @tracked @Length(1, 50) @NotBlank() lastName; + @tracked @Length(0, 16) campusId; + @tracked @Length(0, 16) otherId; + @tracked @IsEmail() @Length(1, 100) @NotBlank() email; + @tracked @Length(0, 200) displayName; + @tracked @Length(0, 50) pronouns; + @tracked @IsEmail() @Length(0, 100) preferredEmail; + @tracked @Length(0, 20) phone; + @tracked + @Length(1, 100) + @NotBlank() + username; + @tracked + @ValidateIf((o) => o.canEditUsernameAndPassword && o.changeUserPassword) + @Length(5) + @NotBlank() + password; + + @tracked showSyncErrorMessage = false; + @tracked showUsernameTakenErrorMessage = false; + @tracked changeUserPassword = false; + @tracked updatedFieldsFromSync = []; + @tracked passwordStrengthScore = 0; +}