API.md 4.27 KB
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
API: Client / Server
====================

Form initial call
-----------------

Request: index.php  (QuickFormQuery.php, included by Typo3 extension)

Response:
Form attributes:

data-hidden:    'yes'|'no'  - yes: The element is not visible yet, maybe later.
data-disabled:  'yes'|'no'  - yes: The element is visible, but the user can't interact with it. 
data-required:  'yes'|'no'  - yes: The element is required. The form can't be submitted if any required element is empty.

General
-------

Asynchronous request (read AJAX) initiated by the client receive a JSON Response from the server containing at least:

    {
      "status": "success"|"error",
      "message": "<message>"
    }
   
`status` indicates whether or not the request has been fullfiled by the server (`"success"`) or encountered an error (`"error"`).
On `"error"` the client must display `"<message>"` to the user. On `"success"`, the client may display `"<message>"` to the user.
 


Form load (update)
------------------

### Trigger

Form Element with attribute `data-load="data-load"`.

The client side JavaScript installs on change handlers for all HTML Form Elements having the `data-load` attribute.

### Request: api/load.php

#### Type
POST

#### Parameters

##### URL
none

##### POST
HTML Form without `<input>` elements of type `file`. The HTML Form is required to have a HTML Form Element named `s`, which must contain the SIP.

### Response

JSON Stream

    {
     "status": "success"|"error",
     "message": "<message>",
     "redirect": "client"|"url"|"no",
     "field-name": "<field name>",
     "field-message": "<message>",
     "form-update": [ 
        {
          "form-element": "<element_name>",
          "hidden": true | false,
          "disabled": true | false,
          "required": true | false,
          "value": <value>
        }
     ]
    }
    
Name    | Description
------- | -----------
status  | see General
message | see General
redirect | not used
field-name | HTML Form Element Name which raised error on server side. Requires status to be `"error"`
field-message | reason of error. Requires status to be `"error"`.
form-update  | Array of Objects. Each object describes the state and value of a HTML Form Element identfied by its `name` attribute.


Form save
---------

### Trigger
none

### Request: api/save.php

#### Type
POST

#### Parameters

##### URL
none

##### POST
HTML Form without `<input>` elements of type `file`. The HTML Form is required to have a HTML Form Element named `s`, which must contain the SIP.

### Response

JSON Stream

    {
     "status": "success"|"error",
     "message": "<message>",
     "redirect": "client"|"url"|"no",
     "field-name": "<field name>",
     "field-message": "<message>",
     "form-update": [ 
        {
          "form-element": "<element_name>",
          "hidden": true | false,
          "disabled": true | false,
          "required": true | false,
          "value": <value>
        }
     ]
    }

Name    | Description
------- | -----------
status  | see General
message | see General
redirect | not used
field-name | HTML Form Element Name which raised error on server side. Requires status to be `"error"`
field-message | reason of error. Requires status to be `"error"`.
form-update  | Array of Objects. Each object describes the state and value of a HTML Form Element identfied by its `name` attribute.


File (upload)
-------------

### Trigger
none

### Request: api/file.php

#### Type
POST

#### Parameters

##### URL
`action=upload`

##### POST
Multi part form with file content, parameter `s` containing SIP, and parameter `name` containing the name of the HTML Form Element. 

### Response

JSON Stream

    {
      "status": "success"|"error",
      "message": "<message>"
    }


Name    | Description
------- | -----------
status  | see General
message | see General


Record delete
-------------

Request: api/delete.php


Return JSON encoded answer

status: success|error
message: <message>
redirect: client|url|no
redirect-url: <url>
field-name:<field name>
field-message: <message>

Description:

Delete successfull.
 status = 'success'
 message = <message>
 redirect = 'client'

Delete successfull.
 status = 'success'
 message = <message>
 redirect = 'url'
 redirect-url = <URL>

Delete failed: Show message.
 status = 'error'
 message = <message>
 redirect = 'no'