Skip to content

Commit 2250bc3

Browse files
committed
Added a little documentation and cleaned up
1 parent 3483cff commit 2250bc3

5 files changed

Lines changed: 74 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Edit settings on `/admin/os2forms_sync/settings`.
1111

1212
## API
1313

14-
JSON:API
14+
See [API](docs/API.md) for details on the API.
1515

1616
## Usage
1717

@@ -21,9 +21,7 @@ settings » OS2Forms » OS2Forms sync
2121
All published webforms are listed on `/admin/os2forms/sync/webform` (API data on
2222
`/os2forms/sync/jsonapi/webform`).
2323

24-
Webforms available for import are listed on `/os2forms/sync/jsonapi/webform/available`.
25-
26-
Imported webforms are listed on `/os2forms/sync/jsonapi/webform/imported`.
24+
Webforms available for import are listed on `/admin/os2forms/sync/webform`.
2725

2826
## Drush commands
2927

docs/API.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# OS2Forms sync – API
2+
3+
Webforms are published via a simple [JSON:API](https://jsonapi.org/) API.
4+
5+
[Example webforms](webforms.json).

docs/webforms.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"data": [
3+
{
4+
"id": "simpel_formular",
5+
"type": "webform",
6+
"attributes": {
7+
"title": "Simpel formular",
8+
"description": "Simpel formular der demonstrerer deling af formularer på tværs af OS2Forms-installationer.",
9+
"category": "Test",
10+
"elements": {
11+
"name": {
12+
"#type": "textfield",
13+
"#title": "Name",
14+
"#required": true
15+
},
16+
"birthday": {
17+
"#type": "datelist",
18+
"#title": "Birthday",
19+
"#date_part_order": [
20+
"year",
21+
"month",
22+
"day"
23+
],
24+
"#required": true
25+
},
26+
"number": {
27+
"#type": "number",
28+
"#title": "Number",
29+
"#min": 1,
30+
"#max": 87
31+
},
32+
"er_du_tilfreds_": {
33+
"#type": "checkbox",
34+
"#title": "Er du tilfreds?"
35+
}
36+
}
37+
},
38+
"links": {
39+
"self": "https://…/os2forms/sync/jsonapi/webform/simpel_formular"
40+
}
41+
},
42+
{
43+
"id": "example_form",
44+
"type": "webform",
45+
"attributes": {
46+
"title": "Example form",
47+
"description": "Example form.",
48+
"category": "Example",
49+
"elements": {
50+
"name": {
51+
"#type": "textfield",
52+
"#title": "Name",
53+
"#required": true
54+
}
55+
}
56+
},
57+
"links": {
58+
"self": "https://…/os2forms/sync/jsonapi/webform/example_form"
59+
}
60+
}
61+
],
62+
"links": {
63+
"self": "https://…/os2forms/sync/jsonapi/webform"
64+
}
65+
}

src/Helper/JsonAPISerializer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public function serializeWebform(WebformInterface $webform, $inline = FALSE): ar
7878
$webform->toArray(),
7979
static function ($key) {
8080
return in_array($key, [
81-
'uuid',
8281
'title',
8382
'description',
8483
'category',

src/Helper/WebformHelper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ public function webformThirdPartySettingsFormAlter(array &$form, FormStateInterf
106106
'#type' => 'checkbox',
107107
'#title' => $this->t('Publish'),
108108
'#default_value' => (bool) ($defaultValues['publish'] ?? FALSE),
109-
'#description' => $this->t('If checked this form will be listed on <a href=":url_index">:url_index</a> and details made available on <a href=":url_show">:url_show</a>', [
110-
':url_index' => Url::fromRoute('os2forms_sync.jsonapi.webform.index')->toString(),
111-
':url_show' => Url::fromRoute('os2forms_sync.jsonapi.webform.show', ['webform' => $webform->id()])->toString(),
109+
'#description' => $this->t('If checked this form will be listed on <a href=":url_index">:url_index</a>. Share this url with others that may import all public webforms on this site.', [
110+
':url_index' => Url::fromRoute('os2forms_sync.jsonapi.webform.index')->setAbsolute()->toString(),
112111
]),
113112
];
114113

0 commit comments

Comments
 (0)