# OpenERP Web web Controllers
#----------------------------------------------------------
+
+def concat_xml(file_list):
+ """Concatenate xml files
+ return (concat,timestamp)
+ concat: concatenation of file content
+ timestamp: max(os.path.getmtime of file_list)
+ """
+ root = None
+ files_timestamp = 0
+ for fname in file_list:
+ ftime = os.path.getmtime(fname)
+ if ftime > files_timestamp:
+ files_timestamp = ftime
+
+ xml = ElementTree.parse(fname).getroot()
+
+ if root is None:
+ root = ElementTree.Element(xml.tag)
+ #elif root.tag != xml.tag:
+ # raise ValueError("Root tags missmatch: %r != %r" % (root.tag, xml.tag))
+
+ for child in xml.getchildren():
+ root.append(child)
+ return ElementTree.tostring(root, 'utf-8'), files_timestamp
+
+
- def concat_files(file_list):
+ def concat_files(file_list, reader=None):
""" Concatenate file content
return (concat,timestamp)
- concat: concatenation of file content
+ concat: concatenation of file content, read by `reader`
timestamp: max(os.path.getmtime of file_list)
"""
+ if reader is None:
+ def reader(f):
+ with open(f) as fp:
+ return fp.read()
+
files_content = []
files_timestamp = 0
for fname in file_list:
def jslist(self, req, mods=None):
return self.manifest_list(req, mods, 'js')
+ @openerpweb.jsonrequest
+ def qweblist(self, req, mods=None):
+ return self.manifest_list(req, mods, 'qweb')
+
@openerpweb.httprequest
def css(self, req, mods=None):
- files = [f[0] for f in self.manifest_glob(req, mods, 'css')]
- content,timestamp = concat_files(files)
+
+ files = list(self.manifest_glob(req, mods, 'css'))
+ file_map = dict(files)
+
+ rx_import = re.compile(r"""@import\s+('|")(?!'|"|/|https?://)""", re.U)
+ rx_url = re.compile(r"""url\s*\(\s*('|"|)(?!'|"|/|https?://)""", re.U)
+
+
+ def reader(f):
+ """read the a css file and absolutify all relative uris"""
+ with open(f) as fp:
+ data = fp.read()
+
+ web_path = file_map[f]
+ web_dir = os.path.dirname(web_path)
+
+ data = re.sub(
+ rx_import,
+ r"""@import \1%s/""" % (web_dir,),
+ data,
+ )
+
+ data = re.sub(
+ rx_url,
+ r"""url(\1%s/""" % (web_dir,),
+ data,
+ )
+ return data
+
+ content,timestamp = concat_files((f[0] for f in files), reader)
# TODO use timestamp to set Last mofified date and E-tag
return req.make_response(content, [('Content-Type', 'text/css')])
openerp.web_kanban = function (openerp) {
+ var _t = openerp.web._t;
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_kanban/static/src/xml/web_kanban.xml');
openerp.web.views.add('kanban', 'openerp.web_kanban.KanbanView');
+
openerp.web_kanban.KanbanView = openerp.web.View.extend({
+ template: "KanbanView",
+ default_nr_columns: 3,
init: function (parent, dataset, view_id, options) {
this._super(parent);
this.set_default_options(options);
this.dataset = dataset;
- this.model = dataset.model;
this.view_id = view_id;
this.fields_view = {};
- this.group_by = [];
- this.source_index = {};
- this.all_display_data = false;
+ this.fields_keys = [];
+ this.group_by = null;
+ this.state = {
+ groups : {},
+ records : {}
+ };
this.groups = [];
- this.qweb = new QWeb2.Engine();
- this.qweb.debug = openerp.connector.debug;
- this.aggregates = {};
- this.NO_OF_COLUMNS = 3;
this.form_dialog = new openerp.web.FormDialog(this, {}, this.options.action_views_ids.form, dataset).start();
- this.form_dialog.on_form_dialog_saved.add_last(this.on_record_saved);
+ this.form_dialog.on_form_dialog_saved.add_last(this.do_reload);
+ this.aggregates = {};
+ this.qweb = new QWeb2.Engine();
- this.qweb.debug = (window.location.search.indexOf('?debug') !== -1);
++ this.qweb.debug = openerp.connection.debug;
+ this.qweb.default_dict = {
+ '_' : _,
+ '_t' : _t
+ }
+ this.has_been_loaded = $.Deferred();
+ this.search_domain = this.search_context = this.search_group_by = null;
+ this.currently_dragging = {};
},
start: function() {
this._super();