material 0.9.19 → 0.9.21
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/package.json +1 -1
- package/src/class/component.js +1 -1
- package/src/class/view.js +3 -6
- package/src/datehour.js +17 -12
- package/src/loader.js +3 -1
- package/src/module/dom.js +0 -1
- package/src/module/layout.js +1 -1
- package/src/slider-new.js +341 -0
- package/src/switch.js +5 -7
- package/src/switcher.js +10 -10
- package/src/text.js +1 -1
- package/src/textfield.js +2 -1
- package/src/list.new/build.js +0 -139
- package/src/list.new/click.js +0 -40
- package/src/list.new/collection.js +0 -30
- package/src/list.new/create.js +0 -45
- package/src/list.new/data.js +0 -16
- package/src/list.new/display.js +0 -78
- package/src/list.new/empty.js +0 -9
- package/src/list.new/filter.js +0 -114
- package/src/list.new/image.js +0 -19
- package/src/list.new/init.js +0 -6
- package/src/list.new/load.js +0 -9
- package/src/list.new/remove.js +0 -22
- package/src/list.new/render.js +0 -142
- package/src/list.new/request.js +0 -216
- package/src/list.new/search.js +0 -155
- package/src/list.new/select.js +0 -221
- package/src/list.new/status.js +0 -21
- package/src/list.new/update.js +0 -75
- package/src/list.new/virtual.js +0 -186
- package/src/list.new/virtual.new.js +0 -213
package/src/list.new/request.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
requestById (id, cb) {
|
|
3
|
-
// log.error('requestById', id)
|
|
4
|
-
if (!id) return
|
|
5
|
-
return this.getPage(id, (data) => {
|
|
6
|
-
// log.error('getPage', data)
|
|
7
|
-
const page = data?.page || null
|
|
8
|
-
if (data?.count) this.virtual.setCount(data?.count)
|
|
9
|
-
this.request(page, null, null, cb)
|
|
10
|
-
})
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
request (page, size, more, cb) {
|
|
14
|
-
// console.log('request', page, size, more, cb)
|
|
15
|
-
if (more !== true) {
|
|
16
|
-
this.ui.body.innerHTML = ''
|
|
17
|
-
this.virtual.reset()
|
|
18
|
-
this.dataList = []
|
|
19
|
-
this.data = []
|
|
20
|
-
this.page = 1
|
|
21
|
-
this.stop = true
|
|
22
|
-
} else {
|
|
23
|
-
if (this.dataList.length < size) {
|
|
24
|
-
// console.log('no more request needed, data ', this.dataList.length)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.data = this.data || []
|
|
30
|
-
let signal = null
|
|
31
|
-
|
|
32
|
-
if (this.abortController) {
|
|
33
|
-
// console.log('abort')
|
|
34
|
-
this.abortController.abort()
|
|
35
|
-
this.abortController = null
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (more !== true && window.AbortController) {
|
|
39
|
-
this.abortController = new AbortController()
|
|
40
|
-
signal = this.abortController.signal
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
page = page || 1
|
|
44
|
-
size = size || this.options.list.size
|
|
45
|
-
// console.log('size', this.options.name, size)
|
|
46
|
-
|
|
47
|
-
if (page === 1) {
|
|
48
|
-
this.ui.body.scrolltop = 0
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const route = this.buildRoute(page, size)
|
|
52
|
-
|
|
53
|
-
if (more !== true && this.options.count) {
|
|
54
|
-
this.requestCount(route)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// console.log('route - ', this.rand, route)
|
|
58
|
-
|
|
59
|
-
fetch(route, { signal }).then((resp) => {
|
|
60
|
-
return resp.json()
|
|
61
|
-
}).then((data) => {
|
|
62
|
-
if (this.options.debug) {
|
|
63
|
-
console.log('data', route, data.length, data)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// console.log('route', route);
|
|
67
|
-
|
|
68
|
-
data = data || []
|
|
69
|
-
|
|
70
|
-
if (this.options.reverse) {
|
|
71
|
-
data.reverse()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (data.error) {
|
|
75
|
-
console.log('error', data.error)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (data.length < this.size && more) {
|
|
80
|
-
this.stop = true
|
|
81
|
-
} else {
|
|
82
|
-
this.stop = false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.data = []
|
|
86
|
-
this.data = data
|
|
87
|
-
this.storeData(data, page, size)
|
|
88
|
-
this.render(data, page, size)
|
|
89
|
-
|
|
90
|
-
// if (more === true) {
|
|
91
|
-
// const a = this.data.concat(data)
|
|
92
|
-
// this.data = a
|
|
93
|
-
// this.storeData(data, more)
|
|
94
|
-
// this.virtual.add(this.data, { page, size })
|
|
95
|
-
// } else {
|
|
96
|
-
// this.data = []
|
|
97
|
-
// this.data = data
|
|
98
|
-
// this.storeData(data)
|
|
99
|
-
// this.render(data, page, size)
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
|
-
if (cb) cb()
|
|
103
|
-
|
|
104
|
-
this.emit('fetched', data)
|
|
105
|
-
|
|
106
|
-
this.loaded = true
|
|
107
|
-
|
|
108
|
-
if (page === 1 && data.length < 1) {
|
|
109
|
-
this.emit('empty')
|
|
110
|
-
}
|
|
111
|
-
}).catch(function (e) {
|
|
112
|
-
// console.log('error', e.message)
|
|
113
|
-
})
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
getPage (id, cb) {
|
|
117
|
-
// log.info('getPage', id)
|
|
118
|
-
if (!id) {
|
|
119
|
-
return Promise.reject(new Error('id is required'))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const route = this.buildRoute(null, null, null, id)
|
|
123
|
-
|
|
124
|
-
// log.error('route', route)
|
|
125
|
-
|
|
126
|
-
return fetch(route)
|
|
127
|
-
.then((resp) => resp.json())
|
|
128
|
-
.then((data) => {
|
|
129
|
-
// log.debug('getPage data', data)
|
|
130
|
-
if (cb) cb(data)
|
|
131
|
-
return data
|
|
132
|
-
})
|
|
133
|
-
.catch((e) => {
|
|
134
|
-
// console.log('error', e.message)
|
|
135
|
-
return Promise.reject(e)
|
|
136
|
-
})
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
requestCount (route, signal) {
|
|
140
|
-
log.error('fetchCount', route + '&count=1')
|
|
141
|
-
fetch(route + '&count=1', { signal }).then((resp) => {
|
|
142
|
-
return resp.json()
|
|
143
|
-
}).then((data) => {
|
|
144
|
-
log.info('data', data.count)
|
|
145
|
-
this.count = data.count
|
|
146
|
-
this.statusDisplay('count', data.count)
|
|
147
|
-
log.info(this.virtual.setCount)
|
|
148
|
-
this.virtual.setCount(data.count)
|
|
149
|
-
}).catch(function (e) {
|
|
150
|
-
// console.log('error', e.message)
|
|
151
|
-
})
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
addParams (route, params) {
|
|
155
|
-
// log.info('addParams', route, params)
|
|
156
|
-
|
|
157
|
-
if (!route) {
|
|
158
|
-
console.log('error: no route specified!')
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (route.indexOf('?') > -1) {
|
|
164
|
-
// console.log('?', route, route.length, route[route.length - 1])
|
|
165
|
-
if (route[route.length - 1] === '&' || route[route.length - 1] === '?') {
|
|
166
|
-
route = route + params
|
|
167
|
-
} else {
|
|
168
|
-
route = route + '&' + params
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
// console.log('add ?')
|
|
172
|
-
route = route + '?' + params
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return route
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
buildRoute (page, size, path, id) {
|
|
179
|
-
// log.info('buildroute', this.options.route, path)
|
|
180
|
-
path = path || 'list'
|
|
181
|
-
|
|
182
|
-
page = page || 1
|
|
183
|
-
size = size || this.options.list.size
|
|
184
|
-
|
|
185
|
-
let route = this.options.route
|
|
186
|
-
|
|
187
|
-
if (path) {
|
|
188
|
-
route = this.options.route[path]
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (this.routeAddOn) {
|
|
192
|
-
route = this.routeAddOn(route, path, id)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (this.params && this.params()) {
|
|
196
|
-
// console.log('params', route, this.params())
|
|
197
|
-
route = this.addParams(route, this.params())
|
|
198
|
-
} else {
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (this.ui.filter && this.ui.filter.element.classList.contains('selected')) {
|
|
203
|
-
route = this.addParams(route, this.getFilter())
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (this.options.pagination) {
|
|
207
|
-
if (id) {
|
|
208
|
-
route = this.addParams(route, 'id=' + id + '&size=' + size)
|
|
209
|
-
} else {
|
|
210
|
-
route = this.addParams(route, 'page=' + page + '&size=' + size)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return route
|
|
215
|
-
}
|
|
216
|
-
}
|
package/src/list.new/search.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
search (keywords, page, size, more) {
|
|
3
|
-
// console.log('search', keywords, page, size, more)
|
|
4
|
-
|
|
5
|
-
this.emit('searching')
|
|
6
|
-
|
|
7
|
-
if (more !== true) {
|
|
8
|
-
this.ui.body.innerHTML = ''
|
|
9
|
-
this.virtual.reset()
|
|
10
|
-
this.data = []
|
|
11
|
-
this.dataList = []
|
|
12
|
-
this.data = []
|
|
13
|
-
this.page = 1
|
|
14
|
-
this.stop = false
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
this.data = this.data || []
|
|
18
|
-
let signal = null
|
|
19
|
-
|
|
20
|
-
if (this.abortController) {
|
|
21
|
-
this.abortController.abort()
|
|
22
|
-
this.abortController = null
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (more !== true) {
|
|
26
|
-
this.abortController = new AbortController()
|
|
27
|
-
signal = this.abortController.signal
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
page = page || 1
|
|
31
|
-
size = size || this.options.list.size
|
|
32
|
-
|
|
33
|
-
if (page === 1) {
|
|
34
|
-
this.ui.body.scrolltop = 0
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let route = this.buildRoute(page, size, 'search')
|
|
38
|
-
|
|
39
|
-
route = this.addParams(route, 'search=' + keywords)
|
|
40
|
-
|
|
41
|
-
// console.log('route', route)
|
|
42
|
-
|
|
43
|
-
if (more !== true && this.options.count) {
|
|
44
|
-
this.requestCount(route)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
fetch(route, { signal }).then((resp) => {
|
|
48
|
-
return resp.json()
|
|
49
|
-
}).then((data) => {
|
|
50
|
-
// console.log('data', data)
|
|
51
|
-
this.storeData(data)
|
|
52
|
-
|
|
53
|
-
this.data = data || []
|
|
54
|
-
|
|
55
|
-
// console.log('list', list)
|
|
56
|
-
|
|
57
|
-
if (data.error) {
|
|
58
|
-
console.log('error', data.error)
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (data.length < this.size && more) {
|
|
63
|
-
this.stop = true
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (more === true) {
|
|
67
|
-
const a = this.data.concat(data)
|
|
68
|
-
this.data = a
|
|
69
|
-
this.storeData(data, more)
|
|
70
|
-
this.virtual.add(this.data)
|
|
71
|
-
} else {
|
|
72
|
-
this.data = []
|
|
73
|
-
this.data = data
|
|
74
|
-
this.storeData(data)
|
|
75
|
-
this.render(data)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.emit('fetched', data)
|
|
79
|
-
}).catch(function (e) {
|
|
80
|
-
// console.log('error', e.message)
|
|
81
|
-
})
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
cancelSearch () {
|
|
85
|
-
// console.log('cancel search')
|
|
86
|
-
this.ui.body.innerHTML = ''
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* [toggleSearch description]
|
|
91
|
-
* @return {[type]} [description]
|
|
92
|
-
*/
|
|
93
|
-
toggleSearch (e) {
|
|
94
|
-
e.stopPropagation()
|
|
95
|
-
// console.log('toggle search', this.ui.body)
|
|
96
|
-
if (!this.ui['search-input'].element.classList.contains('show')) {
|
|
97
|
-
this.showSearch()
|
|
98
|
-
} else {
|
|
99
|
-
this.hideSearch()
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* [showSearch description]
|
|
105
|
-
* @return {[type]} [description]
|
|
106
|
-
*/
|
|
107
|
-
showSearch (doNotEmpty) {
|
|
108
|
-
if (this.hideFilter) {
|
|
109
|
-
this.hideFilter()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// console.log('showSearch')
|
|
113
|
-
this.mode = 'search'
|
|
114
|
-
this.element.classList.add('search-mode')
|
|
115
|
-
|
|
116
|
-
if (this.ui.search) {
|
|
117
|
-
this.ui.search.element.classList.add('selected')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (this.ui['search-input']) {
|
|
121
|
-
this.ui['search-input'].set()
|
|
122
|
-
this.ui['search-input'].show()
|
|
123
|
-
this.ui['search-input'].focus()
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!doNotEmpty) this.ui.body.innerHTML = ''
|
|
127
|
-
|
|
128
|
-
// this.ui['search-list'].classList.add('show')
|
|
129
|
-
// this.ui.body.classList.add('hide')
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* [hideSearch description]
|
|
134
|
-
* @return {[type]} [description]
|
|
135
|
-
*/
|
|
136
|
-
hideSearch (notfetch) {
|
|
137
|
-
// console.log('hideSearch', notfetch)
|
|
138
|
-
this.mode = 'standard'
|
|
139
|
-
this.element.classList.remove('search-mode')
|
|
140
|
-
|
|
141
|
-
if (this.ui.search) {
|
|
142
|
-
this.ui.search.element.classList.remove('selected')
|
|
143
|
-
}
|
|
144
|
-
if (this.ui['search-input']) {
|
|
145
|
-
this.ui['search-input'].hide()
|
|
146
|
-
this.ui['search-input'].set()
|
|
147
|
-
}
|
|
148
|
-
// this.ui['search-list'].classList.remove('show')
|
|
149
|
-
// this.ui.body.classList.remove('hide')
|
|
150
|
-
// console.log('request', notfetch)
|
|
151
|
-
if (!notfetch) {
|
|
152
|
-
this.request()
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
package/src/list.new/select.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import clone from '../module/clone'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
select (item, silent) {
|
|
5
|
-
// console.log('select', item.dataset.id)
|
|
6
|
-
if (!item || !item.dataset.id) return
|
|
7
|
-
|
|
8
|
-
const id = item.dataset.id
|
|
9
|
-
|
|
10
|
-
this.index = this.dataList.indexOf(id)
|
|
11
|
-
this.info = this.dataStore[id]
|
|
12
|
-
|
|
13
|
-
if (this.options.preventSelectAgain && this.id === id) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const selected = this.ui.body.querySelector('.selected')
|
|
18
|
-
if (selected) selected.classList.remove('selected')
|
|
19
|
-
|
|
20
|
-
if (id) {
|
|
21
|
-
this.highlight(item)
|
|
22
|
-
this.item = item
|
|
23
|
-
this.id = id
|
|
24
|
-
|
|
25
|
-
if (silent !== true) {
|
|
26
|
-
this.emit('select', id)
|
|
27
|
-
this.emit('selectItem', item)
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
this.id = null
|
|
31
|
-
this.item = null
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
unselect () {
|
|
36
|
-
// console.log('unselect')
|
|
37
|
-
const item = this.ui.body.querySelector('[data-id="' + this.id + '"]') || this.item
|
|
38
|
-
this.id = null
|
|
39
|
-
if (item) {
|
|
40
|
-
item.classList.remove('selected')
|
|
41
|
-
}
|
|
42
|
-
this.index = null
|
|
43
|
-
this.item = null
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
getInfoById (id) {
|
|
47
|
-
return clone(this.dataStore[id])
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
getSelectedInfo () {
|
|
51
|
-
return clone(this.dataStore[this.id])
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
getItemById (id, silent) {
|
|
55
|
-
// console.log('selectItemById', id)
|
|
56
|
-
const item = this.ui.body.querySelector('[data-id="' + id + '"]')
|
|
57
|
-
|
|
58
|
-
if (!item) {
|
|
59
|
-
return null
|
|
60
|
-
} else {
|
|
61
|
-
return item
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
selectById (id, silent) {
|
|
66
|
-
// console.log('selectById', id)
|
|
67
|
-
|
|
68
|
-
if (!this.dataList) {
|
|
69
|
-
return false
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const index = this.dataList.indexOf(id)
|
|
73
|
-
if (index < 0) {
|
|
74
|
-
// console.log('can\'t selectid, not in the list')
|
|
75
|
-
return false
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.index = index
|
|
79
|
-
this.id = id
|
|
80
|
-
|
|
81
|
-
this.selectItemById(id, 'down')
|
|
82
|
-
|
|
83
|
-
return id
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
selectItemById (id, direction) {
|
|
87
|
-
// console.log('selectItemById', id)
|
|
88
|
-
const item = this.ui.body.querySelector('[data-id="' + id + '"]')
|
|
89
|
-
|
|
90
|
-
this.id = id
|
|
91
|
-
|
|
92
|
-
if (!item) {
|
|
93
|
-
const index = this.dataList.indexOf(id)
|
|
94
|
-
// console.log('not found in DOM, check in dataList', index)
|
|
95
|
-
if (index > -1) {
|
|
96
|
-
const listSize = this.options.list.size
|
|
97
|
-
const slice = listSize * index / listSize
|
|
98
|
-
// console.log('getSlice', slice)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// console.log('item found', item)
|
|
105
|
-
|
|
106
|
-
// if (this.item) this.item.classList.remove('selected')
|
|
107
|
-
|
|
108
|
-
const selected = this.ui.body.querySelector('.selected')
|
|
109
|
-
if (selected) selected.classList.remove('selected')
|
|
110
|
-
|
|
111
|
-
this.item = item
|
|
112
|
-
item.classList.add('selected')
|
|
113
|
-
|
|
114
|
-
if (this.options.updatePosition === true) {
|
|
115
|
-
// console.log('selectPosition', item)
|
|
116
|
-
this.selectPosition(item, direction)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return item
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
selectPosition (item, direction) {
|
|
123
|
-
const offsetY = this.options.item.height
|
|
124
|
-
direction = direction || 'down'
|
|
125
|
-
// console.log('selectPosition', this.ui.body, direction)
|
|
126
|
-
|
|
127
|
-
this.coord = this.ui.body.getBoundingClientRect()
|
|
128
|
-
|
|
129
|
-
// console.log('coord', this.coord)
|
|
130
|
-
|
|
131
|
-
const itemTop = item.offsetTop + this.coord.top - this.ui.body.scrollTop
|
|
132
|
-
|
|
133
|
-
if (direction === 'down' && itemTop + this.options.item.height + offsetY - this.coord.y > this.coord.height) {
|
|
134
|
-
var top = this.ui.body.scrollTop + itemTop - this.coord.height - this.coord.y + this.options.item.height + offsetY
|
|
135
|
-
this.ui.body.scrollTo({
|
|
136
|
-
top,
|
|
137
|
-
left: 0
|
|
138
|
-
// behavior: 'smooth'
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (direction === 'up' && itemTop - offsetY < this.coord.top + this.coord.y) {
|
|
143
|
-
var top = this.ui.body.scrollTop + itemTop - this.coord.top - offsetY
|
|
144
|
-
// console.lof('scrollTo', top, item)
|
|
145
|
-
this.ui.body.scrollTo({
|
|
146
|
-
left: 0,
|
|
147
|
-
top
|
|
148
|
-
// behavior: 'smooth'
|
|
149
|
-
})
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
selectNext (silent) {
|
|
154
|
-
// console.log('selectNext', this.id)
|
|
155
|
-
const idx = this.dataList.indexOf(this.id)
|
|
156
|
-
|
|
157
|
-
const id = this.dataList[idx + 1]
|
|
158
|
-
|
|
159
|
-
// console.log('id', id)
|
|
160
|
-
|
|
161
|
-
if (id) {
|
|
162
|
-
this.id = id
|
|
163
|
-
// console.log('item', item)
|
|
164
|
-
this.selectItemById(id, 'down')
|
|
165
|
-
|
|
166
|
-
if (silent !== true) {
|
|
167
|
-
this.emit('select', id)
|
|
168
|
-
}
|
|
169
|
-
return id
|
|
170
|
-
} else {
|
|
171
|
-
return false
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
selectPrevious (silent) {
|
|
176
|
-
// console.log('selectPrevious', this.id)
|
|
177
|
-
const idx = this.dataList.indexOf(this.id)
|
|
178
|
-
|
|
179
|
-
const id = this.dataList[idx - 1]
|
|
180
|
-
|
|
181
|
-
if (id) {
|
|
182
|
-
this.id = id
|
|
183
|
-
// console.log('item', item)
|
|
184
|
-
this.selectItemById(id, 'up')
|
|
185
|
-
|
|
186
|
-
if (silent !== true) {
|
|
187
|
-
this.emit('select', id)
|
|
188
|
-
}
|
|
189
|
-
return id
|
|
190
|
-
} else {
|
|
191
|
-
return false
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
scrollIntoView (item) {
|
|
196
|
-
// console.log('selectPrevious', this.id)
|
|
197
|
-
item = item || this.item
|
|
198
|
-
|
|
199
|
-
if (item) {
|
|
200
|
-
item.scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' })
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
highlight (item) {
|
|
205
|
-
if (this.item) {
|
|
206
|
-
this.item.classList.remove('selected')
|
|
207
|
-
}
|
|
208
|
-
item.classList.add('selected')
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
selectCreated (info, item) {
|
|
212
|
-
// console.log('select create', info, this.item)
|
|
213
|
-
if (this.item) {
|
|
214
|
-
this.item.classList.remove('selected')
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
item.classList.add('selected')
|
|
218
|
-
|
|
219
|
-
this.emit('selectCreate', info)
|
|
220
|
-
}
|
|
221
|
-
}
|
package/src/list.new/status.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
|
|
3
|
-
statusDisplay (prop, info) {
|
|
4
|
-
// console.log('status', prop, info)
|
|
5
|
-
if (prop === 'count') {
|
|
6
|
-
this.statusCount(info)
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
statusCount (count) {
|
|
11
|
-
// console.log('statusCount', count)
|
|
12
|
-
let items = 'items'
|
|
13
|
-
if (this.status && this.status.count && this.status.count.name) {
|
|
14
|
-
items = this.status.count.name
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (this.ui.count) {
|
|
18
|
-
this.ui.count.innerHTML = '<span class="number">' + count + '</span> ' + items
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/list.new/update.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { create } from '../module/layout'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
update (info) {
|
|
5
|
-
// console.log('update', info)
|
|
6
|
-
|
|
7
|
-
this.getUpdatedInfo(info[this.dataId])
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
updateInfo (info) {
|
|
11
|
-
// console.log('update', info)
|
|
12
|
-
this.dataStore[info._id] = info
|
|
13
|
-
|
|
14
|
-
// update item in the list if visible
|
|
15
|
-
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
|
16
|
-
if (item) {
|
|
17
|
-
item.innerHTML = ''
|
|
18
|
-
const layout = create(this.options.layout.item, item)
|
|
19
|
-
|
|
20
|
-
this.renderInfo(layout, info)
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
getUpdatedIndex (id) {
|
|
25
|
-
// console.log('getUpdatedIndex', id)
|
|
26
|
-
let index = null
|
|
27
|
-
for (let i = 0; i < this.data.length; i++) {
|
|
28
|
-
// console.log('--', this.data[i][this.dataId], id)
|
|
29
|
-
if (this.data[i][this.dataId] === id) {
|
|
30
|
-
index = i
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return index
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
getUpdatedInfo (id) {
|
|
39
|
-
// console.log('getUpdatedInfo', id)
|
|
40
|
-
const index = this.getUpdatedIndex(id)
|
|
41
|
-
// console.log('index', index)
|
|
42
|
-
const route = this.buildRoute(index + 1, 1)
|
|
43
|
-
// console.log('roote', route)
|
|
44
|
-
fetch(route).then((resp) => {
|
|
45
|
-
return resp.json()
|
|
46
|
-
}).then((data) => {
|
|
47
|
-
// console.log('info', data)
|
|
48
|
-
this.updateUpdatedInfo(data[0], index, id)
|
|
49
|
-
})
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
updateUpdatedInfo (info, index, id) {
|
|
53
|
-
// console.log('updateUpdatedInfo', info, index)
|
|
54
|
-
|
|
55
|
-
if (!info) return
|
|
56
|
-
if (info[this.dataId] !== id) return
|
|
57
|
-
|
|
58
|
-
this.info = info
|
|
59
|
-
|
|
60
|
-
// update datalist
|
|
61
|
-
this.data[index] = info
|
|
62
|
-
|
|
63
|
-
// update datastore
|
|
64
|
-
this.dataStore[info[this.dataId]] = info
|
|
65
|
-
|
|
66
|
-
// update item if on the screen
|
|
67
|
-
const item = this.ui.body.querySelector('[data-id="' + info[this.dataId] + '"]')
|
|
68
|
-
if (item) {
|
|
69
|
-
item.innerHTML = ''
|
|
70
|
-
const layout = create(this.options.layout.item, item)
|
|
71
|
-
|
|
72
|
-
this.renderInfo(layout, info)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|