# 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":"subscribedServiceCatalogFilterCard",
                              "@type":"xforms",
                              "@template": "webServiceCatalogFilterCard.xml",
                              "@neverShowInPanel":"false",
                              "@proc":"author.xform.subscribedServiceCatalogFilterCard.cardData.celesta",
                    },
                  
                  
                  {"@id": "subscribedServiceCatalogGrid",
                   "@type": "grid",
                   "@subtype": "JS_LIVE_GRID",
                   "@plugin": "liveDGrid",
                   "@hideOnLoad": "false",
                   "@proc": "author.grids.subscribedServiceCatalogGrid.gridData.celesta",
                   "proc": [
                                {"@id": "subscribedServiceCatalogToolGridBar",
                                "@name": "author.grids.subscribedServiceCatalogGrid.gridToolBar.celesta",
                                "@type": "TOOLBAR"
                                },
                            
                                {"@id":'subscribedServiceCatalogGridMeta',
                                "@name":'author.grids.subscribedServiceCatalogGrid.gridMeta.celesta',
                                "@type": 'METADATA'
                    }
                            ],
                   "related": {"@id":"subscribedServiceCatalogFilterCard"}
                   
                   },
                      {"@id":"subscribedServiceCatalogAddEditCard",
                                                 "@type":"xforms",
                                                 "@template": "subscribedServiceCatalogAddEditCard.xml",
                                                 "@neverShowInPanel":"true",
                                                 "@proc":"author.xform.subscribedServiceCatalogAddEditCard.cardData.celesta",
                                                 "proc":{"@id":"catalogData",
                                                         "@name":"author.xform.subscribedServiceCatalogAddEditCard.cardDataSave.celesta",
                                                         "@type":"SAVE"
                                                         },
                                                 "related":{"@id":"subscribedServiceCatalogGrid"},
       
                                                 },
                            
                    {"@id":"subscribedServiceCatalogDeleteCard",
                                                 "@type":"xforms",
                                                 "@template": "subscribedServiceCatalogDeleteCard.xml",
                                                 "@neverShowInPanel":"true",
                                                 "@proc":"author.xform.subscribedServiceCatalogDeleteCard.cardData.celesta",
                                                 "proc":{"@id":"catalogData",
                                                         "@name":"author.xform.subscribedServiceCatalogDeleteCard.cardDataDelete.celesta",
                                                         "@type":"SAVE"
                                                         },
                                                 "related":{"@id":"subscribedServiceCatalogGrid"},
       
                                                 },
                  ]
                 }

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