-
Notifications
You must be signed in to change notification settings - Fork 2
Create placeholder uncertain locations modal #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
slifty
wants to merge
1
commit into
main
Choose a base branch
from
1122-use-uncertain-locations-flag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
18 changes: 18 additions & 0 deletions
18
...ile-browser/components/uncertain-location-picker/uncertain-location-picker.component.html
This file contains hidden or 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,18 @@ | ||
| <div class="dialog-content"> | ||
| <div class="header"> | ||
| <span>Edit location</span> | ||
| <button class="btn" (click)="cancel()" aria-label="Close"> | ||
| <i class="material-icons">close</i> | ||
| </button> | ||
| </div> | ||
| <div class="dialog-body"> | ||
| <p> | ||
| We're building a new way to record locations, including places that are | ||
| approximate or uncertain. | ||
| </p> | ||
| <p>Location editing is not available here yet.</p> | ||
| </div> | ||
| <div class="dialog-footer"> | ||
| <button class="btn btn-primary" (click)="cancel()">Close</button> | ||
| </div> | ||
| </div> |
46 changes: 46 additions & 0 deletions
46
...ile-browser/components/uncertain-location-picker/uncertain-location-picker.component.scss
This file contains hidden or 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,46 @@ | ||
| @import 'variables'; | ||
|
|
||
| :host { | ||
| display: block; | ||
| flex: 1; | ||
| max-width: 100%; | ||
| background-color: $PR-brand-white; | ||
| } | ||
|
|
||
| // The global `pr-dialog .dialog-content` rules do not apply to CDK-opened | ||
| // dialogs, so the flex structure is declared here alongside the background. | ||
| .dialog-content { | ||
| display: flex; | ||
| flex-direction: column; | ||
| height: 100%; | ||
| background-color: $PR-brand-white; | ||
| } | ||
|
|
||
| .header { | ||
| @include tabbedDialogHeader(none, $body-color); | ||
| font-weight: $font-weight-bold; | ||
| } | ||
|
|
||
| .dialog-body { | ||
| flex: 1 1 auto; | ||
| overflow-y: auto; | ||
| padding: 0 $grid-unit; | ||
|
|
||
| p:last-child { | ||
| margin-bottom: 0; | ||
| } | ||
| } | ||
|
|
||
| .dialog-footer { | ||
| flex: 0 0 auto; | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| padding: $grid-unit; | ||
|
|
||
| // `button.btn` is globally `display: block; margin: 10px auto; width: 100%`, | ||
| // and those auto margins would win over `justify-content` above. | ||
| button { | ||
| margin: 0; | ||
| width: auto; | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
...-browser/components/uncertain-location-picker/uncertain-location-picker.component.spec.ts
This file contains hidden or 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,52 @@ | ||
| import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
| import { TestBed, ComponentFixture } from '@angular/core/testing'; | ||
| import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog'; | ||
| import { RecordVO } from '@models'; | ||
| import { UncertainLocationPickerComponent } from './uncertain-location-picker.component'; | ||
|
|
||
| describe('UncertainLocationPickerComponent', () => { | ||
| let fixture: ComponentFixture<UncertainLocationPickerComponent>; | ||
| let component: UncertainLocationPickerComponent; | ||
| let dialogRef: jasmine.SpyObj<DialogRef>; | ||
| const item = new RecordVO({ recordId: 123 }); | ||
|
|
||
| beforeEach(async () => { | ||
| dialogRef = jasmine.createSpyObj('DialogRef', ['close']); | ||
|
|
||
| await TestBed.configureTestingModule({ | ||
| declarations: [UncertainLocationPickerComponent], | ||
| providers: [ | ||
| { provide: DIALOG_DATA, useValue: { item } }, | ||
| { provide: DialogRef, useValue: dialogRef }, | ||
| ], | ||
| schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(UncertainLocationPickerComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should read the item off the dialog data', () => { | ||
| expect(component.item).toBe(item); | ||
| }); | ||
|
|
||
| it('should render a titled dialog', () => { | ||
| const header = fixture.nativeElement.querySelector('.header span'); | ||
|
|
||
| expect(header.textContent.trim()).toBe('Edit location'); | ||
| }); | ||
|
|
||
| it('should close the dialog from the header close button', () => { | ||
| const close = fixture.nativeElement.querySelector('.header button'); | ||
| close.click(); | ||
|
|
||
| expect(dialogRef.close).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should close the dialog on cancel', () => { | ||
| component.cancel(); | ||
|
|
||
| expect(dialogRef.close).toHaveBeenCalled(); | ||
| }); | ||
| }); |
29 changes: 29 additions & 0 deletions
29
.../file-browser/components/uncertain-location-picker/uncertain-location-picker.component.ts
This file contains hidden or 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,29 @@ | ||
| import { Component, Inject, Optional } from '@angular/core'; | ||
| import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog'; | ||
| import { ItemVO } from '@models'; | ||
| import { ProfileItemVOData } from '@models/profile-item-vo'; | ||
|
|
||
| @Component({ | ||
| selector: 'pr-uncertain-location-picker', | ||
| templateUrl: './uncertain-location-picker.component.html', | ||
| styleUrls: ['./uncertain-location-picker.component.scss'], | ||
| standalone: false, | ||
| }) | ||
| export class UncertainLocationPickerComponent { | ||
| public item: ItemVO; | ||
| public profileItem: ProfileItemVOData; | ||
|
|
||
| constructor( | ||
| @Optional() @Inject(DIALOG_DATA) public dialogData: any, | ||
| @Optional() private dialogRef: DialogRef, | ||
| ) { | ||
| if (this.dialogData) { | ||
| this.item = this.dialogData.item; | ||
| this.profileItem = this.dialogData.profileItem; | ||
| } | ||
| } | ||
|
|
||
| public cancel(): void { | ||
| this.dialogRef?.close(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toHaveBeenCalledWithsatisfies any spy that has been called at some point, with the correct dialog, but this this needs to be made specific for every test.We should add
mockDialogService.open.calls.reset()to thebeforeEachin the profile-edit spec, and switch all four totoHaveBeenCalledOnceWith(...). This way, we make sure every call to the mock dialog service is done specifically for every test.