frappe-ui 0.0.26 → 0.0.27
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/components/Input.vue +16 -8
- package/src/components/Popover.vue +18 -6
- package/src/utils/resources.js +45 -4
package/package.json
CHANGED
package/src/components/Input.vue
CHANGED
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
v-for="option in selectOptions"
|
|
50
50
|
:key="option.value"
|
|
51
51
|
:value="option.value"
|
|
52
|
+
:disabled="option.disabled || false"
|
|
52
53
|
:selected="passedInputValue === option.value"
|
|
53
54
|
>
|
|
54
55
|
{{ option.label }}
|
|
@@ -159,16 +160,23 @@ export default {
|
|
|
159
160
|
})
|
|
160
161
|
},
|
|
161
162
|
selectOptions() {
|
|
162
|
-
return this.options
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
return this.options
|
|
164
|
+
.map((option) => {
|
|
165
|
+
if (typeof option === 'string') {
|
|
166
|
+
return {
|
|
167
|
+
label: option,
|
|
168
|
+
value: option,
|
|
169
|
+
}
|
|
167
170
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
return option
|
|
172
|
+
})
|
|
173
|
+
.filter(Boolean)
|
|
171
174
|
},
|
|
172
175
|
},
|
|
173
176
|
}
|
|
174
177
|
</script>
|
|
178
|
+
<style>
|
|
179
|
+
.form-select {
|
|
180
|
+
background-image: url("data:image/svg+xml;utf8,<svg fill='none' width='8' xmlns='http://www.w3.org/2000/svg' viewBox='-4 -2 16 16'><path d='M4.5 3.636 6.136 2l1.637 1.636M4.5 8.364 6.136 10l1.637-1.636' stroke='%23333C44' stroke-linecap='round' stroke-linejoin='round'/></svg>");
|
|
181
|
+
}
|
|
182
|
+
</style>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
>
|
|
10
10
|
<slot
|
|
11
11
|
name="target"
|
|
12
|
-
v-bind="{ togglePopover, updatePosition, open, close }"
|
|
12
|
+
v-bind="{ togglePopover, updatePosition, open, close, isOpen }"
|
|
13
13
|
></slot>
|
|
14
14
|
</div>
|
|
15
15
|
<teleport to="#frappeui-popper-root">
|
|
@@ -20,11 +20,19 @@
|
|
|
20
20
|
:style="{ minWidth: targetWidth ? targetWidth + 'px' : null }"
|
|
21
21
|
v-show="isOpen"
|
|
22
22
|
>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
<transition v-bind="transition">
|
|
24
|
+
<div v-show="isOpen">
|
|
25
|
+
<div
|
|
26
|
+
v-if="!hideArrow"
|
|
27
|
+
class="popover-arrow"
|
|
28
|
+
ref="popover-arrow"
|
|
29
|
+
></div>
|
|
30
|
+
<slot
|
|
31
|
+
name="content"
|
|
32
|
+
v-bind="{ togglePopover, updatePosition, open, close, isOpen }"
|
|
33
|
+
></slot>
|
|
34
|
+
</div>
|
|
35
|
+
</transition>
|
|
28
36
|
</div>
|
|
29
37
|
</teleport>
|
|
30
38
|
</div>
|
|
@@ -49,6 +57,10 @@ export default {
|
|
|
49
57
|
default: 'bottom-start',
|
|
50
58
|
},
|
|
51
59
|
popoverClass: [String, Object, Array],
|
|
60
|
+
transition: {
|
|
61
|
+
type: Object,
|
|
62
|
+
default: null,
|
|
63
|
+
},
|
|
52
64
|
},
|
|
53
65
|
emits: ['init', 'open', 'close'],
|
|
54
66
|
watch: {
|
package/src/utils/resources.js
CHANGED
|
@@ -196,6 +196,7 @@ export function createDocumentResource(options, vm) {
|
|
|
196
196
|
onSuccess(data) {
|
|
197
197
|
out.doc = transform(data)
|
|
198
198
|
},
|
|
199
|
+
onError: options.onError,
|
|
199
200
|
},
|
|
200
201
|
vm
|
|
201
202
|
),
|
|
@@ -287,8 +288,10 @@ function createListResource(options, vm, getResource) {
|
|
|
287
288
|
if (!options.doctype) return
|
|
288
289
|
|
|
289
290
|
let cacheKey = getCacheKey(options.cache)
|
|
290
|
-
if (
|
|
291
|
-
|
|
291
|
+
if (cacheKey) {
|
|
292
|
+
if (listCache[cacheKey]) {
|
|
293
|
+
return listCache[cacheKey]
|
|
294
|
+
}
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
let out = reactive({
|
|
@@ -298,6 +301,7 @@ function createListResource(options, vm, getResource) {
|
|
|
298
301
|
order_by: options.order_by,
|
|
299
302
|
start: options.start,
|
|
300
303
|
limit: options.limit,
|
|
304
|
+
originalData: null,
|
|
301
305
|
data: null,
|
|
302
306
|
list: createResource(
|
|
303
307
|
{
|
|
@@ -313,6 +317,7 @@ function createListResource(options, vm, getResource) {
|
|
|
313
317
|
}
|
|
314
318
|
},
|
|
315
319
|
onSuccess(data) {
|
|
320
|
+
out.originalData = data
|
|
316
321
|
out.data = transform(data)
|
|
317
322
|
options.onSuccess?.call(vm, out.data)
|
|
318
323
|
},
|
|
@@ -320,6 +325,37 @@ function createListResource(options, vm, getResource) {
|
|
|
320
325
|
},
|
|
321
326
|
vm
|
|
322
327
|
),
|
|
328
|
+
fetchOne: createResource(
|
|
329
|
+
{
|
|
330
|
+
method: 'frappe.client.get_list',
|
|
331
|
+
makeParams(name) {
|
|
332
|
+
return {
|
|
333
|
+
doctype: out.doctype,
|
|
334
|
+
fields: out.fields,
|
|
335
|
+
filters: { name },
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
onSuccess(data) {
|
|
339
|
+
if (data.length > 0 && out.originalData) {
|
|
340
|
+
let doc = data[0]
|
|
341
|
+
let index = out.originalData.findIndex((d) => d.name === doc.name)
|
|
342
|
+
out.originalData = out.originalData.filter(
|
|
343
|
+
(d) => d.name !== doc.name
|
|
344
|
+
)
|
|
345
|
+
out.originalData = [
|
|
346
|
+
out.originalData.slice(0, index),
|
|
347
|
+
data,
|
|
348
|
+
out.originalData.slice(index),
|
|
349
|
+
].flat()
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
out.data = transform(out.originalData)
|
|
353
|
+
options.fetchOne?.onSuccess?.call(vm, out.data)
|
|
354
|
+
},
|
|
355
|
+
onError: options.fetchOne?.onError,
|
|
356
|
+
},
|
|
357
|
+
vm
|
|
358
|
+
),
|
|
323
359
|
insert: createResource(
|
|
324
360
|
{
|
|
325
361
|
method: 'frappe.client.insert',
|
|
@@ -414,8 +450,10 @@ function createListResource(options, vm, getResource) {
|
|
|
414
450
|
// fetch list
|
|
415
451
|
out.list.fetch()
|
|
416
452
|
|
|
417
|
-
|
|
418
|
-
|
|
453
|
+
if (cacheKey) {
|
|
454
|
+
// cache
|
|
455
|
+
listCache[cacheKey] = out
|
|
456
|
+
}
|
|
419
457
|
|
|
420
458
|
return out
|
|
421
459
|
}
|
|
@@ -431,6 +469,9 @@ function createResourceForOptions(options, vm, getResource) {
|
|
|
431
469
|
}
|
|
432
470
|
|
|
433
471
|
function getCacheKey(cacheKey) {
|
|
472
|
+
if (!cacheKey) {
|
|
473
|
+
return null
|
|
474
|
+
}
|
|
434
475
|
if (typeof cacheKey === 'string') {
|
|
435
476
|
cacheKey = [cacheKey]
|
|
436
477
|
}
|