{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "ShowDetails"
    },
    "designerId": "bb655c49-bc2a-45fd-9eec-eb3335650abb",
    "cn": [
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "onLaunch",
                "implHandler": [
                    "this.get();\r",
                    ""
                ]
            },
            "designerId": "7b48225c-f602-4187-8d19-187a22352342"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "get",
                "implHandler": [
                    "this.getMain().setLoading(CCS.Translator.getText('Loading...'));\r",
                    "var params = Ext.Object.fromQueryString(document.location.search);\r",
                    "\r",
                    "Ext.Ajax.request({ //manual AJAX GET\r",
                    "\turl: '../../service/display_details.php',\r",
                    "\tmethod: 'GET',\r",
                    "\tparams: params,\r",
                    "\ttimeout: 180000,\r",
                    "\tsuccess: function(response, object){\r",
                    "\t\tthis.getMain().setLoading(false);\r",
                    "\t\tvar isError = false;\r",
                    "\t\tvar data = {};\r",
                    "\r",
                    "\t\tif(Ext.isEmpty(response)) {\r",
                    "\t\t\tisError = true;\r",
                    "\t\t\tMyApp.app.message(\"An Error Occurred!\", \"Response object was empty!\");\r",
                    "\t\t\tExt.Msg.alert('Error', \"Response object was empty!\");\r",
                    "\t\t}\r",
                    "\t\telse if(Ext.isEmpty(response.responseText)) {\r",
                    "\t\t\tisError = true;\r",
                    "\t\t}\r",
                    "\t\telse {\r",
                    "\t\t\tdata = Ext.decode(response.responseText);\r",
                    "\t\t\t\r",
                    "\t\t\tif(Ext.isEmpty(data.result)) {\r",
                    "\t\t\t\tisError = true;\r",
                    "\t\t\t}\r",
                    "\t\t\tif(Ext.isEmpty(params.type)) {\r",
                    "\t\t\t\tisError = true;\r",
                    "\t\t\t}\r",
                    "\t\t}\r",
                    "\r",
                    "\t\tif(isError === false){\r",
                    "\t\t\tthis.show(data.result, params.type);\r",
                    "\t\t}\r",
                    "\t\telse { //result is apparently empty. This should not happen.\r",
                    "\t\t\tconsole.log(response);\r",
                    "\t\t\tvar text = response.responseText;\r",
                    "\t\t\tExt.Msg.alert('Error', \"Result was empty!<br>\"+ params.type +\"<br>\"+ text);\r",
                    "\t\t\tMyApp.app.message(\"An Error Occurred!\", \"Result was empty!<br>\"+ params.type +\"<br>\"+ text);\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\tfailure: function(response, object){\r",
                    "\t\tthis.getMain().setLoading(false);\r",
                    "\t\tvar text = response.responseText;\r",
                    "\t\tMyApp.app.message(\"An Error Occurred!\",text);\r",
                    "\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});"
                ]
            },
            "designerId": "be876ff2-eb18-45ca-8389-fb43b11ca845"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "data",
                    "type"
                ],
                "fn": "show",
                "implHandler": [
                    "var form = this.getForm(type);\r",
                    "\r",
                    "if(!Ext.isEmpty(form)) {\r",
                    "\tform.show();\r",
                    "\tform.getForm().setValues(data);\r",
                    "\tthis.hideEmptyFields(form, data);\r",
                    "\r",
                    "\tswitch(type) {\r",
                    "\t\tcase 'risk':\r",
                    "\t\t\tMyApp.app.getController('Risk').formatText(data);\r",
                    "\t\tbreak;\r",
                    "\t\tcase 'group':\r",
                    "\r",
                    "\t\tbreak;\r",
                    "\t\tcase 'control':\r",
                    "\t\t\tMyApp.app.getController('Control').formatText(data);\r",
                    "\t\tbreak;\r",
                    "\t\tcase 'check':\r",
                    "\t\t\tMyApp.app.getController('Check').formatText(data);\r",
                    "\t\t\tthis.afterTreatmentCheck(data);\r",
                    "\t\tbreak;\r",
                    "\t\tcase 'area':\r",
                    "\t\t\tMyApp.app.getController('Area').formatText(data);\r",
                    "\t\tbreak;\r",
                    "\t}\r",
                    "}\r",
                    "this.getMain().doLayout();"
                ]
            },
            "designerId": "cf5142b1-fa1a-4750-9251-10f62255a813"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "type"
                ],
                "fn": "getForm",
                "implHandler": [
                    "var form;\r",
                    "\r",
                    "switch(type) {\r",
                    "\tcase 'risk':\r",
                    "\t\tform = this.getRiskForm();\r",
                    "\tbreak;\r",
                    "\tcase 'control':\r",
                    "\t\tform = this.getControlForm();\r",
                    "\tbreak;\r",
                    "\tcase 'area':\r",
                    "\t\tform = this.getAreaForm();\r",
                    "\tbreak;\r",
                    "\tcase 'group':\r",
                    "\t\tform = this.getGroupForm();\r",
                    "\tbreak;\r",
                    "\tcase 'check':\r",
                    "\t\tform = this.getCheckForm();\r",
                    "\tbreak;\r",
                    "}\r",
                    "\r",
                    "return form;"
                ]
            },
            "designerId": "b37c78db-deba-4249-b613-5b2aa07cba9e"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "form",
                    "data"
                ],
                "fn": "hideEmptyFields",
                "implHandler": [
                    "var item;\r",
                    "for(var key in form.items.items) {\r",
                    "\titem = form.items.items[key];\r",
                    "\tif(item.xtype != 'container' && item.xtype != 'tbspacer') {\r",
                    "\t\tif(Ext.isEmpty(data[item.name]))\r",
                    "\t\t\titem.hide();\r",
                    "\t}\r",
                    "\telse {\r",
                    "\t\tif(item.xtype != 'tbspacer')\r",
                    "\t\t\tthis.hideEmptyFields(item, data);\r",
                    "\t}\r",
                    "}\r",
                    ""
                ]
            },
            "designerId": "53517e11-1277-47ad-9e47-c589e6db4508"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "data"
                ],
                "fn": "afterTreatmentCheck",
                "implHandler": [
                    "this.getControlDetailsNoticeIcon().hide();\r",
                    "\r",
                    "this.noticeTooltip = Ext.create('Ext.tip.ToolTip', {\r",
                    "\ttarget: this.getControlDetailsNoticeIcon().getEl(),\r",
                    "\thtml: ''\r",
                    "});\r",
                    "\r",
                    "if(!data.control_id){\r",
                    "\tthis.getControlDetailsNoticeIcon().show();\r",
                    "\tvar tipText = CCS.Translator.getText('Control definition has been deleted!');\r",
                    "\tthis.noticeTooltip.update(tipText);\r",
                    "}\r",
                    "else if(data.control_data_changed){\r",
                    "\tthis.getControlDetailsNoticeIcon().show();\r",
                    "\tvar tipText = CCS.Translator.getText('Control definition has been changed!');\r",
                    "\tthis.noticeTooltip.update(tipText);\r",
                    "}"
                ]
            },
            "designerId": "d45a419e-f76b-45b0-a85a-84adfd2958d2"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "component",
                    "text"
                ],
                "fn": "showText",
                "implHandler": [
                    "var exp = /(\\b(http|https|ftp|file):\\/\\/[\\-A-Z0-9+&@#\\/%?=~_|!:,.;]*[\\-A-Z0-9+&@#\\/%=~_|])/gi;\r",
                    "var text = text.replace(exp, \"<a href='$1' target='_blank'>$1</a>\");\r",
                    "\ttext = text.replace(/(?:\\r\\n|\\r|\\n)/g, '<br />');\r",
                    "\r",
                    "component.down('panel').update(text);\r",
                    "component.down('panel').show();\r",
                    "component.down('label').show();\r",
                    "component.show();\r",
                    ""
                ]
            },
            "designerId": "e35bcf18-f71c-4af8-8df3-e34c2fbe5431"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "main",
                "selector": "#main"
            },
            "designerId": "d542efe3-90e0-436c-9ab3-40874677a83c"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "riskForm",
                "selector": "#riskForm"
            },
            "designerId": "c1eb978b-938a-44f5-8495-9ade580d9bac"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "controlForm",
                "selector": "#controlForm"
            },
            "designerId": "4febd721-fd74-469c-9cf8-14d074eb05a0"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "groupForm",
                "selector": "#groupForm"
            },
            "designerId": "76574cd5-0040-4521-bb5b-ac087411cee4"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "areaForm",
                "selector": "#areaForm"
            },
            "designerId": "4d0a381a-6c63-4429-9832-f8e356e9185c"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "checkForm",
                "selector": "#checkForm"
            },
            "designerId": "1cf8d7ba-dd8b-40b2-9b19-bb8593c14310"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "controlDetailsNoticeIcon",
                "selector": "#controlDetailsNoticeIcon"
            },
            "designerId": "1156ebbf-9b00-43ab-9435-7cfc5a09a01b"
        }
    ]
}