91 displaycols = range(len(self.rset.syntax_tree().children[0].selection)) |
91 displaycols = range(len(self.rset.syntax_tree().children[0].selection)) |
92 return displaycols |
92 return displaycols |
93 |
93 |
94 def call(self, title=None, subvid=None, displayfilter=None, headers=None, |
94 def call(self, title=None, subvid=None, displayfilter=None, headers=None, |
95 displaycols=None, displayactions=None, actions=(), divid=None, |
95 displaycols=None, displayactions=None, actions=(), divid=None, |
96 cellvids=None, cellattrs=None): |
96 cellvids=None, cellattrs=None, mainindex=None): |
97 """Dumps a table displaying a composite query |
97 """Dumps a table displaying a composite query |
98 |
98 |
99 :param title: title added before table |
99 :param title: title added before table |
100 :param subvid: cell view |
100 :param subvid: cell view |
101 :param displayfilter: filter that selects rows to display |
101 :param displayfilter: filter that selects rows to display |
102 :param headers: columns' titles |
102 :param headers: columns' titles |
103 """ |
103 """ |
104 rset = self.rset |
|
105 req = self.req |
104 req = self.req |
106 req.add_js('jquery.tablesorter.js') |
105 req.add_js('jquery.tablesorter.js') |
107 req.add_css(('cubicweb.tablesorter.css', 'cubicweb.tableview.css')) |
106 req.add_css(('cubicweb.tablesorter.css', 'cubicweb.tableview.css')) |
108 # get rql description first since the filter form may remove some |
107 # compute label first since the filter form may remove some necessary |
109 # necessary information |
108 # information from the rql syntax tree |
110 mainindex = self.main_var_index() |
109 if mainindex is None: |
|
110 mainindex = self.main_var_index() |
111 computed_labels = self.columns_labels(mainindex) |
111 computed_labels = self.columns_labels(mainindex) |
112 hidden = True |
112 hidden = True |
113 if not subvid and 'subvid' in req.form: |
113 if not subvid and 'subvid' in req.form: |
114 subvid = req.form.pop('subvid') |
114 subvid = req.form.pop('subvid') |
115 divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(rset)) |
115 divid = divid or req.form.get('divid') or 'rs%s' % make_uid(id(self.rset)) |
116 actions = list(actions) |
116 actions = list(actions) |
117 if mainindex is None: |
117 if mainindex is None: |
118 displayfilter, displayactions = False, False |
118 displayfilter, displayactions = False, False |
119 else: |
119 else: |
120 if displayfilter is None and 'displayfilter' in req.form: |
120 if displayfilter is None and 'displayfilter' in req.form: |
288 # should not be displayed in possible view since it expects some specific |
288 # should not be displayed in possible view since it expects some specific |
289 # parameters |
289 # parameters |
290 title = None |
290 title = None |
291 |
291 |
292 def call(self, title=None, subvid=None, headers=None, divid=None, |
292 def call(self, title=None, subvid=None, headers=None, divid=None, |
293 displaycols=None, displayactions=None): |
293 displaycols=None, displayactions=None, mainindex=None): |
294 """Dumps a table displaying a composite query""" |
294 """Dumps a table displaying a composite query""" |
295 actrql = self.req.form['actualrql'] |
295 actrql = self.req.form['actualrql'] |
296 self.ensure_ro_rql(actrql) |
296 self.ensure_ro_rql(actrql) |
297 displaycols = self.displaycols(displaycols) |
297 displaycols = self.displaycols(displaycols) |
298 if displayactions is None and 'displayactions' in self.req.form: |
298 if displayactions is None and 'displayactions' in self.req.form: |
303 if not title and 'title' in self.req.form: |
303 if not title and 'title' in self.req.form: |
304 # pop title so it's not displayed by the table view as well |
304 # pop title so it's not displayed by the table view as well |
305 title = self.req.form.pop('title') |
305 title = self.req.form.pop('title') |
306 if title: |
306 if title: |
307 self.w(u'<h2>%s</h2>\n' % title) |
307 self.w(u'<h2>%s</h2>\n' % title) |
308 mainindex = self.main_var_index() |
308 if mainindex is None: |
|
309 mainindex = self.main_var_index() |
309 if mainindex is not None: |
310 if mainindex is not None: |
310 actions = self.form_filter(divid, displaycols, displayactions, True) |
311 actions = self.form_filter(divid, displaycols, displayactions, True) |
311 else: |
312 else: |
312 actions = () |
313 actions = () |
313 if not subvid and 'subvid' in self.req.form: |
314 if not subvid and 'subvid' in self.req.form: |