[ADD] Option to list asset bundles in templates editor
This commit is contained in:
@@ -203,10 +203,11 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
return request.redirect(redirect)
|
||||
|
||||
@http.route('/website/customize_template_get', type='json', auth='user', website=True)
|
||||
def customize_template_get(self, xml_id, full=False):
|
||||
def customize_template_get(self, xml_id, full=False, bundles=False):
|
||||
""" Lists the templates customizing ``xml_id``. By default, only
|
||||
returns optional templates (which can be toggled on and off), if
|
||||
``full=True`` returns all templates customizing ``xml_id``
|
||||
``bundles=True`` returns also the asset bundles
|
||||
"""
|
||||
imd = request.registry['ir.model.data']
|
||||
view_model, view_theme_id = imd.get_object_reference(
|
||||
@@ -217,7 +218,7 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||
user_groups = set(user.groups_id)
|
||||
|
||||
views = request.registry["ir.ui.view"]\
|
||||
._views_get(request.cr, request.uid, xml_id, context=request.context)
|
||||
._views_get(request.cr, request.uid, xml_id, bundles=bundles, context=request.context)
|
||||
done = set()
|
||||
result = []
|
||||
for v in views:
|
||||
|
||||
@@ -37,7 +37,7 @@ class view(osv.osv):
|
||||
|
||||
# Returns all views (called and inherited) related to a view
|
||||
# Used by translation mechanism, SEO and optional templates
|
||||
def _views_get(self, cr, uid, view_id, options=True, context=None, root=True):
|
||||
def _views_get(self, cr, uid, view_id, options=True, bundles=False, context=None, root=True):
|
||||
""" For a given view ``view_id``, should return:
|
||||
|
||||
* the view itself
|
||||
@@ -57,13 +57,16 @@ class view(osv.osv):
|
||||
result = [view]
|
||||
|
||||
node = etree.fromstring(view.arch)
|
||||
for child in node.xpath("//t[@t-call]"):
|
||||
xpath = "//t[@t-call]"
|
||||
if bundles:
|
||||
xpath += "| //t[@t-call-assets]"
|
||||
for child in node.xpath(xpath):
|
||||
try:
|
||||
called_view = self._view_obj(cr, uid, child.get('t-call'), context=context)
|
||||
called_view = self._view_obj(cr, uid, child.get('t-call', child.get('t-call-assets')), context=context)
|
||||
except ValueError:
|
||||
continue
|
||||
if called_view not in result:
|
||||
result += self._views_get(cr, uid, called_view, options=options, context=context)
|
||||
result += self._views_get(cr, uid, called_view, options=options, bundles=bundles, context=context)
|
||||
|
||||
extensions = view.inherit_children_ids
|
||||
if not options:
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
.navbar.navbar-inverse .cke_top {
|
||||
background: transparent;
|
||||
border: none;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
-ms-filter: "alpha(opacity=50)";
|
||||
}
|
||||
@@ -57,13 +57,11 @@
|
||||
padding: 2px;
|
||||
margin: 0;
|
||||
z-index: 20000;
|
||||
background: #414141, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #646060), color-stop(100%, #262626));
|
||||
background: #414141, -webkit-linear-gradient(#646060, #262626);
|
||||
background: #414141, -moz-linear-gradient(#646060, #262626);
|
||||
background: #414141, -o-linear-gradient(#646060, #262626);
|
||||
background: #414141, -webkit-linear-gradient(#646060, #262626);
|
||||
background: #414141, linear-gradient(#646060, #262626);
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.oe_website_editorbar li {
|
||||
@@ -225,8 +223,9 @@ ul.oe_menu_editor .disclose {
|
||||
|
||||
/* ---- RTE ---- {{{ */
|
||||
.oe_editable .btn, .btn.oe_editable {
|
||||
-webkit-user-select: auto;
|
||||
-moz-user-select: auto;
|
||||
-ms-user-select: auto;
|
||||
-webkit-user-select: auto;
|
||||
user-select: auto;
|
||||
cursor: text !important;
|
||||
}
|
||||
@@ -384,10 +383,8 @@ ul.oe_menu_editor .disclose {
|
||||
height: 660px;
|
||||
background-color: black;
|
||||
border: 2px solid #1c1f1f;
|
||||
-webkit-border-radius: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
-ms-border-radius: 10px;
|
||||
-o-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
margin: auto;
|
||||
top: 0;
|
||||
@@ -410,13 +407,13 @@ ul.oe_menu_editor .disclose {
|
||||
color: #1c1f1f;
|
||||
}
|
||||
.oe_mobile_preview.modal .modal-content .modal-header .close {
|
||||
color: lightgrey;
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
|
||||
color: lightgray;
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(enabled=false);
|
||||
opacity: 1;
|
||||
}
|
||||
.oe_mobile_preview.modal .modal-content .modal-header .close:hover {
|
||||
color: #e00101;
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(enabled=false);
|
||||
opacity: 1;
|
||||
}
|
||||
.oe_mobile_preview.modal .modal-content .modal-body {
|
||||
@@ -447,10 +444,8 @@ ul.oe_menu_editor .disclose {
|
||||
}
|
||||
.oe_seo_configuration .oe_seo_keyword {
|
||||
padding: 0.2em 0.4em 0.2em 0.5em;
|
||||
-webkit-border-radius: 0.4em;
|
||||
-moz-border-radius: 0.4em;
|
||||
-ms-border-radius: 0.4em;
|
||||
-o-border-radius: 0.4em;
|
||||
-webkit-border-radius: 0.4em;
|
||||
border-radius: 0.4em;
|
||||
}
|
||||
.oe_seo_configuration li.oe_seo_preview_g {
|
||||
@@ -554,3 +549,8 @@ ul.oe_menu_editor .disclose {
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.oe_include_bundles {
|
||||
font-weight: normal;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
@@ -477,6 +477,10 @@ $infobar_height: 20px
|
||||
z-index: -1000
|
||||
+opacity(0)
|
||||
|
||||
.oe_include_bundles
|
||||
font-weight: normal
|
||||
padding: 0 8px
|
||||
|
||||
// }}}
|
||||
|
||||
// vim:tabstop=4:shiftwidth=4:softtabstop=4:fdm=marker:
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
template: 'website.ace_view_editor',
|
||||
events: {
|
||||
'change #ace-view-list': 'displaySelectedView',
|
||||
'click .js_include_bundles': 'loadTemplates',
|
||||
'click button[data-action=save]': 'saveViews',
|
||||
'click button[data-action=format]': 'formatXml',
|
||||
'click button[data-action=close]': 'close',
|
||||
@@ -83,26 +84,7 @@
|
||||
var self = this;
|
||||
self.aceEditor = ace.edit(self.$('#ace-view-editor')[0]);
|
||||
self.aceEditor.setTheme("ace/theme/monokai");
|
||||
var viewId = $(document.documentElement).data('view-xmlid');
|
||||
openerp.jsonRpc('/website/customize_template_get', 'call', {
|
||||
'xml_id': viewId,
|
||||
'full': true,
|
||||
}).then(function (views) {
|
||||
self.loadViews.call(self, views);
|
||||
self.open.call(self);
|
||||
var curentHash = window.location.hash;
|
||||
var indexOfView = curentHash.indexOf("?view=");
|
||||
if (indexOfView >= 0) {
|
||||
var viewId = parseInt(curentHash.substring(indexOfView + 6, curentHash.length), 10);
|
||||
self.$('#ace-view-list').val(viewId).change();
|
||||
} else {
|
||||
if (views.length >= 2) {
|
||||
var mainTemplate = views[1];
|
||||
self.$('#ace-view-list').val(mainTemplate.id).trigger('change');
|
||||
}
|
||||
window.location.hash = hash;
|
||||
}
|
||||
});
|
||||
self.loadTemplates();
|
||||
|
||||
var $editor = self.$('.ace_editor');
|
||||
function resizeEditor (target) {
|
||||
@@ -150,8 +132,34 @@
|
||||
resizeEditor(readEditorWidth());
|
||||
resizeEditorHeight(this.getParent().$el.outerHeight()+2);
|
||||
},
|
||||
loadTemplates: function () {
|
||||
var self = this;
|
||||
var args = {
|
||||
xml_id: $(document.documentElement).data('view-xmlid'),
|
||||
full: true,
|
||||
bundles: this.$('.js_include_bundles')[0].checked
|
||||
};
|
||||
return openerp
|
||||
.jsonRpc('/website/customize_template_get', 'call', args)
|
||||
.then(function (views) {
|
||||
self.loadViews.call(self, views);
|
||||
self.open.call(self);
|
||||
var curentHash = window.location.hash;
|
||||
var indexOfView = curentHash.indexOf("?view=");
|
||||
if (indexOfView >= 0) {
|
||||
var viewId = parseInt(curentHash.substring(indexOfView + 6, curentHash.length), 10);
|
||||
self.$('#ace-view-list').val(viewId).change();
|
||||
} else {
|
||||
if (views.length >= 2) {
|
||||
var mainTemplate = views[1];
|
||||
self.$('#ace-view-list').val(mainTemplate.id).trigger('change');
|
||||
}
|
||||
window.location.hash = hash;
|
||||
}
|
||||
});
|
||||
},
|
||||
loadViews: function (views) {
|
||||
var $viewList = this.$('#ace-view-list');
|
||||
var $viewList = this.$('#ace-view-list').empty();
|
||||
_(this.buildViewGraph(views)).each(function (view) {
|
||||
if (!view.id) { return; }
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<select id="ace-view-list" class="form-control oe_view_list">
|
||||
<!-- filled in JS -->
|
||||
</select>
|
||||
<label class="oe_include_bundles">
|
||||
<input type="checkbox" class="js_include_bundles"/> Include Asset Bundles
|
||||
</label>
|
||||
<button data-action="save" type="submit" class="btn btn-success">Save</button>
|
||||
<button data-action="format" type="button" class="btn btn-warning">Format</button>
|
||||
<button data-action="close" type="button" class="btn btn-info">Close</button>
|
||||
|
||||
Reference in New Issue
Block a user