-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
62 lines (55 loc) · 1.62 KB
/
index.js
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
/** Simple example: Create a web page with form */
var gui = require ( '../../' ) // stand alone: replace with require( 'easy-web-app' )
/** Initialize the framework and the default page */
gui.init ( 'First Example' )
/**
* Add a view of type "pong-easy-form" (= plug-in) to the default page the first
* parameter of addView is the view configuration, a second parameter can define
* the plug-in configuration, a third parameter can specify the page.
*/
gui.addView (
{
'id' : 'myFirstView',
'title': 'Form view showing all field types',
'type' : 'pong-easyform'
},
{
"id" : "tstFormId",
"easyFormFields" : [
"id"
, "c1|Name"
, "c1|Date|date"
, "c1|separator"
, "c1|Remark|3rows"
, "c2|Mailings|label"
, "c2|Send~Ads~~|checkbox_infomails_ads"
, "c2|Newsletter|checkbox_infomails_newsletter"
, "c2|Pass~Word"
],
"actions" : [
{
"id" : "Chk",
"actionName" : "Check",
"actionURL" : "/dummy"
}
]
}
)
// ... Stop here! That's all of easy-web gui :-)
// -----------------------------------------------------------
// For a complete example we need REST web service:
// The browser will send the the data via POST request.
var app = gui.getExpress()
var bodyParser = require( 'body-parser' )
var jsonParser = bodyParser.json()
//app.locals.pretty = true
//app.set('json spaces', 2)
// save changed table config back
app.post(
'/dummy',
jsonParser,
function( req, res ) {
res.statusCode = 200 // = OK
return res.json( {} ) // empty, but valid response object
}
)