frappe-ui 0.0.61 → 0.0.62
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
|
@@ -99,29 +99,40 @@ export function createDocumentResource(options, vm) {
|
|
|
99
99
|
setDoc,
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
-
for (let
|
|
103
|
-
let
|
|
104
|
-
|
|
102
|
+
for (let methodKey in options.whitelistedMethods) {
|
|
103
|
+
let methodOptions = options.whitelistedMethods[methodKey]
|
|
104
|
+
if (typeof methodOptions == 'string') {
|
|
105
|
+
methodOptions = {
|
|
106
|
+
method: methodOptions,
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
let { method, onSuccess, ...otherOptions } = methodOptions
|
|
110
|
+
out[methodKey] = createResource(
|
|
105
111
|
{
|
|
106
112
|
method: 'run_doc_method',
|
|
107
113
|
makeParams(values) {
|
|
108
114
|
return {
|
|
109
115
|
dt: out.doctype,
|
|
110
116
|
dn: out.name,
|
|
111
|
-
method:
|
|
117
|
+
method: method,
|
|
112
118
|
args: JSON.stringify(values),
|
|
113
119
|
}
|
|
114
120
|
},
|
|
115
121
|
onSuccess(data) {
|
|
116
122
|
if (data.docs) {
|
|
117
123
|
for (let doc of data.docs) {
|
|
118
|
-
if (
|
|
124
|
+
if (
|
|
125
|
+
doc.doctype === out.doctype &&
|
|
126
|
+
doc.name.toString() === out.name.toString()
|
|
127
|
+
) {
|
|
119
128
|
out.doc = transform(doc)
|
|
120
129
|
break
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
132
|
}
|
|
133
|
+
onSuccess?.call(vm, out.doc)
|
|
124
134
|
},
|
|
135
|
+
...otherOptions,
|
|
125
136
|
},
|
|
126
137
|
vm
|
|
127
138
|
)
|
package/src/resources/plugin.js
CHANGED
|
@@ -74,6 +74,10 @@ let createMixin = (mixinOptions) => ({
|
|
|
74
74
|
$getDocumentResource(doctype, name) {
|
|
75
75
|
return getCachedDocumentResource(doctype, name)
|
|
76
76
|
},
|
|
77
|
+
$getDoc(doctype, name) {
|
|
78
|
+
let resource = this.$getDocumentResource(doctype, name)
|
|
79
|
+
return resource ? resource.doc : null
|
|
80
|
+
},
|
|
77
81
|
$getListResource(cacheKey) {
|
|
78
82
|
return getCachedListResource(cacheKey)
|
|
79
83
|
},
|
|
@@ -74,13 +74,11 @@ export function createResource(options, vm, getResource) {
|
|
|
74
74
|
try {
|
|
75
75
|
invalidMessage = await validateFunction.call(vm, out.params)
|
|
76
76
|
if (invalidMessage && typeof invalidMessage == 'string') {
|
|
77
|
-
out.loading = false
|
|
78
77
|
let error = new Error(invalidMessage)
|
|
79
78
|
handleError(error, errorFunctions)
|
|
80
79
|
return
|
|
81
80
|
}
|
|
82
81
|
} catch (error) {
|
|
83
|
-
out.loading = false
|
|
84
82
|
handleError(error, errorFunctions)
|
|
85
83
|
return
|
|
86
84
|
}
|
|
@@ -131,6 +129,7 @@ export function createResource(options, vm, getResource) {
|
|
|
131
129
|
}
|
|
132
130
|
|
|
133
131
|
function handleError(error, errorFunctions) {
|
|
132
|
+
out.loading = false
|
|
134
133
|
if (out.previousData) {
|
|
135
134
|
out.data = out.previousData
|
|
136
135
|
}
|