frappe-ui 0.1.16 → 0.1.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -203,7 +203,7 @@ export default {
203
203
  : async () => {
204
204
  loading.value = true
205
205
  try {
206
- await action.onClick()
206
+ await action.onClick(this.close)
207
207
  } finally {
208
208
  loading.value = false
209
209
  }
@@ -5,7 +5,7 @@ import {
5
5
  deleteRowInListResource,
6
6
  revertRowInListResource,
7
7
  } from './listResource'
8
- import { getLocal, saveLocal } from './local'
8
+ import { getLocal, saveLocal, deleteLocal } from './local'
9
9
  import { onDocUpdate } from './realtime'
10
10
  import { getConfig } from '../utils/config'
11
11
 
@@ -83,7 +83,12 @@ export function createDocumentResource(options, vm) {
83
83
  out.originalDoc = JSON.parse(JSON.stringify(out.doc))
84
84
  options.onSuccess?.call(vm, out.doc)
85
85
  },
86
- onError: options.onError,
86
+ onError(error) {
87
+ deleteLocal(cacheKey)
88
+ out.doc = null
89
+ out.originalDoc = null
90
+ options.onError?.call(vm, error)
91
+ },
87
92
  },
88
93
  vm
89
94
  ),
@@ -1,4 +1,4 @@
1
- import { get, set } from 'idb-keyval'
1
+ import { get, set, del } from 'idb-keyval'
2
2
 
3
3
  export function saveLocal(key, data) {
4
4
  if (typeof indexedDB === 'undefined') {
@@ -8,6 +8,14 @@ export function saveLocal(key, data) {
8
8
  return set(key, JSON.stringify(data))
9
9
  }
10
10
 
11
+ export function deleteLocal(key) {
12
+ if (typeof indexedDB === 'undefined') {
13
+ return Promise.resolve(null)
14
+ }
15
+ if (!key) return Promise.resolve()
16
+ return del(key)
17
+ }
18
+
11
19
  export function getLocal(key) {
12
20
  if (typeof indexedDB === 'undefined') {
13
21
  return Promise.resolve(null)