Skip to content

Commit 09bf62a

Browse files
committed
feat: omit properties from being cloned
1 parent 0319b83 commit 09bf62a

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

packages/common-types/src/values.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export type iNodeFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [
1818
) => boolean | undefined | iNodeFnResponse | Promise<boolean | undefined | iNodeFnResponse>;
1919

2020
/**
21-
* used on FactoryTable and related components
21+
* Used on Table and related components
22+
*
23+
* @action Any task performed at each row cell (property)
24+
* @nested Any task performed at a relation table within a modal
2225
*/
2326
export interface iProperty<
2427
T extends Record<string, any> = Record<string, any>,
@@ -28,6 +31,9 @@ export interface iProperty<
2831
/**
2932
* Function to create a node within the relation
3033
* The parent is given since the node doesn't exist yet
34+
*
35+
* @action Showcases an button to create a new node/value within this property/relation
36+
* @nested Passed down to the related table if any
3137
*/
3238
createNode?: iNodeFn<P, [P?]>;
3339
/**
@@ -36,18 +42,28 @@ export interface iProperty<
3642
disableCreateNode?: (p: P) => boolean;
3743
/**
3844
* Function to clone a node within the relation
45+
* Set to false to omit cloning this property/relation
46+
*
47+
* @action No inline action
48+
* @nested Passed down to the related table if any
3949
*/
40-
cloneNode?: iNodeFn<T, [T?]>;
50+
cloneNode?: iNodeFn<T, [T?]> | false;
4151
/**
4252
* Function to update a node within the relation
53+
*
54+
* @action Showcases an button to update this node/value within this property/relation
55+
* @nested Passed down to the related table if any
4356
*/
4457
updateNode?: iNodeFn<T, [T?, P?]>;
4558
/**
4659
* Function to delete a node within the relation
60+
*
61+
* @action No inline action
62+
* @nested Passed down to the related table if any
4763
*/
4864
deleteNode?: iNodeFn<T, [T?]>;
4965
/**
50-
* Render using this component instead
66+
* Render row cell (property) using this component instead
5167
*/
5268
component?: ComponentType;
5369
/**

packages/components-vue/src/components/table/Simple.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,15 @@
318318
// display loader
319319
Swal.fireLoader();
320320
321+
// Remove properties that should not be cloned
322+
const clearNode = { ...node };
323+
324+
for (const property of propertiesMeta.value) {
325+
if (property.cloneNode === false) delete clearNode[property.value];
326+
}
327+
321328
// run process
322-
const [cloned, event, closeModal] = await resolveNodeFn(props.cloneNode?.(node));
329+
const [cloned, event, closeModal] = await resolveNodeFn(props.cloneNode?.(clearNode));
323330
324331
// unfinished task
325332
if (typeof cloned !== "boolean") {

packages/components-vue/src/components/value/Complex.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
:theme="invertedTheme"
4949
:modal-props="{ theme, ...modalProps }"
5050
:classes="classes"
51-
:clone-node="property?.cloneNode"
51+
:clone-node="property?.cloneNode || undefined"
5252
:update-node="property?.updateNode"
5353
:delete-node="property?.deleteNode"
5454
/>

0 commit comments

Comments
 (0)