playbook_ui 12.18.0.pre.alpha.play786multilevelselectimprovements613 → 12.18.0.pre.alpha.play786multilevelselectimprovements627
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71565d1e911bd318cffad56ff64e34bab539bc740f5138b68d1f1896c1a6808e
|
4
|
+
data.tar.gz: '0278d976d8320ee5013b5cc1cb9ae03349ba1948317c315624291a4ef1c9c93a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c0a50b86ab971669772bfffb39f010929ca496ded033027592aac11de73efb74f40a13b24705a379bba1e81df2b0e4a863415ab1c51b281a1b313a967cd216
|
7
|
+
data.tar.gz: e0703c831017c9f2adb8b05f0eeb61a934142e52beca288c37fa3ee08d6268a6db7198e146e2efb743238a5a5245b7bd54b1a5e0f2c5c7518eb63a8fed94e114
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo } from "react";
|
|
2
2
|
import classnames from "classnames";
|
3
3
|
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
|
4
4
|
import { globalProps } from "../utilities/globalProps";
|
5
|
-
import { findItemById, checkIt, unCheckIt } from "./helper_functions";
|
5
|
+
import { findItemById, checkIt, unCheckIt, getParentAndAncestorsIds } from "./helper_functions";
|
6
6
|
import MultiSelectHelper from "./_multi_select_helper";
|
7
7
|
|
8
8
|
type MultiLevelSelectProps = {
|
@@ -52,14 +52,20 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
52
52
|
if (currentNode.checked) {
|
53
53
|
checkIt(foundItem, selectedItems, setSelectedItems, false);
|
54
54
|
if (currentNode._parent) {
|
55
|
-
const
|
56
|
-
|
57
|
-
|
55
|
+
const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
|
56
|
+
parents.forEach((item:string) => {
|
57
|
+
const ancestor = findItemById(formattedData,item)
|
58
|
+
ancestor.expanded = true
|
59
|
+
});
|
60
|
+
}
|
58
61
|
} else {
|
59
62
|
unCheckIt(foundItem, selectedItems, setSelectedItems, false);
|
60
63
|
if (currentNode._parent) {
|
61
|
-
|
62
|
-
|
64
|
+
const parents = getParentAndAncestorsIds(currentNode._parent, formattedData)
|
65
|
+
parents.forEach((item:string) => {
|
66
|
+
const ancestor = findItemById(formattedData,item)
|
67
|
+
ancestor.expanded = true
|
68
|
+
});
|
63
69
|
}
|
64
70
|
}
|
65
71
|
}
|
@@ -61,3 +61,27 @@ export const unCheckIt = (
|
|
61
61
|
}
|
62
62
|
setSelectedItems([...newSelectedItems]);
|
63
63
|
};
|
64
|
+
|
65
|
+
|
66
|
+
export const getParentAndAncestorsIds = (itemId:string, items:{ [key: string]: string; }[], ancestors:string[] = []):any => {
|
67
|
+
for (let i = 0; i < items.length; i++) {
|
68
|
+
const item:any = items[i];
|
69
|
+
if (item.id === itemId) {
|
70
|
+
// item found in current level of items array
|
71
|
+
return [...ancestors, item.id];
|
72
|
+
}
|
73
|
+
if (item.children && item.children.length > 0) {
|
74
|
+
// recursively search through children
|
75
|
+
const foundAncestors = getParentAndAncestorsIds(
|
76
|
+
itemId,
|
77
|
+
item.children,
|
78
|
+
[...ancestors, item.id]
|
79
|
+
);
|
80
|
+
if (foundAncestors) {
|
81
|
+
return foundAncestors;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
// item not found in this level of items array or its children
|
86
|
+
return null;
|
87
|
+
}
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.18.0.pre.alpha.
|
4
|
+
version: 12.18.0.pre.alpha.play786multilevelselectimprovements627
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-05-
|
12
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|