{
    "type": "Ext.app.Controller",
    "reference": {
        "name": "items",
        "type": "array"
    },
    "codeClass": null,
    "userConfig": {
        "designer|userClassName": "Consolidated_CUD"
    },
    "designerId": "c541c54f-abf3-4c50-8ebe-4214e0bf9a17",
    "cn": [
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "licenseMap",
                "selector": "#licenseMap"
            },
            "designerId": "5b3304d9-9b32-433c-9dc8-db958ba2548a"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "autoCreate": true,
                "ref": "licenseCategoryWindow",
                "selector": "#LicenseCategoryWindow",
                "xtype": "LicenseCategoryWindow"
            },
            "designerId": "2a607bce-e4d3-4b18-ac8c-e32b2ad6c7c6"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "licenseCategoryForm",
                "selector": "#licenseCategoryForm"
            },
            "designerId": "4f3db097-8338-4205-a335-7d9795f24540"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "btnLicenseCategoryCreate",
                "selector": "#btnLicenseCategoryCreate"
            },
            "designerId": "74384362-5e62-42d8-b81f-30cf0161453c"
        },
        {
            "type": "controllerref",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "ref": "btnLicenseCategoryEdit",
                "selector": "#btnLicenseCategoryEdit"
            },
            "designerId": "f269750a-06ab-45f1-a0a6-0e42ccd8039d"
        },
        {
            "type": "fixedfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "application"
                ],
                "fn": "init",
                "implHandler": [
                    "this.control({\r",
                    "\t'#btnCreateCategory': {\r",
                    "\t\tclick: function(btn) {\r",
                    "\t\t\tthis.createCategoryOpenWindow(btn);\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\t'#licenseCategoryForm': {\r",
                    "\t\tvaliditychange: function(component, isValid) {\r",
                    "\t\t\tif(isValid) {\r",
                    "\t\t\t\t//this.getBtnLicenseCategoryCreate().enable();\r",
                    "\t\t\t\t//this.getBtnLicenseCategoryEdit().enable();\r",
                    "\t\t\t}\r",
                    "\t\t\telse {\r",
                    "\t\t\t\t//this.getBtnLicenseCategoryCreate().disable();\r",
                    "\t\t\t\t//this.getBtnLicenseCategoryEdit().disable();\r",
                    "\t\t\t}\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\t'#btnEditCategory': {\r",
                    "\t\tclick: function(btn) {\r",
                    "\t\t\tthis.createCategoryOpenWindow(btn);\r",
                    "\t\t\tvar record = this.getLicenseMap().getSelectionModel().getSelection()[0];\r",
                    "\t\t\tthis.getLicenseCategoryForm().getForm().loadRecord(record);\r",
                    "\t\t\tthis.getBtnLicenseCategoryCreate().hide();\r",
                    "\t\t\tthis.getBtnLicenseCategoryEdit().show();\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\t'#btnLicenseCategoryCreate': {\r",
                    "\t\tclick: function(btn) {\r",
                    "\t\t\tbtn.disable();\r",
                    "\t\t\tvar data = this.getLicenseCategoryForm().getForm().getValues();\r",
                    "\t\t\tthis.createCategory(data);\r",
                    "\t\t\tthis.getLicenseCategoryWindow().close();\r",
                    "\t\t}\r",
                    "\t},\r",
                    "\t'#btnLicenseCategoryEdit': {\r",
                    "\t\tclick: function(btn) {\r",
                    "\t\t\tbtn.disable();\r",
                    "\t\t\tvar data = this.getLicenseCategoryForm().getForm().getValues();\r",
                    "\t\t\tthis.editCategory(data);\r",
                    "\t\t\tthis.getLicenseCategoryWindow().close();\r",
                    "\t\t}\r",
                    "\t}\r",
                    "\r",
                    "});"
                ]
            },
            "designerId": "2d020e4d-d573-44f1-bbd5-7f1ee1a12dd6"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "button"
                ],
                "fn": "createCategoryOpenWindow",
                "implHandler": [
                    "this.getLicenseCategoryWindow().animateTarget = button;\r",
                    "this.getLicenseCategoryWindow().show();\r",
                    "var userLicense = this.getLicenseCategoryForm().getForm().findField('type').getStore().getAt(0);\r",
                    "this.getLicenseCategoryForm().getForm().findField('type').setValue(userLicense);\r",
                    "\r",
                    "//focus needs to happen after window has fully opened\r",
                    "var task = new Ext.util.DelayedTask(function(){\r",
                    "\tthis.getLicenseCategoryForm().getForm().findField('category').focus();\r",
                    "}, this);\r",
                    "\r",
                    "task.delay(350);"
                ]
            },
            "designerId": "0fe896be-24a9-453c-9f0b-9e44595528ac"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "data"
                ],
                "fn": "createCategory",
                "implHandler": [
                    "//adding a few extra properties\r",
                    "data.icon = '../gfx/create.gif';\r",
                    "data.leaf = true;\r",
                    "data.license_type = MyApp.app.getStore('LicenseType').getById(data.type).get('type');\r",
                    "data.license_type_id = data.type;\r",
                    "data.command = 'create';\r",
                    "\r",
                    "//creating new record and adding it\r",
                    "var model = this.getLicenseMap().getStore().model;\r",
                    "var newCat = new model(data);\r",
                    "this.getLicenseMap().getStore().getRootNode().appendChild(newCat);\r",
                    "this.getLicenseMap().getStore().sync({\r",
                    "\tcallback: function() {\r",
                    "\t\tthis.getLicenseMap().getStore().load();\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});"
                ]
            },
            "designerId": "01cff8d5-66f4-4458-b277-51688c0bd7a8"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "designer|params": [
                    "data"
                ],
                "fn": "editCategory",
                "implHandler": [
                    "var record = this.getLicenseMap().getStore().getById(data.id);\r",
                    "\r",
                    "//setting properties\r",
                    "record.set('category', data.category);\r",
                    "record.set('quantity', data.quantity);\r",
                    "record.set('cost', data.cost);\r",
                    "record.set('dash_abbr', data.dash_abbr);\r",
                    "record.set('dash_incl', data.dash_incl);\r",
                    "record.set('license_type', MyApp.app.getStore('LicenseType').getById(data.type).get('type'));\r",
                    "record.set('license_type_id', data.type);\r",
                    "record.set('command', 'edit');\r",
                    "\r",
                    "//creating new record and adding it\r",
                    "this.getLicenseMap().getStore().sync({\r",
                    "\tcallback: function() {\r",
                    "\t\tthis.getLicenseMap().getStore().load();\r",
                    "\t},\r",
                    "\tscope: this\r",
                    "});"
                ]
            },
            "designerId": "785108f0-c70c-4dd6-bf62-f3d13a010393"
        },
        {
            "type": "basicfunction",
            "reference": {
                "name": "items",
                "type": "array"
            },
            "codeClass": null,
            "userConfig": {
                "fn": "deleteCategory",
                "implHandler": [
                    "//Are you totally sure ? \r",
                    "// Really?"
                ]
            },
            "designerId": "ce8d6477-fe58-4b13-9395-757b5a10a27a"
        }
    ]
}