8000 Vihko Open Form [Closes #708] by rpulkka · Pull Request #798 · luomus/laji · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 46 commits into from
Jun 16, 2025
Merged

Vihko Open Form [Closes #708] #798

merged 46 commits into from
Jun 16, 2025

Conversation

rpulkka
Copy link
Contributor
@rpulkka rpulkka commented Jun 12, 2025

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.

@rpulkka rpulkka changed the title Vihko Open Form Vihko Open Form [Closes #708] Jun 13, 2025
@@ -0,0 +1,14 @@
<ng-container *ngIf="thankYouData$ | async as data">
<div class="m-6">
Copy link
Contributor

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
Copy link
Contributor

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[] {
Copy link
Contributor

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({
Copy link
Contributor

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">
Copy link
Contributor

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(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

9E7A
@@ -102,7 +102,16 @@ export class FormService {
return `/project/${formId}/form`;
}

getFormAlias(formId: string) {
Copy link
Contributor

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 {
Copy link
Contributor

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;
Copy link
Contributor

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%',
Copy link
Contributor

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}`

@rpulkka rpulkka requested a review from Blodir June 13, 2025 12:30
@@ -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}`,
Copy link
Contributor

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

@rpulkka rpulkka requested a review from Blodir June 16, 2025 05:00
@Blodir Blodir added this to the Release 83 milestone Jun 16, 2025
@Blodir Blodir merged commit 574e882 into development Jun 16, 2025
1 check passed
@Blodir Blodir deleted the porpoise-form-708 branch June 16, 2025 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0