{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "CreateEditDeleteRuleController"
    },
    "designerId": "40793c73-5a58-4b1f-a8f8-1f99c87f6ee3",
    "cn": [
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "mainTreeGrid",
                "selector": "#treegrid"
            },
            "designerId": "412d142d-81a0-46b5-81c2-272989e5c29d"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "deleteRuleButton",
                "selector": "#deleteRuleButton"
            },
            "designerId": "ccd7740c-aa0b-4c8d-8d8d-e7088d28398e"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "copyRuleButton",
                "selector": "#copyRuleButton"
            },
            "designerId": "307c1fd1-a1cc-4c1f-b9f3-4fa943d244b9"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "createnewruleButton",
                "selector": "#createnewruleButton"
            },
            "designerId": "1683e6a6-3a00-4319-91a7-bc1e9542d2c6"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleButton",
                "selector": "#editRuleButton"
            },
            "designerId": "6d309c29-a79b-4282-a127-f8923f6e5b16"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "autoCreate": true,
                "ref": "editRuleWindow",
                "selector": "#editRuleWindow",
                "xtype": "editRuleWindowAlias"
            },
            "designerId": "894ea926-2783-4398-b804-c04fa17d81a2"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleNumberLabel",
                "selector": "#editRuleNumberLabel"
            },
            "designerId": "f65f8fad-6043-44ca-b58c-86eb7bccff8e"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleSettingsPanel",
                "selector": "#editRuleSettingsPanel"
            },
            "designerId": "089de05d-0388-4613-a289-3fe390daf74a"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleName",
                "selector": "#editRuleName"
            },
            "designerId": "8cd0e1ee-ce13-44d1-816f-1d326e0b3caa"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleWarning",
                "selector": "#editRuleWarning"
            },
            "designerId": "3b0403b2-8cd7-4a87-9764-8922bb3e593e"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleApprover",
                "selector": "#editRuleApprover"
            },
            "designerId": "301f5795-1d1d-44c1-8601-85b4449ebedf"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleMessage",
                "selector": "#editRuleMessage"
            },
            "designerId": "4f9af5e1-26c7-4e3a-8b2a-240e9afadb76"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleRisk",
                "selector": "#editRuleRisk"
            },
            "designerId": "1dac6614-e1ed-41df-9f09-81957068c9db"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleMitigation",
                "selector": "#editRuleMitigation"
            },
            "designerId": "545082d8-f080-4583-8fb8-97a1a215e823"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleDescription",
                "selector": "#editRuleDescription"
            },
            "designerId": "50172cf9-e8bc-4484-b8a7-85f49244958b"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleGroup",
                "selector": "#editRuleGroup"
            },
            "designerId": "e211fc50-186d-42e7-8fcb-08efd1004e90"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleOrigin",
                "selector": "#editRuleOrigin"
            },
            "designerId": "f3d775a2-49b0-46a3-8972-0daa32381836"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleActive",
                "selector": "#editRuleActive"
            },
            "designerId": "bb7f296c-5931-4c81-a859-a38666332851"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleConfirmButton",
                "selector": "#editRuleConfirmButton"
            },
            "designerId": "791ff013-ebf6-4bca-9eb6-a2aee7e23fab"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleSaveButton",
                "selector": "#editRuleSaveButton"
            },
            "designerId": "a92aac98-5f76-4318-a3cd-f3987f0bdeaa"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleCancelButton",
                "selector": "#editRuleCancelButton"
            },
            "designerId": "9ee457dc-293a-4963-82fc-97b2963de87a"
        },
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "application"
                ],
                "fn": "init",
                "implHandler": [
                    "this.control({\r",
                    "    '#deleteRuleButton': {\r",
                    "        click: function() {\r",
                    "            this.deleteRule();\r",
                    "        }\r",
                    "    },\r",
                    "    '#copyRuleButton': {\r",
                    "        click: function() {\r",
                    "            this.copyRule();\r",
                    "        }\r",
                    "    },\r",
                    "    '#editRuleButton': {\r",
                    "        click: function() {\r",
                    "\t\t\tthis.edit = true;\r",
                    "            this.getDefaultSettings();\r",
                    "        }\r",
                    "    },\r",
                    "    '#createnewruleButton': {\r",
                    "        click: function() {\r",
                    "\t\t\tthis.edit = false;\r",
                    "\t\t\tthis.getDefaultSettings();\r",
                    "        }\r",
                    "    },\r",
                    "//close window on cancel\r",
                    "    '#editRuleCancelButton': {\r",
                    "        click: function() {\r",
                    "            this.getEditRuleWindow().destroy();\r",
                    "        }\r",
                    "    },\r",
                    "//do stuff on confirm\r",
                    "    '#editRuleConfirmButton': {\r",
                    "        click: function() {\r",
                    "\t\t\tthis.createRule();\r",
                    "\t\t\tthis.getEditRuleWindow().destroy(); //close popup window\r",
                    "        }\r",
                    "    },\r",
                    "//save on edit\r",
                    "    '#editRuleSaveButton': {\r",
                    "        click: function() {\r",
                    "            this.editRule();\r",
                    "\t\t\tthis.getEditRuleWindow().destroy(); //close popup window\r",
                    "        }\r",
                    "    },\r",
                    "//active / inactive check box\r",
                    "    '#editRuleActive': {\r",
                    "        change: function() {\r",
                    "\r",
                    "\t\t}\r",
                    "    },\r",
                    "//check comboboxes for change\r",
                    "    '#editRuleWarning': {\r",
                    "        change: function() {\r",
                    "\t\t\tthis.warningTypeChanged();\r",
                    "        }\r",
                    "    },\r",
                    "\t'#editRuleApprover': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "\t'#editRuleMessage': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "\t'#editRuleRisk': {\r",
                    "        select: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "    '#editRuleGroup': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "\t'#editRuleFrequency': {\r",
                    "\t\tchange: function(component, newValue) {\r",
                    "\t\t\tif(newValue == 9) {\r",
                    "\t\t\t\tthis.getEditRuleAutoRenewal().setValue(false);\r",
                    "\t\t\t}\r",
                    "\t\t\telse {\r",
                    "\t\t\t\tthis.getEditRuleAutoRenewal().setValue(true);\r",
                    "\t\t\t}\r",
                    "\t\t}\r",
                    "\t},\r",
                    "//check fields for changes\r",
                    "    '#editRuleName': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "    '#editRuleMitigation': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "    '#editRuleDescription': {\r",
                    "        change: function() {\r",
                    "            this.checkFieldStates();\r",
                    "        }\r",
                    "    },\r",
                    "\t'#selectMultiApproversMinimumNumber': {\r",
                    "\t\tchange: function() {\r",
                    "\t\t\tthis.checkFieldStates();\r",
                    "\t\t}\r",
                    "\t},\r",
                    "    '#editSignature': {\r",
                    "        change: this.checkUniqueSignature\r",
                    "    },\t\r",
                    "//multiapprover buttons\r",
                    "    '#editRuleAddApproverButton': {\r",
                    "        click: function() {\r",
                    "\t\t\tthis.multiApproversStart();\r",
                    "        }\r",
                    "    },\r",
                    "    '#selectMultiApproversDoneButton': {\r",
                    "        click: function() {\r",
                    "            this.multiApproversDone();\r",
                    "        }\r",
                    "    }\r",
                    "});"
                ]
            },
            "designerId": "57e3311b-8dfe-4e24-ba06-32e6370fde47"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "createSetUpWindow",
                "implHandler": [
                    "var groupId = '0';\r",
                    "var selNode = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "if(!Ext.isEmpty(selNode)) {\r",
                    "\tif(selNode.isLeaf()) {\r",
                    "\t\t//function\r",
                    "\t\tgroupId = selNode.parentNode.parentNode.data.id;\r",
                    "\t} else if (selNode.data.ruleId !== null && selNode.data.ruleId !== undefined && selNode.data.ruleId !== \"\") {\r",
                    "\t\t//rule\r",
                    "\t\tgroupId = selNode.parentNode.data.id;\r",
                    "\t} else {\r",
                    "\t\t//group\r",
                    "\t\tgroupId = selNode.data.id;\r",
                    "\t}\r",
                    "}\r",
                    "groupId = \"\"+groupId;\r",
                    "this.getEditRuleGroup().setValue(groupId);\r",
                    "//set defaults\r",
                    "this.multiApprovers = [];\r",
                    "this.getEditRuleRisk().setValue('Low');\r",
                    "this.getEditRuleOrigin().setValue('Local');\r",
                    "this.getEditRuleMessage().setValue(\"0\");\r",
                    "\r",
                    "//reduce system reaction store if settings requires it\r",
                    "var me = this;\r",
                    "var myData = [];\r",
                    "this.RSstore = this.getEditRuleWarning().getStore();\r",
                    "this.RSstore.each(function(rec) {\r",
                    "\tif(me.defaults[\"defaultsSR\"+rec.data.id]) {\r",
                    "\t\tmyData.push(rec);\r",
                    "\t}\r",
                    "});\r",
                    "var myNewStore = new Ext.data.ArrayStore( {\r",
                    "\tfields:\t['id', 'text]'],\r",
                    "\tdata:\tmyData\r",
                    "});\r",
                    "\r",
                    "this.getEditRuleWarning().bindStore(myNewStore);\r",
                    "this.getEditRuleWarning().getStore().load();\r",
                    "\r",
                    "this.multiApproversMin = this.defaults.approver_minimum;\r",
                    "this.getEditRuleWarning().setValue(this.defaults.system_reaction);\r",
                    "//if lock reaction setting is set then lock\r",
                    "if(this.defaults.system_reaction_locked)\r",
                    "\tthis.getEditRuleWarning().disable();\r",
                    "\r",
                    "//focus on name\r",
                    "this.getEditRuleWindow().setLoading(false);\r",
                    "this.getEditRuleName().focus();"
                ]
            },
            "designerId": "4a9eff65-e4a9-4ba2-b665-cbffb778d21b"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "createRule",
                "implHandler": [
                    "var myStore = this.getMainTreeGrid().getStore();\r",
                    "var rootNode = this.getMainTreeGrid().getRootNode();\r",
                    "var groupNode = rootNode.findChild('id', this.getEditRuleGroup().getValue(), false);\r",
                    "if(this.getEditRuleOrigin().getValue().length === 0) {\r",
                    "\tthis.getEditRuleOrigin().setValue('Local');\r",
                    "}\r",
                    "\r",
                    "//rule creation stuff\r",
                    "var myModel = myStore.model;\r",
                    "var newRecord = new myModel({\r",
                    "    ruleId:\t\t\"New rule\",\r",
                    "    name:\t\tthis.getEditRuleName().getValue(),\r",
                    "    warning:\tthis.getEditRuleWarning().getValue(),\r",
                    "    responseId: this.getEditRuleMessage().getValue(),\r",
                    "    levelId:\tthis.getEditRuleRisk().getValue(),\r",
                    "    mitigation:\tthis.getEditRuleMitigation().getValue(),\r",
                    "    description:this.getEditRuleDescription().getValue(),\r",
                    "    groupId:\tthis.getEditRuleGroup().getValue(),\r",
                    "    origin:\t\tthis.getEditRuleOrigin().getValue(),\r",
                    "    statusId:\t(this.getEditRuleActive().getValue())? 'Active' : 'Inactive',\r",
                    "\tapproverId: (this.getEditRuleWarning().getValue() == 2)? this.getEditRuleApprover().getValue() : 0,\r",
                    "\tapprover:\tthis.getEditRuleApprover().getRawValue(),\r",
                    "\tworkflow_autostart: this.getEditRuleAutoRenewal().getValue(),\r",
                    "\tworkflow_frequency: this.getEditRuleFrequency().getValue(),\r",
                    "\tsignature:\tthis.getEditSignature().getValue(),\r",
                    "\r",
                    "\tmultiApprovers: this.multiApprovers,\r",
                    "\tmultiApproversMin : this.multiApproversMin,\r",
                    "\ticon:\t\t'../gfx/rule.png'\r",
                    "});\r",
                    "\r",
                    "groupNode.appendChild(newRecord);\r",
                    "newRecord.expand();\r",
                    "this.getMainTreeGrid().getSelectionModel().deselectAll(true);\r",
                    "this.getMainTreeGrid().getSelectionModel().doSelect(newRecord);"
                ]
            },
            "designerId": "46a3591c-001e-4a18-831f-688c10d228f3"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "editSetUpWindow",
                "implHandler": [
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "\r",
                    "this.getEditRuleWindow().setTitle(CCS.Translator.getText('Edit risk ID {1} for critical roles',[record.data.ruleId]));\r",
                    "this.getEditRuleConfirmButton().hide();\r",
                    "this.getEditRuleSaveButton().show();\r",
                    "\r",
                    "this.multiApprovers = record.get('multiApprovers');\r",
                    "this.multiApproversMin = record.get('multiApproversMin');\r",
                    "this.getEditRuleName().setValue(record.get('name'));\r",
                    "\r",
                    "//reduce system reaction store if settings requires it\r",
                    "var me = this;\r",
                    "var myData = [];\r",
                    "this.RSstore = this.getEditRuleWarning().getStore();\r",
                    "this.RSstore.each(function(rec) {\r",
                    "\tif(me.defaults[\"defaultsSR\"+rec.data.id]) {\r",
                    "\t\tmyData.push(rec);\r",
                    "\t}\r",
                    "});\r",
                    "var myNewStore = new Ext.data.ArrayStore( {\r",
                    "\tfields:\t['id', 'text]'],\r",
                    "\tdata:\tmyData\r",
                    "});\r",
                    "\r",
                    "this.getEditRuleWarning().bindStore(myNewStore);\r",
                    "this.getEditRuleWarning().getStore().load();\r",
                    "this.getEditRuleWarning().setValue(record.get('warning'));\r",
                    "\r",
                    "if(this.multiApprovers.length > 0)\r",
                    "\tthis.multiApproversOutput();\r",
                    "else\r",
                    "\tthis.getEditRuleApprover().setValue(record.get('approverId'));\r",
                    "\r",
                    "this.getEditSignature().setValue(record.get('signature'));\r",
                    "this.getEditRuleMessage().setValue(record.get('responseId'));\r",
                    "this.getEditRuleRisk().setValue(record.get('levelId'));\r",
                    "this.getEditRuleMitigation().setValue(record.get('mitigation'));\r",
                    "this.getEditRuleDescription().setValue(record.get('description'));\r",
                    "this.getEditRuleGroup().setValue(record.get('groupId'));\r",
                    "this.getEditRuleOrigin().setValue(record.get('origin'));\r",
                    "this.getEditRuleActive().setValue((record.get('statusId') == \"Active\"));\r",
                    "this.getEditRuleFrequency().setValue(record.get('workflow_frequency'));\r",
                    "\r",
                    "this.getEditRuleWindow().setLoading(false);\r",
                    "\r",
                    "//reduced system reaction store may need to be messaged to the user\r",
                    "if(this.getEditRuleWarning().getValue() === null) {\r",
                    "\tif(this.defaults.system_reaction != record.get('warning')) {\r",
                    "\t\tMyApp.app.message(\tCCS.Translator.getText('System reaction no longer available due to system settings!'),\r",
                    "\t\t\t\t\t\t\tCCS.Translator.getText('You must choose an available option to edit this risk definition.'));\r",
                    "\t}\r",
                    "}"
                ]
            },
            "designerId": "56c22fdf-e995-483a-a6cb-b0d8271c1b34"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "editRule",
                "implHandler": [
                    "var store = this.getMainTreeGrid().getStore();\r",
                    "store.suspendAutoSync();\r",
                    "\r",
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "\r",
                    "//No empty origin\r",
                    "if(this.getEditRuleOrigin().getValue().length === 0) {\r",
                    "\tthis.getEditRuleOrigin().setValue(record.data.origin);\r",
                    "}\r",
                    "\r",
                    "//if the group is changed\r",
                    "if(record.data.groupId != this.getEditRuleGroup().getValue()) {\r",
                    "\tvar newGroup = this.getMainTreeGrid().getRootNode().findChild('id', this.getEditRuleGroup().getValue(), false);\r",
                    "\r",
                    "\trecord.remove(false);\r",
                    "\r",
                    "\tnewGroup.appendChild(record);\r",
                    "\trecord.expand();\r",
                    "}\r",
                    "\r",
                    "record.set(\"name\", this.getEditRuleName().getValue());\r",
                    "record.set(\"warning\", this.getEditRuleWarning().getValue());\r",
                    "record.set(\"warningText\", this.getEditRuleWarning().getRawValue());\r",
                    "record.set(\"approverId\", (this.getEditRuleWarning().getValue() == 2)? this.getEditRuleApprover().getValue() : 0);\r",
                    "record.set(\"approver\", this.getEditRuleApprover().getRawValue());\r",
                    "record.set(\"responseId\", this.getEditRuleMessage().getValue());\r",
                    "record.set(\"response\", this.getEditRuleMessage().getRawValue());\r",
                    "record.set(\"levelId\", this.getEditRuleRisk().getValue());\r",
                    "record.set(\"mitigation\", this.getEditRuleMitigation().getValue());\r",
                    "record.set(\"description\", this.getEditRuleDescription().getValue());\r",
                    "record.set(\"groupId\", this.getEditRuleGroup().getValue());\r",
                    "record.set(\"origin\", this.getEditRuleOrigin().getValue());\r",
                    "record.set(\"statusId\", (this.getEditRuleActive().getValue())? 'Active' : 'Inactive');\r",
                    "record.set(\"multiApprovers\", this.multiApprovers);\r",
                    "record.set(\"multiApproversMin\", this.multiApproversMin);\r",
                    "record.set(\"workflow_autostart\", this.getEditRuleAutoRenewal().getValue());\r",
                    "record.set(\"workflow_frequency\", this.getEditRuleFrequency().getValue());\r",
                    "record.set(\"signature\", this.getEditSignature().getValue());\r",
                    "\r",
                    "record.set(\"ruleId\", \"Update rule\");\r",
                    "\r",
                    "var model = this.getMainTreeGrid().getSelectionModel();\r",
                    "store.resumeAutoSync();\r",
                    "store.sync({callback:\r",
                    "\tfunction(){\r",
                    "\t\tmodel.deselectAll();\r",
                    "\t\trecord.commit();\r",
                    "\t\tmodel.doSelect(record);\r",
                    "\t}\r",
                    "});"
                ]
            },
            "designerId": "30ed7a3f-2452-469b-a557-1f64d581f2aa"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "copyRule",
                "implHandler": [
                    "//suspend grid\r",
                    "MyApp.app.getController('GUIController').disableAll();\r",
                    "this.getMainTreeGrid().setLoading({border: false}, true);\r",
                    "\r",
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0); //there is no multiselect\r",
                    "var myStore = this.getMainTreeGrid().getStore();\r",
                    "var groupId = record.data.groupId;\r",
                    "\r",
                    "//rule creation stuff\r",
                    "var myModel = myStore.model;\r",
                    "var newRecord = new myModel({\r",
                    "\tid:\t\t\trecord.data.id,\r",
                    "\tname:\t\t\"Copy of \"+record.data.name,\r",
                    "\tgroupId:\tgroupId,\r",
                    "//\tchildren:\trecord.data.children,\r",
                    "\truleId:\t\t\"Copying rule\",\r",
                    "\ticon:\t\t'../gfx/rule.png'\r",
                    "\r",
                    "});\r",
                    "\r",
                    "var groupNode = this.getMainTreeGrid().getRootNode().findChild('id', groupId, false);\r",
                    "myStore.suspendAutoSync();\r",
                    "myStore.autoSync = false;\r",
                    "groupNode.appendChild(newRecord);\r",
                    "newRecord.expand();\r",
                    "\r",
                    "myStore.sync({\r",
                    "\tsuccess: function(operationdata, operation) {\r",
                    "\t\tvar rule = operationdata.operations[0].records[0]; //find return risk with new id\r",
                    "\t\tvar selection = rule.data.children; //find children in received data\r",
                    "\t\tfor (var i = 0; i < selection.length; i++) { //add children to rule\r",
                    "\t\t\tvar newRecord = new myModel({\r",
                    "\t\t\t\tid: selection[i].id,\r",
                    "\t\t\t\tname: selection[i].name,\r",
                    "\t\t\t\tdescription: selection[i].description,\r",
                    "\t\t\t\tleaf: true,\r",
                    "\t\t\t\ticon: selection[i].icon\r",
                    "\t\t\t});\r",
                    "\r",
                    "\t\t\trule.appendChild(newRecord);\r",
                    "\t\t}\r",
                    "\t\toperation.scope.getMainTreeGrid().setLoading(false);\r",
                    "\t},\r",
                    "\tfailure: function() {\talert(\"Error on copying rule. Please press F5.\");\t},\r",
                    "\tcallback: function(){\tmyStore.autoSync = true; myStore.resumeAutoSync();\t},\r",
                    "\tscope: this\r",
                    "}, record);"
                ]
            },
            "designerId": "71a268da-b61c-48b9-a7d5-ddc21a9bdf2f"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "deleteRule",
                "implHandler": [
                    "var node = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "var rule = node.get('name');\r",
                    "var groupNode = this.getMainTreeGrid().getRootNode().findChild('id', node.get('groupId'), false);\r",
                    "var group = groupNode.get('name');\r",
                    "\r",
                    "var scope = this;\r",
                    "var question = CCS.Translator.getText('Are you sure you want to remove {1} from {2}?', [rule, group]);\r",
                    "Ext.MessageBox.confirm(CCS.Translator.getText('Delete risk definition'), question, function(btn){\r",
                    "    if(btn === 'yes'){\r",
                    "        node.data.ruleId = \"Delete rule\";\r",
                    "        node.remove();\r",
                    "\t\tscope.getMainTreeGrid().getStore().sync();\r",
                    "    }\r",
                    "});"
                ]
            },
            "designerId": "764f8b53-1a84-4c07-82f5-3dac64aac858"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "warningTypeChanged",
                "implHandler": [
                    "var warning = this.getEditRuleWarning().getValue();\r",
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "\r",
                    "this.getEditRuleApprover().disable(); //single approver select\r",
                    "this.getEditRuleAddApproverButton().disable(); //btn for multi approver select\r",
                    "this.getEditRuleAutoRenewal().disable();\r",
                    "this.getEditRuleFrequency().disable();\r",
                    "this.getEditRuleFrequency().setValue(9);\r",
                    "\r",
                    "if(warning != '0') {\r",
                    "\tthis.getEditRuleMessage().enable();\r",
                    "\r",
                    "\tif(record !== undefined && record !== null && this.edit) {\r",
                    "\t\tthis.getEditRuleMessage().setValue(record.data.responseId);\r",
                    "\t}\r",
                    "\tswitch(warning) {\r",
                    "\t\tcase '2':\r",
                    "\t\t\tthis.getEditRuleApprover().setValue(0);\r",
                    "\t\t\tif(record !== undefined && record !== null && this.edit) {\r",
                    "\t\t\t\tthis.getEditRuleApprover().setValue(record.data.approverId);\r",
                    "\t\t\t}\r",
                    "\t\t\tthis.getEditRuleApprover().enable();\r",
                    "\t\t\tthis.multiApprovers = [];\r",
                    "\t\t\tthis.multiApproversMin = 0;\r",
                    "\t\tbreak;\r",
                    "\t\tcase '4':\r",
                    "\t\t\tthis.getEditRuleAddApproverButton().enable();\r",
                    "\t\t\tthis.getEditRuleAutoRenewal().enable();\r",
                    "\t\t\tthis.getEditRuleFrequency().enable();\r",
                    "\r",
                    "\t\t\tif(record !== undefined && record !== null && this.edit)\r",
                    "\t\t\t\tif(!Ext.isEmpty(record.get('multiApprovers')))\r",
                    "\t\t\t\t\tthis.multiApprovers = record.get('multiApprovers');\r",
                    "\t\t\t\telse {\r",
                    "\t\t\t\t\tthis.multiApprovers = [];\r",
                    "\t\t\t\t\tthis.multiApproversMin = (record.get('multiApproversMin') > this.defaults.approver_minimum)? record.get('multiApproversMin') : this.defaults.approver_minimum;\r",
                    "\t\t\t\t}\r",
                    "\t\t\tthis.multiApproversOutput();\r",
                    "\t\tbreak;\r",
                    "\t\tdefault:\r",
                    "\t\t\tthis.getEditRuleApprover().setValue(0);\r",
                    "\t\t\tthis.multiApprovers = [];\r",
                    "\t\t\tthis.multiApproversMin = 0;\r",
                    "\t}\r",
                    "} else {\r",
                    "\tthis.getEditRuleMessage().setValue(0);\r",
                    "\tthis.getEditRuleMessage().disable();\r",
                    "}\r",
                    "this.checkFieldStates();"
                ]
            },
            "designerId": "e8fbcd78-56ef-4486-b5ac-6a5bf2aa8f26"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "uniqueSignature"
                ],
                "fn": "checkFieldStates",
                "implHandler": [
                    "if(this.getSelectMultiApproversMinimumNumber() !== undefined && this.getSelectMultiApproversMinimumNumber().getValue() < this.defaults.approver_minimum)\r",
                    "\tthis.getSelectMultiApproversMinimumNumber().setValue(this.defaults.approver_minimum);\r",
                    "\r",
                    "this.getEditRuleConfirmButton().disable();\r",
                    "this.getEditRuleSaveButton().disable();\r",
                    "\r",
                    "this.getEditRuleName().addCls('formFieldNotReady');\r",
                    "this.getEditRuleMessage().removeCls('formFieldNotReady');\r",
                    "this.getEditRuleApprover().removeCls('formFieldNotReady');\r",
                    "this.getEditRuleAddApproverButton().removeCls('formButtonNotReady');\r",
                    "\r",
                    "//avoid null on comboboxes\r",
                    "if(\tthis.getEditRuleWarning().getValue() !== null && uniqueSignature === undefined) {\r",
                    "\r",
                    "\t//name field\r",
                    "\tif(\tExt.String.trim(this.getEditRuleName().getValue()).length > 0) {\r",
                    "\t\t//enable create / save button\r",
                    "\t\tthis.getEditRuleName().removeCls('formFieldNotReady');\r",
                    "\t\tthis.getEditRuleConfirmButton().enable();\r",
                    "\t\tthis.getEditRuleSaveButton().enable();\r",
                    "\t}\r",
                    "\t//common for message check\r",
                    "\tif(this.getEditRuleWarning().getValue() > 0 && this.getEditRuleMessage().getValue() === null) {\r",
                    "\t\tthis.getEditRuleConfirmButton().disable();\r",
                    "\t\tthis.getEditRuleSaveButton().disable();\r",
                    "\t\tthis.getEditRuleMessage().addCls('formFieldNotReady');\r",
                    "\t}\r",
                    "\r",
                    "\t//do checks according to warning type (system reaction)\r",
                    "\tthis.getEditRuleWarning().removeCls('formFieldNotReady');\r",
                    "\tswitch(this.getEditRuleWarning().getValue()) {\r",
                    "\t\tcase '0': break; //don't do nothing\r",
                    "\t\tcase '2':\r",
                    "\t\t\t//check approver\r",
                    "\t\t\tif(this.getEditRuleApprover().getValue() === null) {\r",
                    "\t\t\t\tthis.getEditRuleConfirmButton().disable();\r",
                    "\t\t\t\tthis.getEditRuleSaveButton().disable();\r",
                    "\t\t\t\tthis.getEditRuleApprover().addCls('formFieldNotReady');\r",
                    "\t\t\t}\r",
                    "\t\t\tbreak;\r",
                    "\t\tcase '4':\r",
                    "\t\t\tif(this.multiApprovers.length < this.multiApproversMin) {\r",
                    "\t\t\t\tthis.getEditRuleConfirmButton().disable();\r",
                    "\t\t\t\tthis.getEditRuleSaveButton().disable();\r",
                    "\t\t\t\tthis.getEditRuleAddApproverButton().addCls('formButtonNotReady');\r",
                    "\t\t\t}\r",
                    "\t\t\tbreak;\r",
                    "\t\tdefault: //case '1' & '3'\r",
                    "\t}\r",
                    "\r",
                    "}\r",
                    "//reduced warning types / sytem reactions can result in null value\r",
                    "else {\r",
                    "\tif(\tExt.String.trim(this.getEditRuleName().getValue()).length > 0)\r",
                    "\t\tthis.getEditRuleName().removeCls('formFieldNotReady');\r",
                    "}\r",
                    "\r",
                    "if (uniqueSignature === true) {\r",
                    "\tthis.getEditRuleConfirmButton().enable();\r",
                    "\tthis.getEditRuleSaveButton().enable();\r",
                    "}\r",
                    ""
                ]
            },
            "designerId": "91616edc-e813-4da7-ad95-7c8fe670b94c"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "actionsPanel",
                "selector": "#actionsPanel"
            },
            "designerId": "776073c2-5b13-4361-9438-6c4d5c86599e"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "autoCreate": true,
                "ref": "selectMultiApproversWindow",
                "selector": "#selectMultiApproversWindow",
                "xtype": "selectMultiApproversWindow"
            },
            "designerId": "7df5c8cb-0414-494d-bb1a-86245e021df3"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "selectMultiApproversGrid",
                "selector": "#selectMultiApproversGrid"
            },
            "designerId": "5c8f6cd1-dcb8-439c-9739-0a7769ca016f"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "selectMultiApproversDoneButton",
                "selector": "#selectMultiApproversDoneButton"
            },
            "designerId": "a6dd4fdd-d980-4b36-8204-55127f58aee5"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "selectMultiApproversMinimumNumber",
                "selector": "#selectMultiApproversMinimumNumber"
            },
            "designerId": "805d2724-a35e-4ba7-95e7-d432753d8e9f"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleAddApproverButton",
                "selector": "#editRuleAddApproverButton"
            },
            "designerId": "c9053492-a2f4-4a60-b070-e07552eb0f36"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "multiApproversStart",
                "implHandler": [
                    "this.getSelectMultiApproversWindow().show();\r",
                    "\r",
                    "var currentMultiApproversMin = (this.multiApproversMin > this.defaults.approver_minimum)? this.multiApproversMin : this.defaults.approver_minimum;\r",
                    "\r",
                    "this.getSelectMultiApproversMinimumNumber().setValue(Number(currentMultiApproversMin));\r",
                    "this.getSelectMultiApproversMinimumNumber().minValue = Number(this.defaults.approver_minimum);\r",
                    "\r",
                    "if(Ext.isArray(this.multiApprovers) && this.multiApprovers.length > 0) {\r",
                    "\tfor(i = 0; i < this.multiApprovers.length; i++) {\r",
                    "\t\tvar record = this.getSelectMultiApproversGrid().getStore().findRecord('id', this.multiApprovers[i]);\r",
                    "\t\tthis.getSelectMultiApproversGrid().getSelectionModel().select(record, true);\r",
                    "\t}\r",
                    "}"
                ]
            },
            "designerId": "72ac0a1d-7e10-4d85-a232-e07d5a166bb9"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "multiApproversDone",
                "implHandler": [
                    "var mySelection = this.getSelectMultiApproversGrid().getSelectionModel().getSelection();\r",
                    "var selectedApproverIds = [];\r",
                    "if (mySelection.length > 0) {\r",
                    "\tfor(i = 0; i < mySelection.length; i++) {\r",
                    "\t\tselectedApproverIds.push( mySelection[i].get('id') );\r",
                    "\t}\r",
                    "}\r",
                    "this.multiApprovers = selectedApproverIds;\r",
                    "this.multiApproversMin = this.getSelectMultiApproversMinimumNumber().getValue();\r",
                    "this.multiApproversOutput();\r",
                    "this.getSelectMultiApproversWindow().destroy();\r",
                    "this.checkFieldStates();"
                ]
            },
            "designerId": "2998595c-16e3-4ff6-90e8-dd2f9c0597dc"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "multiApproversOutput",
                "implHandler": [
                    "var selectedOutput = \"\";\r",
                    "if (this.multiApprovers.length > 0) {\r",
                    "\tfor(i = 0; i < this.multiApprovers.length; i++) {\r",
                    "\t\tselectedOutput += this.getEditRuleApprover().getStore().getById(this.multiApprovers[i]).get('text');\r",
                    "\t\tif(i < this.multiApprovers.length-1)\r",
                    "\t\t\tselectedOutput += \", \";\r",
                    "\t}\r",
                    "\tthis.getEditRuleApprover().setRawValue(selectedOutput);\r",
                    "} else {\r",
                    "\tthis.getEditRuleApprover().setValue(0);\r",
                    "}"
                ]
            },
            "designerId": "f2b5d045-9a74-4ccc-bb3a-957c629be783"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "mode"
                ],
                "fn": "getDefaultSettings",
                "implHandler": [
                    "this.getEditRuleWindow().show();\r",
                    "this.getEditRuleWindow().setLoading(CCS.Translator.getText('Loading...'));\r",
                    "\r",
                    "//load all data needed to set up window\r",
                    "this.numLoaded = 0;\r",
                    "this.getEditRuleMessage().getStore().load({callback: function() { this.onLoad(); }, scope: this});\r",
                    "this.getEditRuleApprover().getStore().load({callback: function() { this.onLoad(); }, scope: this});\r",
                    "this.getEditRuleWarning().getStore().load({callback: function() { this.onLoad(); }, scope: this});\r",
                    "this.getEditRuleRisk().getStore().load({callback: function() { this.onLoad(); }, scope: this});\r",
                    "this.getEditRuleGroup().getStore().load({callback: function() { this.onLoad(); }, scope: this});\r",
                    "\r",
                    "//get data from service and call the right method afterwards\r",
                    "Ext.Ajax.request({\r",
                    "\turl: '../../service/default_settings.php',\r",
                    "\tmethod: 'GET',\r",
                    "\tparams: Ext.Object.fromQueryString(document.location.search),\r",
                    "\tsuccess: function(response, object){\r",
                    "\t\tthis.defaults = Ext.JSON.decode(response.responseText);\r",
                    "\t\tthis.onLoad();\r",
                    "\t},\r",
                    "\tfailure: function(response, object){\r",
                    "\t\tvar text = response.responseText;\r",
                    "\t\tExt.Error.raise({\r",
                    "\t\t\tmsg: 'Failed to get report parameters',\r",
                    "\t\t\toption: text,   // whatever was passed into the method\r",
                    "\t\t\t'object': object // other arbitrary info\r",
                    "\t\t});\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});"
                ]
            },
            "designerId": "5f82a550-e655-407b-b344-b417001c67df"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "onLoad",
                "implHandler": [
                    "this.numLoaded++;\r",
                    "if (this.numLoaded == 6) {\r",
                    "\tif(this.edit)\r",
                    "\t\tthis.editSetUpWindow();\r",
                    "\telse\r",
                    "\t\tthis.createSetUpWindow();\r",
                    "}"
                ]
            },
            "designerId": "6164024b-2c74-4959-8ed1-2aee8394021a"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleFrequency",
                "selector": "#editRuleFrequency"
            },
            "designerId": "68ad2784-e7ea-489d-87f1-023c64886d9d"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editRuleAutoRenewal",
                "selector": "#editRuleAutoRenewal"
            },
            "designerId": "19a11590-16a8-472c-a087-727c4a364eab"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "editSignature",
                "selector": "#editSignature"
            },
            "designerId": "a7f97acc-0faf-4b86-9f9b-cd97697f1b5e"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "field",
                    "newValue",
                    "oldValue",
                    "eOpts"
                ],
                "fn": "checkUniqueSignature",
                "implHandler": [
                    "field.removeCls('formFieldNotReady');\r",
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "\r",
                    "var notSame = false;\r",
                    "if(record !== null) {\r",
                    "\tnotSame = record.get('signature') != newValue;\r",
                    "}\r",
                    "else {\r",
                    "\tnotSame = true;\r",
                    "}\r",
                    "\r",
                    "if(newValue.length > 0 && notSame) {\r",
                    "\tparams = Ext.Object.fromQueryString(document.location.search);\r",
                    "\tparams.signature = newValue;\r",
                    "\tExt.Ajax.request({ //manual AJAX\r",
                    "\t\turl: '../../service/is_unique_signature.php',\r",
                    "\t\tmethod: 'GET',\r",
                    "\t\tparams: params,\r",
                    "\t\tsuccess: function(response, object){\r",
                    "\t\t\tvar data = Ext.JSON.decode(response.responseText);\r",
                    "\t\t\tif(!data.result)\r",
                    "\t\t\t\tfield.addCls('formFieldNotReady');\r",
                    "\t\t\t\r",
                    "\t\t\tthis.checkFieldStates(data.result);\r",
                    "\t\t},\r",
                    "\t\tfailure: function(response, object){\r",
                    "\t\t\tfield.setValue(oldValue);\r",
                    "\r",
                    "\t\t\tvar text = response.responseText;\r",
                    "\t\t\tExt.Error.raise({\r",
                    "\t\t\t\tmsg: 'Ajax Get systems and clients failed',\r",
                    "\t\t\t\toption: text,   // whatever was passed into the method\r",
                    "\t\t\t\t'object': object // other arbitrary info\r",
                    "\t\t\t});\r",
                    "\t\t},\r",
                    "\t\tscope: this\r",
                    "\t});\r",
                    "}\r",
                    "else {\r",
                    "\tthis.checkFieldStates(true);\r",
                    "}"
                ]
            },
            "designerId": "b498b8b1-7d54-41c1-8fab-5b0f2e2f5b5d"
        }
    ]
}