material 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tracks.svg +10 -0
- package/package.json +1 -1
- package/src/appbar.js +1 -2
- package/src/control/button.js +263 -0
- package/src/control/button.new.js +190 -0
- package/src/control/datehour.js +65 -0
- package/src/control/dialog.js +174 -0
- package/src/control/file.js +123 -0
- package/src/control/image.js +92 -0
- package/src/control/link.js +61 -0
- package/src/control/list.js +77 -0
- package/src/control/loading.js +128 -0
- package/src/control/module/addclass.js +16 -0
- package/src/control/module/attributes.js +21 -0
- package/src/control/search.js +98 -0
- package/src/control/select.js +130 -0
- package/src/control/selecter.js +246 -0
- package/src/control/switch.js +272 -0
- package/src/control/switcher.js +245 -0
- package/src/control/text.js +66 -0
- package/src/control/textfield.js +177 -0
- package/src/field/image.js +9 -3
- package/src/form/build.js +60 -6
- package/src/form/cancel.js +7 -3
- package/src/form/controller.js +90 -0
- package/src/form/create.js +12 -6
- package/src/form/data.js +82 -0
- package/src/form/delete.js +2 -1
- package/src/form/fetch.js +30 -0
- package/src/form/render.js +14 -19
- package/src/form/set.js +27 -12
- package/src/form/submit.js +24 -49
- package/src/form/update.js +46 -0
- package/src/layout.js +26 -22
- package/src/list/add.js +34 -0
- package/src/list/build.js +100 -6
- package/src/list/click.js +10 -5
- package/src/list/collection.js +187 -0
- package/src/list/create.js +21 -11
- package/src/list/display.js +78 -0
- package/src/list/empty.js +4 -1
- package/src/list/filter.js +114 -0
- package/src/list/load.js +2 -2
- package/src/list/remove.js +17 -4
- package/src/list/render.js +32 -9
- package/src/list/request.js +182 -0
- package/src/list/search.js +118 -35
- package/src/list/select.js +151 -30
- package/src/list/status.js +10 -3
- package/src/list/update.js +49 -8
- package/src/list/virtual.js +195 -127
- package/src/map/build.js +103 -0
- package/src/map/countries.js +114 -0
- package/src/map/display.js +135 -0
- package/src/map/focus.js +39 -0
- package/src/map/init.js +24 -0
- package/src/map/label.js +0 -0
- package/src/map/mode.js +44 -0
- package/src/map/mouse.js +65 -0
- package/src/map/select.js +68 -0
- package/src/map/set.js +71 -0
- package/src/map/viewport.js +46 -0
- package/src/map.js +71 -0
- package/src/module/attach.js +15 -16
- package/src/module/extract.js +35 -28
- package/src/module/mediator.js +56 -0
- package/src/module/object.js +17 -1
- package/src/module/observer.js +1 -1
- package/src/module/passive.js +17 -0
- package/src/module/remove.js +74 -0
- package/src/module/scrollbar.js +48 -0
- package/src/module/smoothscroll.js +20 -0
- package/src/module/viewport.js +20 -0
- package/src/selector.js +239 -0
- package/src/skin/material/base/body.sass +3 -0
- package/src/skin/material/button/file.sass +1 -1
- package/src/skin/material/container/container.sass +1 -1
- package/src/skin/material/container/dialog.sass +57 -1
- package/src/skin/material/container/drawer.sass +3 -3
- package/src/skin/material/control/button.sass +125 -0
- package/src/skin/material/control/dialog.sass +0 -0
- package/src/skin/material/control/progress.sass +136 -0
- package/src/skin/material/control/search.sass +40 -0
- package/src/skin/material/control/selecter.sass +131 -0
- package/src/skin/material/control/selector.sass +38 -0
- package/src/skin/material/control/slider.sass +2 -2
- package/src/skin/material/control/switch.sass +146 -3
- package/src/skin/material/control/switcher.sass +41 -0
- package/src/skin/material/control/textfield.sass +2 -1
- package/src/skin/material/icon/cancel.svg +1 -0
- package/src/skin/material/material.sass +3 -0
- package/src/skin/material/view/list.sass +81 -188
- package/src/skin/material/view/listview.sass +187 -96
- package/src/skin/material/view/tabview.sass +7 -5
- package/src/skin/material.bak/base/body.sass +52 -0
- package/src/skin/material.bak/base/elevation.sass +50 -0
- package/src/skin/material.bak/base/grid.sass +63 -0
- package/src/skin/material.bak/base/typo.sass +107 -0
- package/src/skin/material.bak/button/action.sass +89 -0
- package/src/skin/material.bak/button/button.sass +183 -0
- package/src/skin/material.bak/button/file.sass +24 -0
- package/src/skin/material.bak/button/floating.sass +113 -0
- package/src/skin/material.bak/button/raised.sass +101 -0
- package/src/skin/material.bak/button/stroked.sass +71 -0
- package/src/skin/material.bak/component/component.sass +7 -0
- package/src/skin/material.bak/component/divider.sass +17 -0
- package/src/skin/material.bak/component/image.sass +6 -0
- package/src/skin/material.bak/component/label.sass +2 -0
- package/src/skin/material.bak/component/progress.sass +138 -0
- package/src/skin/material.bak/component/subheader.sass +3 -0
- package/src/skin/material.bak/component/text.sass +85 -0
- package/src/skin/material.bak/container/appbar.sass +167 -0
- package/src/skin/material.bak/container/banner.sass +38 -0
- package/src/skin/material.bak/container/card.sass +18 -0
- package/src/skin/material.bak/container/container.sass +1 -0
- package/src/skin/material.bak/container/dialog.sass +184 -0
- package/src/skin/material.bak/container/drawer.sass +159 -0
- package/src/skin/material.bak/container/drawernew.sass +159 -0
- package/src/skin/material.bak/container/menu.sass +58 -0
- package/src/skin/material.bak/container/snackbar.sass +18 -0
- package/src/skin/material.bak/container/tabs.sass +75 -0
- package/src/skin/material.bak/container/toolbar.sass +161 -0
- package/src/skin/material.bak/control/button.sass +125 -0
- package/src/skin/material.bak/control/checkbox.sass +105 -0
- package/src/skin/material.bak/control/dialog.sass +0 -0
- package/src/skin/material.bak/control/search.sass +40 -0
- package/src/skin/material.bak/control/selecter.sass +128 -0
- package/src/skin/material.bak/control/slider.sass +181 -0
- package/src/skin/material.bak/control/switch.sass +284 -0
- package/src/skin/material.bak/control/switcher.sass +35 -0
- package/src/skin/material.bak/control/textfield.sass +126 -0
- package/src/skin/material.bak/control/tooltip.sass +36 -0
- package/src/skin/material.bak/icon/back.svg +5 -0
- package/src/skin/material.bak/icon/cancel.svg +1 -0
- package/src/skin/material.bak/icon/checkbox.svg +4 -0
- package/src/skin/material.bak/icon/forward.svg +5 -0
- package/src/skin/material.bak/icon/menu.svg +4 -0
- package/src/skin/material.bak/icon/pin.svg +4 -0
- package/src/skin/material.bak/layout/layout.sass +69 -0
- package/src/skin/material.bak/layout/resizer.sass +69 -0
- package/src/skin/material.bak/material.css +2042 -0
- package/src/skin/material.bak/material.css.map +7 -0
- package/src/skin/material.bak/material.sass +65 -0
- package/src/skin/material.bak/module/ripple.sass +9 -0
- package/src/skin/material.bak/theme/default.sass +50 -0
- package/src/skin/material.bak/theme/ocean.sass +29 -0
- package/src/skin/material.bak/theme/theme.sass +3 -0
- package/src/skin/material.bak/view/calendar.sass +193 -0
- package/src/skin/material.bak/view/form.sass +15 -0
- package/src/skin/material.bak/view/grid.sass +116 -0
- package/src/skin/material.bak/view/list.sass +89 -0
- package/src/skin/material.bak/view/listview.sass +195 -0
- package/src/skin/material.bak/view/map.sass +6 -0
- package/src/skin/material.bak/view/page.sass +4 -0
- package/src/skin/material.bak/view/tabview-bak.sass +40 -0
- package/src/skin/material.bak/view/tabview.sass +55 -0
- package/src/skin/material.bak/view/tree.sass +73 -0
- package/src/skin/material.bak/view/view.sass +7 -0
- package/src/switch.js +1 -1
- package/src/tabs/setup.js +0 -0
- package/src/tabview.js +64 -14
- package/src/tooltip.js +23 -5
- package/src/view/build.js +15 -3
- package/src/view/display.js +79 -7
- package/src/form/clean.js +0 -6
- package/src/form/mode.js +0 -16
- package/src/form/setup.js +0 -30
- package/src/list/fetch.js +0 -66
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
|
|
4
|
+
initController () {
|
|
5
|
+
// console.log('initController', this.field)
|
|
6
|
+
|
|
7
|
+
this.disableControls()
|
|
8
|
+
|
|
9
|
+
for (var field in this.field) {
|
|
10
|
+
if (this.field.hasOwnProperty(field)) {
|
|
11
|
+
this.bindControl(this.field[field])
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (var file in this.file) {
|
|
16
|
+
if (this.file.hasOwnProperty(file)) {
|
|
17
|
+
this.bindControl(this.file[file])
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setMode (mode) {
|
|
23
|
+
// console.log('setMode', mode)
|
|
24
|
+
this.mode = mode
|
|
25
|
+
|
|
26
|
+
this.updateClassMode(mode)
|
|
27
|
+
|
|
28
|
+
this.emit('mode', mode)
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
updateClassMode (mode) {
|
|
32
|
+
var modes = ['read', 'create', 'update']
|
|
33
|
+
|
|
34
|
+
for (var i = 0; i < modes.length; i++) {
|
|
35
|
+
this.form.classList.remove(modes[i] + '-mode')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.form.classList.add(mode + '-mode')
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
changeMode (mode) {
|
|
42
|
+
console.log('changeMode', mode)
|
|
43
|
+
|
|
44
|
+
if (mode === 'update' && this.enableControls) {
|
|
45
|
+
this.enableControls()
|
|
46
|
+
} else if (mode === 'update' && this.disableControls) {
|
|
47
|
+
this.disableControls()
|
|
48
|
+
} else if (mode === 'read' && this.disableControls) {
|
|
49
|
+
this.disableControls()
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
bindControl (control) {
|
|
54
|
+
// console.log('bindControl')
|
|
55
|
+
if (control && control.on) {
|
|
56
|
+
control.on('change', () => {
|
|
57
|
+
// console.log('change', control, this.mode)
|
|
58
|
+
if (this.mode === 'read') {
|
|
59
|
+
this.setMode('update')
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
enableControls () {
|
|
66
|
+
// console.log('enableControls')
|
|
67
|
+
var controls = this.options.controls || ['submit', 'cancel']
|
|
68
|
+
|
|
69
|
+
if (controls === null) return
|
|
70
|
+
|
|
71
|
+
for (var i = 0; i < controls.length; i++) {
|
|
72
|
+
if (this.ui[controls[i]] && this.ui[controls[i]].enable) {
|
|
73
|
+
this.ui[controls[i]].enable()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
disableControls () {
|
|
79
|
+
// console.log('disableControls')
|
|
80
|
+
var controls = this.options.controls || ['submit', 'cancel']
|
|
81
|
+
|
|
82
|
+
if (controls === null) return
|
|
83
|
+
|
|
84
|
+
for (var i = 0; i < controls.length; i++) {
|
|
85
|
+
if (this.ui[controls[i]] && this.ui[controls[i]].disable) {
|
|
86
|
+
this.ui[controls[i]].disable()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/form/create.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
export default {
|
|
3
3
|
|
|
4
|
-
create (
|
|
5
|
-
|
|
6
|
-
this.form.style.display = 'flex'
|
|
4
|
+
create () {
|
|
5
|
+
console.log('create', this.options.create.info)
|
|
7
6
|
|
|
7
|
+
this.clean()
|
|
8
|
+
|
|
9
|
+
var info = this.options.create.info || { name: 'New Item' }
|
|
10
|
+
|
|
11
|
+
console.log('info', info)
|
|
12
|
+
|
|
13
|
+
this.render(info, 'create')
|
|
8
14
|
this.setMode('create')
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
this.enableControls()
|
|
16
|
+
|
|
17
|
+
this.emit('new')
|
|
12
18
|
}
|
|
13
19
|
}
|
package/src/form/data.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { byString } from '../module/object'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
|
|
5
|
+
initData () {
|
|
6
|
+
// console.log('submit', this.mode)
|
|
7
|
+
|
|
8
|
+
var data = new FormData()
|
|
9
|
+
|
|
10
|
+
if (this.mode !== 'create') {
|
|
11
|
+
this.appendSysinfo(data)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
this.appendFields(data)
|
|
15
|
+
this.appendFiles(data)
|
|
16
|
+
|
|
17
|
+
return data
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
appendSysinfo (data) {
|
|
21
|
+
var sys = this.options.sysinfo
|
|
22
|
+
for (var i = 0; i < sys.length; i++) {
|
|
23
|
+
// console.log('sys', sys[i], this.info[sys[i]])
|
|
24
|
+
var name = sys[i]
|
|
25
|
+
if (sys[i] === '_id') name = 'id'
|
|
26
|
+
|
|
27
|
+
data.append(name, this.info[sys[i]])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return data
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
appendFields (data) {
|
|
34
|
+
for (var field in this.field) {
|
|
35
|
+
// console.log('field', field)
|
|
36
|
+
if (this.field.hasOwnProperty(field)) {
|
|
37
|
+
// console.log('check field', field)
|
|
38
|
+
var value = this.field[field].get()
|
|
39
|
+
if (value !== null) {
|
|
40
|
+
if (this.mode === 'update' && this.options.update && this.options.update.modifiedOnly) {
|
|
41
|
+
var modified = this.isModified(field, value)
|
|
42
|
+
if (modified) {
|
|
43
|
+
data.append(field, value)
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
data.append(field, value)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return data
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
appendFiles (data) {
|
|
56
|
+
// console.log('appendFiles', this.file)
|
|
57
|
+
for (var file in this.file) {
|
|
58
|
+
// console.log('this file', this.file, this.file[file].input)
|
|
59
|
+
// console.log('file', file, this.file[file])
|
|
60
|
+
if (this.file.hasOwnProperty(file) && this.file[file].input && this.file[file].input.value) {
|
|
61
|
+
data.append(file, this.file[file].input.files[0])
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return data
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
isModified (field, value) {
|
|
69
|
+
var initial = byString(this.info, field)
|
|
70
|
+
|
|
71
|
+
if (typeof initial === 'number') {
|
|
72
|
+
value = Number(value)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (initial !== value) {
|
|
76
|
+
// console.log('field', field, typeof value, value)
|
|
77
|
+
return true
|
|
78
|
+
} else {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/form/delete.js
CHANGED
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
// console.log('delete', this.info._id)
|
|
19
19
|
if (!this.info._id) return
|
|
20
20
|
this.setMode('delete')
|
|
21
|
-
fetch(this.options.
|
|
21
|
+
fetch(this.options.action, {
|
|
22
22
|
headers: {
|
|
23
23
|
'Accept': 'application/json',
|
|
24
24
|
'Content-Type': 'application/json'
|
|
@@ -32,6 +32,7 @@ export default {
|
|
|
32
32
|
return resp.json()
|
|
33
33
|
}).then((data) => {
|
|
34
34
|
// console.log('data', data)
|
|
35
|
+
this.form.reset()
|
|
35
36
|
this.emit('deleted', this.info._id)
|
|
36
37
|
})
|
|
37
38
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
fetch (option) {
|
|
3
|
+
// console.log('fetch', this.options.route, option.method)
|
|
4
|
+
fetch(this.options.route, {
|
|
5
|
+
method: option.method,
|
|
6
|
+
body: option.formData
|
|
7
|
+
}).then(r => r.json()).then(info => {
|
|
8
|
+
if (info.error) {
|
|
9
|
+
// console.log('Error: ' + info.error)
|
|
10
|
+
if (this.error) {
|
|
11
|
+
this.error(info)
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
// console.log('updated', info, this.mode)
|
|
15
|
+
if (this.mode === 'create') {
|
|
16
|
+
this.emit('created', info)
|
|
17
|
+
this.mode = 'read'
|
|
18
|
+
} else {
|
|
19
|
+
this.info = info
|
|
20
|
+
this.emit('updated', info)
|
|
21
|
+
this.mode = 'read'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (this.success) {
|
|
25
|
+
this.success(info)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/form/render.js
CHANGED
|
@@ -2,7 +2,7 @@ import dot from '../module/dot'
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
render (object, option) {
|
|
5
|
-
console.log('render', object)
|
|
5
|
+
// console.log('render', object)
|
|
6
6
|
|
|
7
7
|
var info = dot(object)
|
|
8
8
|
|
|
@@ -18,26 +18,19 @@ export default {
|
|
|
18
18
|
|
|
19
19
|
for (var field in this.field) {
|
|
20
20
|
if (this.field.hasOwnProperty(field)) {
|
|
21
|
-
// console.log('field type', field)
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} else if (object[field] !== undefined) {
|
|
28
|
-
var value = this.objectValueByDotKey(object, field)
|
|
29
|
-
this.field[field].set(value)
|
|
30
|
-
}
|
|
21
|
+
// console.log('field type', field, this.field[field])
|
|
22
|
+
if (this.field[field] &&
|
|
23
|
+
this.field[field].set) {
|
|
24
|
+
var value = this.objectValueByDotKey(object, field)
|
|
25
|
+
// console.log('value', value)
|
|
26
|
+
this.field[field].set(value, true)
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
this.ui.submit.disable()
|
|
36
|
-
this.ui.cancel.disable()
|
|
37
|
-
|
|
38
31
|
this.emit('rendered')
|
|
39
32
|
|
|
40
|
-
// won't stay
|
|
33
|
+
// won't stay here
|
|
41
34
|
if (option === 'create' && this.field['name']) {
|
|
42
35
|
this.focusNameOnRender(this.field['name'])
|
|
43
36
|
}
|
|
@@ -47,18 +40,20 @@ export default {
|
|
|
47
40
|
// console.log('objectValueByDotKey', object, dotkey)
|
|
48
41
|
var keys = dotkey.split(/\./)
|
|
49
42
|
|
|
50
|
-
var value
|
|
51
|
-
var o = object
|
|
43
|
+
var value = Object.assign({}, object)
|
|
52
44
|
|
|
53
45
|
for (var i = 0; i < keys.length; i++) {
|
|
54
|
-
value
|
|
46
|
+
if (value !== undefined) {
|
|
47
|
+
value = value[keys[i]]
|
|
48
|
+
}
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
return value
|
|
58
52
|
},
|
|
59
53
|
|
|
60
54
|
focusNameOnRender (field) {
|
|
61
|
-
|
|
55
|
+
// console.log('focusNameOnRender', field)
|
|
56
|
+
field.input.focus()
|
|
62
57
|
field.input.select()
|
|
63
58
|
}
|
|
64
59
|
}
|
package/src/form/set.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
set (id) {
|
|
3
|
-
// console.log('set',
|
|
3
|
+
// console.log('set', id)
|
|
4
4
|
if (!id) return
|
|
5
5
|
|
|
6
|
+
if (this.clean) {
|
|
7
|
+
this.clean()
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
this.emit('set', id)
|
|
7
11
|
|
|
8
12
|
this.setMode('read')
|
|
9
13
|
// this.render(info)
|
|
10
|
-
fetch(this.options.
|
|
14
|
+
fetch(this.options.action + id, {
|
|
11
15
|
headers: {
|
|
12
16
|
'Accept': 'application/json'
|
|
13
17
|
},
|
|
@@ -15,17 +19,28 @@ export default {
|
|
|
15
19
|
}).then((resp) => {
|
|
16
20
|
// console.log('resp', resp)
|
|
17
21
|
return resp.json()
|
|
18
|
-
}).then((
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.info = data
|
|
22
|
-
this.render(data)
|
|
23
|
-
|
|
24
|
-
if (this.ui.delete) {
|
|
25
|
-
this.ui.delete.enable()
|
|
22
|
+
}).then((info) => {
|
|
23
|
+
if (this.options.debug) {
|
|
24
|
+
console.log('info', info)
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
this.
|
|
26
|
+
this.info = info
|
|
27
|
+
this.render(info)
|
|
28
|
+
this.emit('setted', info)
|
|
29
29
|
})
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
setInfo (info) {
|
|
33
|
+
// console.log('set', id)
|
|
34
|
+
if (!info) return
|
|
35
|
+
|
|
36
|
+
// console.log('info', info)
|
|
37
|
+
this.info = info
|
|
38
|
+
this.render(info)
|
|
39
|
+
this.emit('setted', info)
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
updateInfo (info) {
|
|
43
|
+
Object.assign(this.info, info)
|
|
44
|
+
this.render(info)
|
|
30
45
|
}
|
|
31
46
|
}
|
package/src/form/submit.js
CHANGED
|
@@ -1,66 +1,41 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
|
|
3
3
|
submit (ev) {
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
if (!this.verify()) return
|
|
4
|
+
ev.preventDefault()
|
|
5
|
+
// console.log('submit', this.mode)
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
this.ui.submit.disable()
|
|
10
|
-
this.ui.cancel.disable()
|
|
7
|
+
var data = this.initData()
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
// console.log('data', data)
|
|
13
10
|
|
|
14
|
-
if (this.
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
if (this.update) {
|
|
12
|
+
this.update(data)
|
|
13
|
+
} else {
|
|
14
|
+
this.setMethod(data)
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (var field in this.field) {
|
|
22
|
-
if (this.field.hasOwnProperty(field)) {
|
|
23
|
-
// console.log('append field', field, this.field[field])
|
|
24
|
-
formData.append(field, this.field[field].get())
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// append files
|
|
29
|
-
|
|
30
|
-
for (var file in this.file) {
|
|
31
|
-
// console.log('this file', this.file, this.file[file].input)
|
|
32
|
-
// console.log('file', file, this.file[file])
|
|
33
|
-
if (this.file.hasOwnProperty(file) && this.file[file].input && this.file[file].input.value) {
|
|
34
|
-
// console.log('---- append file', this.file[file].input.value)
|
|
35
|
-
formData.append(file, this.file[file].input.files[0])
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// console.log('formData', formData.keys())
|
|
17
|
+
return false
|
|
18
|
+
},
|
|
40
19
|
|
|
20
|
+
setMethod (formData) {
|
|
41
21
|
var method = 'PUT'
|
|
42
22
|
if (this.mode === 'create') {
|
|
43
23
|
method = 'POST'
|
|
44
24
|
}
|
|
45
25
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// console.log('submit ok', info, this.mode)
|
|
54
|
-
this.ui.submit.setLabel('Apply')
|
|
26
|
+
if (this.fetch) {
|
|
27
|
+
// console.log('formData', formData.keys())
|
|
28
|
+
this.fetch({
|
|
29
|
+
method: method,
|
|
30
|
+
formData: formData
|
|
31
|
+
})
|
|
32
|
+
}
|
|
55
33
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
34
|
+
if (this.action) {
|
|
35
|
+
this.action({
|
|
36
|
+
method: method,
|
|
37
|
+
formData: formData
|
|
38
|
+
})
|
|
39
|
+
}
|
|
65
40
|
}
|
|
66
41
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
update (data, options) {
|
|
3
|
+
// console.log('update', data, options)
|
|
4
|
+
// console.log('mode', this.mode)
|
|
5
|
+
options = options || {}
|
|
6
|
+
|
|
7
|
+
// console.log('mode', this.mode)
|
|
8
|
+
var method = options.method ||
|
|
9
|
+
this.options[this.mode].method ||
|
|
10
|
+
'put'
|
|
11
|
+
|
|
12
|
+
var action = options.action ||
|
|
13
|
+
this.options[this.mode].action ||
|
|
14
|
+
this.options.action
|
|
15
|
+
|
|
16
|
+
if (this.beforeCreate) {
|
|
17
|
+
this.beforeCreate(data)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fetch(action, {
|
|
21
|
+
method: method,
|
|
22
|
+
body: data
|
|
23
|
+
}).then((resp) => {
|
|
24
|
+
// console.log('resp', resp)
|
|
25
|
+
return resp.json()
|
|
26
|
+
}).then(info => {
|
|
27
|
+
// console.log('update', info)
|
|
28
|
+
if (info.error) {
|
|
29
|
+
// console.log('Error: ' + info.error)
|
|
30
|
+
if (this.error) {
|
|
31
|
+
this.error(info)
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
// console.log('info', this.mode, info)
|
|
35
|
+
if (this.mode === 'create') {
|
|
36
|
+
this.emit('created', info)
|
|
37
|
+
this.setMode('read')
|
|
38
|
+
} else {
|
|
39
|
+
this.emit('updated', info)
|
|
40
|
+
this.setMode('read')
|
|
41
|
+
}
|
|
42
|
+
this.info = info
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
|
|
1
2
|
import { is as isObject } from './module/object'
|
|
2
3
|
import css from './module/css'
|
|
3
|
-
import insert from './element/insert'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -13,8 +13,10 @@ class Layout {
|
|
|
13
13
|
* @return {?} [description]
|
|
14
14
|
*/
|
|
15
15
|
constructor (schema, container) {
|
|
16
|
+
this.components = []
|
|
16
17
|
this.component = this.create(schema, container)
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
// console.log('this', this)
|
|
18
20
|
|
|
19
21
|
return this
|
|
20
22
|
}
|
|
@@ -30,9 +32,6 @@ class Layout {
|
|
|
30
32
|
level = level || 0
|
|
31
33
|
level++
|
|
32
34
|
|
|
33
|
-
// console.log('level', level, schema)
|
|
34
|
-
// console.log('-------------')
|
|
35
|
-
|
|
36
35
|
structure = structure || {}
|
|
37
36
|
let component = null
|
|
38
37
|
|
|
@@ -43,39 +42,44 @@ class Layout {
|
|
|
43
42
|
|
|
44
43
|
if (schema[i] instanceof Object &&
|
|
45
44
|
typeof schema[i] === 'function') {
|
|
46
|
-
if (isObject(schema[i +
|
|
45
|
+
if (isObject(schema[i + 1])) {
|
|
46
|
+
options = schema[i + 1]
|
|
47
|
+
} else if (isObject(schema[i + 2])) {
|
|
47
48
|
options = schema[i + 2]
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
if (typeof schema[i + 1] === 'string') {
|
|
51
52
|
name = schema[i + 1]
|
|
52
|
-
if (!schema[i].isElement) {
|
|
53
|
+
if (!schema[i].isElement && !schema[i].isComponent) {
|
|
53
54
|
options.name = name
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
component = new schema[i](options)
|
|
59
|
+
var element = component.root || component
|
|
58
60
|
|
|
59
|
-
if (
|
|
60
|
-
structure
|
|
61
|
+
if (level === 1) {
|
|
62
|
+
structure.root = element
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
this.
|
|
65
|
+
if (name) {
|
|
66
|
+
structure[name] = component
|
|
67
|
+
this.components.push([name, component])
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// console.log('root', component.root)
|
|
73
|
-
structure.root = component.root
|
|
74
|
-
}
|
|
70
|
+
// if (component) {
|
|
71
|
+
// this.display(component.root, options)
|
|
72
|
+
// this.style(component, options)
|
|
73
|
+
// }
|
|
75
74
|
|
|
76
75
|
if (component && container) {
|
|
77
|
-
if (component.insert)
|
|
78
|
-
|
|
76
|
+
if (component.insert) {
|
|
77
|
+
component.insert(container)
|
|
78
|
+
} else {
|
|
79
|
+
var wrapper = container.root || container
|
|
80
|
+
|
|
81
|
+
wrapper.appendChild(element)
|
|
82
|
+
}
|
|
79
83
|
component._container = container
|
|
80
84
|
}
|
|
81
85
|
} else if (Array.isArray(schema[i])) {
|
|
@@ -162,7 +166,7 @@ class Layout {
|
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
console.log('--- field', field)
|
|
169
|
+
// console.log('--- field', field)
|
|
166
170
|
|
|
167
171
|
return field
|
|
168
172
|
}
|
package/src/list/add.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
|
|
2
2
|
export default {
|
|
3
|
+
add (info, context) {
|
|
4
|
+
// console.log('list add', info)
|
|
3
5
|
|
|
6
|
+
if (!this.dataStore) return
|
|
7
|
+
context = context || null
|
|
8
|
+
|
|
9
|
+
this.dataList = this.dataList || []
|
|
10
|
+
|
|
11
|
+
if (context === 'bottom') {
|
|
12
|
+
if (this.data) { this.data.push(info) }
|
|
13
|
+
if (this.dataList) { this.dataList.push(info[this.dataId]) }
|
|
14
|
+
} else {
|
|
15
|
+
if (this.data) {
|
|
16
|
+
this.data.unshift(info)
|
|
17
|
+
} else {
|
|
18
|
+
console.log('error no data')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (this.dataList) { this.dataList.unshift(info[this.dataId]) }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.dataStore[info[this.dataId]] = info
|
|
25
|
+
// console.log('data', this.data.length, this.data)
|
|
26
|
+
|
|
27
|
+
if (window.getComputedStyle(this.root, null).display === 'none') {
|
|
28
|
+
this.virtual.items = this.data
|
|
29
|
+
} else {
|
|
30
|
+
this.virtual.update(this.data)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// this.ui.body.scrollTo(0, this.ui.body.scrollTop + 1)
|
|
34
|
+
// this.ui.body.scrollTo(0, this.ui.body.scrollTop - 1)
|
|
35
|
+
|
|
36
|
+
return info
|
|
37
|
+
}
|
|
4
38
|
}
|