material 0.8.0 → 0.8.2
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/list/add.js +16 -3
- package/src/list/collection.js +0 -1
- package/src/module/request.js +6 -3
package/package.json
CHANGED
package/src/list/add.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
export default {
|
|
3
3
|
add (info, context) {
|
|
4
|
-
|
|
4
|
+
// console.log('list add', info)
|
|
5
5
|
|
|
6
6
|
if (!this.dataStore) return
|
|
7
|
-
context = context
|
|
7
|
+
context = context !== undefined ? context : null
|
|
8
8
|
|
|
9
9
|
this.dataList = this.dataList || []
|
|
10
10
|
|
|
11
|
-
if (context === '
|
|
11
|
+
if (typeof context === 'number') {
|
|
12
|
+
if (this.data) {
|
|
13
|
+
this.data.splice(context, 0, info)
|
|
14
|
+
} else {
|
|
15
|
+
console.log('error no data')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (this.dataList) {
|
|
19
|
+
this.dataList.splice(context, 0, info[this.dataId])
|
|
20
|
+
}
|
|
21
|
+
} else if (context === 'bottom') {
|
|
12
22
|
if (this.data) { this.data.push(info) }
|
|
13
23
|
if (this.dataList) { this.dataList.push(info[this.dataId]) }
|
|
14
24
|
} else {
|
|
@@ -30,9 +40,12 @@ export default {
|
|
|
30
40
|
this.virtual.update(this.data)
|
|
31
41
|
}
|
|
32
42
|
|
|
43
|
+
this.emit('added', info, context)
|
|
44
|
+
|
|
33
45
|
// this.ui.body.scrollTo(0, this.ui.body.scrollTop + 1)
|
|
34
46
|
// this.ui.body.scrollTo(0, this.ui.body.scrollTop - 1)
|
|
35
47
|
|
|
36
48
|
return info
|
|
37
49
|
}
|
|
50
|
+
|
|
38
51
|
}
|
package/src/list/collection.js
CHANGED
package/src/module/request.js
CHANGED
|
@@ -21,7 +21,7 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
|
|
|
21
21
|
try {
|
|
22
22
|
const response = await fetch(url, options)
|
|
23
23
|
if (!response.ok) {
|
|
24
|
-
|
|
24
|
+
// console.log('Error', response)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Determine response type based on 'Accept' header
|
|
@@ -31,8 +31,11 @@ const request = async (url, method = 'GET', body = null, headers = {}, signal =
|
|
|
31
31
|
return await response.json()
|
|
32
32
|
}
|
|
33
33
|
} catch (error) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (headers.Accept === 'text/xml') {
|
|
35
|
+
throw error
|
|
36
|
+
} else {
|
|
37
|
+
throw { error }
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
|