From ab3dd302fa711a7b4209e4b15e72042f7eb6333a Mon Sep 17 00:00:00 2001 From: Sanj Date: Sat, 9 Apr 2011 06:21:31 +0530 Subject: [PATCH] boxes, lists --- itf/boxes/models.py | 13 +++++-- itf/static/js/itf/box_types.js | 36 ++++++++++++++++++ itf/static/js/itf/boxes.js | 61 ++++++++++++++++++++++++++++--- itf/static/js/itf/button_types.js | 39 ++++++++++++++++++++ 4 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 itf/static/js/itf/button_types.js diff --git a/itf/boxes/models.py b/itf/boxes/models.py index a3074c8..87e0c9e 100644 --- a/itf/boxes/models.py +++ b/itf/boxes/models.py @@ -18,6 +18,7 @@ class ModelExtra(models.Model): def get_dict(self): return { + 'id': self.id, 'module': self.model.model_class()._meta.app_label, 'model': self.model.model, # 'info': self.info, @@ -25,17 +26,17 @@ class ModelExtra(models.Model): 'friendly_name_plural': self.friendly_name_plural, 'fk_filters': self.model.model_class().fk_filters, 'fts_fields': self.model.model_class().fts_fields, - 'sort_options': map(lambda x: {'key': x.key, 'text': x.text}, self.sort_options.all()) + 'sort_options': map(lambda x: {'key': x.key, 'operator': x.operator}, self.sort_options.all()) } class ModelSort(models.Model): - key = models.CharField(max_length=64) - text = models.CharField(max_length=512) + operator = models.CharField(max_length=64) + key = models.CharField(max_length=512) def __unicode__(self): - return "%s: %s" % (self.key, self.text,) + return "%s: %s" % (self.operator, self.key,) @@ -55,6 +56,7 @@ class Button(ItfModel): def get_dict(self): data = self.get_data() + data['id'] = self.id, data['type'] = self.typ, data['icon'] = self.icon, data['mouseover'] = self.mouseover @@ -180,6 +182,7 @@ class StaticBox(Box): def get_dict(self): return { + 'id': self.id, 'type': 'StaticBox', 'title': self.title, 'html': self.html, @@ -198,6 +201,7 @@ class ModelsBox(Box): def get_dict(self): data = { + 'id': self.id, 'type': 'ModelsBox', 'title': self.title, 'info': self.info, @@ -220,6 +224,7 @@ class Panel(models.Model): def get_dict(self): return { + 'id': self.id, 'title': self.title, 'boxes': map(lambda x: x.get_dict(), self.boxes.all()) } diff --git a/itf/static/js/itf/box_types.js b/itf/static/js/itf/box_types.js index e69de29..a7e0488 100644 --- a/itf/static/js/itf/box_types.js +++ b/itf/static/js/itf/box_types.js @@ -0,0 +1,36 @@ +ItfBoxTypes = { + 'StaticBox': { + 'buttons': [], + 'render': function(data) { + return new Ox.Element().html(data.html); + } + }, + + 'ModelsBox': { + 'buttons': [ + { + 'type': 'search', + 'icon': 'search', + 'mouseover': 'Search' + }, + { + 'type': 'info', + 'icon': 'info', + 'mouseover': 'More about..' + } + ], + 'render': function(data) { + var id = data.itfId + "ModelsContainer"; + var that = new Ox.Element({ + 'id': id + }); + that.updateView = function(model) { + var $list = new Ox.ItfList(model, data); + that.empty(); + that.append($list); + } + that.updateView(data.default_model); + return that; + } + } +} diff --git a/itf/static/js/itf/boxes.js b/itf/static/js/itf/boxes.js index 831545a..35831c0 100644 --- a/itf/static/js/itf/boxes.js +++ b/itf/static/js/itf/boxes.js @@ -25,6 +25,7 @@ Ox.ItfPage = function(page, parentPanel) { return that; } + Ox.ItfPanel = function(panelData, displayed) { var items = []; var id = panelData.title; @@ -41,15 +42,20 @@ Ox.ItfPanel = function(panelData, displayed) { that.displayed = displayed; }; + Ox.HiddenPanelContainer = function() { }; + Ox.ItfBox = function(boxData) { + var self = {}; + boxData.itfId = "Box" + boxData.id; var options = { - 'title': boxData.title, - } - var that = new Ox.Element(options, self); + 'id': boxData.itfId, + 'title': boxData.title + }; + var that = app.ui[boxData.itfId] = new Ox.Element(options, self); var $titlebar = new Ox.Bar({ orientation: 'horizontal', size: '24 @@ -62,14 +68,59 @@ Ox.ItfBox = function(boxData) { var boxButtons = Ox.merge(ItfBoxTypes[boxData.type].buttons, boxData.extra_buttons); for (var i=0; i