{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "HistoryController"
    },
    "designerId": "88dbc2df-429f-4ab7-8f09-acc031120fa1",
    "cn": [
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "autoCreate": true,
                "ref": "historyRuleWindow",
                "selector": "#HistoryRule",
                "xtype": "HistoryRuleAlias"
            },
            "designerId": "ac0618b7-99d8-4d81-ae8f-4afa0de897ab"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "viewRuleHistoryButton",
                "selector": "#viewRuleHistoryButton"
            },
            "designerId": "467a09dd-7038-4e51-8261-508769bb57eb"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "historyRuleContainer",
                "selector": "#HistoryRuleContainer"
            },
            "designerId": "df6e5128-1dff-40ce-ae6f-7b83903c6b50"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "historyRuleLabel",
                "selector": "#HistoryRuleLabel"
            },
            "designerId": "a42bcfa7-518a-433e-8031-1734197bd1ff"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "mainTreeGrid",
                "selector": "#treegrid"
            },
            "designerId": "41222175-ef2e-4d53-992f-15380dc4fd0e"
        },
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "application"
                ],
                "fn": "init",
                "implHandler": [
                    "this.control({\r",
                    "    '#viewRuleHistoryButton': {\r",
                    "        click: function() {\r",
                    "            this.getHistoryRuleWindow().show();\r",
                    "\t\t\tthis.getHistoryRule();\r",
                    "        }\r",
                    "    }\r",
                    "});"
                ]
            },
            "designerId": "880703d6-bbff-49b4-ad4b-92152c0926b3"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "data"
                ],
                "fn": "setUpWindowRule",
                "implHandler": [
                    "if (data && data.length && data.length > 0) {\r",
                    "\tvar fulltext = '';\r",
                    "\tfor(var i = 0; i < data.length; i++) {\r",
                    "\t\tvar user = data[i].user;\r",
                    "\t\tvar date = data[i].date;\r",
                    "\t\tvar text = data[i].text;\r",
                    "\t\tvar line = date + ', ' + user + ': '+text;\r",
                    "\r",
                    "\t\tif (i > 0) {\r",
                    "\t\t\tfulltext += \"\\n\";\r",
                    "\t\t}\r",
                    "\t\tfulltext += line;\r",
                    "\t}\r",
                    "\tthis.getHistoryRuleLabel().setValue(fulltext);\r",
                    "} else {\r",
                    "\tthis.getHistoryRuleLabel().setValue(CCS.Translator.getText('NO DATA!'));\r",
                    "}"
                ]
            },
            "designerId": "04708c2d-1bfb-4c85-9572-fb8faab06278"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "getHistoryRule",
                "implHandler": [
                    "var record = this.getMainTreeGrid().getSelectionModel().selected.getAt(0);\r",
                    "var params = Ext.Object.fromQueryString(document.location.search);\r",
                    "params.id = record.data.id;\r",
                    "\r",
                    "this.getHistoryRuleWindow().setTitle(CCS.Translator.getText('History log for risk ID {1}', [record.data.ruleId]));\r",
                    "this.getHistoryRuleWindow().setLoading(CCS.Translator.getText('Loading...'));\r",
                    "Ext.Ajax.request({\r",
                    "\turl: '../../service/sod_get_history_rule.php',\r",
                    "\tmethod: 'GET',\r",
                    "\tparams: params,\r",
                    "\tsuccess: function(response, object){\r",
                    "\t\tvar data = response.responseText;\r",
                    "\t\tthis.setUpWindowRule(Ext.JSON.decode(data));\r",
                    "\t\tthis.getHistoryRuleWindow().setLoading(false);\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\tthis.getHistoryRuleWindow().setLoading(false);\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});"
                ]
            },
            "designerId": "4d060980-d6db-49a9-9d14-635398b8639d"
        }
    ]
}