material 0.4.3 → 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 +127 -44
- package/src/control/button.new.js +190 -0
- package/src/control/dialog.js +174 -0
- package/src/control/{upload.js → file.js} +33 -8
- 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 +3 -1
- package/src/control/search.js +98 -0
- package/src/control/select.js +80 -22
- 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 +18 -3
- package/src/control/textfield.js +89 -15
- package/src/field/image.js +9 -3
- package/src/form/build.js +28 -4
- package/src/form/cancel.js +7 -3
- package/src/form/controller.js +90 -0
- package/src/form/create.js +11 -7
- package/src/form/data.js +82 -0
- package/src/form/delete.js +2 -1
- package/src/form/fetch.js +5 -3
- package/src/form/render.js +11 -9
- package/src/form/set.js +27 -12
- package/src/form/submit.js +11 -37
- package/src/form/update.js +35 -16
- package/src/layout.js +25 -21
- package/src/list/add.js +34 -0
- package/src/list/build.js +96 -12
- 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 +9 -2
- 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 +6 -4
- 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 +13 -1
- package/src/view/display.js +63 -2
- package/src/form/clean.js +0 -6
- package/src/form/controls.js +0 -56
- package/src/form/mode.js +0 -8
- package/src/form/setup.js +0 -5
- package/src/list/fetch.js +0 -66
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
|
|
2
|
+
import emitter from 'material/src/module/emitter'
|
|
3
|
+
|
|
4
|
+
const defaults = {
|
|
5
|
+
size: 25,
|
|
6
|
+
count: true
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class Collection {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor
|
|
12
|
+
* @param {Object} options - Component options
|
|
13
|
+
* @return {Object} Class instance
|
|
14
|
+
*/
|
|
15
|
+
constructor (options) {
|
|
16
|
+
this.options = Object.assign({}, defaults, options || {})
|
|
17
|
+
Object.assign(this, emitter)
|
|
18
|
+
|
|
19
|
+
return this
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get (page, size, more) {
|
|
23
|
+
7
|
|
24
|
+
// console.log('fetch', page, size, more)
|
|
25
|
+
if (more !== true) {
|
|
26
|
+
this.page = 1
|
|
27
|
+
this.stop = false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.data = this.data || []
|
|
31
|
+
var signal = null
|
|
32
|
+
|
|
33
|
+
if (this.abortController) {
|
|
34
|
+
// console.log('abort')
|
|
35
|
+
this.abortController.abort()
|
|
36
|
+
this.abortController = null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (more !== true) {
|
|
40
|
+
this.abortController = new AbortController()
|
|
41
|
+
signal = this.abortController.signal
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
page = page || 1
|
|
45
|
+
size = size || this.options.list.size
|
|
46
|
+
// console.log('fetch')
|
|
47
|
+
|
|
48
|
+
if (page === 1) {
|
|
49
|
+
this.ui.body.scrolltop = 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var route = this.buildRoute(page, size)
|
|
53
|
+
|
|
54
|
+
if (more !== true && this.options.count) {
|
|
55
|
+
this.fetchCount(route)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fetch(route, {signal}).then((resp) => {
|
|
59
|
+
return resp.json()
|
|
60
|
+
}).then((data) => {
|
|
61
|
+
if (this.options.debug) {
|
|
62
|
+
console.log('data', route, data.length, data)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
data = data || []
|
|
66
|
+
|
|
67
|
+
if (data.error) {
|
|
68
|
+
console.log('error', data.error)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (data.length < this.size && more) {
|
|
73
|
+
this.stop = true
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (more === true) {
|
|
77
|
+
var a = this.data.concat(data)
|
|
78
|
+
this.data = a
|
|
79
|
+
this.storeData(data, more)
|
|
80
|
+
this.virtual.add(this.data)
|
|
81
|
+
} else {
|
|
82
|
+
this.data = []
|
|
83
|
+
this.data = data
|
|
84
|
+
this.storeData(data)
|
|
85
|
+
this.render(data)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.emit('fetched', data)
|
|
89
|
+
}).catch(function (e) {
|
|
90
|
+
// console.log('error', e.message)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fetchCount (route, signal) {
|
|
95
|
+
// console.log('fetchCount', route)
|
|
96
|
+
fetch(route + '&count=1', {signal}).then((resp) => {
|
|
97
|
+
return resp.json()
|
|
98
|
+
}).then((data) => {
|
|
99
|
+
// console.log('data', data.count)
|
|
100
|
+
this.count = data.count
|
|
101
|
+
this.statusDisplay('count', data.count)
|
|
102
|
+
}).catch(function (e) {
|
|
103
|
+
// console.log('error', e.message)
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
addParams (route, params) {
|
|
108
|
+
// console.log('addParams', route, params)
|
|
109
|
+
|
|
110
|
+
if (!route) {
|
|
111
|
+
console.log('error: no route specified!')
|
|
112
|
+
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (route.indexOf('?') > -1) {
|
|
117
|
+
// console.log('?', route, route.length, route[route.length - 1])
|
|
118
|
+
if (route[route.length - 1] === '&' || route[route.length - 1] === '?') {
|
|
119
|
+
route = route + params
|
|
120
|
+
} else {
|
|
121
|
+
route = route + '&' + params
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// console.log('add ?')
|
|
125
|
+
route = route + '?' + params
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return route
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
buildRoute (page, size, path) {
|
|
132
|
+
// console.log('buildroute', this.options.route, path)
|
|
133
|
+
path = path || 'list'
|
|
134
|
+
|
|
135
|
+
page = page || 1
|
|
136
|
+
size = size || this.options.list.size
|
|
137
|
+
|
|
138
|
+
var route = this.options.route
|
|
139
|
+
|
|
140
|
+
if (path) {
|
|
141
|
+
route = this.options.route[path]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (this.routeAddOn) {
|
|
145
|
+
route = this.routeAddOn(route)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (this.params) {
|
|
149
|
+
// console.log('params', route, this.params())
|
|
150
|
+
route = this.addParams(route, this.params())
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (this.ui.filter && this.ui.filter.root.classList.contains('selected')) {
|
|
154
|
+
route = this.addParams(route, this.getFilter())
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (this.options.pagination) {
|
|
158
|
+
route = this.addParams(route, 'page=' + page + '&size=' + size)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return route
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
storeData (list, more) {
|
|
165
|
+
// console.log('storeData', list.length, more)
|
|
166
|
+
if (more !== true) {
|
|
167
|
+
this.dataList = []
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// console.log('storeData', this.dataStore)
|
|
171
|
+
this.dataStore = this.dataStore || {}
|
|
172
|
+
for (var i = 0; i < list.length; i++) {
|
|
173
|
+
this.dataList.push(list[i]this.dataId)
|
|
174
|
+
this.dataStore[list[i]this.dataId] = list[i]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
set () {
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
setRoute (route) {
|
|
183
|
+
this.route = route
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export default Collection
|
package/src/list/create.js
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
create () {
|
|
3
|
-
console.log('create', this.mode, this.options.item.new)
|
|
3
|
+
// console.log('create', this.mode, this.options.item.new)
|
|
4
4
|
// console.log('selected', this.info, this.item)
|
|
5
5
|
|
|
6
6
|
if (this.mode === 'create') return
|
|
7
7
|
|
|
8
8
|
this.mode = 'create'
|
|
9
9
|
|
|
10
|
-
if (this.options.
|
|
11
|
-
this.
|
|
10
|
+
if (this.options.virtual === true) {
|
|
11
|
+
this.data.unshift(this.options.item.new)
|
|
12
|
+
this.render(this.data)
|
|
13
|
+
} else {
|
|
14
|
+
if (this.options.item) {
|
|
15
|
+
this.newItem = this.renderItem(this.options.item.new, 'create')
|
|
16
|
+
}
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
this.emit('create', this.options.item.new)
|
|
15
20
|
},
|
|
16
21
|
|
|
17
22
|
created (data) {
|
|
18
|
-
console.log('created', data)
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// console.log('created', this.data.length, data)
|
|
24
|
+
if (this.options.virtual === true) {
|
|
25
|
+
this.data[0] = data
|
|
26
|
+
this.render(this.data)
|
|
27
|
+
} else {
|
|
28
|
+
this.mode = null
|
|
29
|
+
this.info = data
|
|
30
|
+
this.ui.body.removeChild(this.newItem)
|
|
31
|
+
this.item = this.renderItem(data, 'top')
|
|
32
|
+
}
|
|
23
33
|
},
|
|
24
34
|
|
|
25
35
|
createCancel () {
|
|
26
|
-
console.log('createCancel', this.newItem)
|
|
27
|
-
console.log('remove')
|
|
28
|
-
console.log('prepare reselect', this.info, this.item)
|
|
36
|
+
// console.log('createCancel', this.newItem)
|
|
37
|
+
// console.log('remove')
|
|
38
|
+
// console.log('prepare reselect', this.info, this.item)
|
|
29
39
|
this.ui.body.removeChild(this.newItem)
|
|
30
40
|
this.mode = null
|
|
31
41
|
if (this.item && this.info) {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
toggle () {
|
|
4
|
+
this.visible ? this.hide() : this.show()
|
|
5
|
+
|
|
6
|
+
this.emit('toggle')
|
|
7
|
+
return this
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
show () {
|
|
11
|
+
// console.log('show', this.visible)
|
|
12
|
+
|
|
13
|
+
this.root.getBoundingClientRect()
|
|
14
|
+
|
|
15
|
+
this.root.classList.add('show')
|
|
16
|
+
this.visible = true
|
|
17
|
+
|
|
18
|
+
if (this.underlay) {
|
|
19
|
+
this.underlay.classList.add('show')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.virtual.setOffset('onShow')
|
|
23
|
+
|
|
24
|
+
this.emit('show')
|
|
25
|
+
return this
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
hide () {
|
|
29
|
+
// console.log('hide', this.root.style.display)
|
|
30
|
+
|
|
31
|
+
if (!this.root) return
|
|
32
|
+
|
|
33
|
+
this.root.classList.remove('show')
|
|
34
|
+
this.visible = false
|
|
35
|
+
|
|
36
|
+
if (this.underlay) {
|
|
37
|
+
this.underlay.classList.remove('show')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.emit('hide')
|
|
41
|
+
return this
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
destroy () {
|
|
45
|
+
// console.log('destroy', this.options.transition)
|
|
46
|
+
if (this.options.transition && this.root) {
|
|
47
|
+
this.root.classList.remove('show')
|
|
48
|
+
|
|
49
|
+
if (this.underlay) {
|
|
50
|
+
this.underlay.classList.remove('show')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
this.removeChild()
|
|
55
|
+
}, this.options.transition)
|
|
56
|
+
} else {
|
|
57
|
+
this.removeChild()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.emit('destroy')
|
|
61
|
+
|
|
62
|
+
return this
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
removeChild () {
|
|
66
|
+
if (this.root && this.root.parentNode) {
|
|
67
|
+
this.root.parentNode.removeChild(this.root)
|
|
68
|
+
this.root = null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (this.underlay && this.underlay.parentNode) {
|
|
72
|
+
this.underlay.parentNode.removeChild(this.underlay)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.emit('remove')
|
|
76
|
+
return this
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/list/empty.js
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
initFilter () {
|
|
4
|
+
this.filter = this.extractFilter(this.ui)
|
|
5
|
+
|
|
6
|
+
for (var name in this.filter) {
|
|
7
|
+
if (this.filter.hasOwnProperty(name)) {
|
|
8
|
+
this.filter[name].on('change', () => {
|
|
9
|
+
this.request()
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
this.ui['filter-clear'].on('click', () => {
|
|
15
|
+
this.clearFilter()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
this.ui['filter'].on('click', () => {
|
|
19
|
+
this.toggleFilter()
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
getFilter () {
|
|
24
|
+
// console.log('getFilter')
|
|
25
|
+
var filter = null
|
|
26
|
+
for (var name in this.filter) {
|
|
27
|
+
if (this.filter.hasOwnProperty(name)) {
|
|
28
|
+
// console.log('--', typeof this.filter[name].get(), this.filter[name].get())
|
|
29
|
+
if (this.filter[name].get() !== '' && this.filter[name].get() !== []) {
|
|
30
|
+
if (filter) {
|
|
31
|
+
filter = filter + '&' + name + '=' + this.filter[name].get()
|
|
32
|
+
} else {
|
|
33
|
+
filter = name + '=' + this.filter[name].get()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// console.log('filter', filter)
|
|
40
|
+
|
|
41
|
+
return filter
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
toggleFilter () {
|
|
45
|
+
// console.log('toggleFilter', this.ui['filter-input'])
|
|
46
|
+
|
|
47
|
+
if (this.ui['filter-input'].classList.contains('show')) {
|
|
48
|
+
this.hideFilter()
|
|
49
|
+
} else {
|
|
50
|
+
this.showFilter()
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* [showSearch description]
|
|
56
|
+
* @return {[type]} [description]
|
|
57
|
+
*/
|
|
58
|
+
showFilter () {
|
|
59
|
+
if (this.hideSearch) {
|
|
60
|
+
this.hideSearch()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// console.log('showSearch')
|
|
64
|
+
this.ui['filter'].root.classList.add('selected')
|
|
65
|
+
this.ui['filter-input'].classList.add('show')
|
|
66
|
+
|
|
67
|
+
// this.ui['search-list'].classList.add('show')
|
|
68
|
+
// this.ui.body.classList.add('hide')
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* [hideSearch description]
|
|
73
|
+
* @return {[type]} [description]
|
|
74
|
+
*/
|
|
75
|
+
hideFilter () {
|
|
76
|
+
// console.log('hideSearch')
|
|
77
|
+
this.ui['filter'].root.classList.remove('selected')
|
|
78
|
+
this.ui['filter-input'].classList.remove('show')
|
|
79
|
+
// this.ui['search-list'].classList.remove('show')
|
|
80
|
+
// this.ui.body.classList.remove('hide')
|
|
81
|
+
this.clearFilter()
|
|
82
|
+
this.request()
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
clearFilter () {
|
|
86
|
+
for (var name in this.filter) {
|
|
87
|
+
if (this.filter.hasOwnProperty(name)) {
|
|
88
|
+
this.filter[name].set('')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.request()
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
extractFilter (object) {
|
|
96
|
+
// console.log('extractField', object)
|
|
97
|
+
|
|
98
|
+
var filter = {}
|
|
99
|
+
|
|
100
|
+
for (var property in object) {
|
|
101
|
+
if (object.hasOwnProperty(property)) {
|
|
102
|
+
var str = property.split(/\./)
|
|
103
|
+
|
|
104
|
+
if (str[0] === 'filter' && str[1] !== undefined) {
|
|
105
|
+
var name = property.substr(7, property.length)
|
|
106
|
+
|
|
107
|
+
filter[name] = object[property]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return filter
|
|
113
|
+
}
|
|
114
|
+
}
|
package/src/list/load.js
CHANGED
package/src/list/remove.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
remove (id) {
|
|
3
|
-
// console.log('remove', id, this.
|
|
3
|
+
// console.log('remove', id, this.dataList)
|
|
4
|
+
// console.log('datalist', this.dataList)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
6
|
+
if (!id) return
|
|
7
|
+
|
|
8
|
+
if (!this.dataStore[id]) {
|
|
9
|
+
// console.log('not in the list')
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
this.dataList.splice(this.dataList.indexOf(id), 1)
|
|
14
|
+
|
|
15
|
+
// remove id from the list
|
|
16
|
+
this.data = this.data.filter((info) => { return info[this.dataId] !== id })
|
|
17
|
+
|
|
18
|
+
// console.log('data', this.data)
|
|
19
|
+
|
|
20
|
+
this.virtual.update(this.data)
|
|
8
21
|
}
|
|
9
22
|
}
|
package/src/list/render.js
CHANGED
|
@@ -8,6 +8,10 @@ export default {
|
|
|
8
8
|
render (list, option) {
|
|
9
9
|
// console.log('render', list)
|
|
10
10
|
this.virtual.set(list)
|
|
11
|
+
|
|
12
|
+
if (this.status && this.options.count !== true) {
|
|
13
|
+
this.status('count', list.length)
|
|
14
|
+
}
|
|
11
15
|
},
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -16,7 +20,7 @@ export default {
|
|
|
16
20
|
* @param {[type]} context [description]
|
|
17
21
|
*/
|
|
18
22
|
renderItem (info, context) {
|
|
19
|
-
// console.log('renderItem',
|
|
23
|
+
// console.log('renderItem', info)
|
|
20
24
|
info = info || {}
|
|
21
25
|
|
|
22
26
|
var container = this.ui.body
|
|
@@ -25,29 +29,44 @@ export default {
|
|
|
25
29
|
container.scrolltop = 0
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
if (context === 'search') {
|
|
29
|
-
|
|
30
|
-
}
|
|
32
|
+
// if (context === 'search') {
|
|
33
|
+
// container = this.ui['search-list']
|
|
34
|
+
// }
|
|
31
35
|
|
|
32
36
|
var element = new Element({
|
|
33
37
|
tag: 'li',
|
|
34
38
|
class: 'item'
|
|
35
39
|
})
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
// console.log('---', this.id)
|
|
42
|
+
|
|
43
|
+
if (this.id && this.id === info[this.dataId]) {
|
|
38
44
|
element.classList.add('selected')
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
element.dataset.id = info.
|
|
47
|
+
element.dataset.id = info[this.dataId]
|
|
42
48
|
element.dataset.info = this.options.info
|
|
43
49
|
|
|
44
50
|
var layout = null
|
|
45
51
|
|
|
46
52
|
if (this.options.itemSwitch) {
|
|
47
53
|
var item = info[this.options.itemSwitch]
|
|
48
|
-
|
|
54
|
+
|
|
55
|
+
if (this.options.layout.item[item]) {
|
|
56
|
+
layout = new Layout(this.options.layout.item[item], element)
|
|
57
|
+
} else {
|
|
58
|
+
layout = new Layout(this.options.layout.item.base, element)
|
|
59
|
+
}
|
|
49
60
|
} else {
|
|
50
|
-
|
|
61
|
+
var itemName = this.options.itemName || 'item'
|
|
62
|
+
layout = new Layout(this.options.layout[itemName], element)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// console.log('translate', layout)
|
|
66
|
+
|
|
67
|
+
if (this.translate && this.options.item && this.options.item.translate) {
|
|
68
|
+
// console.log('----')
|
|
69
|
+
this.translate(layout)
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
this.renderInfo(layout, info)
|
|
@@ -59,6 +78,8 @@ export default {
|
|
|
59
78
|
container.appendChild(element)
|
|
60
79
|
}
|
|
61
80
|
|
|
81
|
+
this.emit('infoRendered', info, element)
|
|
82
|
+
|
|
62
83
|
return element
|
|
63
84
|
},
|
|
64
85
|
|
|
@@ -92,7 +113,9 @@ export default {
|
|
|
92
113
|
var value = Object.assign({}, object)
|
|
93
114
|
|
|
94
115
|
for (var i = 0; i < keys.length; i++) {
|
|
95
|
-
value
|
|
116
|
+
if (value !== undefined) {
|
|
117
|
+
value = value[keys[i]]
|
|
118
|
+
}
|
|
96
119
|
}
|
|
97
120
|
|
|
98
121
|
return value
|