-
Notifications
You must be signed in to change notification settings - Fork 0
Vihko Open Form [Closes #708] #798
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
Conversation
@@ -0,0 +1,14 @@ | |||
<ng-container *ngIf="thankYouData$ | async as data"> | |||
<div class="m-6"> |
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.
this should probably be a my-6
, unless you want the horizontal padding?
}) | ||
export class ThankYouComponent implements OnInit, OnDestroy { | ||
|
||
Rights = Rights; // eslint-disable-line @typescript-eslint/naming-convention |
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.
Is this unused?
@@ -8,4 +9,16 @@ import { Form } from '../../shared/model/Form'; | |||
}) | |||
export class SurveyBoxComponent { | |||
@Input() form!: Form.List; | |||
|
|||
formLink(): string[] { |
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.
rename: getFormLink
@@ -1,5 +1,6 @@ | |||
import { Component, Input } from '@angular/core'; | |||
import { Form } from '../../shared/model/Form'; | |||
import { Global } from '../../../environments/global'; | |||
|
|||
@Component({ |
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.
could make this ChangeDetectionStrategy.OnPush
while you're at it.
@@ -24,7 +24,7 @@ | |||
</div> | |||
</div> | |||
<div id="navbar" class="collapse navbar-collapse" [class.in]="openMenu"> | |||
<ul class="nav navbar-nav"> | |||
<ul class="nav navbar-nav" *ngIf="navbarService.navbarVisible"> |
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.
use navbarService.navbarVisible$ | async
here directly and get rid of the cdr.markForCheck()
@@ -70,6 +72,10 @@ export class NavbarComponent implements AfterViewInit, OnInit, OnDestroy { | |||
if (this.platformService.isServer) { | |||
return; | |||
} | |||
this.navbarService.navbarVisible$.subscribe(() => { |
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.
remove
@@ -102,7 +102,16 @@ export class FormService { | |||
return `/project/${formId}/form`; | |||
} | |||
|
|||
getFormAlias(formId: string) { |
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.
this could be private
import { Subject } from 'rxjs'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class NavbarService { |
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.
use a BehaviorSubject
navbarVisible$ = new BehaviorSubject(true);
set navbarVisible(v) {
this.navbarVisible$.next(v)
}
get navbarVisible() {
return this.navbarVisible$.value
}
@@ -36,6 +37,12 @@ export interface ExcelFormOptions { | |||
allowGenerate: boolean; | |||
} | |||
|
|||
export interface RegistrationContact { | |||
preferredName: string | undefined; |
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.
optional syntax would be nicer eg.
preferredName?: string;
const params: string[] = [ | ||
`next=${this.location.path(true)}`, | ||
'redirectMethod=POST', | ||
'locale=%lang%', |
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.
why not
`locale=${this.translate.currentLang}`
@@ -255,7 +255,7 @@ export class UserService implements OnDestroy { | |||
const params: string[] = [ | |||
`next=${this.location.path(true)}`, | |||
'redirectMethod=POST', | |||
'locale=%lang%', | |||
`locale=${this.translate.currentLang}`, |
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.
you need to remove the .replace('%lang%'...
below
This PR contains the new Vihko open form changes. Open forms have /about, /form and /thank-you pages. The specs included that the address must include "/pyoriaiset" instead of the formId, like https://708.dev.laji.fi/en/project/pyoriaiset/form and this required some work-arounds.
Open form can be used without logging in. If user submits the form without login, and emailHasAccount returns a matching user from the API, the user is asked to login to their account. The formState is saved to localStorage while the user is logging in on laji-auth, and ngOnInit checks if there's formState (which is, user returning from laji-auth).
If the email doesn't have an account, registrationContacts are saved to project-form.service and thank-you page has a link to register, which takes registrationContacts as params to prefill the sign up form.
Even when user doesn't log in or sign up, email is mandatory. In this case it is stored to document in format:
'vihko:' + email
, so that all of the anonymous user's observations can be linked to their new account later with a backend process, if they ever create one.The open form hides some of the navbar content with the new NavbarService.