@fctc/edu-logic-lib 1.1.2 → 1.1.4

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/dist/hooks.js CHANGED
@@ -4,41 +4,13 @@ var reactQuery = require('@tanstack/react-query');
4
4
  require('react-redux');
5
5
  var toolkit = require('@reduxjs/toolkit');
6
6
  var axios = require('axios');
7
- var React = require('react');
7
+ require('react');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var axios__default = /*#__PURE__*/_interopDefault(axios);
12
- var React__default = /*#__PURE__*/_interopDefault(React);
13
12
 
14
13
  // src/hooks/auth/use-forgot-password.ts
15
-
16
- // src/constants/api/uri-constant.ts
17
- var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
18
- UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
19
- UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
20
- UriConstants2["CALL_PATH"] = "/call";
21
- UriConstants2["COMPANY_PATH"] = "/company";
22
- UriConstants2["PROFILE_PATH"] = "/userinfo";
23
- UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
24
- UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
25
- UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
26
- UriConstants2["LOAD_ACTION"] = `/load_action`;
27
- UriConstants2["REPORT_PATH"] = `/report`;
28
- UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
29
- UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
30
- UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
31
- UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
32
- UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
33
- UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
34
- UriConstants2["IMAGE_PATH"] = `/web/image`;
35
- UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
36
- UriConstants2["TOKEN"] = `/check_token`;
37
- UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
38
- UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
39
- UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
40
- return UriConstants2;
41
- })(UriConstants || {});
42
14
  var initialState = {
43
15
  baseUrl: "",
44
16
  requests: null,
@@ -2641,34 +2613,6 @@ function parseExpr(expr) {
2641
2613
  const tokens = tokenize(expr);
2642
2614
  return parse(tokens);
2643
2615
  }
2644
- function evaluateExpr(expr, context = {}) {
2645
- let ast;
2646
- try {
2647
- ast = parseExpr(expr);
2648
- } catch (error) {
2649
- throw new EvalError(
2650
- `Can not parse python expression: (${expr})
2651
- Error: ${error.message}`
2652
- );
2653
- }
2654
- try {
2655
- return evaluate(ast, context);
2656
- } catch (error) {
2657
- throw new EvalError(
2658
- `Can not evaluate python expression: (${expr})
2659
- Error: ${error.message}`
2660
- );
2661
- }
2662
- }
2663
- function evaluateBooleanExpr(expr, context = {}) {
2664
- if (!expr || expr === "False" || expr === "0") {
2665
- return false;
2666
- }
2667
- if (expr === "True" || expr === "1") {
2668
- return true;
2669
- }
2670
- return evaluateExpr(`bool(${expr})`, context);
2671
- }
2672
2616
 
2673
2617
  // src/utils/domain/objects.ts
2674
2618
  function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
@@ -3006,38 +2950,6 @@ function matchDomain(record, domain) {
3006
2950
  }
3007
2951
  return matchCondition(record, condStack.pop());
3008
2952
  }
3009
- var checkDomain = (context, domain) => {
3010
- try {
3011
- if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
3012
- return false;
3013
- } else if (domain === "1" || domain === "True" || domain === true) {
3014
- return true;
3015
- }
3016
- try {
3017
- if (context && domain) {
3018
- const d = new Domain(domain);
3019
- return d.contains(context);
3020
- }
3021
- } catch (error) {
3022
- if (context && domain) {
3023
- const domainEval = evaluateBooleanExpr(domain, context);
3024
- return domainEval;
3025
- }
3026
- return false;
3027
- }
3028
- return false;
3029
- } catch (e) {
3030
- return false;
3031
- }
3032
- };
3033
- var matchDomains = (context, domains) => {
3034
- if (Array.isArray(domains)) {
3035
- if (domains?.length > 0) {
3036
- return domains && domains.some((domain) => checkDomain(context, domain));
3037
- }
3038
- } else return checkDomain(context, domains);
3039
- return false;
3040
- };
3041
2953
 
3042
2954
  // src/utils/function.ts
3043
2955
  var toQueryString = (params) => {
@@ -3045,21 +2957,6 @@ var toQueryString = (params) => {
3045
2957
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
3046
2958
  ).join("&");
3047
2959
  };
3048
- var isBase64File = (str) => {
3049
- try {
3050
- const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
3051
- if (dataUriPattern.test(str)) {
3052
- return true;
3053
- }
3054
- const base64Pattern = (
3055
- // eslint-disable-next-line no-useless-escape
3056
- /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
3057
- );
3058
- return base64Pattern.test(str);
3059
- } catch (e) {
3060
- return false;
3061
- }
3062
- };
3063
2960
 
3064
2961
  // src/services/action-service/index.ts
3065
2962
  var ActionService = {
@@ -3177,1689 +3074,20 @@ var ActionService = {
3177
3074
  }
3178
3075
  };
3179
3076
  var action_service_default = ActionService;
3180
-
3181
- // src/services/auth-service/index.ts
3182
- var AuthService = {
3183
- async login(body) {
3184
- const env2 = getEnv();
3185
- const payload = Object.fromEntries(
3186
- Object.entries({
3187
- username: body.email,
3188
- password: body.password,
3189
- grant_type: env2?.config?.grantType || "",
3190
- client_id: env2?.config?.clientId || "",
3191
- client_secret: env2?.config?.clientSecret || ""
3192
- }).filter(([_, value]) => !!value)
3193
- );
3194
- const encodedData = new URLSearchParams(payload).toString();
3195
- return env2?.requests?.post(body.path, encodedData, {
3196
- headers: {
3197
- "Content-Type": "application/x-www-form-urlencoded"
3198
- }
3199
- });
3200
- },
3201
- async forgotPassword(email) {
3202
- const env2 = getEnv();
3203
- const bodyData = {
3204
- login: email,
3205
- url: `${window.location.origin}/reset-password`
3206
- };
3207
- return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3208
- headers: {
3209
- "Content-Type": "application/json"
3210
- }
3211
- });
3212
- },
3213
- async resetPassword(data, token) {
3214
- const env2 = getEnv();
3215
- const bodyData = {
3216
- token,
3217
- password: data.password,
3218
- new_password: data.confirmPassword
3219
- };
3220
- return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3221
- headers: {
3222
- "Content-Type": "application/json"
3223
- }
3224
- });
3225
- },
3226
- async updatePassword(data, token) {
3227
- const env2 = getEnv();
3228
- const bodyData = {
3229
- token,
3230
- old_password: data.oldPassword,
3231
- new_password: data.newPassword
3232
- };
3233
- return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3234
- headers: {
3235
- "Content-Type": "application/json"
3236
- }
3237
- });
3238
- },
3239
- async isValidToken(token) {
3240
- const env2 = getEnv();
3241
- const bodyData = {
3242
- token
3243
- };
3244
- return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3245
- headers: {
3246
- "Content-Type": "application/json"
3247
- }
3248
- });
3249
- },
3250
- async loginSocial({
3251
- state,
3252
- access_token
3253
- }) {
3254
- const env2 = getEnv();
3255
- return env2?.requests?.post(
3256
- "/token/generate" /* GENTOKEN_SOCIAL */,
3257
- { state, access_token },
3258
- {
3259
- headers: {
3260
- "Content-Type": "application/json"
3261
- }
3262
- }
3263
- );
3264
- },
3265
- async getProviders(db) {
3266
- const env2 = getEnv();
3267
- return env2?.requests?.get("/oauth/providers", { params: { db } });
3268
- }
3269
- };
3270
- var auth_service_default = AuthService;
3271
-
3272
- // src/constants/widget/widget-avatar-constant.ts
3273
- var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
3274
- WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
3275
- WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
3276
- return WIDGETAVATAR2;
3277
- })(WIDGETAVATAR || {});
3278
-
3279
- // src/services/company-service/index.ts
3280
- var CompanyService = {
3281
- async getCurrentCompany() {
3282
- const env2 = getEnv();
3283
- return await env2.requests.get("/company" /* COMPANY_PATH */, {
3284
- headers: {
3285
- "Content-Type": "application/json"
3286
- }
3287
- });
3288
- },
3289
- async getInfoCompany(id) {
3290
- const env2 = getEnv();
3291
- const jsonData = {
3292
- ids: [id],
3293
- model: "res.company" /* COMPANY */,
3294
- method: "web_read" /* WEB_READ */,
3295
- kwargs: {
3296
- specification: {
3297
- primary_color: {},
3298
- secondary_color: {},
3299
- logo: {},
3300
- display_name: {},
3301
- secondary_logo: {}
3302
- }
3303
- }
3304
- };
3305
- return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3306
- headers: {
3307
- "Content-Type": "application/json"
3308
- }
3309
- });
3310
- }
3311
- };
3312
- var company_service_default = CompanyService;
3313
-
3314
- // src/services/excel-service/index.ts
3315
- var ExcelService = {
3316
- async uploadFile({ formData }) {
3317
- const env2 = getEnv();
3318
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3319
- headers: {
3320
- "Content-Type": "multipart/form-data"
3321
- }
3322
- });
3323
- },
3324
- async uploadIdFile({ formData }) {
3325
- const env2 = getEnv();
3326
- return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3327
- headers: {
3328
- "Content-Type": "multipart/form-data"
3329
- }
3330
- });
3331
- },
3332
- async parsePreview({
3333
- id,
3334
- selectedSheet,
3335
- isHeader,
3336
- context
3337
- }) {
3338
- const env2 = getEnv();
3339
- const jsonData = {
3340
- model: "base_import.import" /* BASE_IMPORT */,
3341
- method: "parse_preview",
3342
- ids: [id],
3343
- kwargs: {
3344
- options: {
3345
- import_skip_records: [],
3346
- import_set_empty_fields: [],
3347
- fallback_values: {},
3348
- name_create_enabled_fields: {},
3349
- encoding: "",
3350
- separator: "",
3351
- quoting: '"',
3352
- date_format: "",
3353
- datetime_format: "",
3354
- float_thousand_separator: ",",
3355
- float_decimal_separator: ".",
3356
- advanced: true,
3357
- has_headers: isHeader,
3358
- keep_matches: false,
3359
- limit: 2e3,
3360
- sheets: [],
3361
- sheet: selectedSheet,
3362
- skip: 0,
3363
- tracking_disable: true
3364
- }
3365
- },
3366
- with_context: context
3367
- };
3368
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3369
- headers: {
3370
- "Content-Type": "multipart/form-data"
3371
- }
3372
- });
3373
- },
3374
- async executeImport({
3375
- columns,
3376
- fields,
3377
- idFile,
3378
- options,
3379
- dryrun,
3380
- context
3381
- }) {
3382
- const env2 = getEnv();
3383
- const jsonData = {
3384
- model: "base_import.import" /* BASE_IMPORT */,
3385
- method: "execute_import",
3386
- ids: [idFile],
3387
- kwargs: {
3388
- fields,
3389
- columns,
3390
- options,
3391
- dryrun
3392
- },
3393
- with_context: context
3394
- };
3395
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3396
- headers: {
3397
- "Content-Type": "multipart/form-data"
3398
- }
3399
- });
3400
- },
3401
- async getFileExcel({ model, context }) {
3402
- const env2 = getEnv();
3403
- const jsonData = {
3404
- model,
3405
- method: "get_import_templates" /* GET_IMPORT */,
3406
- args: [],
3407
- with_context: context
3408
- };
3409
- return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3410
- },
3411
- async getFieldExport({
3412
- ids,
3413
- model,
3414
- isShow,
3415
- parentField,
3416
- fieldType,
3417
- parentName,
3418
- prefix,
3419
- name,
3420
- context,
3421
- importCompat
3422
- }) {
3423
- const env2 = getEnv();
3424
- const jsonData = {
3077
+ function useButton() {
3078
+ return reactQuery.useMutation({
3079
+ mutationFn: ({
3425
3080
  model,
3426
- import_compat: importCompat,
3427
- domain: [["id", "in", ids]],
3428
- with_context: context
3429
- };
3430
- if (isShow) {
3431
- jsonData.parent_field = parentField;
3432
- jsonData.parent_field_type = fieldType;
3433
- jsonData.parent_name = parentName;
3434
- jsonData.name = name;
3435
- jsonData.prefix = prefix;
3436
- jsonData.exclude = [null];
3437
- }
3438
- return env2.requests.post("/export/get_fields", jsonData);
3439
- },
3440
- async exportExcel({
3441
- model,
3442
- domain,
3443
- ids,
3444
- fields,
3445
- type,
3446
- importCompat,
3447
- context,
3448
- groupby
3449
- }) {
3450
- const env2 = getEnv();
3451
- const jsonData = {
3452
- model,
3453
- domain,
3454
- ids,
3455
- import_compat: importCompat,
3456
- fields,
3457
- with_context: context,
3458
- groupby: groupby ?? []
3459
- };
3460
- return env2.requests.post_excel(`/export/${type}`, jsonData);
3461
- }
3462
- };
3463
- var excel_service_default = ExcelService;
3464
-
3465
- // src/services/form-service/index.ts
3466
- var FormService = {
3467
- async getComment({ data }) {
3468
- try {
3469
- const env2 = getEnv();
3470
- const jsonData = {
3471
- thread_id: data.thread_id,
3472
- thread_model: data.thread_model,
3473
- limit: 100,
3474
- with_context: {
3475
- lang: data.lang
3476
- }
3477
- };
3478
- return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3479
- headers: {
3480
- "Content-Type": "application/json"
3481
- }
3482
- });
3483
- } catch (error) {
3484
- console.error("Error when sending message:", error);
3485
- throw error;
3486
- }
3487
- },
3488
- async sentComment({ data }) {
3489
- try {
3490
- const env2 = getEnv();
3491
- const jsonData = {
3492
- context: {
3493
- tz: "Asia/Saigon",
3494
- uid: 2,
3495
- allowed_company_ids: [1],
3496
- mail_post_autofollow: false,
3497
- temporary_id: 142183.01
3498
- },
3499
- post_data: {
3500
- body: data.message,
3501
- message_type: "comment",
3502
- attachment_ids: data.attachment_ids,
3503
- attachment_tokens: [],
3504
- subtype_xmlid: data.subtype
3505
- },
3506
- thread_id: Number(data.thread_id),
3507
- thread_model: data.thread_model
3508
- };
3509
- return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3510
- headers: {
3511
- "Content-Type": "application/json"
3512
- }
3513
- });
3514
- } catch (error) {
3515
- console.error("Error when sent message:", error);
3516
- throw error;
3517
- }
3518
- },
3519
- async deleteComment({ data }) {
3520
- try {
3521
- const env2 = getEnv();
3522
- const jsonData = {
3523
- attachment_ids: [],
3524
- attachment_tokens: [],
3525
- body: "",
3526
- message_id: data.message_id
3527
- };
3528
- return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3529
- headers: {
3530
- "Content-Type": "application/json"
3531
- }
3532
- });
3533
- } catch (error) {
3534
- console.error("Error when sent message:", error);
3535
- throw error;
3536
- }
3537
- },
3538
- async getImage({ data }) {
3539
- try {
3540
- const env2 = getEnv();
3541
- return env2.requests.get(
3542
- `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3543
- {
3544
- headers: {
3545
- "Content-Type": "application/json"
3546
- }
3547
- }
3548
- );
3549
- } catch (error) {
3550
- console.error("Error when sent message:", error);
3551
- throw error;
3552
- }
3553
- },
3554
- async uploadImage({ data }) {
3555
- try {
3556
- const env2 = getEnv();
3557
- return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3558
- headers: {
3559
- "Content-Type": "multipart/form-data"
3560
- }
3561
- });
3562
- } catch (error) {
3563
- console.error("Error when sent message:", error);
3564
- throw error;
3565
- }
3566
- },
3567
- async getFormView({ data }) {
3568
- try {
3569
- const env2 = getEnv();
3570
- const jsonData = {
3571
- model: data.model,
3572
- method: "get_formview_action",
3573
- ids: data.id ? [data.id] : [],
3574
- with_context: data.context
3575
- };
3576
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3577
- headers: {
3578
- "Content-Type": "application/json"
3579
- }
3580
- });
3581
- } catch (error) {
3582
- console.error("Error when fetching form view:", error);
3583
- throw error;
3584
- }
3585
- },
3586
- async changeStatus({ data }) {
3587
- const env2 = getEnv();
3588
- const vals = {
3589
- [data.name]: data.stage_id
3590
- };
3591
- const jsonData = {
3592
- model: data.model,
3593
- method: "web_save",
3594
- with_context: {
3595
- lang: data.lang,
3596
- allowed_company_ids: [1],
3597
- uid: 2,
3598
- search_default_my_ticket: true,
3599
- search_default_is_open: true
3600
- },
3601
- ids: [data.id],
3602
- kwargs: {
3603
- vals,
3604
- specification: {}
3605
- }
3606
- };
3607
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3608
- headers: {
3609
- "Content-Type": "application/json"
3610
- }
3611
- });
3612
- }
3613
- };
3614
- var form_service_default = FormService;
3615
-
3616
- // src/services/model-service/index.ts
3617
- var OBJECT_POSITION = 2;
3618
- var ModelService = {
3619
- async getAll({ data }) {
3620
- const env2 = getEnv();
3621
- const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3622
- fields: data.fields,
3623
- groupby: data.groupby
3624
- } : {
3625
- count_limit: 10001,
3626
- order: data.sort,
3627
- specification: data.specification
3628
- };
3629
- const jsonData = {
3630
- model: String(data.model),
3631
- method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3632
- ids: data.ids,
3633
- with_context: data.context,
3634
- kwargs: {
3635
- domain: data.domain,
3636
- limit: data.limit,
3637
- offset: data.offset,
3638
- ...jsonReadGroup
3639
- }
3640
- };
3641
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3642
- headers: {
3643
- "Content-Type": "application/json"
3644
- }
3645
- });
3646
- },
3647
- async getList({
3648
- model,
3649
- ids = [],
3650
- specification = {},
3651
- domain = [],
3652
- offset,
3653
- order,
3654
- context = {},
3655
- limit = 10
3656
- }) {
3657
- const env2 = getEnv();
3658
- const jsonData = {
3659
- model,
3660
- method: "web_search_read" /* WEB_SEARCH_READ */,
3661
- ids,
3662
- with_context: context,
3663
- kwargs: {
3664
- specification,
3665
- domain,
3666
- limit,
3667
- offset,
3668
- order
3669
- }
3670
- };
3671
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3672
- headers: {
3673
- "Content-Type": "application/json"
3674
- }
3675
- });
3676
- },
3677
- async getDetail({
3678
- ids = [],
3679
- model,
3680
- specification,
3681
- context
3682
- }) {
3683
- const env2 = getEnv();
3684
- const jsonData = {
3685
- model,
3686
- method: "web_read" /* WEB_READ */,
3687
- ids,
3688
- with_context: context,
3689
- kwargs: {
3690
- specification
3691
- }
3692
- };
3693
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3694
- headers: {
3695
- "Content-Type": "application/json"
3696
- }
3697
- });
3698
- },
3699
- async save({
3700
- model,
3701
- ids = [],
3702
- data = {},
3703
- specification = {},
3704
- context = {}
3705
- }) {
3706
- const env2 = getEnv();
3707
- const jsonData = {
3708
- model,
3709
- method: "web_save" /* WEB_SAVE */,
3710
- with_context: context,
3711
- ids,
3712
- kwargs: {
3713
- vals: data,
3714
- specification
3715
- }
3716
- };
3717
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3718
- headers: {
3719
- "Content-Type": "application/json"
3720
- }
3721
- });
3722
- },
3723
- async delete({ ids = [], model }) {
3724
- const env2 = getEnv();
3725
- const jsonData = {
3726
- model,
3727
- method: "unlink" /* UNLINK */,
3728
- ids
3729
- };
3730
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3731
- headers: {
3732
- "Content-Type": "application/json"
3733
- }
3734
- });
3735
- },
3736
- async onChange({
3737
- ids = [],
3738
- model,
3739
- object,
3740
- specification,
3741
- context,
3742
- fieldChange
3743
- }) {
3744
- const env2 = getEnv();
3745
- const jsonData = {
3746
- model,
3747
- method: "onchange" /* ONCHANGE */,
3748
- ids,
3749
- with_context: context,
3750
- args: [
3751
- object ? object : {},
3752
- fieldChange ? fieldChange : [],
3753
- specification
3754
- ]
3755
- };
3756
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3757
- headers: {
3758
- "Content-Type": "application/json"
3759
- }
3760
- });
3761
- },
3762
- async getListFieldsOnchange({ model }) {
3763
- const env2 = getEnv();
3764
- const jsonData = {
3765
- model,
3766
- method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3767
- };
3768
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3769
- headers: {
3770
- "Content-Type": "application/json"
3771
- }
3772
- });
3773
- },
3774
- parseORMOdoo(data) {
3775
- for (const key in data) {
3776
- if (key === "display_name") {
3777
- delete data[key];
3778
- }
3779
- if (!data[key] && data[key] !== 0) {
3780
- data[key] = false;
3781
- } else if (data[key] === "Draft") {
3782
- data[key] = "/";
3783
- }
3784
- }
3785
- return { ...data };
3786
- },
3787
- toDataJS(data, viewData, model) {
3788
- for (const key in data) {
3789
- if (data[key] === false) {
3790
- if (viewData && model) {
3791
- if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
3792
- data[key] = null;
3793
- }
3794
- } else {
3795
- data[key] = null;
3796
- }
3797
- } else if (data[key] === "/") {
3798
- data[key] = "Draft";
3799
- } else if (data[key] !== false) {
3800
- if (model !== void 0) {
3801
- if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
3802
- data[key] = (data[key] ??= [])?.map((item, index) => {
3803
- const relation = viewData?.models?.[model]?.[key]?.relation;
3804
- if (relation !== void 0) {
3805
- if (viewData?.models?.[relation]) {
3806
- if (item?.length >= 3) {
3807
- if (item[0] === 2 /* DELETE */) {
3808
- delete data[key][index];
3809
- return;
3810
- }
3811
- return ModelService.toDataJS(
3812
- { ...item[OBJECT_POSITION], id: `virtual_${index}` },
3813
- viewData,
3814
- relation
3815
- );
3816
- } else {
3817
- return ModelService.toDataJS(item, viewData, relation);
3818
- }
3819
- } else {
3820
- if (item?.length >= 3) {
3821
- if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
3822
- delete data[key][index];
3823
- return;
3824
- }
3825
- return item[OBJECT_POSITION];
3826
- } else {
3827
- return item;
3828
- }
3829
- }
3830
- }
3831
- });
3832
- }
3833
- }
3834
- }
3835
- }
3836
- return { ...data };
3837
- }
3838
- };
3839
- var model_service_default = ModelService;
3840
-
3841
- // src/services/user-service/index.ts
3842
- var UserService = {
3843
- async getProfile() {
3844
- const env2 = getEnv();
3845
- return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
3846
- headers: {
3847
- "Content-Type": "application/x-www-form-urlencoded"
3848
- }
3849
- });
3850
- },
3851
- async getUser({ context, id }) {
3852
- const env2 = getEnv();
3853
- const jsonData = {
3854
- model: "res.users",
3855
- method: "web_read",
3856
- ids: [id],
3857
- with_context: context,
3858
- kwargs: {
3859
- specification: {
3860
- display_name: {},
3861
- image_1920: {},
3862
- name: {},
3863
- login: {},
3864
- email: {},
3865
- password: {},
3866
- visible_group_id: {
3867
- fields: {
3868
- id: {},
3869
- display_name: {}
3870
- }
3871
- },
3872
- company_id: {
3873
- fields: {
3874
- id: {},
3875
- display_name: {}
3876
- }
3877
- }
3878
- }
3879
- }
3880
- };
3881
- return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3882
- headers: {
3883
- "Content-Type": "application/json"
3884
- }
3885
- });
3886
- },
3887
- switchUserLocale: async ({ id, values }) => {
3888
- const env2 = getEnv();
3889
- const jsonData = {
3890
- model: "res.users",
3891
- domain: [["id", "=", id]],
3892
- values
3893
- };
3894
- return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
3895
- headers: {
3896
- "Content-Type": "application/json"
3897
- }
3898
- });
3899
- }
3900
- };
3901
- var user_service_default = UserService;
3902
-
3903
- // src/services/view-service/index.ts
3904
- var ViewService = {
3905
- async getView({
3906
- model,
3907
- views,
3908
- context = {},
3909
- options = {},
3910
- aid
3911
- }) {
3912
- const env2 = getEnv();
3913
- const defaultOptions = {
3914
- load_filters: true,
3915
- toolbar: true,
3916
- action_id: aid
3917
- };
3918
- const jsonDataView = {
3919
- model,
3920
- method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
3921
- kwargs: {
3922
- views,
3923
- options: { ...options, ...defaultOptions }
3924
- },
3925
- with_context: context
3926
- };
3927
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3928
- headers: {
3929
- "Content-Type": "application/json"
3930
- }
3931
- });
3932
- },
3933
- async getMenu(context) {
3934
- const env2 = getEnv();
3935
- const jsonData = {
3936
- model: "ir.ui.menu" /* MENU */,
3937
- method: "web_search_read" /* WEB_SEARCH_READ */,
3938
- ids: [],
3939
- with_context: context,
3940
- kwargs: {
3941
- specification: {
3942
- active: {},
3943
- name: {},
3944
- is_display: {},
3945
- sequence: {},
3946
- complete_name: {},
3947
- action: {
3948
- fields: {
3949
- display_name: {},
3950
- type: {},
3951
- binding_view_types: {}
3952
- // res_model: {},
3953
- }
3954
- },
3955
- url_icon: {},
3956
- web_icon: {},
3957
- web_icon_data: {},
3958
- groups_id: {
3959
- fields: {
3960
- full_name: {}
3961
- },
3962
- limit: 40,
3963
- order: ""
3964
- },
3965
- display_name: {},
3966
- child_id: {
3967
- fields: {
3968
- active: {},
3969
- name: {},
3970
- is_display: {},
3971
- sequence: {},
3972
- complete_name: {},
3973
- action: {
3974
- fields: {
3975
- display_name: {},
3976
- type: {},
3977
- binding_view_types: {}
3978
- // res_model: {},
3979
- }
3980
- },
3981
- url_icon: {},
3982
- web_icon: {},
3983
- web_icon_data: {},
3984
- groups_id: {
3985
- fields: {
3986
- full_name: {}
3987
- },
3988
- limit: 40,
3989
- order: ""
3990
- },
3991
- display_name: {},
3992
- child_id: {
3993
- fields: {
3994
- active: {},
3995
- name: {},
3996
- is_display: {},
3997
- sequence: {},
3998
- complete_name: {},
3999
- action: {
4000
- fields: {
4001
- display_name: {},
4002
- type: {},
4003
- binding_view_types: {}
4004
- // res_model: {},
4005
- }
4006
- },
4007
- url_icon: {},
4008
- web_icon: {},
4009
- web_icon_data: {},
4010
- groups_id: {
4011
- fields: {
4012
- full_name: {}
4013
- },
4014
- limit: 40,
4015
- order: ""
4016
- },
4017
- display_name: {},
4018
- child_id: {
4019
- fields: {
4020
- active: {},
4021
- name: {},
4022
- is_display: {},
4023
- sequence: {},
4024
- complete_name: {},
4025
- action: {
4026
- fields: {
4027
- display_name: {},
4028
- type: {},
4029
- binding_view_types: {}
4030
- // res_model: {},
4031
- }
4032
- },
4033
- url_icon: {},
4034
- web_icon: {},
4035
- web_icon_data: {},
4036
- groups_id: {
4037
- fields: {
4038
- full_name: {}
4039
- },
4040
- limit: 40,
4041
- order: ""
4042
- },
4043
- display_name: {},
4044
- child_id: {
4045
- fields: {},
4046
- limit: 40,
4047
- order: ""
4048
- }
4049
- },
4050
- limit: 40,
4051
- order: ""
4052
- }
4053
- },
4054
- limit: 40,
4055
- order: ""
4056
- }
4057
- },
4058
- limit: 40,
4059
- order: ""
4060
- }
4061
- },
4062
- domain: [
4063
- "&",
4064
- ["is_display", "=", true],
4065
- "&",
4066
- ["active", "=", true],
4067
- ["parent_id", "=", false]
4068
- ]
4069
- }
4070
- };
4071
- return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4072
- headers: {
4073
- "Content-Type": "application/json"
4074
- }
4075
- });
4076
- },
4077
- async getSelectionItem({ data }) {
4078
- const env2 = getEnv();
4079
- const jsonData = {
4080
- model: data.model,
4081
- ids: [],
4082
- method: "get_data_select",
4083
- with_context: data.context,
4084
- kwargs: {
4085
- count_limit: 10001,
4086
- domain: data.domain ? data.domain : [],
4087
- offset: 0,
4088
- order: "",
4089
- specification: data?.specification ?? {
4090
- id: {},
4091
- name: {},
4092
- display_name: {}
4093
- }
4094
- }
4095
- };
4096
- return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4097
- headers: {
4098
- "Content-Type": "application/json"
4099
- }
4100
- });
4101
- },
4102
- async loadMessages() {
4103
- const env2 = getEnv();
4104
- return env2.requests.post(
4105
- "/load_message_failures" /* LOAD_MESSAGE */,
4106
- {},
4107
- {
4108
- headers: {
4109
- "Content-Type": "application/json"
4110
- }
4111
- }
4112
- );
4113
- },
4114
- async getVersion() {
4115
- const env2 = getEnv();
4116
- return env2?.requests.get("", {
4117
- headers: {
4118
- "Content-Type": "application/json"
4119
- }
4120
- });
4121
- }
4122
- };
4123
- var view_service_default = ViewService;
4124
-
4125
- // src/hooks/auth/use-forgot-password.ts
4126
- var useForgotPassword = () => {
4127
- return reactQuery.useMutation({
4128
- mutationFn: (email) => {
4129
- return auth_service_default.forgotPassword(email);
4130
- }
4131
- });
4132
- };
4133
- var use_forgot_password_default = useForgotPassword;
4134
- var useGetProvider = () => {
4135
- return reactQuery.useMutation({
4136
- mutationFn: (data) => {
4137
- return auth_service_default.getProviders(data?.db);
4138
- }
4139
- });
4140
- };
4141
- var use_get_provider_default = useGetProvider;
4142
- var useIsValidToken = () => {
4143
- return reactQuery.useMutation({
4144
- mutationFn: (token) => {
4145
- return auth_service_default.isValidToken(token);
4146
- }
4147
- });
4148
- };
4149
- var use_isvalid_token_default = useIsValidToken;
4150
- var useLoginCredential = () => {
4151
- return reactQuery.useMutation({
4152
- mutationFn: (data) => {
4153
- return auth_service_default.login(data);
4154
- }
4155
- });
4156
- };
4157
- var use_login_credential_default = useLoginCredential;
4158
- var useLoginSocial = () => {
4159
- return reactQuery.useMutation({
4160
- mutationFn: (data) => {
4161
- return auth_service_default.loginSocial(data);
4162
- }
4163
- });
4164
- };
4165
- var use_login_socical_default = useLoginSocial;
4166
- var useResetPassword = () => {
4167
- return reactQuery.useMutation({
4168
- mutationFn: (request) => {
4169
- return auth_service_default.resetPassword(request.data, request.token);
4170
- }
4171
- });
4172
- };
4173
- var use_reset_password_default = useResetPassword;
4174
- var useUpdatePassword = () => {
4175
- return reactQuery.useMutation({
4176
- mutationFn: (request) => {
4177
- return auth_service_default.updatePassword(request.data, request.token);
4178
- }
4179
- });
4180
- };
4181
- var use_update_password_default = useUpdatePassword;
4182
- var useField = (props) => {
4183
- const [invisible, setInvisible] = React__default.default.useState(true);
4184
- const [required, setRequired] = React__default.default.useState(false);
4185
- const [readonly, setReadOnly] = React__default.default.useState(false);
4186
- const {
4187
- invisible: inv,
4188
- required: req,
4189
- readonly: rea,
4190
- onchangeData,
4191
- rootField,
4192
- index,
4193
- name
4194
- } = props;
4195
- const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
4196
- React.useEffect(() => {
4197
- if (onchangeData && Object.keys(onchangeData).length > 0) {
4198
- setRequired(
4199
- typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
4200
- );
4201
- setInvisible(matchDomains(onchangeData, inv));
4202
- setReadOnly(
4203
- typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
4204
- );
4205
- }
4206
- }, [onchangeData]);
4207
- return {
4208
- invisible,
4209
- required,
4210
- readonly,
4211
- nameField
4212
- };
4213
- };
4214
- var use_field_default = useField;
4215
- var useGetCompanyInfo = () => {
4216
- return reactQuery.useMutation({
4217
- mutationFn: (id) => company_service_default.getInfoCompany(id)
4218
- });
4219
- };
4220
- var use_get_company_info_default = useGetCompanyInfo;
4221
- var useGetCurrentCompany = () => {
4222
- return reactQuery.useMutation({
4223
- mutationFn: () => company_service_default.getCurrentCompany()
4224
- });
4225
- };
4226
- var use_get_current_company_default = useGetCurrentCompany;
4227
- var useChangeStatus = () => {
4228
- return reactQuery.useMutation({
4229
- mutationFn: ({ data }) => {
4230
- return form_service_default.changeStatus({
4231
- data
4232
- });
4233
- }
4234
- });
4235
- };
4236
- var use_change_status_default = useChangeStatus;
4237
- var useDeleteComment = () => {
4238
- return reactQuery.useMutation({
4239
- mutationFn: ({ data }) => form_service_default.deleteComment({
4240
- data
4241
- })
4242
- });
4243
- };
4244
- var use_delete_comment_default = useDeleteComment;
4245
- var useGetComment = ({ data, queryKey }) => {
4246
- return reactQuery.useQuery({
4247
- queryKey,
4248
- queryFn: () => form_service_default.getComment({ data }).then((res) => {
4249
- if (res) {
4250
- return res;
4251
- }
4252
- }),
4253
- enabled: !!data.thread_id && !isNaN(data.thread_id),
4254
- refetchOnWindowFocus: false
4255
- });
4256
- };
4257
- var use_get_comment_default = useGetComment;
4258
- var useGetFormView = ({
4259
- data,
4260
- queryKey,
4261
- enabled
4262
- }) => {
4263
- return reactQuery.useQuery({
4264
- queryKey,
4265
- queryFn: () => form_service_default.getFormView({ data }).then((res) => {
4266
- if (res) {
4267
- return res;
4268
- }
4269
- }),
4270
- enabled,
4271
- refetchOnWindowFocus: false
4272
- });
4273
- };
4274
- var use_get_form_view_default = useGetFormView;
4275
- var useGetImage = ({
4276
- data,
4277
- queryKey,
4278
- src
4279
- }) => {
4280
- return reactQuery.useQuery({
4281
- queryKey,
4282
- queryFn: () => form_service_default.getImage({ data }).then((res) => {
4283
- if (res) {
4284
- return res;
4285
- }
4286
- }),
4287
- enabled: !src && !isBase64File(src),
4288
- refetchOnWindowFocus: false
4289
- });
4290
- };
4291
- var use_get_image_default = useGetImage;
4292
- var useSendComment = () => {
4293
- return reactQuery.useMutation({
4294
- mutationFn: ({ data }) => form_service_default.sentComment({
4295
- data
4296
- })
4297
- });
4298
- };
4299
- var use_send_comment_default = useSendComment;
4300
- var useUploadImage = () => {
4301
- return reactQuery.useMutation({
4302
- mutationFn: ({ data }) => form_service_default.uploadImage({
4303
- data
4304
- })
4305
- });
4306
- };
4307
- var use_upload_image_default = useUploadImage;
4308
- var useExportExcel = () => {
4309
- return reactQuery.useMutation({
4310
- mutationFn: ({
4311
- model,
4312
- domain,
4313
- ids,
4314
- fields,
4315
- type,
4316
- importCompat,
4317
- context,
4318
- groupby
4319
- }) => excel_service_default.exportExcel({
4320
- model,
4321
- domain,
4322
- ids,
4323
- fields,
4324
- type,
4325
- importCompat,
4326
- context,
4327
- groupby
4328
- })
4329
- });
4330
- };
4331
- var use_export_excel_default = useExportExcel;
4332
- var useGetFieldExport = () => {
4333
- return reactQuery.useMutation({
4334
- mutationFn: ({
4335
- ids,
4336
- model,
4337
- isShow,
4338
- parentField,
4339
- fieldType,
4340
- parentName,
4341
- prefix,
4342
- name,
4343
- context,
4344
- importCompat
4345
- }) => excel_service_default.getFieldExport({
4346
- ids,
4347
- model,
4348
- isShow,
4349
- parentField,
4350
- fieldType,
4351
- parentName,
4352
- prefix,
4353
- name,
4354
- context,
4355
- importCompat
4356
- })
4357
- });
4358
- };
4359
- var use_get_field_export_default = useGetFieldExport;
4360
- var useGetFileExcel = ({
4361
- model,
4362
- context
4363
- }) => {
4364
- return reactQuery.useQuery({
4365
- queryKey: [],
4366
- queryFn: () => excel_service_default.getFileExcel({
4367
- model,
4368
- context
4369
- }).then((res) => {
4370
- if (res) {
4371
- return res;
4372
- }
4373
- return [];
4374
- }),
4375
- refetchOnWindowFocus: false
4376
- });
4377
- };
4378
- var use_get_file_excel_default = useGetFileExcel;
4379
- var useParsePreview = () => {
4380
- return reactQuery.useMutation({
4381
- mutationFn: ({
4382
- id,
4383
- selectedSheet,
4384
- isHeader,
4385
- context
4386
- }) => excel_service_default.parsePreview({
4387
- id,
4388
- selectedSheet,
4389
- isHeader,
4390
- context
4391
- })
4392
- });
4393
- };
4394
- var use_parse_preview_default = useParsePreview;
4395
- var useUploadFile = () => {
4396
- return reactQuery.useMutation({
4397
- mutationFn: ({ formData }) => excel_service_default.uploadFile({
4398
- formData
4399
- })
4400
- });
4401
- };
4402
- var use_upload_file_default = useUploadFile;
4403
- var useUploadIdFile = () => {
4404
- return reactQuery.useMutation({
4405
- mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
4406
- formData
4407
- })
4408
- });
4409
- };
4410
- var use_upload_id_file_default = useUploadIdFile;
4411
- var useExecuteImport = () => {
4412
- return reactQuery.useMutation({
4413
- mutationFn: ({
4414
- fields,
4415
- columns,
4416
- idFile,
4417
- options,
4418
- dryrun,
4419
- context
4420
- }) => excel_service_default.executeImport({
4421
- fields,
4422
- columns,
4423
- idFile,
4424
- options,
4425
- dryrun,
4426
- context
4427
- })
4428
- });
4429
- };
4430
- var uss_execute_import_default = useExecuteImport;
4431
- var useDelete = () => {
4432
- return reactQuery.useMutation({
4433
- mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
4434
- });
4435
- };
4436
- var use_delete_default = useDelete;
4437
- var useGetAll = ({ data, queryKey, viewResponse }) => {
4438
- return reactQuery.useQuery({
4439
- queryKey,
4440
- queryFn: () => model_service_default.getAll({ data }).then((res) => {
4441
- if (res) {
4442
- return res;
4443
- }
4444
- }),
4445
- enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
4446
- refetchOnWindowFocus: false
4447
- // placeholderData: keepPreviousData,
4448
- });
4449
- };
4450
- var use_get_all_default = useGetAll;
4451
- var useGetDetail = () => {
4452
- return reactQuery.useMutation({
4453
- mutationFn: ({
4454
- model,
4455
- ids,
4456
- specification,
4457
- context
4458
- }) => model_service_default.getDetail({
4459
- model,
4460
- ids,
4461
- specification,
4462
- context
4463
- })
4464
- });
4465
- };
4466
- var use_get_detail_default = useGetDetail;
4467
- var useGetFieldOnChange = ({ model }) => {
4468
- return reactQuery.useQuery({
4469
- queryKey: [`field-onchange-${model}`, model],
4470
- queryFn: () => model_service_default.getListFieldsOnchange({
4471
- model
4472
- }).then((res) => {
4473
- if (res) {
4474
- return res;
4475
- }
4476
- }),
4477
- refetchOnWindowFocus: false,
4478
- staleTime: Infinity
4479
- });
4480
- };
4481
- var use_get_field_onchange_default = useGetFieldOnChange;
4482
-
4483
- // src/models/base-model/index.ts
4484
- var BaseModel = class {
4485
- name;
4486
- view;
4487
- actContext;
4488
- fields;
4489
- constructor(init) {
4490
- this.name = init.name;
4491
- this.view = init.view;
4492
- this.actContext = init.actContext;
4493
- this.fields = init.fields;
4494
- }
4495
- getSpecificationByFields({
4496
- fields = [],
4497
- specification = {},
4498
- modelsData,
4499
- model,
4500
- modelRoot
4501
- }) {
4502
- if (Array.isArray(fields)) {
4503
- let spec = { ...specification };
4504
- fields.forEach((field) => {
4505
- if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
4506
- if (modelsData?.[model]?.[field?.name]) {
4507
- if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
4508
- const relation = modelsData?.[model]?.[field?.name]?.relation;
4509
- const modelRelation = modelsData?.[relation];
4510
- if (modelRelation) {
4511
- spec[field?.name] = {
4512
- fields: {}
4513
- };
4514
- if (modelRoot && modelRoot === relation) {
4515
- spec[field?.name].fields = { id: {} };
4516
- } else {
4517
- spec[field?.name].fields = this.getSpecificationByFields({
4518
- fields: Object.values(modelRelation),
4519
- specification: {},
4520
- modelsData,
4521
- model: relation,
4522
- modelRoot: model
4523
- });
4524
- }
4525
- } else {
4526
- spec[field?.name] = {
4527
- fields: {
4528
- id: {},
4529
- display_name: {}
4530
- }
4531
- };
4532
- }
4533
- } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
4534
- spec[field?.name] = {
4535
- fields: {
4536
- id: {},
4537
- display_name: {},
4538
- ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
4539
- ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
4540
- ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
4541
- }
4542
- };
4543
- } else {
4544
- spec[field?.name] = {};
4545
- }
4546
- }
4547
- } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
4548
- const specGroup = this.getSpecificationByFields({
4549
- fields: field?.fields,
4550
- specification: spec,
4551
- modelsData,
4552
- model
4553
- });
4554
- spec = { ...spec, ...specGroup };
4555
- } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
4556
- const relation = modelsData?.[model]?.[field?.name]?.relation;
4557
- const specTreee = this.getSpecificationByFields({
4558
- fields: field?.fields,
4559
- specification: {},
4560
- modelsData,
4561
- model: relation,
4562
- modelRoot: model
4563
- });
4564
- spec = {
4565
- ...spec,
4566
- [field?.name]: {
4567
- fields: { ...spec?.[field?.name]?.fields, ...specTreee }
4568
- }
4569
- };
4570
- }
4571
- });
4572
- return spec;
4573
- } else {
4574
- console.warn("fields is not array");
4575
- }
4576
- }
4577
- getTreeProps() {
4578
- const props = this.view?.views?.list || {};
4579
- return props;
4580
- }
4581
- getTreeFields() {
4582
- const fields = this.view?.views?.list?.fields || [];
4583
- return fields;
4584
- }
4585
- getSpecification() {
4586
- const specInit = {};
4587
- const modelData = this.view?.models || {};
4588
- const specification = this.getSpecificationByFields({
4589
- fields: this.fields,
4590
- specification: specInit,
4591
- modelsData: modelData,
4592
- model: this.name,
4593
- modelRoot: ""
4594
- });
4595
- return specification;
4596
- }
4597
- };
4598
- var base_model_default = BaseModel;
4599
-
4600
- // src/hooks/model/use-model.ts
4601
- var useModel = () => {
4602
- const initModel = (modelData) => {
4603
- switch (modelData?.name) {
4604
- default:
4605
- return new base_model_default(modelData);
4606
- }
4607
- };
4608
- return {
4609
- initModel
4610
- };
4611
- };
4612
- var use_model_default = useModel;
4613
-
4614
- // src/hooks/model/use-odoo-data-transform.ts
4615
- var useOdooDataTransform = () => {
4616
- return {
4617
- toDataJS: model_service_default.toDataJS,
4618
- parseORM: model_service_default.parseORMOdoo
4619
- };
4620
- };
4621
- var use_odoo_data_transform_default = useOdooDataTransform;
4622
- var useOnChangeForm = () => {
4623
- return reactQuery.useMutation({
4624
- mutationFn: ({
4625
- ids,
4626
- model,
4627
- specification,
4628
- context,
4629
- object,
4630
- fieldChange
4631
- }) => model_service_default.onChange({
4632
- ids,
4633
- model,
4634
- specification,
4635
- context,
4636
- object,
4637
- fieldChange
4638
- })
4639
- });
4640
- };
4641
- var use_onchange_form_default = useOnChangeForm;
4642
- var useSave = () => {
4643
- return reactQuery.useMutation({
4644
- mutationFn: ({
4645
- ids,
4646
- model,
4647
- data,
4648
- specification,
4649
- context
4650
- }) => model_service_default.save({ ids, model, data, specification, context })
4651
- });
4652
- };
4653
- var use_save_default = useSave;
4654
- var useGetProfile = () => {
4655
- return reactQuery.useMutation({
4656
- mutationFn: () => user_service_default.getProfile()
4657
- });
4658
- };
4659
- var use_get_profile_default = useGetProfile;
4660
- var useGetUser = () => {
4661
- return reactQuery.useMutation({
4662
- mutationFn: ({ id, context }) => user_service_default.getUser({
4663
- id,
4664
- context
4665
- })
4666
- });
4667
- };
4668
- var use_get_user_default = useGetUser;
4669
- var useSwitchLocale = () => {
4670
- return reactQuery.useMutation({
4671
- mutationFn: ({ data }) => {
4672
- return user_service_default.switchUserLocale({
4673
- id: data.id,
4674
- values: data.values
4675
- });
4676
- }
4677
- });
4678
- };
4679
- var use_switch_locale_default = useSwitchLocale;
4680
- var useButton = () => {
4681
- return reactQuery.useMutation({
4682
- mutationFn: ({
4683
- model,
4684
- ids,
4685
- context,
4686
- method
4687
- }) => action_service_default.callButton({
3081
+ ids,
3082
+ context,
3083
+ method
3084
+ }) => action_service_default.callButton({
4688
3085
  model,
4689
3086
  ids,
4690
3087
  context,
4691
3088
  method
4692
- }),
4693
- onSuccess: (response) => {
4694
- return response;
4695
- }
4696
- });
4697
- };
4698
- var use_button_default = useButton;
4699
- var useDuplicateRecord = () => {
4700
- return reactQuery.useMutation({
4701
- mutationFn: ({
4702
- id,
4703
- model,
4704
- context
4705
- }) => action_service_default.duplicateRecord({
4706
- id,
4707
- model,
4708
- context
4709
3089
  })
4710
3090
  });
4711
- };
4712
- var use_duplicate_record_default = useDuplicateRecord;
4713
- var useGetListData = (listDataProps, queryKey, enabled) => {
4714
- return reactQuery.useQuery({
4715
- queryKey,
4716
- queryFn: () => model_service_default.getAll({ data: listDataProps }).then((res) => {
4717
- if (res) {
4718
- return res;
4719
- }
4720
- return [];
4721
- }),
4722
- enabled,
4723
- refetchOnWindowFocus: false,
4724
- staleTime: 0
4725
- });
4726
- };
4727
- var use_get_list_data_default = useGetListData;
4728
- var useGetMenu = ({ context, enabled, queryKey }) => {
4729
- return reactQuery.useQuery({
4730
- queryKey,
4731
- queryFn: async () => {
4732
- const res = await view_service_default.getMenu(context);
4733
- if (res?.records && Array.isArray(res.records) && res.records.length > 0) {
4734
- return res.records;
4735
- }
4736
- return [];
4737
- },
4738
- refetchOnWindowFocus: false,
4739
- staleTime: Infinity,
4740
- enabled
4741
- });
4742
- };
4743
- var use_get_menu_default = useGetMenu;
4744
- var useGetSelection = ({
4745
- data,
4746
- queryKey,
4747
- enabled
4748
- }) => {
4749
- return reactQuery.useQuery({
4750
- queryKey,
4751
- queryFn: () => view_service_default.getSelectionItem({ data }),
4752
- enabled,
4753
- refetchOnWindowFocus: false
4754
- });
4755
- };
4756
- var use_get_selection_default = useGetSelection;
4757
- var useGetView = (viewParams, actData) => {
4758
- return reactQuery.useQuery({
4759
- queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
4760
- queryFn: () => view_service_default.getView(viewParams),
4761
- enabled: !!actData,
4762
- refetchOnWindowFocus: false,
4763
- staleTime: Infinity
4764
- });
4765
- };
4766
- var use_get_view_default = useGetView;
4767
- var useLoadAction = ({
4768
- idAction,
4769
- context
4770
- }) => {
4771
- return reactQuery.useQuery({
4772
- queryKey: ["load_action", idAction],
4773
- queryFn: () => action_service_default.loadAction({
4774
- idAction,
4775
- context
4776
- }),
4777
- enabled: false,
4778
- staleTime: Infinity,
4779
- gcTime: Infinity
4780
- });
4781
- };
4782
- var use_load_action_default = useLoadAction;
4783
- var usePrint = () => {
4784
- return reactQuery.useMutation({
4785
- mutationFn: ({ id, report, db }) => action_service_default.print({
4786
- id,
4787
- report,
4788
- db
4789
- })
4790
- });
4791
- };
4792
- var use_print_default = usePrint;
4793
- var useRemoveRow = () => {
4794
- return reactQuery.useMutation({
4795
- mutationFn: ({
4796
- model,
4797
- ids,
4798
- context
4799
- }) => action_service_default.removeRows({
4800
- model,
4801
- ids,
4802
- context
4803
- })
4804
- });
4805
- };
4806
- var use_remove_row_default = useRemoveRow;
4807
- var useRunAction = ({ idAction, context }) => {
4808
- return reactQuery.useQuery({
4809
- queryKey: ["run_action", idAction],
4810
- queryFn: () => action_service_default.runAction({
4811
- idAction,
4812
- context
4813
- }),
4814
- enabled: false,
4815
- staleTime: Infinity,
4816
- gcTime: Infinity
4817
- });
4818
- };
4819
- var use_run_action_default = useRunAction;
3091
+ }
4820
3092
 
4821
- exports.useButton = use_button_default;
4822
- exports.useChangeStatus = use_change_status_default;
4823
- exports.useDelete = use_delete_default;
4824
- exports.useDeleteComment = use_delete_comment_default;
4825
- exports.useDuplicateRecord = use_duplicate_record_default;
4826
- exports.useExecuteImport = uss_execute_import_default;
4827
- exports.useExportExcel = use_export_excel_default;
4828
- exports.useField = use_field_default;
4829
- exports.useForgotPassword = use_forgot_password_default;
4830
- exports.useGetAll = use_get_all_default;
4831
- exports.useGetComment = use_get_comment_default;
4832
- exports.useGetCompanyInfo = use_get_company_info_default;
4833
- exports.useGetCurrentCompany = use_get_current_company_default;
4834
- exports.useGetDetail = use_get_detail_default;
4835
- exports.useGetFieldExport = use_get_field_export_default;
4836
- exports.useGetFieldOnChange = use_get_field_onchange_default;
4837
- exports.useGetFileExcel = use_get_file_excel_default;
4838
- exports.useGetFormView = use_get_form_view_default;
4839
- exports.useGetImage = use_get_image_default;
4840
- exports.useGetListData = use_get_list_data_default;
4841
- exports.useGetMenu = use_get_menu_default;
4842
- exports.useGetProfile = use_get_profile_default;
4843
- exports.useGetProvider = use_get_provider_default;
4844
- exports.useGetSelection = use_get_selection_default;
4845
- exports.useGetUser = use_get_user_default;
4846
- exports.useGetView = use_get_view_default;
4847
- exports.useIsValidToken = use_isvalid_token_default;
4848
- exports.useLoadAction = use_load_action_default;
4849
- exports.useLoginCredential = use_login_credential_default;
4850
- exports.useLoginSocial = use_login_socical_default;
4851
- exports.useModel = use_model_default;
4852
- exports.useOdooDataTransform = use_odoo_data_transform_default;
4853
- exports.useOnChangeForm = use_onchange_form_default;
4854
- exports.useParsePreview = use_parse_preview_default;
4855
- exports.usePrint = use_print_default;
4856
- exports.useRemoveRow = use_remove_row_default;
4857
- exports.useResetPassword = use_reset_password_default;
4858
- exports.useRunAction = use_run_action_default;
4859
- exports.useSave = use_save_default;
4860
- exports.useSendComment = use_send_comment_default;
4861
- exports.useSwitchLocale = use_switch_locale_default;
4862
- exports.useUpdatePassword = use_update_password_default;
4863
- exports.useUploadFile = use_upload_file_default;
4864
- exports.useUploadIdFile = use_upload_id_file_default;
4865
- exports.useUploadImage = use_upload_image_default;
3093
+ exports.useButton = useButton;