material 0.9.12 → 0.9.13
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/control.js +3 -6
- package/src/list/data.js +3 -0
- package/src/list/request.js +11 -0
- package/src/list.new/add.js +55 -0
- package/src/list.new/build.js +139 -0
- package/src/list.new/click.js +40 -0
- package/src/list.new/collection.js +30 -0
- package/src/list.new/create.js +45 -0
- package/src/list.new/data.js +16 -0
- package/src/list.new/display.js +78 -0
- package/src/list.new/empty.js +9 -0
- package/src/list.new/filter.js +114 -0
- package/src/list.new/image.js +19 -0
- package/src/list.new/init.js +6 -0
- package/src/list.new/load.js +9 -0
- package/src/list.new/remove.js +22 -0
- package/src/list.new/render.js +142 -0
- package/src/list.new/request.js +231 -0
- package/src/list.new/search.js +155 -0
- package/src/list.new/select.js +221 -0
- package/src/list.new/status.js +21 -0
- package/src/list.new/update.js +75 -0
- package/src/list.new/virtual.js +186 -0
- package/src/list.new/virtual.new.js +213 -0
- package/src/module/mutation.js +16 -0
- package/src/tabs.js +61 -72
package/package.json
CHANGED
package/src/class/control.js
CHANGED
|
@@ -14,18 +14,15 @@ class Control extends Component {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
on (event, listener) {
|
|
17
|
-
|
|
18
|
-
this.events[event] = []
|
|
19
|
-
}
|
|
17
|
+
this.events[event] ??= []
|
|
20
18
|
this.events[event].push(listener)
|
|
21
19
|
|
|
22
20
|
return this
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
emit (event, ...args) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
24
|
+
this.events?.[event]?.forEach(listener => listener.apply(this, args))
|
|
25
|
+
|
|
29
26
|
return this
|
|
30
27
|
}
|
|
31
28
|
}
|
package/src/list/data.js
ADDED
package/src/list/request.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
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
|
+
|
|
2
13
|
request (page, size, more, cb) {
|
|
3
14
|
// console.log('request', page, size, more, cb)
|
|
4
15
|
if (more !== true) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
add (info, context, silent) {
|
|
4
|
+
// console.log('list add', info)
|
|
5
|
+
|
|
6
|
+
if (this.options.reverse) {
|
|
7
|
+
context = 'bottom'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!this.dataStore) return
|
|
11
|
+
context = context !== undefined ? context : null
|
|
12
|
+
|
|
13
|
+
this.dataList = this.dataList || []
|
|
14
|
+
|
|
15
|
+
if (typeof context === 'number') {
|
|
16
|
+
if (this.data) {
|
|
17
|
+
this.data.splice(context, 0, info)
|
|
18
|
+
} else {
|
|
19
|
+
console.log('error no data')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (this.dataList) {
|
|
23
|
+
this.dataList.splice(context, 0, info[this.dataId])
|
|
24
|
+
}
|
|
25
|
+
} else if (context === 'bottom') {
|
|
26
|
+
if (this.data) { this.data.push(info) }
|
|
27
|
+
if (this.dataList) { this.dataList.push(info[this.dataId]) }
|
|
28
|
+
} else {
|
|
29
|
+
if (this.data) {
|
|
30
|
+
this.data.unshift(info)
|
|
31
|
+
} else {
|
|
32
|
+
console.log('error no data')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this.dataList) { this.dataList.unshift(info[this.dataId]) }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.dataStore[info[this.dataId]] = info
|
|
39
|
+
// console.log('data', this.data.length, this.data)
|
|
40
|
+
|
|
41
|
+
if (window.getComputedStyle(this.element, null).display === 'none') {
|
|
42
|
+
this.virtual.items = this.data
|
|
43
|
+
} else {
|
|
44
|
+
this.virtual.update(this.data)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (silent !== true) this.emit('added', info, context)
|
|
48
|
+
|
|
49
|
+
// this.ui.body.scrollTo(0, this.ui.body.scrollTop + 1)
|
|
50
|
+
// this.ui.body.scrollTo(0, this.ui.body.scrollTop - 1)
|
|
51
|
+
|
|
52
|
+
return info
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import scrollbar from '../module/scrollbar'
|
|
2
|
+
import dataset from '../module/dataset'
|
|
3
|
+
|
|
4
|
+
import { create } from '../module/layout'
|
|
5
|
+
import Virtual from './virtual'
|
|
6
|
+
import Loading from '../loading'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
build (data) {
|
|
10
|
+
// console.log('options', this.options.name)
|
|
11
|
+
|
|
12
|
+
this.dataId = this.options.dataId || '_id'
|
|
13
|
+
|
|
14
|
+
this.element = document.createElement('div')
|
|
15
|
+
this.element.classList.add('list')
|
|
16
|
+
|
|
17
|
+
if (this.options.class) {
|
|
18
|
+
this.addClass(this.options.class)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this.element.addEventListener('click', (e) => {
|
|
22
|
+
e.stopPropagation()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if (this.options.name) {
|
|
26
|
+
this.name = this.options.name
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (this.options.data) {
|
|
30
|
+
dataset(this.element, this.options.data)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.layout = create(this.options.layout.main, this.element)
|
|
34
|
+
this.ui = this.layout.component
|
|
35
|
+
|
|
36
|
+
// prepare loading
|
|
37
|
+
// this.ui.loading = new Loading()
|
|
38
|
+
|
|
39
|
+
if (this.options.container) {
|
|
40
|
+
this.options.container.appendChild(this.element)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const scrollbarOffset = scrollbar()
|
|
44
|
+
|
|
45
|
+
// console.log('scrollbarOffset', scrollbarOffset)
|
|
46
|
+
if (this.ui && this.ui.body) {
|
|
47
|
+
// console.log('body padding', 11 - scrollbarOffset + 'px')
|
|
48
|
+
this.ui.body.style.marginRight = 11 - scrollbarOffset + 'px'
|
|
49
|
+
this.ui.body.classList.add('offset' + scrollbarOffset)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.buildVirtual()
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
addClass (c) {
|
|
56
|
+
const list = c.split(' ')
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < list.length; i++) {
|
|
59
|
+
this.element.classList.add(list[i])
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
buildVirtual () {
|
|
64
|
+
// console.log('buildVirtual', this.options.class)
|
|
65
|
+
let height = 80
|
|
66
|
+
this.size = this.options.list.size
|
|
67
|
+
this.stop = false
|
|
68
|
+
|
|
69
|
+
if (this.options.item && this.options.item.height) {
|
|
70
|
+
height = this.options.item.height
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.virtual = new Virtual({
|
|
74
|
+
view: this.options.name,
|
|
75
|
+
container: this.ui.body,
|
|
76
|
+
itemHeight: height,
|
|
77
|
+
size: this.size,
|
|
78
|
+
render: (i) => {
|
|
79
|
+
// console.log('render', this.data[i])
|
|
80
|
+
return this.renderItem(this.data[i])
|
|
81
|
+
}
|
|
82
|
+
}).on('next', (total) => {
|
|
83
|
+
// console.log('next', total)
|
|
84
|
+
if (this.stop) return
|
|
85
|
+
|
|
86
|
+
// console.log('next', total, this.page, this.size)
|
|
87
|
+
this.page = this.page || 1
|
|
88
|
+
// console.log('slide', total, this.options.list.size)
|
|
89
|
+
// var page = Math.ceil(total / this.size) + 1
|
|
90
|
+
|
|
91
|
+
this.page++
|
|
92
|
+
|
|
93
|
+
if (this.mode === 'search') {
|
|
94
|
+
this.search(this.ui['search-input'].input.value, this.page, this.size, true)
|
|
95
|
+
} else {
|
|
96
|
+
// console.log('request', this.page, this.size, true)
|
|
97
|
+
this.request(this.page, this.size, true)
|
|
98
|
+
}
|
|
99
|
+
}).on('progress', (progress) => {
|
|
100
|
+
// console.log('progress', progress, this.count)
|
|
101
|
+
|
|
102
|
+
if (this.statusDisplay) {
|
|
103
|
+
const percent = parseInt(progress / this.count * 100)
|
|
104
|
+
this.statusDisplay('count', percent + '% | ' + progress + ' / ' + this.count)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.onProgress(progress)
|
|
108
|
+
})
|
|
109
|
+
// .on('size', (size) => {
|
|
110
|
+
// console.log('!!!!size', size)
|
|
111
|
+
// this.size = size
|
|
112
|
+
// })
|
|
113
|
+
//
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
onProgress (value) {
|
|
117
|
+
// console.log('progress', value, this._value)
|
|
118
|
+
|
|
119
|
+
if (this.ui.head) {
|
|
120
|
+
if (this.ui.body.scrollTop > 0 && this.ui.head) {
|
|
121
|
+
this.ui.head.classList.add('scrolled')
|
|
122
|
+
} else if (this.ui.head) {
|
|
123
|
+
this.ui.head.classList.remove('scrolled')
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (value > this._value) {
|
|
128
|
+
// console.log('scrolling down')
|
|
129
|
+
this.emit('scrolling', 'down')
|
|
130
|
+
} else if (value < this._value) {
|
|
131
|
+
// console.log('scrolling up')
|
|
132
|
+
this.emit('scrolling', 'up')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._value = value
|
|
136
|
+
|
|
137
|
+
this.scrollTop = this.ui.body.scrollTop
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
click (e) {
|
|
4
|
+
// console.log('click', e.target)
|
|
5
|
+
e.stopPropagation()
|
|
6
|
+
|
|
7
|
+
if (e.target === e.currentTarget) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const target = '[data-id]'
|
|
12
|
+
let item = e.target
|
|
13
|
+
let i = 0
|
|
14
|
+
|
|
15
|
+
while (item && !item.matches(target)) {
|
|
16
|
+
// console.log('item', item)
|
|
17
|
+
if (i > 10) {
|
|
18
|
+
item = null
|
|
19
|
+
break
|
|
20
|
+
}
|
|
21
|
+
item = item.parentNode
|
|
22
|
+
i++
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (e.target.matches('BUTTON') && e.target.dataset.name && item.dataset.id) {
|
|
26
|
+
// console.log('button', e.target.dataset.name)
|
|
27
|
+
this.emit(e.target.dataset.name, item.dataset.id)
|
|
28
|
+
return this
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this.select) {
|
|
32
|
+
this.select(item)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// console.log('item', item, e.target.dataset.name)
|
|
36
|
+
|
|
37
|
+
return this
|
|
38
|
+
// console.log(item)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class Collection {
|
|
2
|
+
constructor () {
|
|
3
|
+
this.items = {}
|
|
4
|
+
this.ids = []
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
add (item) {
|
|
8
|
+
const id = item[this.dataId]
|
|
9
|
+
this.items[id] = item
|
|
10
|
+
this.ids.push(id)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get (id) {
|
|
14
|
+
return this.items[id] || null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getIndex (id) {
|
|
18
|
+
return this.ids.indexOf(id)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getPage (page, pageSize) {
|
|
22
|
+
const start = (page - 1) * pageSize
|
|
23
|
+
const end = start + pageSize
|
|
24
|
+
return this.ids.slice(start, end).map(id => this.items[id])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getCount () {
|
|
28
|
+
return this.ids.length
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
create () {
|
|
3
|
+
// console.log('create', this.mode, this.options.item.new)
|
|
4
|
+
// console.log('selected', this.info, this.item)
|
|
5
|
+
|
|
6
|
+
if (this.mode === 'create') return
|
|
7
|
+
|
|
8
|
+
this.mode = 'create'
|
|
9
|
+
|
|
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
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.emit('create', this.options.item.new)
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
created (data) {
|
|
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
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
createCancel () {
|
|
36
|
+
// console.log('createCancel', this.newItem)
|
|
37
|
+
// console.log('remove')
|
|
38
|
+
// console.log('prepare reselect', this.info, this.item)
|
|
39
|
+
this.ui.body.removeChild(this.newItem)
|
|
40
|
+
this.mode = null
|
|
41
|
+
if (this.item && this.info) {
|
|
42
|
+
this.select(this.info, this.item)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
storeData (list, more) {
|
|
3
|
+
console.log('storeData', list.length, more)
|
|
4
|
+
if (more !== true) {
|
|
5
|
+
this.dataList = []
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// console.log('storeData', this.dataStore)
|
|
9
|
+
this.dataStore = this.dataStore || {}
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < list.length; i++) {
|
|
12
|
+
this.dataList.push(list[i][this.dataId])
|
|
13
|
+
this.dataStore[list[i][this.dataId]] = list[i]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -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.element.getBoundingClientRect()
|
|
14
|
+
|
|
15
|
+
this.element.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.element.style.display)
|
|
30
|
+
|
|
31
|
+
if (!this.element) return
|
|
32
|
+
|
|
33
|
+
this.element.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.element) {
|
|
47
|
+
this.element.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.element && this.element.parentNode) {
|
|
67
|
+
this.element.parentNode.removeChild(this.element)
|
|
68
|
+
this.element = 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
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
initFilter () {
|
|
4
|
+
this.filter = this.extractFilter(this.ui)
|
|
5
|
+
|
|
6
|
+
for (const 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
|
+
let filter = null
|
|
26
|
+
for (const 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.element.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.element.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 (const 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
|
+
const filter = {}
|
|
99
|
+
|
|
100
|
+
for (const property in object) {
|
|
101
|
+
if (object.hasOwnProperty(property)) {
|
|
102
|
+
const str = property.split(/\./)
|
|
103
|
+
|
|
104
|
+
if (str[0] === 'filter' && str[1] !== undefined) {
|
|
105
|
+
const name = property.substr(7, property.length)
|
|
106
|
+
|
|
107
|
+
filter[name] = object[property]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return filter
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
image (info, layout) {
|
|
3
|
+
if (info.image) {
|
|
4
|
+
let format = 'thumb'
|
|
5
|
+
if (this.options.image && this.options.image.format) {
|
|
6
|
+
format = this.options.image.format || format + '/'
|
|
7
|
+
} else {
|
|
8
|
+
format = ''
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const r = Math.floor(Math.random() * 100000) + 1
|
|
12
|
+
|
|
13
|
+
if (info.image.filename) {
|
|
14
|
+
const image = info.image.url + format + info.image.filename
|
|
15
|
+
layout.get('image').style.backgroundImage = 'url("' + image + '?' + r + '")'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
remove (id) {
|
|
3
|
+
// console.log('remove', id, this.dataList)
|
|
4
|
+
// console.log('datalist', this.dataList)
|
|
5
|
+
|
|
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)
|
|
21
|
+
}
|
|
22
|
+
}
|