# coding: utf-8
'''
Created on 07.02.2014

@author: d.bozhenko P.
'''

import json

try:
    from ru.curs.showcase.core.jython import JythonDTO
except:
    from ru.curs.celesta.showcase import JythonDTO

try:
    from ru.curs.showcase.core.selector import ResultSelectorData
    from ru.beta2.extra.gwt.ui.selector.api import DataRecord
except:
    pass

from ru.curs.celesta.showcase.utils import XMLJSONConverter


def cardData(context, main, add, filterinfo=None, session=None, elementId=None):
    xformsdata = {
        "schema": {
            "@xmlns":"",
            "data": {
                "@filter": "1",
                "eor_name": "",
                "statusId":"",
                "statusName":"",
                "authorId":"",
                "authorName":"",
                "exauthorId":"",
                "exauthorName":"",
                "cath_id":"",  # чтоб использовать уже существующий селектор
                "cathedraName":"",
                "spec": "",
                "dpp": "",
                "nmo": ""
            }
        }
    }
    xformssettings = {
        "properties":{
            "action": {
                "#sorted": [
                    {"main_context": "current"},
                    {"datapanel": {
                        "@type": "current",
                        "@tab": "current",
                        "element": {
                            "@id": "btzCatalogGrid",
                            "add_context": "current"
                        }
                    }
                }]
            },
            "event": [{
                "@name": "single_click",
                "@linkId": "11",
                "action": {
                    "#sorted": [
                        {"main_context": "current"},
                        {"datapanel": {
                            "@type": "current",
                            "@tab": "current",
                            "element": [{
                                "@id": "btzCatalogGrid",
                                "add_context": 'current'
                            },
                            {
                                "@id": "btzAttributesGrid",
                                "add_context": "hide"
                            }]
                        }
                    }]}
            }]
        }
    }
    

                        
                        
    jsonData = XMLJSONConverter.jsonToXml(json.dumps(xformsdata))
    jsonSettings = XMLJSONConverter.jsonToXml(json.dumps(xformssettings))
    return JythonDTO(jsonData, jsonSettings)
