# 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": "0",
                "name": ""}}}
    
    xformssettings = {
        "properties":{
            "event": [{
                "@name": "single_click",
                "@linkId": "1",
                "action": {
                    "#sorted": [
                        {"main_context": "current"},
                        {"datapanel": {
                            "@type": "current",
                            "@tab": "current",
                            "element": [{
                                "@id": "practicalGrid",
                                "add_context": 'current'}]}}]}}]}}                        
                        
    jsonData = XMLJSONConverter.jsonToXml(json.dumps(xformsdata))
    jsonSettings = XMLJSONConverter.jsonToXml(json.dumps(xformssettings))
    return JythonDTO(jsonData, jsonSettings)
