-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Data Sharing Terms component and integrated into create flow (#…
…1968) Co-authored-by: Gino Miceli <[email protected]>
- Loading branch information
Showing
11 changed files
with
401 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
web/src/app/pages/create-survey/data-sharing-terms/data-sharing-terms.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
Copyright 2024 The Ground Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<form [formGroup]="formGroup"> | ||
<mat-radio-group class="data-sharing-terms" | ||
[id]="typeControlKey" | ||
[formControlName]="typeControlKey" | ||
> | ||
<mat-card *ngFor="let option of dataSharingTermsOptions" | ||
class="data-sharing-terms-card" | ||
> | ||
<mat-card-content> | ||
<mat-radio-button class="option-radio-button" [value]="option.value"> | ||
<span class="data-sharing-label">{{ option.label }}</span> | ||
<p>{{ option.description }}</p> | ||
</mat-radio-button> | ||
<div *ngIf="shouldShowCustomizeAgreementSection(option.value)"> | ||
<h3 id="customize-agreement-header" | ||
class="field-header"> | ||
Customize agreement | ||
</h3> | ||
<p class="field-description"> | ||
Create a custom agreement which will be shown to data collectors before they can | ||
collect data. Data collectors must agree to the terms of this agreement. | ||
</p> | ||
<mat-form-field class="custom-terms"> | ||
<textarea matInput | ||
formControlName="customText" | ||
placeholder="Enter the terms of your custom agreement..." | ||
aria-labelledby="customize-agreement-header"> | ||
</textarea> | ||
<mat-error *ngIf="customTextControl.touched && customTextControl.invalid"> | ||
<ng-container *ngIf="customTextControl.getError('required')"> | ||
Required | ||
</ng-container> | ||
</mat-error> | ||
</mat-form-field> | ||
</div> | ||
</mat-card-content> | ||
</mat-card> | ||
</mat-radio-group> | ||
</form> |
36 changes: 36 additions & 0 deletions
36
web/src/app/pages/create-survey/data-sharing-terms/data-sharing-terms.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 2024 The Ground Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the 'License'); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an 'AS IS' BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
.data-sharing-terms { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
|
||
.data-sharing-terms-card { | ||
color: #202124; | ||
font-size: 14px; | ||
font-weight: 500; | ||
|
||
.data-sharing-label { | ||
font-size: 16px; | ||
font-weight: 700; | ||
} | ||
} | ||
|
||
.custom-terms { | ||
display: block; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
web/src/app/pages/create-survey/data-sharing-terms/data-sharing-terms.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright 2024 The Ground Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the 'License'); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an 'AS IS' BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {CommonModule} from '@angular/common'; | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {DataSharingType} from 'app/models/survey.model'; | ||
import {DataSharingTermsComponent} from 'app/pages/create-survey/data-sharing-terms/data-sharing-terms.component'; | ||
|
||
describe('DataSharingTermsComponent', () => { | ||
let component: DataSharingTermsComponent; | ||
let fixture: ComponentFixture<DataSharingTermsComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DataSharingTermsComponent], | ||
imports: [CommonModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DataSharingTermsComponent); | ||
fixture.componentInstance.type = DataSharingType.PUBLIC; | ||
fixture.componentInstance.customText = 'Hey there here is an agreement'; | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('displays mat-cards for each of the three data sharing types', () => { | ||
const matCards: HTMLElement[] = | ||
fixture.debugElement.nativeElement.querySelectorAll( | ||
'.data-sharing-terms-card' | ||
); | ||
const contentValues = Array.from(matCards).map((card: HTMLElement) => ({ | ||
label: card | ||
.querySelector('.option-radio-button .data-sharing-label')! | ||
.textContent!.trim(), | ||
description: card | ||
.querySelector('.option-radio-button p')! | ||
.textContent!.trim(), | ||
})); | ||
expect(contentValues).toEqual([ | ||
{ | ||
label: 'Private', | ||
description: 'Data will be shared with survey organizers only', | ||
}, | ||
{ | ||
label: 'Public', | ||
description: | ||
'Survey organizers may share and use data publicly with no constraints', | ||
}, | ||
{ | ||
label: 'Custom agreement', | ||
description: | ||
'Survey organizers create terms which must be accepted by data collectors before collecting data', | ||
}, | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.