@simitgroup/simpleapp-generator 1.6.6-m-alpha → 1.6.6-o-alpha
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/ReleaseNote.md +7 -0
- package/dist/buildinschemas/customfield.js +1 -1
- package/dist/buildinschemas/customfield.js.map +1 -1
- package/dist/buildinschemas/index.d.ts +1 -0
- package/dist/buildinschemas/index.d.ts.map +1 -1
- package/dist/buildinschemas/index.js +3 -2
- package/dist/buildinschemas/index.js.map +1 -1
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +2 -1
- package/dist/framework.js.map +1 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +0 -5
- package/dist/generate.js.map +1 -1
- package/dist/processors/jsonschemabuilder.d.ts.map +1 -1
- package/dist/processors/jsonschemabuilder.js +75 -35
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/type.d.ts +1 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
- package/reset-install.sh +2 -1
- package/src/buildinschemas/customfield.ts +47 -0
- package/src/buildinschemas/index.ts +11 -11
- package/src/framework.ts +2 -0
- package/src/processors/jsonschemabuilder.ts +268 -192
- package/src/type.ts +3 -2
- package/templates/basic/nest/apischema.ts.eta +68 -28
- package/templates/basic/nest/controller.ts.eta +2 -1
- package/templates/basic/nest/default.ts.eta +6 -1
- package/templates/basic/nest/type.ts.eta +33 -11
- package/templates/basic/nuxt/default.ts.eta +7 -1
- package/templates/basic/nuxt/pages.form.vue.eta +5 -3
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +70 -32
- package/templates/nest/src/enums/enums.generate.ts.eta +23 -0
- package/templates/nest/src/simpleapp/generate/apischemas/simpleapp.apischema.ts.eta +7 -1
- package/templates/nest/src/simpleapp/generate/types/simpleapp.type.ts.eta +7 -1
- package/templates/nuxt/components/simpleApp/SimpleAppForm.vue.eta +8 -0
- package/templates/nuxt/components/simpleApp/SimpleAppInput.vue.eta +15 -2
- package/templates/nuxt/components/simpleApp/SimpleAppInputTable.vue.eta +6 -1
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +4 -0
- package/templates/nuxt/enums/enums.generate.ts.eta +23 -0
- package/templates/nuxt/i18n/lang/cn.ts._eta +15 -0
- package/templates/nuxt/i18n/lang/en.ts.eta +19 -0
- package/templates/nuxt/lang/en.ts.eta +1 -1
- package/templates/nuxt/plugins/18.simpleapp-custom-field-store.ts.eta +38 -0
- package/templates/nuxt/plugins/19.app-plugins.ts.eta +422 -0
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +8 -1
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +249 -213
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppCustomFieldClient.ts.eta +191 -0
- package/templates/nuxt/types/schema.ts.eta +19 -2
|
@@ -4,115 +4,147 @@
|
|
|
4
4
|
* last change 2024-03-08
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
|
-
import { ref } from
|
|
8
|
-
import type { Ref } from
|
|
9
|
-
import type { AxiosResponse } from
|
|
10
|
-
import {
|
|
11
|
-
|
|
7
|
+
import { ref } from "vue";
|
|
8
|
+
import type { Ref } from "vue";
|
|
9
|
+
import type { AxiosResponse } from "axios";
|
|
10
|
+
import {
|
|
11
|
+
SearchBody,
|
|
12
|
+
TextSearchBody,
|
|
13
|
+
NotificationStatus,
|
|
14
|
+
SchemaType,
|
|
15
|
+
FormActions,
|
|
16
|
+
} from "~/types";
|
|
17
|
+
import { getValidateService } from "~/simpleapp/generate/sharelibs/validate";
|
|
18
|
+
import { SimpleAppCustomFieldClient } from "./SimpleAppCustomFieldClient";
|
|
19
|
+
import { WatchHandle } from "vue";
|
|
12
20
|
|
|
13
21
|
// import { useToast, } from 'primevue/usetoast';
|
|
14
22
|
// import type { ToastMessageOptions } from 'primevue/toast';
|
|
15
23
|
// const toast = useToast();
|
|
16
24
|
|
|
17
25
|
type crudType = {
|
|
18
|
-
runFindOne: Function;
|
|
26
|
+
runFindOne: Function;
|
|
19
27
|
runCreate: Function;
|
|
20
|
-
runUpdate: Function;
|
|
21
|
-
runPatch: Function;
|
|
28
|
+
runUpdate: Function;
|
|
29
|
+
runPatch: Function;
|
|
22
30
|
runDelete: Function;
|
|
23
31
|
runSearch: Function;
|
|
24
|
-
runDefault:Function;
|
|
25
|
-
runFullTextSearch?:Function;
|
|
32
|
+
runDefault: Function;
|
|
33
|
+
runFullTextSearch?: Function;
|
|
26
34
|
};
|
|
27
35
|
export class SimpleAppClient<
|
|
28
|
-
TData extends { _id?: string
|
|
36
|
+
TData extends { _id?: string; created?: string; more?: any },
|
|
29
37
|
TApi extends crudType,
|
|
30
38
|
> {
|
|
31
39
|
// protected defaultTimeOut=5000
|
|
32
40
|
protected ready = true;
|
|
33
|
-
protected delayAfterGetId = 0.5*1000;
|
|
34
|
-
protected unwantchobj:any;
|
|
41
|
+
protected delayAfterGetId = 0.5 * 1000;
|
|
42
|
+
protected unwantchobj: any;
|
|
35
43
|
protected docapi;
|
|
36
|
-
public event:Function|null=null;
|
|
37
|
-
public listen:Function|null=null;
|
|
44
|
+
public event: Function | null = null;
|
|
45
|
+
public listen: Function | null = null;
|
|
38
46
|
protected data = <Ref<TData>>ref({} as TData);
|
|
39
47
|
public schema = {} as SchemaType; //cant define data type, cause it make autocomplete gone.
|
|
40
|
-
protected doctype =
|
|
41
|
-
protected docname =
|
|
48
|
+
protected doctype = "";
|
|
49
|
+
protected docname = "";
|
|
42
50
|
protected errorlist = ref({});
|
|
43
51
|
protected completeformula = true;
|
|
44
|
-
protected axios
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
protected axios;
|
|
53
|
+
private _customFieldClient = new SimpleAppCustomFieldClient();
|
|
54
|
+
protected _customFieldWatch: WatchHandle | null = null;
|
|
55
|
+
|
|
56
|
+
constructor(apiobj: TApi, doctype: string, docname: string) {
|
|
47
57
|
this.docapi = apiobj;
|
|
48
|
-
this.doctype=doctype
|
|
49
|
-
this.docname = docname
|
|
50
|
-
this.axios = useNuxtApp().$axios
|
|
58
|
+
this.doctype = doctype;
|
|
59
|
+
this.docname = docname;
|
|
60
|
+
this.axios = useNuxtApp().$axios;
|
|
51
61
|
}
|
|
52
|
-
isReady = ()=>this.ready
|
|
62
|
+
isReady = () => this.ready;
|
|
53
63
|
getDocType = () => this.doctype;
|
|
54
|
-
getDocName = (capFirst:boolean=false) =>
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
getDocName = (capFirst: boolean = false) =>
|
|
65
|
+
capFirst ? upperFirst(this.docname) : this.docname;
|
|
66
|
+
setNew = () => {};
|
|
67
|
+
isNew = () => this.data.value?.created == "";
|
|
57
68
|
setSchema = (schema: SchemaType) => (this.schema = schema);
|
|
58
|
-
getSchema = ():SchemaType=> this.schema;
|
|
69
|
+
getSchema = (): SchemaType => this.schema;
|
|
59
70
|
getErrors = () => this.errorlist;
|
|
60
71
|
getData = () => this.data.value;
|
|
61
|
-
getApi = () =>this.docapi;
|
|
72
|
+
getApi = () => this.docapi;
|
|
62
73
|
getReactiveData = () => this.data;
|
|
63
|
-
public reCalculateValue
|
|
64
|
-
public isReadOnly():boolean{
|
|
74
|
+
public reCalculateValue() {}
|
|
75
|
+
public isReadOnly(): boolean {
|
|
76
|
+
return false;
|
|
77
|
+
} //if there is readonly attribute in data, will override it at processor and client
|
|
65
78
|
setData = (data: any) => {
|
|
66
79
|
// this.data.value = data;
|
|
80
|
+
// TODO: TS ERROR
|
|
81
|
+
data.more = this._customFieldClient.processCustomFieldData(
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
this.schema.properties?.["more"],
|
|
84
|
+
data.createdBy == "",
|
|
85
|
+
data.more,
|
|
86
|
+
);
|
|
87
|
+
|
|
67
88
|
Object.assign(this.data.value, data);
|
|
68
89
|
};
|
|
69
|
-
|
|
90
|
+
|
|
91
|
+
async processCustomField() {
|
|
92
|
+
const resp = this._customFieldClient.processCustomField(this.doctype);
|
|
93
|
+
// TODO: TS ERROR
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
this.schema.properties.more = resp.schema;
|
|
96
|
+
this.setData(this.data.value);
|
|
97
|
+
}
|
|
98
|
+
|
|
70
99
|
async getById(id?: string) {
|
|
71
|
-
this.ready=false
|
|
72
|
-
if(this.unwantchobj)this.unwantchobj()
|
|
73
|
-
return await this.docapi
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
this.ready = false;
|
|
101
|
+
if (this.unwantchobj) this.unwantchobj();
|
|
102
|
+
return await this.docapi
|
|
103
|
+
.runFindOne(id, this.axios)
|
|
104
|
+
.then((res: AxiosResponse) => {
|
|
105
|
+
// if(this.event){this.event('info:getById',res.data)}
|
|
106
|
+
// this.data.value = {} as TData;
|
|
107
|
+
// Object.assign(this.data.value, res.data);
|
|
108
|
+
this.setData(res.data);
|
|
109
|
+
this.setWatchChange();
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
this.ready = true;
|
|
112
|
+
}, this.delayAfterGetId);
|
|
113
|
+
|
|
114
|
+
return res;
|
|
115
|
+
})
|
|
116
|
+
.catch((res: any) => {
|
|
117
|
+
// if(this.event){this.event('error:getById',res)}
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
this.ready = true;
|
|
120
|
+
}, this.delayAfterGetId);
|
|
121
|
+
return Promise.reject(res);
|
|
122
|
+
});
|
|
91
123
|
}
|
|
92
|
-
setWatchChange(){}
|
|
124
|
+
setWatchChange() {}
|
|
93
125
|
|
|
94
|
-
async runDefault(){
|
|
95
|
-
const res = await this.docapi.runDefault()
|
|
96
|
-
return res.data
|
|
126
|
+
async runDefault() {
|
|
127
|
+
const res = await this.docapi.runDefault();
|
|
128
|
+
return res.data;
|
|
97
129
|
}
|
|
98
|
-
async create() {
|
|
130
|
+
async create() {
|
|
99
131
|
const errors = this.validateFailed();
|
|
100
|
-
const {$event} =useNuxtApp()
|
|
132
|
+
const { $event } = useNuxtApp();
|
|
101
133
|
|
|
102
134
|
if (errors) {
|
|
103
|
-
$event(
|
|
104
|
-
documentName:this.getDocName(),
|
|
105
|
-
summary:
|
|
106
|
-
status:NotificationStatus.error,
|
|
107
|
-
data:errors
|
|
108
|
-
})
|
|
135
|
+
$event("Notification", {
|
|
136
|
+
documentName: this.getDocName(),
|
|
137
|
+
summary: "Record create failed",
|
|
138
|
+
status: NotificationStatus.error,
|
|
139
|
+
data: errors,
|
|
140
|
+
});
|
|
109
141
|
// this.event('error:create',errors)
|
|
110
142
|
return await Promise.reject(errors);
|
|
111
143
|
} else {
|
|
112
|
-
holdScreenStart()
|
|
113
|
-
this.ready=false
|
|
144
|
+
holdScreenStart();
|
|
145
|
+
this.ready = false;
|
|
114
146
|
return await this.docapi
|
|
115
|
-
.runCreate(this.data.value,this.axios)
|
|
147
|
+
.runCreate(this.data.value, this.axios)
|
|
116
148
|
.then((res: AxiosResponse) => {
|
|
117
149
|
// if(this.event){this.event('success:create',res.data);return res.data}
|
|
118
150
|
// console.log(this.getDocName(), "ok")
|
|
@@ -121,49 +153,50 @@ export class SimpleAppClient<
|
|
|
121
153
|
// summary:'Record create successfully',
|
|
122
154
|
// status:NotificationStatus.success
|
|
123
155
|
// })
|
|
124
|
-
this.data.value = {} as TData
|
|
156
|
+
this.data.value = {} as TData;
|
|
125
157
|
this.data.value = { ...res.data };
|
|
126
|
-
setTimeout(()=>{
|
|
127
|
-
this.ready=true
|
|
128
|
-
},this.delayAfterGetId)
|
|
129
|
-
holdScreenEnd()
|
|
158
|
+
setTimeout(() => {
|
|
159
|
+
this.ready = true;
|
|
160
|
+
}, this.delayAfterGetId);
|
|
161
|
+
holdScreenEnd();
|
|
130
162
|
return res.data;
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
163
|
+
})
|
|
164
|
+
.catch((errors: any) => {
|
|
165
|
+
$event("Notification", {
|
|
166
|
+
documentName: this.getDocName(),
|
|
167
|
+
summary: "Record create failed",
|
|
168
|
+
status: NotificationStatus.error,
|
|
169
|
+
data: errors.response.data.statusMessage,
|
|
170
|
+
});
|
|
171
|
+
console.error("error:create", errors.response.data);
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
this.ready = true;
|
|
174
|
+
}, this.delayAfterGetId);
|
|
175
|
+
holdScreenEnd();
|
|
176
|
+
return Promise.reject(errors);
|
|
144
177
|
});
|
|
145
178
|
}
|
|
146
179
|
}
|
|
147
180
|
|
|
148
181
|
async update() {
|
|
149
|
-
const {$event} =useNuxtApp()
|
|
150
|
-
const recordid: string = this.data.value._id ??
|
|
182
|
+
const { $event } = useNuxtApp();
|
|
183
|
+
const recordid: string = this.data.value._id ?? "";
|
|
151
184
|
const errors = this.validateFailed();
|
|
152
185
|
if (errors) {
|
|
153
186
|
// if(this.event){this.event('error:update',errors)}
|
|
154
|
-
$event(
|
|
155
|
-
documentName:this.getDocName(),
|
|
156
|
-
summary:
|
|
157
|
-
status:NotificationStatus.error,
|
|
158
|
-
data:errors
|
|
159
|
-
})
|
|
160
|
-
console.error(
|
|
187
|
+
$event("Notification", {
|
|
188
|
+
documentName: this.getDocName(),
|
|
189
|
+
summary: "Record update failed",
|
|
190
|
+
status: NotificationStatus.error,
|
|
191
|
+
data: errors,
|
|
192
|
+
});
|
|
193
|
+
console.error("update errors", errors);
|
|
161
194
|
return await Promise.reject(errors);
|
|
162
195
|
} else {
|
|
163
|
-
holdScreenStart()
|
|
164
|
-
this.ready=false
|
|
196
|
+
holdScreenStart();
|
|
197
|
+
this.ready = false;
|
|
165
198
|
return await this.docapi
|
|
166
|
-
.runUpdate(recordid, this.data.value,this.axios)
|
|
199
|
+
.runUpdate(recordid, this.data.value, this.axios)
|
|
167
200
|
.then((res: AxiosResponse) => {
|
|
168
201
|
// if(this.event){this.event('success:update',res.data)}
|
|
169
202
|
// $event('Notification',{
|
|
@@ -171,82 +204,84 @@ export class SimpleAppClient<
|
|
|
171
204
|
// summary:'Record update success',
|
|
172
205
|
// status:NotificationStatus.success,
|
|
173
206
|
// data:errors
|
|
174
|
-
// })
|
|
175
|
-
this.data.value = res.data
|
|
176
|
-
setTimeout(()=>{
|
|
177
|
-
this.ready=true
|
|
178
|
-
},this.delayAfterGetId)
|
|
179
|
-
holdScreenEnd()
|
|
207
|
+
// })
|
|
208
|
+
this.data.value = res.data;
|
|
209
|
+
setTimeout(() => {
|
|
210
|
+
this.ready = true;
|
|
211
|
+
}, this.delayAfterGetId);
|
|
212
|
+
holdScreenEnd();
|
|
180
213
|
return res.data;
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
214
|
+
})
|
|
215
|
+
.catch((errors: any) => {
|
|
216
|
+
$event("Notification", {
|
|
217
|
+
documentName: this.getDocName(),
|
|
218
|
+
summary: "Record update failed",
|
|
219
|
+
status: NotificationStatus.error,
|
|
220
|
+
data: errors.response.data.statusMessage,
|
|
221
|
+
});
|
|
188
222
|
// console.error('error:update---',errors,",---",errors.message)
|
|
189
223
|
// if(this.event){
|
|
190
224
|
// this.event('error:update',errors.response.data.data)}
|
|
191
|
-
console.error(
|
|
192
|
-
setTimeout(()=>{
|
|
193
|
-
this.ready=true
|
|
194
|
-
},this.delayAfterGetId)
|
|
195
|
-
holdScreenEnd()
|
|
196
|
-
return Promise.reject(errors)
|
|
225
|
+
console.error("error:update", errors.response.data);
|
|
226
|
+
setTimeout(() => {
|
|
227
|
+
this.ready = true;
|
|
228
|
+
}, this.delayAfterGetId);
|
|
229
|
+
holdScreenEnd();
|
|
230
|
+
return Promise.reject(errors);
|
|
197
231
|
});
|
|
198
232
|
}
|
|
199
233
|
}
|
|
200
234
|
|
|
201
235
|
async patch() {
|
|
202
|
-
const {$event} =useNuxtApp()
|
|
203
|
-
const recordid: string = this.data.value._id ??
|
|
204
|
-
holdScreenStart()
|
|
205
|
-
this.ready=false
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
const { $event } = useNuxtApp();
|
|
237
|
+
const recordid: string = this.data.value._id ?? "";
|
|
238
|
+
holdScreenStart();
|
|
239
|
+
this.ready = false;
|
|
240
|
+
return await this.docapi
|
|
241
|
+
.runPatch(recordid, this.data.value, this.axios)
|
|
242
|
+
.then((res: AxiosResponse) => {
|
|
243
|
+
// if(this.event){this.event('success:update',res.data)}
|
|
244
|
+
// $event('Notification',{
|
|
245
|
+
// documentName:this.getDocName(),
|
|
246
|
+
// summary:'Record update success',
|
|
247
|
+
// status:NotificationStatus.success,
|
|
248
|
+
// data:errors
|
|
249
|
+
// })
|
|
250
|
+
this.data.value = res.data;
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
this.ready = true;
|
|
253
|
+
}, this.delayAfterGetId);
|
|
254
|
+
holdScreenEnd();
|
|
255
|
+
return res.data;
|
|
256
|
+
})
|
|
257
|
+
.catch((errors: any) => {
|
|
258
|
+
$event("Notification", {
|
|
259
|
+
documentName: this.getDocName(),
|
|
260
|
+
summary: "Record patch failed",
|
|
261
|
+
status: NotificationStatus.error,
|
|
262
|
+
data: errors.response.data.statusMessage,
|
|
263
|
+
});
|
|
264
|
+
// console.error('error:update---',errors,",---",errors.message)
|
|
265
|
+
// if(this.event){
|
|
266
|
+
// this.event('error:update',errors.response.data.data)}
|
|
267
|
+
console.error("error:patch", errors.response.data);
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
this.ready = true;
|
|
270
|
+
}, this.delayAfterGetId);
|
|
271
|
+
holdScreenEnd();
|
|
272
|
+
return Promise.reject(errors);
|
|
273
|
+
});
|
|
240
274
|
}
|
|
241
275
|
async delete(id?: string) {
|
|
242
|
-
if(!id){
|
|
243
|
-
id = this.data.value._id ??
|
|
276
|
+
if (!id) {
|
|
277
|
+
id = this.data.value._id ?? "";
|
|
244
278
|
}
|
|
245
|
-
const {$event} =useNuxtApp()
|
|
246
|
-
holdScreenStart()
|
|
247
|
-
this.ready=false
|
|
248
|
-
return await this.docapi
|
|
249
|
-
.
|
|
279
|
+
const { $event } = useNuxtApp();
|
|
280
|
+
holdScreenStart();
|
|
281
|
+
this.ready = false;
|
|
282
|
+
return await this.docapi
|
|
283
|
+
.runDelete(id, this.axios)
|
|
284
|
+
.then((res: AxiosResponse) => {
|
|
250
285
|
// if(this.event){this.event('success:delete',res.data)}
|
|
251
286
|
// $event('Notification',{
|
|
252
287
|
// documentName:this.getDocName(),
|
|
@@ -254,48 +289,51 @@ export class SimpleAppClient<
|
|
|
254
289
|
// status:NotificationStatus.success,
|
|
255
290
|
// data:res.data
|
|
256
291
|
// })
|
|
257
|
-
setTimeout(()=>{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
holdScreenEnd()
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
this.ready = true;
|
|
294
|
+
}, this.delayAfterGetId);
|
|
295
|
+
holdScreenEnd();
|
|
261
296
|
|
|
262
|
-
return Promise.resolve(res.data)
|
|
263
|
-
})
|
|
297
|
+
return Promise.resolve(res.data);
|
|
298
|
+
})
|
|
299
|
+
.catch((errors: any) => {
|
|
264
300
|
// if(this.event){this.event('error:delete',errors.response.data.data)}
|
|
265
|
-
$event(
|
|
266
|
-
documentName:this.getDocName(),
|
|
267
|
-
summary:
|
|
268
|
-
status:NotificationStatus.error,
|
|
269
|
-
data:errors.response.data.statusMessage
|
|
270
|
-
})
|
|
271
|
-
console.error(errors.response.data)
|
|
272
|
-
setTimeout(()=>{
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
holdScreenEnd()
|
|
276
|
-
return Promise.reject(errors)
|
|
301
|
+
$event("Notification", {
|
|
302
|
+
documentName: this.getDocName(),
|
|
303
|
+
summary: "Record delete failed",
|
|
304
|
+
status: NotificationStatus.error,
|
|
305
|
+
data: errors.response.data.statusMessage,
|
|
306
|
+
});
|
|
307
|
+
console.error(errors.response.data);
|
|
308
|
+
setTimeout(() => {
|
|
309
|
+
this.ready = true;
|
|
310
|
+
}, this.delayAfterGetId);
|
|
311
|
+
holdScreenEnd();
|
|
312
|
+
return Promise.reject(errors);
|
|
277
313
|
});
|
|
278
314
|
}
|
|
279
|
-
async search(searchbody:SearchBody) {
|
|
280
|
-
return await this.docapi
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
315
|
+
async search(searchbody: SearchBody) {
|
|
316
|
+
return await this.docapi
|
|
317
|
+
.runSearch(searchbody, this.axios)
|
|
318
|
+
.then((res: AxiosResponse) => {
|
|
319
|
+
// if(this.event){this.event('info:listready',res.data);}
|
|
320
|
+
return res.data;
|
|
321
|
+
})
|
|
322
|
+
.catch((errors: any) => {
|
|
323
|
+
// if(this.event){this.event('error:list',errors.response.data.data)}
|
|
324
|
+
return Promise.reject(errors);
|
|
325
|
+
});
|
|
288
326
|
}
|
|
289
|
-
|
|
327
|
+
|
|
290
328
|
hook(type: string, data: TData) {
|
|
291
329
|
//console.log('internal save hook');
|
|
292
330
|
return true;
|
|
293
331
|
}
|
|
294
332
|
validateFailed() {
|
|
295
333
|
const ajv = getValidateService();
|
|
296
|
-
|
|
334
|
+
|
|
297
335
|
this.errorlist.value = {};
|
|
298
|
-
this.hook(
|
|
336
|
+
this.hook("pre-validation", this.data.value);
|
|
299
337
|
const validate = ajv.compile(this.schema);
|
|
300
338
|
const valid = validate(this.data.value);
|
|
301
339
|
if (!valid) {
|
|
@@ -303,13 +341,11 @@ export class SimpleAppClient<
|
|
|
303
341
|
const tmp: { [key: string]: any } = {};
|
|
304
342
|
if (errors) {
|
|
305
343
|
for (let i = 0; i < errors?.length; i++) {
|
|
306
|
-
const err = errors[i]
|
|
307
|
-
let key: string =
|
|
308
|
-
if(err.keyword ==
|
|
309
|
-
key += `/${err.params.missingProperty}
|
|
344
|
+
const err = errors[i];
|
|
345
|
+
let key: string = err.instancePath;
|
|
346
|
+
if (err.keyword == "required") {
|
|
347
|
+
key += `/${err.params.missingProperty}`;
|
|
310
348
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
349
|
|
|
314
350
|
if (!tmp[key]) {
|
|
315
351
|
tmp[key] = [];
|
|
@@ -321,28 +357,28 @@ export class SimpleAppClient<
|
|
|
321
357
|
this.errorlist.value = tmp;
|
|
322
358
|
// console.error(this.errorlist);
|
|
323
359
|
// return validate.errors;
|
|
324
|
-
return ajv.errors??validate.errors;
|
|
360
|
+
return ajv.errors ?? validate.errors;
|
|
325
361
|
} else {
|
|
326
|
-
this.hook(
|
|
362
|
+
this.hook("post-validation", this.data.value);
|
|
327
363
|
return false;
|
|
328
364
|
}
|
|
329
365
|
}
|
|
330
366
|
|
|
331
|
-
public getActions():FormActions{
|
|
332
|
-
const data:FormActions =
|
|
333
|
-
crud:[
|
|
334
|
-
docstatus:[],
|
|
335
|
-
api:[]
|
|
336
|
-
}
|
|
337
|
-
return data
|
|
367
|
+
public getActions(): FormActions {
|
|
368
|
+
const data: FormActions = {
|
|
369
|
+
crud: ["create", "update", "delete"],
|
|
370
|
+
docstatus: [],
|
|
371
|
+
api: [],
|
|
372
|
+
};
|
|
373
|
+
return data;
|
|
338
374
|
}
|
|
339
375
|
|
|
340
|
-
async runFullTextSearh(body:TextSearchBody) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const response = await this.docapi.runFullTextSearch(body)
|
|
346
|
-
return response.data
|
|
376
|
+
async runFullTextSearh(body: TextSearchBody) {
|
|
377
|
+
if (!this.docapi.runFullTextSearch) {
|
|
378
|
+
return [];
|
|
347
379
|
}
|
|
380
|
+
|
|
381
|
+
const response = await this.docapi.runFullTextSearch(body);
|
|
382
|
+
return response.data;
|
|
383
|
+
}
|
|
348
384
|
}
|