{
  "eventsAndFunctions": [
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "actions",
            "variableName": "actions"
          },
          {
            "command": "Hide",
            "widgetName": "actionsContainer"
          },
          {
            "children": [
              {
                "command": "Show",
                "widgetName": "actionsContainer"
              },
              {
                "command": "SetValue",
                "expression": "{}",
                "widgetName": "renGoalOptions"
              }
            ],
            "command": "If",
            "expression": "^actions"
          },
          {
            "command": "Execute",
            "expression": "loadTree()"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "actions",
            "type": "boolean"
          }
        ]
      },
      "name": "main_init"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "treeNodeRef",
            "type": "string"
          }
        ],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "actions",
            "variableName": "actions"
          },
          {
            "command": "ReadTreeNode",
            "expressionTreeNodeRef": "^treeNodeRef",
            "variableName": "treeNode",
            "widgetName": "goalsTree"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "treeNode.properties.type",
                "variableName": "goalType"
              },
              {
                "children": [
                  {
                    "command": "Set",
                    "expression": "^treeNode.properties.id",
                    "variableName": "goalId"
                  },
                  {
                    "command": "Set",
                    "expression": "^treeNode.properties.mainId",
                    "variableName": "mainGoalId"
                  }
                ],
                "command": "If",
                "expression": "Contains(^treeNode.properties.type,\"goal\") || Contains(^treeNode.properties.type,\"mainGoal\")"
              },
              {
                "children": [
                  {
                    "command": "Set",
                    "expression": "null",
                    "variableName": "goalId"
                  },
                  {
                    "command": "Set",
                    "expression": "null",
                    "variableName": "mainGoalId"
                  },
                  {
                    "command": "Set",
                    "expression": "null",
                    "variableName": "goalType"
                  }
                ],
                "command": "Else"
              },
              {
                "command": "WriteModel",
                "expression": "^goalId",
                "modelVariableName": "goalId"
              },
              {
                "command": "WriteModel",
                "expression": "^mainGoalId",
                "modelVariableName": "mainGoalId"
              },
              {
                "command": "WriteModel",
                "expression": "^goalType",
                "modelVariableName": "goalType"
              },
              {
                "command": "SendDataToParent",
                "expressionData": "{action:\"openGoal\", goalId: ^goalId, goalType: ^goalType, mainGoalId: ^mainGoalId}"
              }
            ],
            "command": "If",
            "expression": "^actions"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "treeNode",
            "type": "TreeNode"
          },
          {
            "name": "actions",
            "type": "boolean"
          },
          {
            "name": "goalId",
            "type": "string"
          },
          {
            "name": "goalType",
            "type": "string"
          },
          {
            "name": "mainGoalId",
            "type": "string"
          }
        ]
      },
      "name": "goalsTree_selectTreeNode"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "recordRef",
            "type": "string"
          },
          {
            "name": "arg",
            "type": "string"
          }
        ],
        "statements": [
          {
            "command": "Execute",
            "expression": "loadTree()"
          }
        ],
        "typeReturn": "any",
        "variables": []
      },
      "name": "renGoalOptions_handlerRecordAction_refresh"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "data",
            "type": "any"
          }
        ],
        "statements": [
          {
            "children": [
              {
                "command": "Execute",
                "expression": "loadTree()"
              }
            ],
            "command": "If",
            "expression": "Contains(^data.action, \"refresh\")"
          }
        ],
        "typeReturn": "any",
        "variables": []
      },
      "name": "main_receiveData"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "goalType",
            "variableName": "goalType"
          },
          {
            "command": "ReadModel",
            "modelVariableName": "goalId",
            "variableName": "goalId"
          },
          {
            "command": "ReadModel",
            "modelVariableName": "mainGoalId",
            "variableName": "mainGoalId"
          },
          {
            "command": "SendDataToParent",
            "expressionData": "{action: \"createMainGoal\"}"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "goalType",
            "type": "string"
          },
          {
            "name": "goalId",
            "type": "string"
          },
          {
            "name": "mainGoalId",
            "type": "string"
          }
        ]
      },
      "name": "renGoalActions_handlerAction_add"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "WriteModel",
            "expression": "null",
            "modelVariableName": "goalId"
          },
          {
            "command": "WriteModel",
            "expression": "null",
            "modelVariableName": "goalType"
          },
          {
            "command": "ReadModel",
            "modelVariableName": "actions",
            "variableName": "actions"
          },
          {
            "command": "ReadModel",
            "modelVariableName": "planId",
            "variableName": "planId"
          },
          {
            "command": "Set",
            "expression": "{ fields: [\"Goals\"]}",
            "variableName": "args"
          },
          {
            "command": "Set",
            "expression": "ExtStrategicPlanMng.PlanMainGoalList(^planId, ^args)",
            "variableName": "goals"
          },
          {
            "command": "Set",
            "expression": "{children:[], expanded:true, properties:{type:\"root\"}, text: \"[[Goals]]\"}",
            "variableName": "rootNode"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "convertMainGoalToTreeNode(^goal)",
                    "variableNameList": "rootNode.children"
                  }
                ],
                "command": "ForEach",
                "expressionList": "^goals",
                "variableNameItem": "goal"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^goals) && Count(^goals) > 0"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "SendDataToParent",
                    "expressionData": "{action: \"createMainGoal\"}"
                  }
                ],
                "command": "If",
                "expression": "^actions"
              }
            ],
            "command": "Else"
          },
          {
            "command": "SetValue",
            "expression": "^rootNode",
            "widgetName": "goalsTree"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "actions",
            "type": "boolean"
          },
          {
            "name": "planId",
            "type": "string"
          },
          {
            "name": "mainGoalId",
            "type": "string"
          },
          {
            "name": "goalId",
            "type": "string"
          },
          {
            "name": "rootNode",
            "type": "TreeNode"
          },
          {
            "name": "args",
            "type": "ExtStrategicPlanMng.ArgsPlanMainGoalList"
          },
          {
            "name": "args",
            "type": "ExtStrategicPlanMng.ArgsPlanGoalList"
          },
          {
            "name": "goal",
            "type": "ExtStrategicPlanMng.MainGoal"
          },
          {
            "name": "goals",
            "type": "list(ExtStrategicPlanMng.MainGoal)"
          }
        ]
      },
      "name": "loadTree"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "goal",
            "type": "ExtStrategicPlanMng.Goal"
          },
          {
            "name": "mainGoalId",
            "type": "string"
          }
        ],
        "statements": [
          {
            "command": "Set",
            "expression": "{icon:\"goal.svg\", text: ^goal.name, children: [], expanded:true, properties:{type:\"goal\", id: ^goal.id, mainId: ^mainGoalId}}",
            "variableName": "node"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "{icon:\"user.svg\", text: ^goal.assignTo.name, children: [], expanded:true, properties:{type:\"assign\", id: ^goal.assignTo.id, mainId: ^mainGoalId}}",
                "variableName": "assignNode"
              },
              {
                "command": "Push",
                "expressionItem": "^assignNode",
                "variableNameList": "node.children"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^goal.assignTo)"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "convertGoalToTreeNode(^childGoal, ^mainGoalId)",
                    "variableNameList": "node.children"
                  }
                ],
                "command": "ForEach",
                "expressionList": "^goal.goals",
                "variableNameItem": "childGoal"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^goal.goals)"
          },
          {
            "command": "Return",
            "expression": "^node"
          }
        ],
        "typeReturn": "TreeNode",
        "variables": [
          {
            "name": "node",
            "type": "TreeNode"
          },
          {
            "name": "childGoal",
            "type": "ExtStrategicPlanMng.Goal"
          },
          {
            "name": "assignNode",
            "type": "TreeNode"
          }
        ]
      },
      "name": "convertGoalToTreeNode"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "goal",
            "type": "ExtStrategicPlanMng.MainGoal"
          }
        ],
        "statements": [
          {
            "command": "Set",
            "expression": "\"main-goal-forecast.svg\"",
            "variableName": "icon"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "Concat(\"main-goal-\",^goal.scope.id,\".svg\")",
                "variableName": "icon"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^goal.scope)"
          },
          {
            "command": "Set",
            "expression": "{icon:^icon, text: ^goal.name, children: [], expanded:true, properties:{type:\"mainGoal\", id: ^goal.id}}",
            "variableName": "node"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "command": "Push",
                    "expressionItem": "convertGoalToTreeNode(^childGoal, ^goal.id)",
                    "variableNameList": "node.children"
                  }
                ],
                "command": "ForEach",
                "expressionList": "^goal.goals",
                "variableNameItem": "childGoal"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^goal.goals)"
          },
          {
            "command": "Return",
            "expression": "^node"
          }
        ],
        "typeReturn": "TreeNode",
        "variables": [
          {
            "name": "node",
            "type": "TreeNode"
          },
          {
            "name": "childGoal",
            "type": "ExtStrategicPlanMng.Goal"
          },
          {
            "name": "icon",
            "type": "string"
          }
        ]
      },
      "name": "convertMainGoalToTreeNode"
    }
  ],
  "model": [
    {
      "name": "planId",
      "required": true,
      "type": "string"
    },
    {
      "name": "actions",
      "required": false,
      "type": "boolean"
    },
    {
      "name": "goalId",
      "required": false,
      "type": "string"
    },
    {
      "name": "goalType",
      "required": false,
      "type": "string"
    },
    {
      "name": "mainGoalId",
      "required": false,
      "type": "string"
    }
  ],
  "root": {
    "children": [
      {
        "children": [
          {
            "children": [
              {
                "htmlTemplate": "<div style=\"display: inline-flex\">   \n   <div class=\"blz-btn blz-btn-default blz-toolbar-element blz-component-class-enabled plain \n      blz-border-radius blz-cast-shadow blz-border-top blz-border-right blz-border-left blz-border-bottom\"\n      style=\"width: auto; background-color: white;\" tabindex=\"-1\" onclick=\"[RecordAction:refresh]\">\n      <span class=\"blz-btn-icon\">\n      [Icon:refresh.svg]\n      </span>\n      <span class=\"blz-btn-text\"></span>\n      <input type=\"text\" style=\"width: 1px; height: 1px;\">\n   </div>\n</div>",
                "name": "renGoalOptions",
                "recordActions": [
                  {
                    "key": "refresh"
                  }
                ],
                "widget": "HtmlRenderer"
              }
            ],
            "cssClass": "blz-padding-top-small blz-padding-right blz-padding-left blz-padding-bottom-small",
            "layout": "fit",
            "size": 3
          },
          {
            "children": [
              {
                "actions": [
                  {
                    "icon": "add.svg",
                    "key": "add",
                    "text": "[[Add]]"
                  }
                ],
                "htmlTemplate": "<div>\n  \t<br/>\n</div>\n\t",
                "name": "renGoalActions",
                "title": "[[Blank]]",
                "widget": "HtmlRenderer"
              }
            ],
            "layout": "fit",
            "size": 9
          }
        ],
        "layout": "responsive",
        "name": "actionsContainer"
      },
      {
        "name": "goalsTree",
        "widget": "Tree"
      }
    ],
    "layout": "responsive"
  },
  "routing": {
    "path": "/sf-plan/{planId}/goals/tree"
  },
  "unused": []
}