Skip to content

Commit

Permalink
Merge pull request #1153 from ORCID/member-update
Browse files Browse the repository at this point in the history
Member update
  • Loading branch information
bobcaprice authored Apr 8, 2024
2 parents 1f25fbb + a151577 commit d21f18d
Show file tree
Hide file tree
Showing 27 changed files with 11,619 additions and 5,191 deletions.
24 changes: 6 additions & 18 deletions ui/src/app/affiliation/affiliation-update.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,8 @@
(editForm.get('departmentName')?.dirty || editForm.get('departmentName')?.touched)
"
>
<small
class="form-text text-danger"
*ngIf="(editForm.get('departmentName')?.errors)!['maxlength']"
i18n="@@entity.validation.maxlength.string"
>
This field cannot be longer than 4000 characters.
<small class="form-text text-danger" *ngIf="(editForm.get('departmentName')?.errors)!['maxlength']">
{{ maxChars4000 }}
</small>
</div>
</div>
Expand All @@ -271,12 +267,8 @@
(editForm.get('roleTitle')?.dirty || editForm.get('roleTitle')?.touched)
"
>
<small
class="form-text text-danger"
*ngIf="(editForm.get('roleTitle')?.errors)!['maxlength']"
i18n="@@entity.validation.maxlength.string"
>
This field cannot be longer than 4000 characters.
<small class="form-text text-danger" *ngIf="(editForm.get('roleTitle')?.errors)!['maxlength']">
{{ maxChars4000 }}
</small>
</div>
</div>
Expand All @@ -286,12 +278,8 @@
>
<input type="text" class="form-control" name="url" id="field_url" formControlName="url" />
<div *ngIf="editForm.get('url')?.invalid && (editForm.get('url')?.dirty || editForm.get('url')?.touched)">
<small
class="form-text text-danger"
*ngIf="(editForm.get('url')?.errors)!['maxlength']"
i18n="@@entity.validation.maxlength.string"
>
This field cannot be longer than 8000 characters.
<small class="form-text text-danger" *ngIf="(editForm.get('url')?.errors)!['maxlength']">
{{ maxChars8000 }}
</small>
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions ui/src/app/affiliation/affiliation-update.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'
import { AffiliationUpdateComponent } from './affiliation-update.component'
import { HttpClientModule } from '@angular/common/http'
import { RouterTestingModule } from '@angular/router/testing'
import { NO_ERRORS_SCHEMA } from '@angular/core'
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import { LocalizePipe } from '../shared/pipe/localize'
import { AffiliationService } from './service/affiliation.service'
import { ReactiveFormsModule } from '@angular/forms'
import { of } from 'rxjs'
import { DateUtilService } from '../shared/service/date-util.service'

describe('AffiliationUpdateComponent', () => {
Expand All @@ -33,7 +32,7 @@ describe('AffiliationUpdateComponent', () => {
{ provide: AffiliationService, useValue: affiliationServiceSpy },
{ provide: DateUtilService, useValue: dateUtilServiceSpy },
],
schemas: [NO_ERRORS_SCHEMA],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents()
affiliationService = TestBed.inject(AffiliationService) as jasmine.SpyObj<AffiliationService>
dateUtilService = TestBed.inject(DateUtilService) as jasmine.SpyObj<DateUtilService>
Expand Down
10 changes: 10 additions & 0 deletions ui/src/app/affiliation/affiliation-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export class AffiliationUpdateComponent implements OnInit {
ngbDate: any
faBan = faBan
faSave = faSave
maxChars4000 = ''
maxChars8000 = ''

editForm = this.fb.group(
{
Expand Down Expand Up @@ -174,6 +176,7 @@ export class AffiliationUpdateComponent implements OnInit {
) {}

ngOnInit() {
this.localizeString()
this.startYearsList = this.dateUtilService.getYearsList(0)
this.endYearsList = this.dateUtilService.getYearsList(DEFAULT_LATEST_YEAR_INCREMENT)
this.monthsList = this.dateUtilService.getMonthsList()
Expand All @@ -187,6 +190,13 @@ export class AffiliationUpdateComponent implements OnInit {
this.onChanges()
}

localizeString() {
let maxCharLimit = 4000
this.maxChars4000 = $localize`:@@entity.validation.maxlength.string:This field cannot be longer than ${maxCharLimit} characters.`
maxCharLimit = 8000
this.maxChars8000 = $localize`:@@entity.validation.maxlength.string:This field cannot be longer than ${maxCharLimit} characters.`
}

onChanges(): void {
this.editForm.get('startMonth')?.valueChanges.subscribe((val) => {
this.startDaysList = this.dateUtilService.getDaysList(
Expand Down
3 changes: 3 additions & 0 deletions ui/src/app/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export enum AlertType {
USER_CREATED = 'User created. Invite sent.',
USER_UPDATED = 'User updated successfully',
USER_DELETED = 'User deleted successfully',
MEMBER_CREATED = 'Member created',
MEMBER_UPDATED = 'Member updated successfully',
NOTIFICATION_IN_PROGRESS = 'Notification in progress',
AFFILIATION_CREATED = 'Affiliation created',
AFFILIATION_UPDATED = 'Affiliation updated',
Expand All @@ -42,6 +44,7 @@ export function emailValidator(control: FormControl): { [key: string]: any } | n
}
const environment = window.location.hostname.replace('member-portal.', '').replace('.orcid.org', '')
export const ORCID_BASE_URL = 'https://' + environment + '.orcid.org'
export const BASE_URL = window.location.origin

// eslint-disable-next-line
export const EMAIL_REGEXP = /^([^@\s]|(".+"))+@([^@\s\."'\(\)\[\]\{\}\\/,:;]+\.)+([^@\s\."'\(\)\[\]\{\}\\/,:;]{2,})+$/
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/landing-page/landing-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class LandingPageComponent implements OnInit {
'&scope=/read-limited /activities/update /person/update openid&prompt=login&state=' +
state_param

this.incorrectDataMessage = $localize`:@@landingPage.success.ifYouFind:If you find that data added to your ORCID record is incorrect, please contact ${this.clientName}`
this.incorrectDataMessage = $localize`:@@landingPage.success.ifYouFind.string:If you find that data added to your ORCID record is incorrect, please contact ${this.clientName}`
this.linkAlreadyUsedMessage = $localize`:@@landingPage.connectionExists.differentUser.string:This authorization link has already been used. Please contact ${this.clientName} for a new authorization link.`
this.allowToUpdateRecordMessage = $localize`:@@landingPage.denied.grantAccess.string:Allow ${this.clientName} to update my ORCID record.`
this.successfullyGrantedMessage = $localize`:@@landingPage.success.youHaveSuccessfully.string:You have successfully granted ${this.clientName} permission to update your ORCID record, and your record has been updated with affiliation information.`
Expand Down
194 changes: 194 additions & 0 deletions ui/src/app/member/member-update.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<div class="row justify-content-center">
<div class="col-8">
<form name="editForm" role="form" novalidate (ngSubmit)="save()" [formGroup]="editForm">
<h1
id="jhi-ms-member-heading"
class="mt-5"
i18n="@@gatewayApp.msUserServiceMSMember.home.createOrEditLabel.string"
>
Add or edit member
</h1>
<div>
<app-error-alert></app-error-alert>
<div class="alerts top right" role="alert" *ngIf="validation.errors && validation.errors.length > 0">
<ngb-alert
class="alert alert-danger alert-dismissible"
role="alert"
ng-reflect-type="danger"
(close)="validation.errors = null"
[dismissible]="false"
>
<ul class="validation-errors">
<li *ngFor="let error of validation.errors">
{{ error }}
</li>
</ul>
<a
(click)="validation.errors = null"
(keyup.esc)="validation.errors = null"
(keyup.enter)="validation.errors = null"
tabindex="0"
class="close"
>×</a
>
</ngb-alert>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.salesforceId.string"
for="field_salesforceId.string"
>Salesforce Id</label
>
<input
type="text"
class="form-control"
name="salesforceId"
id="field_salesforceId"
[attr.disabled]="editForm.get('id')?.value !== undefined ? true : null"
formControlName="salesforceId"
/>
<div
*ngIf="
editForm.get('salesforceId')?.invalid &&
(editForm.get('salesforceId')?.dirty || editForm.get('salesforceId')?.touched)
"
>
<small
class="form-text text-danger"
*ngIf="(editForm.get('salesforceId')?.errors)!['required']"
i18n="@@entity.validation.required.string"
>
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.parentSalesforceId.string"
for="field_parentSalesforceId.string"
>Parent Salesforce Id</label
>
<input
type="text"
class="form-control"
name="parentSalesforceId"
id="field_parentSalesforceId"
formControlName="parentSalesforceId"
/>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.clientName.string"
for="field_clientName.string"
>Member Name</label
>
<input
type="text"
class="form-control"
name="clientName"
id="field_clientName"
formControlName="clientName"
/>
<div
*ngIf="
editForm.get('clientName')?.invalid &&
(editForm.get('clientName')?.dirty || editForm.get('clientName')?.touched)
"
>
<small
class="form-text text-danger"
*ngIf="(editForm.get('clientName')?.errors)!['required']"
i18n="@@entity.validation.required.string"
>
This field is required.
</small>
</div>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.clientId.label.string"
for="field_clientId.string"
>Client ID</label
>
<p>
<em
><span i18n="@@gatewayApp.msUserServiceMSMember.clientId.note.string"
>Note: Client ID must have User OBO enabled AND</span
>
<a href="{{ baseUrl }}"> {{ baseUrl }} </a>
<span i18n="@@gatewayApp.msUserServiceMSMember.clientId.addedAsRedirect.string"
>added as a Redirect URI in</span
>
<a href="{{ orcidBaseUrl }}/manage-members.string"> {{ orcidBaseUrl }}/manage-members</a></em
>
</p>
<input type="text" class="form-control" name="clientId" id="field_clientId" formControlName="clientId" />
<div
*ngIf="
editForm.get('clientId')?.invalid &&
(editForm.get('clientId')?.dirty || editForm.get('clientId')?.touched)
"
>
<small
class="form-text text-danger"
*ngIf="(editForm.get('clientId')?.errors)!['required']"
i18n="@@entity.validation.required.string"
>
This field is required.
</small>
<small class="form-text text-danger" *ngIf="!this.editForm.get('clientId')?.hasError('validClientId')">
Client Id should be in the format XXXX-XXXX-XXXX-XXXX or APP-XXXXXXXXXXXXXXXX. X can be a digit or an
uppercase character."
</small>
</div>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.isConsortiumLead.string"
for="field_isConsortiumLead.string"
>Consortium Lead</label
>
<input
type="checkbox"
class="form-control"
name="isConsortiumLead"
id="field_isConsortiumLead"
formControlName="isConsortiumLead"
/>
</div>
<div class="form-group">
<label
class="form-control-label"
i18n="@@gatewayApp.msUserServiceMSMember.assertionServiceEnabled.string"
for="field_assertionServiceEnabled.string"
>Assertions Enabled</label
>
<input
type="checkbox"
class="form-control"
name="assertionServiceEnabled"
id="field_assertionServiceEnabled"
formControlName="assertionServiceEnabled"
/>
</div>
</div>
<div *ngIf="isSaving" class="progress progress-striped">
<div class="progress-bar indeterminate" role="progressbar"></div>
</div>
<br />
<div class="form-group">
<button type="button" id="cancel-save" class="btn btn-outline-primary mr-2" (click)="navigateToMembersList()">
<fa-icon [icon]="faBan"></fa-icon>&nbsp;<span i18n="@@entity.action.cancel.string">Cancel</span>
</button>
<button type="submit" id="save-entity" [disabled]="editForm.invalid || isSaving" class="btn btn-primary">
<fa-icon [icon]="faSave"></fa-icon>&nbsp;<span i18n="@@entity.action.save.string">Save</span>
</button>
</div>
</form>
</div>
</div>
Loading

0 comments on commit d21f18d

Please sign in to comment.