Skip to content
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

Add sweet URI fragments support #50

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c1b7b40
Fix Choisissez un motif de déplacement - en dark mode
lpmtsf Oct 30, 2020
af33a79
Merge pull request #39 from knrdhz/fixDarkMode
betalabmi Oct 30, 2020
5421912
Add param support
a2br Oct 30, 2020
06c681c
Switch to URI fragments
a2br Oct 30, 2020
8703b26
Remove log
a2br Oct 30, 2020
9c65013
Merge branch 'main' into param-support
a2br Oct 30, 2020
73b591c
Remove useless security
a2br Oct 30, 2020
fb28302
Add support for reasons
a2br Oct 30, 2020
3ff2bfc
Change syntax
a2br Oct 30, 2020
e93fd95
Remove log
a2br Oct 30, 2020
b0a6fc7
Add auto-download capability
a2br Oct 30, 2020
7d986ed
Add new line at end of file
a2br Oct 30, 2020
6e454c5
Correct id problem
a2br Oct 30, 2020
6ce031f
Simplify code
a2br Oct 30, 2020
4a463f4
Reorganize & Add date/hour support
a2br Oct 31, 2020
15e8fbf
Correct autoDownload
a2br Oct 31, 2020
80a0d9e
Delete console.log
a2br Oct 31, 2020
1ff8797
Rename Func & Group changes
a2br Oct 31, 2020
148763c
Rename reasons alias
a2br Oct 31, 2020
9e22490
Simplify reasons params eval code
a2br Oct 31, 2020
1cbfe86
URI is now synced with inputs
a2br Nov 1, 2020
5681bef
Add comment
a2br Nov 1, 2020
c13598e
Reverse 'name' rename
a2br Nov 1, 2020
3dce1b1
Move default hour changes to another branch
a2br Nov 1, 2020
e19b9fa
Add reasons sync support
a2br Nov 1, 2020
d1d1e7e
Add ability to watch URI hash changes
a2br Nov 2, 2020
ee8b5c4
Add special function to clean params
a2br Nov 2, 2020
e40ba7a
Remove console.log
a2br Nov 2, 2020
362d686
Update branch
a2br Nov 2, 2020
4fa887b
Resolve merge conflicts by removing local changes
a2br Nov 3, 2020
34e3a5e
Corrections
a2br Nov 3, 2020
09ac3ed
Correct reasons' relation with URI
a2br Nov 3, 2020
f83c916
Merge branch 'main' into param-support
a2br Nov 4, 2020
174b1f8
Merge branch 'main' into param-support
a2br Dec 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/form-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[
{
"key": "firstname",
"alias": "prenom",
a2br marked this conversation as resolved.
Show resolved Hide resolved
"type": "text",
"contentType": "firstname",
"label": "Prénom",
Expand All @@ -10,6 +11,7 @@
},
{
"key": "lastname",
"alias": "nom",
"type": "text",
"contentType": "lastname",
"label": "Nom",
Expand Down
13 changes: 11 additions & 2 deletions src/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import formData from '../form-data.json'

import { $, appendTo, createElement } from './dom-utils'

const params = new URLSearchParams(window.location.search)

const createTitle = () => {
const h2 = createElement('h2', { className: 'titre-2', innerHTML: 'Remplissez en ligne votre déclaration numérique : ' })
const p = createElement('p', { className: 'msg-info', innerHTML: 'Tous les champs sont obligatoires.' })
Expand Down Expand Up @@ -53,6 +55,11 @@ const createFormGroup = ({
type,
}

if (params.get(name)) {
inputAttrs.value = params.get(name)
if (name.includes('date') || name.includes('heure')) inputAttrs.value = new Date(params.get(name)).toISOString().slice(0, 10)
}
console.log(inputAttrs.value)
a2br marked this conversation as resolved.
Show resolved Hide resolved
const input = createElement('input', inputAttrs)

const validityAttrs = {
Expand Down Expand Up @@ -103,7 +110,7 @@ const createReasonFieldset = (reasonsData) => {
const appendToFieldset = appendTo(fieldset)

const legendAttrs = {
className: 'legend titre 3 ',
className: 'legend titre-3 ',
innerHTML: 'Choisissez un motif de déplacement',
}
const legend = createElement('legend', legendAttrs)
Expand Down Expand Up @@ -141,10 +148,12 @@ export function createForm () {
.filter(field => !field.isHidden)
.map((field,
index) => {
// Permet de changer la clé devant être présente dans l'URI en ajoutant la propriété 'alias'
const name = field.alias || field.key
const formGroup = createFormGroup({
autofocus: index === 0,
...field,
name: field.key,
name,
})

return formGroup
Expand Down