/ittf/meta/html/t/js/dataManager.js.ittf (primary)
edit
1 $group
2 #
3 # implements editSave
4 # params
5 # { ctx
6 #
7 class DataManager
8 ctor
9 param ctx
10 set this.ctx = ctx
11 set this.editSaveUrl = ctx.editSaveUrl
12 set this.editSaveHttpMethod = ctx.editSaveHttpMethod
13 m editSave
14 param hash
15 param content
16 log 'wz.DataManager.editSave', hash, content
17 _ fetch
18 @ this.editSaveUrl
19 {
20 @ method this.editSaveHttpMethod.toUpperCase()
21 { headers
22 @ "Content-Type" "application/json"
23 @ body
24 _ JSON.stringify
25 {
26 @ hash hash
27 @ content content
28 @ prettify true
29 ._ then
30 =>
31 param response
32 _ response.json()
33 ._ then
34 =>
35 param json
36 $if true
37 _ alert
38 @ 'editSave: ' + JSON.stringify(json, null, 2)
39 if this.ctx.editManager && this.ctx.editManager.onSave
40 set json.data.hash = hash
41 set json.data.content = content
42 #
43 _ alert
44 @ 'editSave: ' + JSON.stringify(json, null, 2)
45 _ this.ctx.editManager.onSave
46 @ json.data
47 ._ catch
48 =>
49 param err
50 error err
51 _ alert
52 @ 'editSave error: ' + err