@antscorp/antsomi-ui 1.3.5-beta.33 → 1.3.5-beta.34
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/es/components/molecules/TemplateSaveAs/TemplateSaveAsModal.js +12 -2
- package/es/models/ObjectTemplate.d.ts +3 -0
- package/es/models/ObjectTemplate.js +3 -0
- package/es/queries/TemplateListing/index.js +7 -2
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/types/share-access.d.ts +17 -0
- package/es/types/share-access.js +1 -0
- package/es/types/variables.d.ts +1 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { useState } from 'react';
|
|
12
|
+
import React, { useEffect, useState } from 'react';
|
|
13
13
|
import { ModalV2 } from '../ModalV2';
|
|
14
14
|
import { TemplateSaveAs } from './TemplateSaveAs';
|
|
15
15
|
// NOTE: helper link (read more about controlled and uncontrolled component)
|
|
@@ -18,6 +18,10 @@ export const TemplateSaveAsModal = props => {
|
|
|
18
18
|
const { open, onCancel, okText, onOk, title, templateProps, defaultValue } = props, restProps = __rest(props, ["open", "onCancel", "okText", "onOk", "title", "templateProps", "defaultValue"]);
|
|
19
19
|
const { onChange: templateOnChange, value: templateValue } = templateProps, restTemplateProps = __rest(templateProps, ["onChange", "value"]);
|
|
20
20
|
const [internalValue, setInternalValue] = useState(defaultValue || templateValue);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (defaultValue)
|
|
23
|
+
setInternalValue(defaultValue);
|
|
24
|
+
}, [defaultValue]);
|
|
21
25
|
const handleOnChange = (value) => {
|
|
22
26
|
if (templateOnChange) {
|
|
23
27
|
templateOnChange(value);
|
|
@@ -33,6 +37,12 @@ export const TemplateSaveAsModal = props => {
|
|
|
33
37
|
onOk(event, templateValue && templateOnChange ? templateValue : internalValue);
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
|
-
|
|
40
|
+
const handleCancel = (event) => {
|
|
41
|
+
if (onCancel) {
|
|
42
|
+
setInternalValue(defaultValue);
|
|
43
|
+
onCancel(event);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return (React.createElement(ModalV2, Object.assign({ open: open, onCancel: handleCancel, onOk: handleOk, okText: okText || 'Save', width: 1177, title: title || 'Save as my template' }, restProps),
|
|
37
47
|
React.createElement(TemplateSaveAs, Object.assign({ onChange: handleOnChange, value: templateValue || internalValue }, restTemplateProps))));
|
|
38
48
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { TTemplateStatus } from '../types/templateListing';
|
|
3
3
|
import { Model } from './model';
|
|
4
|
+
import { TShareAccess } from '../types';
|
|
4
5
|
export type TObjectTemplate = {
|
|
5
6
|
template_id: number;
|
|
6
7
|
template_name: string;
|
|
@@ -26,6 +27,7 @@ export type TObjectTemplate = {
|
|
|
26
27
|
goal: number[];
|
|
27
28
|
journey_type: number[];
|
|
28
29
|
lifecycle_stage: number[];
|
|
30
|
+
share_access: TShareAccess;
|
|
29
31
|
};
|
|
30
32
|
export declare class ObjectTemplate extends Model<TObjectTemplate> {
|
|
31
33
|
get id(): number | "";
|
|
@@ -50,4 +52,5 @@ export declare class ObjectTemplate extends Model<TObjectTemplate> {
|
|
|
50
52
|
get lifecycleStage(): number[] | undefined;
|
|
51
53
|
get journeyType(): number[] | undefined;
|
|
52
54
|
get goal(): number[] | undefined;
|
|
55
|
+
get shareAccess(): TShareAccess | undefined;
|
|
53
56
|
}
|
|
@@ -33,7 +33,7 @@ export const useGetObjectTemplateList = (params) => {
|
|
|
33
33
|
};
|
|
34
34
|
export const useGetObjectTemplateDetail = (params) => {
|
|
35
35
|
const { args, options } = params;
|
|
36
|
-
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL, args.params], queryFn: () => objectTemplate.getDetail(args), enabled: !!args.params.template_id }, options));
|
|
36
|
+
return useQuery(Object.assign({ queryKey: [QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL, args.params.template_id], queryFn: () => objectTemplate.getDetail(args), enabled: !!args.params.template_id }, options));
|
|
37
37
|
};
|
|
38
38
|
export const useValidateTemplateName = (params) => {
|
|
39
39
|
const { options } = params;
|
|
@@ -83,7 +83,12 @@ export const usePersistTemplate = (params) => {
|
|
|
83
83
|
default:
|
|
84
84
|
return objectTemplate.create(Object.assign(Object.assign({}, params), { data: omit(params.data, ['template_id']) }));
|
|
85
85
|
}
|
|
86
|
-
}, onSettled() {
|
|
86
|
+
}, onSettled(data, error, variables, context) {
|
|
87
|
+
console.log('🚀 ~ onSettled ~ variables:', variables);
|
|
88
|
+
queryClientAntsomiUI.invalidateQueries([
|
|
89
|
+
QUERY_KEYS.GET_OBJECT_TEMPLATE_DETAIL,
|
|
90
|
+
variables.params.data.template_id,
|
|
91
|
+
]);
|
|
87
92
|
queryClientAntsomiUI.invalidateQueries([QUERY_KEYS.GET_OBJECT_TEMPLATE_LIST], {
|
|
88
93
|
exact: false,
|
|
89
94
|
});
|
package/es/types/index.d.ts
CHANGED
package/es/types/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TBoolean } from './variables';
|
|
2
|
+
export type TUserAccess = {
|
|
3
|
+
allow_comment: TBoolean;
|
|
4
|
+
allow_edit: TBoolean;
|
|
5
|
+
allow_view: TBoolean;
|
|
6
|
+
avatar: string;
|
|
7
|
+
email: string;
|
|
8
|
+
full_name: string;
|
|
9
|
+
role: number;
|
|
10
|
+
user_id: number;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export type TShareAccess = {
|
|
14
|
+
is_public: TBoolean;
|
|
15
|
+
public_role: number | null;
|
|
16
|
+
list_access: TUserAccess[];
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/types/variables.d.ts
CHANGED