waibu-maps 2.7.6 → 2.7.7
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.
|
@@ -23,10 +23,10 @@ async function controlSearch () {
|
|
|
23
23
|
`)
|
|
24
24
|
this.addBlock('dataInit', `
|
|
25
25
|
this.$watch('$store.mapSearch.value', async val => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.$store.mapSearch.
|
|
26
|
+
await this.${prefix}FetchList(val)
|
|
27
|
+
})
|
|
28
|
+
this.$watch('$store.mapSearch.page', async val => {
|
|
29
|
+
if (val > 0) await this.${prefix}FetchList(this.$store.mapSearch.value, val)
|
|
30
30
|
})
|
|
31
31
|
this.$watch('$store.mapSearch.recent', async val => {
|
|
32
32
|
val = val ?? ''
|
|
@@ -38,6 +38,7 @@ async function controlSearch () {
|
|
|
38
38
|
})
|
|
39
39
|
this.$watch('$store.mapSearch.feed', async val => {
|
|
40
40
|
this.$store.mapSearch.recent = ''
|
|
41
|
+
this.$store.mapSearch.page = null
|
|
41
42
|
})
|
|
42
43
|
this.$watch('$store.mapSearch.busy', async val => {
|
|
43
44
|
const el = document.querySelector('#${id} .input-group .dropdown-toggle')
|
|
@@ -56,6 +57,52 @@ async function controlSearch () {
|
|
|
56
57
|
]
|
|
57
58
|
return [await wmpa.createComponent(body)]
|
|
58
59
|
}
|
|
60
|
+
`, `
|
|
61
|
+
async ${prefix}FetchList (val, page) {
|
|
62
|
+
if (_.isEmpty(val)) return wbs.notify('enterPhrase', { type: 'danger' })
|
|
63
|
+
page = page || this.$store.mapSearch.page || 1
|
|
64
|
+
let result = await ${this.params.attr.method}(val, this.$store.mapSearch.feed, { page })
|
|
65
|
+
if (_.isString(result)) {
|
|
66
|
+
this.$store.mapSearch.recent = result
|
|
67
|
+
this.$store.mapSearch.busy = false
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let pagination = ''
|
|
72
|
+
const { response, transformer, fields } = result
|
|
73
|
+
if (response.data.length === 0) {
|
|
74
|
+
this.$store.mapSearch.recent = await smaps.searchNotFound()
|
|
75
|
+
this.$store.mapSearch.busy = false
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
if (transformer) response.data = await transformer(response)
|
|
79
|
+
const body = ['<c:div><c:table hover><c:thead><c:tr>']
|
|
80
|
+
for (const key of fields) {
|
|
81
|
+
body.push('<c:th t:content="field.' + key + '" />')
|
|
82
|
+
}
|
|
83
|
+
body.push('</c:tr></c:thead><c:tbody divider>')
|
|
84
|
+
for (const row of response.data) {
|
|
85
|
+
body.push('<c:tr style="cursor:pointer" @click="select(\\'' + row._selector + '\\')">')
|
|
86
|
+
for (const key of fields) {
|
|
87
|
+
body.push('<c:td>' + (row[key] || '') + '</c:td>')
|
|
88
|
+
}
|
|
89
|
+
body.push('</c:tr>')
|
|
90
|
+
}
|
|
91
|
+
body.push('</c:tbody></c:table>')
|
|
92
|
+
if (response.pages > 1) {
|
|
93
|
+
body.push('<c:div flex=justify-content:center margin=top-3><c:pagination>')
|
|
94
|
+
const max = response.pages < 10 ? response.pages : 10
|
|
95
|
+
for (let idx = 0; idx < max; idx++) {
|
|
96
|
+
const pageNo = idx + 1
|
|
97
|
+
body.push('<c:pagination-item @click=goto(' + pageNo + ') ' + (pageNo === response.page ? 'active' : '') + '>' + (idx + 1) + '</c:pagination-item>')
|
|
98
|
+
}
|
|
99
|
+
body.push('</c:pagination></c:div>')
|
|
100
|
+
}
|
|
101
|
+
body.push('</c:div>')
|
|
102
|
+
result = await wmpa.fetchRender(body)
|
|
103
|
+
this.$store.mapSearch.recent = result
|
|
104
|
+
this.$store.mapSearch.busy = false
|
|
105
|
+
}
|
|
59
106
|
`, `
|
|
60
107
|
async ${prefix}Populate () {
|
|
61
108
|
const selector = '#${id} .input-group .dropdown-menu'
|
|
@@ -86,8 +133,12 @@ async function controlSearch () {
|
|
|
86
133
|
search () {
|
|
87
134
|
this.$store.mapSearch.value = this.$refs.input.value
|
|
88
135
|
},
|
|
136
|
+
goto (page) {
|
|
137
|
+
this.$store.mapSearch.page = page
|
|
138
|
+
},
|
|
89
139
|
clearHistory () {
|
|
90
140
|
this.$store.mapSearch.recent = ''
|
|
141
|
+
Alpine.store('mapSearch').page = null
|
|
91
142
|
},
|
|
92
143
|
abort () {
|
|
93
144
|
const endpoint = this.$store.mapSearch.busy
|
|
@@ -99,6 +150,7 @@ async function controlSearch () {
|
|
|
99
150
|
resetValue () {
|
|
100
151
|
const el = document.querySelector('#${id} input[type=search]')
|
|
101
152
|
el.value = ''
|
|
153
|
+
Alpine.store('mapSearch').page = null
|
|
102
154
|
},
|
|
103
155
|
select (id) {
|
|
104
156
|
this.$store.mapSearch.select = id
|
|
@@ -106,7 +158,7 @@ async function controlSearch () {
|
|
|
106
158
|
instance.hide()
|
|
107
159
|
}
|
|
108
160
|
}" x-init="$watch('$store.mapSearch.feed', resetValue)">
|
|
109
|
-
<c:form-input x-ref="input" type="search" dim="width:max" @keyup.enter="search()" :disabled="$store.mapSearch.busy">
|
|
161
|
+
<c:form-input x-ref="input" type="search" dim="width:max" @keyup.enter="search()" :disabled="$store.mapSearch.busy" :value="$store.mapSearch.value">
|
|
110
162
|
<c:form-input-addon prepend>
|
|
111
163
|
<c:dropdown>
|
|
112
164
|
</c:dropdown>
|
|
@@ -148,9 +200,10 @@ async function controlSearch () {
|
|
|
148
200
|
Alpine.store('mapSearch', {
|
|
149
201
|
feed: Alpine.$persist('latLng:latLng').as('mapSearchFeed'),
|
|
150
202
|
recent: Alpine.$persist('').as('mapSearchRecent'),
|
|
203
|
+
page: null,
|
|
151
204
|
feeds: [],
|
|
152
205
|
select: null,
|
|
153
|
-
value: null,
|
|
206
|
+
value: Alpine.$persist(null).as('mapSearchValue'),
|
|
154
207
|
busy: false
|
|
155
208
|
})
|
|
156
209
|
`)
|
package/package.json
CHANGED