# coding:utf-8
import json
from ru.curs.celesta.showcase.utils import XMLJSONConverter

def catalogDatapanel(context, main=None, session=None):

    catalogTab = {"@id":1,
             "@name":u"Каталоги",
             "element":
                 [{"@id":"webServiceCatalogFilterCard",
                              "@type":"xforms",
                              "@template": "webServiceCatalogFilterCard.xml",
                              "@neverShowInPanel":"false",
                              "@proc":"author.xform.webServiceCatalogFilterCard.cardData.celesta",
                    },
                  
                  
                  {"@id": "webServiceCatalogGrid",
                   "@type": "grid",
                   "@subtype": "JS_LIVE_GRID",
                   "@plugin": "liveDGrid",
                   "@hideOnLoad": "false",
                   "@proc": "author.grids.webServiceCatalogGrid.gridData.celesta",
                   "proc": [
                                {"@id": "webServiceCatalogToolGridBar",
                                "@name": "author.grids.webServiceCatalogGrid.gridToolBar.celesta",
                                "@type": "TOOLBAR"
                                },
                            
                                {"@id":'webServiceCatalogGridMeta',
                                "@name":'author.grids.webServiceCatalogGrid.gridMeta.celesta',
                                "@type": 'METADATA'
                    }
                            ],
                   "related": {"@id":"webServiceCatalogFilterCard"}
                   
                   },
                      {"@id":"webServiceCatalogAddEditCard",
                                                 "@type":"xforms",
                                                 "@template": "webServiceCatalogAddEditCard.xml",
                                                 "@neverShowInPanel":"true",
                                                 "@proc":"author.xform.webServiceCatalogAddEditCard.cardData.celesta",
                                                 "proc":{"@id":"catalogData",
                                                         "@name":"author.xform.webServiceCatalogAddEditCard.cardDataSave.celesta",
                                                         "@type":"SAVE"
                                                         },
                                                 "related":{"@id":"webServiceCatalogGrid"},
       
                                                 },
                            
                    {"@id":"webServiceCatalogDeleteCard",
                                                 "@type":"xforms",
                                                 "@template": "webServiceCatalogDeleteCard.xml",
                                                 "@neverShowInPanel":"true",
                                                 "@proc":"author.xform.webServiceCatalogDeleteCard.cardData.celesta",
                                                 "proc":{"@id":"catalogData",
                                                         "@name":"author.xform.webServiceCatalogDeleteCard.cardDataDelete.celesta",
                                                         "@type":"SAVE"
                                                         },
                                                 "related":{"@id":"webServiceCatalogGrid"},
       
                                                 },
                  ]
                 }

    data = {"datapanel": { "tab": catalogTab }}
    
    return XMLJSONConverter.jsonToXml(json.dumps(data))
