[REF] web_editor, website: move ACE editor to web_editor
The commit e59a7fe3ff has moved
the ACE editor from website to web_editor. As some code on ir_ui_view
was used for this widget, the code has also been moved to web_editor.
This commit is contained in:
committed by
Géry Debongnie
parent
fa4fa90890
commit
e11f23b701
@@ -222,3 +222,11 @@ class Web_Editor(http.Controller):
|
|||||||
if attachments_to_remove:
|
if attachments_to_remove:
|
||||||
attachments_to_remove.unlink()
|
attachments_to_remove.unlink()
|
||||||
return removal_blocked_by
|
return removal_blocked_by
|
||||||
|
|
||||||
|
@http.route('/web_editor/customize_template_get', type='json', auth='user', website=True)
|
||||||
|
def customize_template_get(self, key, full=False, bundles=False):
|
||||||
|
""" Get inherit view's informations of the template ``key``.
|
||||||
|
returns templates (which can be active or not)
|
||||||
|
``bundles=True`` returns also the asset bundles
|
||||||
|
"""
|
||||||
|
return request.env["ir.ui.view"].customize_template_get(key, full=full, bundles=bundles)
|
||||||
|
|||||||
@@ -113,3 +113,99 @@ class IrUiView(models.Model):
|
|||||||
view.write({'arch': view._pretty_arch(arch)})
|
view.write({'arch': view._pretty_arch(arch)})
|
||||||
|
|
||||||
self.sudo().mapped('model_data_id').write({'noupdate': True})
|
self.sudo().mapped('model_data_id').write({'noupdate': True})
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _view_obj(self, view_id):
|
||||||
|
if isinstance(view_id, basestring):
|
||||||
|
return self.env.ref(view_id)
|
||||||
|
elif isinstance(view_id, (int, long)):
|
||||||
|
return self.browse(view_id)
|
||||||
|
# assume it's already a view object (WTF?)
|
||||||
|
return view_id
|
||||||
|
|
||||||
|
# Returns all views (called and inherited) related to a view
|
||||||
|
# Used by translation mechanism, SEO and optional templates
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _views_get(self, view_id, options=True, bundles=False, root=True):
|
||||||
|
""" For a given view ``view_id``, should return:
|
||||||
|
* the view itself
|
||||||
|
* all views inheriting from it, enabled or not
|
||||||
|
- but not the optional children of a non-enabled child
|
||||||
|
* all views called from it (via t-call)
|
||||||
|
:returns recordset of ir.ui.view
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
view = self._view_obj(view_id)
|
||||||
|
except ValueError:
|
||||||
|
_logger.warning("Could not find view object with view_id '%s'", view_id)
|
||||||
|
return []
|
||||||
|
|
||||||
|
while root and view.inherit_id:
|
||||||
|
view = view.inherit_id
|
||||||
|
|
||||||
|
views_to_return = view
|
||||||
|
|
||||||
|
node = etree.fromstring(view.arch)
|
||||||
|
xpath = "//t[@t-call]"
|
||||||
|
if bundles:
|
||||||
|
xpath += "| //t[@t-call-assets]"
|
||||||
|
for child in node.xpath(xpath):
|
||||||
|
try:
|
||||||
|
called_view = self._view_obj(child.get('t-call', child.get('t-call-assets')))
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
if called_view not in views_to_return:
|
||||||
|
views_to_return += self._views_get(called_view, options=options, bundles=bundles)
|
||||||
|
|
||||||
|
extensions = view.inherit_children_ids
|
||||||
|
if not options:
|
||||||
|
# only active children
|
||||||
|
extensions = view.inherit_children_ids.filtered(lambda view: view.active)
|
||||||
|
|
||||||
|
# Keep options in a deterministic order regardless of their applicability
|
||||||
|
for extension in extensions.sorted(key=lambda v: v.id):
|
||||||
|
# only return optional grandchildren if this child is enabled
|
||||||
|
for ext_view in self._views_get(extension, options=extension.active, root=False):
|
||||||
|
if ext_view not in views_to_return:
|
||||||
|
views_to_return += ext_view
|
||||||
|
return views_to_return
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def customize_template_get(self, key, full=False, bundles=False):
|
||||||
|
""" Get inherit view's informations of the template ``key``.
|
||||||
|
returns templates (which can be active or not)
|
||||||
|
``bundles=True`` returns also the asset bundles
|
||||||
|
"""
|
||||||
|
user = self.env.user
|
||||||
|
user_groups = set(user.groups_id)
|
||||||
|
views = self.with_context(active_test=False)._views_get(key, bundles=bundles)
|
||||||
|
done = set()
|
||||||
|
result = []
|
||||||
|
for view in views:
|
||||||
|
if full:
|
||||||
|
if not user_groups.issuperset(view.groups_id):
|
||||||
|
continue
|
||||||
|
if view.inherit_id not in done:
|
||||||
|
result.append({
|
||||||
|
'name': view.inherit_id.name,
|
||||||
|
'id': view.id,
|
||||||
|
'key': view.key,
|
||||||
|
'xml_id': view.xml_id,
|
||||||
|
'arch': view.arch,
|
||||||
|
'inherit_id': view.inherit_id.id,
|
||||||
|
'header': True,
|
||||||
|
'active': False
|
||||||
|
})
|
||||||
|
done.add(view.inherit_id)
|
||||||
|
result.append({
|
||||||
|
'name': view.name,
|
||||||
|
'id': view.id,
|
||||||
|
'key': view.key,
|
||||||
|
'xml_id': view.xml_id,
|
||||||
|
'arch': view.arch,
|
||||||
|
'inherit_id': view.inherit_id.id,
|
||||||
|
'header': False,
|
||||||
|
'active': view.active,
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
|||||||
@@ -119,6 +119,63 @@
|
|||||||
.o-animation(fadeInDownSmall, 700ms, @fill-mode: forwards);
|
.o-animation(fadeInDownSmall, 700ms, @fill-mode: forwards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ACE EDITOR
|
||||||
|
.o_ace_view_editor {
|
||||||
|
@o-ace-color: #2F3129;
|
||||||
|
background: @o-ace-color;
|
||||||
|
color: white;
|
||||||
|
.o-flex-display();
|
||||||
|
.o-flex-flow(column, nowrap);
|
||||||
|
|
||||||
|
.o_ace_view_editor_title {
|
||||||
|
.o-flex(0, 0, auto);
|
||||||
|
.o-flex-display();
|
||||||
|
.o-align-items(center);
|
||||||
|
.o-justify-content(space-between);
|
||||||
|
padding: @grid-gutter-width/4;
|
||||||
|
|
||||||
|
> * {
|
||||||
|
.o-flex(0, 0, auto);
|
||||||
|
margin: 0 @grid-gutter-width/4;
|
||||||
|
|
||||||
|
&.oe_include_bundles {
|
||||||
|
.o-flex-display();
|
||||||
|
.o-align-items(center);
|
||||||
|
font-size: 11px;
|
||||||
|
|
||||||
|
> .o_checkbox {
|
||||||
|
margin-right: @grid-gutter-width/4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
> select {
|
||||||
|
.o-flex(0, 1, auto);
|
||||||
|
min-width: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ace-view-id {
|
||||||
|
.o-flex(0, 0, auto);
|
||||||
|
padding: @grid-gutter-width/4 @grid-gutter-width/2;
|
||||||
|
background-color: lighten(@o-ace-color, 10%);
|
||||||
|
}
|
||||||
|
#ace-view-editor {
|
||||||
|
height: 70%; // in case flex is not supported
|
||||||
|
.o-flex(1, 1, auto);
|
||||||
|
.ace_gutter {
|
||||||
|
cursor: ew-resize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.oe_ace_open {
|
||||||
|
opacity: 0.97;
|
||||||
|
}
|
||||||
|
&.oe_ace_closed {
|
||||||
|
z-index: -1000;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MODALS
|
// MODALS
|
||||||
body .modal {
|
body .modal {
|
||||||
// SELECT MEDIA
|
// SELECT MEDIA
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class Website(Home):
|
|||||||
return request.redirect(redirect)
|
return request.redirect(redirect)
|
||||||
|
|
||||||
@http.route('/website/customize_template_get', type='json', auth='user', website=True)
|
@http.route('/website/customize_template_get', type='json', auth='user', website=True)
|
||||||
def customize_template_get(self, key, full=False, bundles=False):
|
def customize_template_get(self, key, full=True, bundles=False):
|
||||||
""" Get inherit view's informations of the template ``key``. By default, only
|
""" Get inherit view's informations of the template ``key``. By default, only
|
||||||
:returns ``customize_show`` templates (which can be active or not), if
|
:returns ``customize_show`` templates (which can be active or not), if
|
||||||
``full=True`` returns inherit view's informations of the template ``key``.
|
``full=True`` returns inherit view's informations of the template ``key``.
|
||||||
|
|||||||
@@ -69,54 +69,6 @@ class View(models.Model):
|
|||||||
# assume it's already a view object (WTF?)
|
# assume it's already a view object (WTF?)
|
||||||
return view_id
|
return view_id
|
||||||
|
|
||||||
# Returns all views (called and inherited) related to a view
|
|
||||||
# Used by translation mechanism, SEO and optional templates
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _views_get(self, view_id, options=True, bundles=False, root=True):
|
|
||||||
""" For a given view ``view_id``, should return:
|
|
||||||
* the view itself
|
|
||||||
* all views inheriting from it, enabled or not
|
|
||||||
- but not the optional children of a non-enabled child
|
|
||||||
* all views called from it (via t-call)
|
|
||||||
:returns recordset of ir.ui.view
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
view = self._view_obj(view_id)
|
|
||||||
except ValueError:
|
|
||||||
_logger.warning("Could not find view object with view_id '%s'", view_id)
|
|
||||||
return []
|
|
||||||
|
|
||||||
while root and view.inherit_id:
|
|
||||||
view = view.inherit_id
|
|
||||||
|
|
||||||
views_to_return = view
|
|
||||||
|
|
||||||
node = etree.fromstring(view.arch)
|
|
||||||
xpath = "//t[@t-call]"
|
|
||||||
if bundles:
|
|
||||||
xpath += "| //t[@t-call-assets]"
|
|
||||||
for child in node.xpath(xpath):
|
|
||||||
try:
|
|
||||||
called_view = self._view_obj(child.get('t-call', child.get('t-call-assets')))
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
if called_view not in views_to_return:
|
|
||||||
views_to_return += self._views_get(called_view, options=options, bundles=bundles)
|
|
||||||
|
|
||||||
extensions = view.inherit_children_ids
|
|
||||||
if not options:
|
|
||||||
# only active children
|
|
||||||
extensions = view.inherit_children_ids.filtered(lambda view: view.active)
|
|
||||||
|
|
||||||
# Keep options in a deterministic order regardless of their applicability
|
|
||||||
for extension in extensions.sorted(key=lambda v: v.id):
|
|
||||||
# only return optional grandchildren if this child is enabled
|
|
||||||
for ext_view in self._views_get(extension, options=extension.active, root=False):
|
|
||||||
if ext_view not in views_to_return:
|
|
||||||
views_to_return += ext_view
|
|
||||||
return views_to_return
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@tools.ormcache_context('self._uid', 'xml_id', keys=('website_id',))
|
@tools.ormcache_context('self._uid', 'xml_id', keys=('website_id',))
|
||||||
def get_view_id(self, xml_id):
|
def get_view_id(self, xml_id):
|
||||||
@@ -186,37 +138,23 @@ class View(models.Model):
|
|||||||
@api.model
|
@api.model
|
||||||
def customize_template_get(self, key, full=False, bundles=False):
|
def customize_template_get(self, key, full=False, bundles=False):
|
||||||
""" Get inherit view's informations of the template ``key``. By default, only
|
""" Get inherit view's informations of the template ``key``. By default, only
|
||||||
returns ``customize_show`` templates (which can be active or not), if
|
:returns ``customize_show`` templates (which can be active or not), if
|
||||||
``full=True`` returns inherit view's informations of the template ``key``.
|
``full=True`` returns inherit view's informations of the template ``key``.
|
||||||
``bundles=True`` returns also the asset bundles
|
``bundles=True`` returns also the asset bundles
|
||||||
"""
|
"""
|
||||||
|
result = super(View, self).customize_template_get(key, full=full, bundles=bundles)
|
||||||
|
|
||||||
imd = self.env['ir.model.data']
|
imd = self.env['ir.model.data']
|
||||||
view_theme_id = imd.xmlid_to_res_id('website.theme')
|
view_theme_id = imd.xmlid_to_res_id('website.theme')
|
||||||
user = self.env.user
|
|
||||||
user_groups = set(user.groups_id)
|
result_filtered = []
|
||||||
views = self.with_context(active_test=False)._views_get(key, bundles=bundles)
|
for x in result:
|
||||||
done = set()
|
if not full:
|
||||||
result = []
|
view = self.browse(x['id'])
|
||||||
for view in views:
|
if not view.customize_show:
|
||||||
if not user_groups.issuperset(view.groups_id):
|
continue
|
||||||
|
if view_theme_id and x['inherit_id'] == view_theme_id:
|
||||||
continue
|
continue
|
||||||
if full or (view.customize_show and view.inherit_id.id != view_theme_id):
|
result_filtered.append(x)
|
||||||
if view.inherit_id not in done:
|
|
||||||
result.append({
|
return result_filtered
|
||||||
'name': view.inherit_id.name,
|
|
||||||
'id': view.id,
|
|
||||||
'key': view.key,
|
|
||||||
'inherit_id': view.inherit_id.id,
|
|
||||||
'header': True,
|
|
||||||
'active': False
|
|
||||||
})
|
|
||||||
done.add(view.inherit_id)
|
|
||||||
result.append({
|
|
||||||
'name': view.name,
|
|
||||||
'id': view.id,
|
|
||||||
'key': view.key,
|
|
||||||
'inherit_id': view.inherit_id.id,
|
|
||||||
'header': False,
|
|
||||||
'active': view.active,
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
|
|||||||
@@ -324,63 +324,9 @@ body .modal {
|
|||||||
|
|
||||||
// ACE EDITOR
|
// ACE EDITOR
|
||||||
.o_ace_view_editor {
|
.o_ace_view_editor {
|
||||||
@o-ace-color: #2F3129;
|
|
||||||
|
|
||||||
.o-position-absolute(@odoo-navbar-height, 0, 0);
|
.o-position-absolute(@odoo-navbar-height, 0, 0);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
.o-flex-display();
|
|
||||||
.o-flex-flow(column, nowrap);
|
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
background: @o-ace-color;
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
.o_ace_view_editor_title {
|
|
||||||
.o-flex(0, 0, auto);
|
|
||||||
.o-flex-display();
|
|
||||||
.o-align-items(center);
|
|
||||||
.o-justify-content(space-between);
|
|
||||||
padding: @grid-gutter-width/4;
|
|
||||||
|
|
||||||
> * {
|
|
||||||
.o-flex(0, 0, auto);
|
|
||||||
margin: 0 @grid-gutter-width/4;
|
|
||||||
|
|
||||||
&.oe_include_bundles {
|
|
||||||
.o-flex-display();
|
|
||||||
.o-align-items(center);
|
|
||||||
font-size: 11px;
|
|
||||||
|
|
||||||
> .o_checkbox {
|
|
||||||
margin-right: @grid-gutter-width/4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
> select {
|
|
||||||
.o-flex(0, 1, auto);
|
|
||||||
min-width: 60px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ace-view-id {
|
|
||||||
.o-flex(0, 0, auto);
|
|
||||||
padding: @grid-gutter-width/4 @grid-gutter-width/2;
|
|
||||||
background-color: lighten(@o-ace-color, 10%);
|
|
||||||
}
|
|
||||||
#ace-view-editor {
|
|
||||||
height: 70%; // in case flex is not supported
|
|
||||||
.o-flex(1, 1, auto);
|
|
||||||
.ace_gutter {
|
|
||||||
cursor: ew-resize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.oe_ace_open {
|
|
||||||
opacity: 0.97;
|
|
||||||
}
|
|
||||||
&.oe_ace_closed {
|
|
||||||
z-index: -1000;
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PLANNER DIALOG
|
// PLANNER DIALOG
|
||||||
|
|||||||
Reference in New Issue
Block a user