Commit a777208f authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[ajax] allow inlineCreationForms to add their own JS / CSS

--HG--
branch : stable
parent d3b80a4faf3f
......@@ -248,6 +248,7 @@ function addInlineCreationForm(peid, ttype, rtype, role) {
d.addCallback(function (response) {
var linknode = getNode('add' + rtype + ':' + peid + 'link');
var dom = getDomFromResponse(response);
preprocessAjaxLoad(null, dom);
var form = jQuery(dom);
form.css('display', 'none');
form.insertBefore(linknode.parentNode).slideDown('fast');
......
......@@ -298,21 +298,8 @@ class JSonController(Controller):
return None
return None
@xhtmlize
def js_view(self):
# XXX try to use the page-content template
def _call_view(self, view, **kwargs):
req = self.req
rql = req.form.get('rql')
if rql:
rset = self._exec(rql)
else:
rset = None
vid = req.form.get('vid') or vid_from_rset(req, rset, self.schema)
try:
view = self.vreg['views'].select(vid, req, rset=rset)
except NoSelectableObject:
vid = req.form.get('fallbackvid', 'noresult')
view = self.vreg['views'].select(vid, req, rset=rset)
divid = req.form.get('divid', 'pageContent')
# we need to call pagination before with the stream set
stream = view.set_stream()
......@@ -326,7 +313,7 @@ class JSonController(Controller):
view.pagination(req, rset, view.w, not view.need_navigation)
if divid == 'pageContent':
stream.write(u'<div id="contentmain">')
view.render()
view.render(**kwargs)
extresources = req.html_headers.getvalue(skiphead=True)
if extresources:
stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget ?
......@@ -336,6 +323,23 @@ class JSonController(Controller):
stream.write(u'</div></div>')
return stream.getvalue()
@xhtmlize
def js_view(self):
# XXX try to use the page-content template
req = self.req
rql = req.form.get('rql')
if rql:
rset = self._exec(rql)
else:
rset = None
vid = req.form.get('vid') or vid_from_rset(req, rset, self.schema)
try:
view = self.vreg['views'].select(vid, req, rset=rset)
except NoSelectableObject:
vid = req.form.get('fallbackvid', 'noresult')
view = self.vreg['views'].select(vid, req, rset=rset)
return self._call_view(view)
@xhtmlize
def js_prop_widget(self, propkey, varname, tabindex=None):
"""specific method for CWProperty handling"""
......@@ -370,7 +374,8 @@ class JSonController(Controller):
view = self.vreg['views'].select('inline-creation', self.req,
etype=ttype, peid=peid, rtype=rtype,
role=role)
return view.render(etype=ttype, peid=peid, rtype=rtype, role=role)
return self._call_view(view, etype=ttype, peid=peid,
rtype=rtype, role=role)
@jsonize
def js_validate_form(self, action, names, values):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment