Skip to content

Commit

Permalink
implemented findParent script function
Browse files Browse the repository at this point in the history
  • Loading branch information
ishubin committed Nov 11, 2023
1 parent 909c88c commit e8f6b83
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
1 change: 1 addition & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ ul.tabs li .tab {
text-transform: uppercase;
font-weight: bold;
cursor: pointer;
line-height: 1;
}
@media (max-width: 900px) {
ul.tabs li .tab {
Expand Down
40 changes: 8 additions & 32 deletions assets/templates/ui/dropdown.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@
"effects": [],
"childItems": [
{
"id": "btn-dropdown",
"name": "btn-dropdown-open",
"shapeProps": {
"cornerRadius": { "$-expr": "cornerRadius" },
"fill": {"$-expr": "buttonBackground" },
Expand All @@ -241,7 +243,6 @@
},
"opacity": 100,
"blendMode": "normal",
"name": "btn-dropdown-open",
"description": "",
"links": [],
"textSlots": {
Expand Down Expand Up @@ -270,7 +271,6 @@
"interactionMode": "tooltip",
"tooltipBackground": "rgba(230,230,230,1.0)",
"tooltipColor": "rgba(30,30,30,1.0)",
"id": "mz8-ugRWs",
"childItems": [
{
"id": "carret",
Expand All @@ -293,36 +293,12 @@
"id": "Zapz2S9OMg",
"closed": true,
"points": [
{
"t": "L",
"x": 0,
"y": 26.6
},
{
"t": "L",
"x": 50,
"y": 100
},
{
"t": "L",
"x": 100,
"y": 26.6
},
{
"t": "L",
"x": 89.28,
"y": 0
},
{
"t": "L",
"x": 50,
"y": 60
},
{
"t": "L",
"x": 10.71,
"y": 0
}
{ "t": "L", "x": 0, "y": 26.6 },
{ "t": "L", "x": 50, "y": 100 },
{ "t": "L", "x": 100, "y": 26.6 },
{ "t": "L", "x": 89.28, "y": 0 },
{ "t": "L", "x": 50, "y": 60 },
{ "t": "L", "x": 10.71, "y": 0 }
],
"pos": "relative"
}
Expand Down
8 changes: 7 additions & 1 deletion docs/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Schemio offers a possibility of simple scripting. At this moment the Schemio scr
- [findItemByName](#finditembyname)
- [findItemById](#finditembyid)
- [findChildItemByName](#findchilditembyname)
- [findParent](#findparent)


Basic syntax
Expand Down Expand Up @@ -534,4 +535,9 @@ it.setTextSize('body', 30)

##### findChildItemByName

`findChildItemByName(name)` searches only for child items of the current item and returns the first one which name matches the specified `name` argument. This is used when you want to narrow the scope of items within particular group.
`findChildItemByName(name)` searches only for child items of the current item and returns the first one which name matches the specified `name` argument. This is used when you want to narrow the scope of items within particular group.


##### findParent

`findParent()` searches for parent item of the current item
7 changes: 7 additions & 0 deletions src/ui/userevents/functions/ScriptFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ function findChildItemByName(item, name) {
export function createItemBasedScope(item, schemeContainer, userEventBus) {
const itemInterface = createItemScriptWrapper(item, schemeContainer, userEventBus);
return new Scope({
findParent: () => {
let parentId = null;
if (item && item.meta) {
parentId = item.meta.parentId
}
return createItemScriptWrapper(schemeContainer.findItemById(parentId), schemeContainer, userEventBus);
},
findItemById: (id) => {
return createItemScriptWrapper(schemeContainer.findItemById(id), schemeContainer, userEventBus);
},
Expand Down

0 comments on commit e8f6b83

Please sign in to comment.