[ADD] website: added a shorted version of publish management, to allow smaller inclusion in some views like blog post comments
bzr revid: tde@openerp.com-20130930154511-r0mng3cxqu1ox3g2
This commit is contained in:
@@ -367,6 +367,25 @@ ul.nav-stacked > li > a {
|
||||
}
|
||||
|
||||
/* ---- PUBLISH ---- */
|
||||
a[data-publish] {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
a[data-publish] .css_unpublish, a[data-publish] .css_publish, a[data-publish] .css_unpublished, a[data-publish] .css_published {
|
||||
display: none;
|
||||
}
|
||||
a[data-publish][data-publish='off'] .css_unpublished, a[data-publish][data-publish='off']:hover .css_publish {
|
||||
display: inline;
|
||||
}
|
||||
a[data-publish][data-publish='off']:hover .css_unpublished {
|
||||
display: none;
|
||||
}
|
||||
a[data-publish][data-publish='on'] .css_published, a[data-publish][data-publish='on']:hover .css_unpublish {
|
||||
display: inline;
|
||||
}
|
||||
a[data-publish][data-publish='on']:hover .css_published {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dropdown .css_unpublish, .dropdown .css_publish {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -283,6 +283,20 @@ ul.nav-stacked > li > a
|
||||
text-transform: uppercase
|
||||
|
||||
/* ---- PUBLISH ---- */
|
||||
a[data-publish]
|
||||
text-decoration: none !important
|
||||
.css_unpublish, .css_publish, .css_unpublished, .css_published
|
||||
display: none
|
||||
&[data-publish='off']
|
||||
.css_unpublished, &:hover .css_publish
|
||||
display: inline
|
||||
&:hover .css_unpublished
|
||||
display: none
|
||||
&[data-publish='on']
|
||||
.css_published, &:hover .css_unpublish
|
||||
display: inline
|
||||
&:hover .css_published
|
||||
display: none
|
||||
|
||||
.dropdown .css_unpublish, .dropdown .css_publish
|
||||
display: none
|
||||
|
||||
@@ -117,9 +117,29 @@
|
||||
};
|
||||
|
||||
dom_ready.then(function () {
|
||||
|
||||
/* ----- PUBLISHING STUFF ---- */
|
||||
$('[data-publish]:has(.js_publish)').each(function () {
|
||||
var $pub = $("[data-publish]", this);
|
||||
if($pub.size())
|
||||
$(this).attr("data-publish", $pub.attr("data-publish"));
|
||||
else
|
||||
$(this).removeAttr("data-publish");
|
||||
});
|
||||
|
||||
$('[data-publish]:has(.js_publish_management)').each(function () {
|
||||
$(this).attr("data-publish", $(".js_publish_management .btn-success", this).size() ? "on" : 'off');
|
||||
$(this).attr("data-publish", $(".js_publish_management .btn-success", this).size() ? "on" : 'off');
|
||||
});
|
||||
|
||||
$(document).on('click', '.js_publish', function (e) {
|
||||
e.preventDefault();
|
||||
var $data = $(":first", this).parents("[data-publish]");
|
||||
$data.attr("data-publish", $data.first().attr("data-publish") == 'off' ? 'on' : 'off');
|
||||
openerp.jsonRpc('/website/publish', 'call', {'id': $(this).data('id'), 'object': $(this).data('object')})
|
||||
.then(function (result) {
|
||||
$data.attr("data-publish", +result ? 'on' : 'off');
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.js_publish_management .js_publish_btn', function (e) {
|
||||
|
||||
@@ -361,22 +361,37 @@
|
||||
<template id="publish_management">
|
||||
<t t-if="editable" t-ignore="true">
|
||||
<div t-attf-class="dropdown js_publish_management pull-right #{object.id and object.website_published and 'css_publish' or 'css_unpublish'}" t-att-data-id="object.id" t-att-data-object="object._name">
|
||||
<a t-attf-class="btn btn-sm btn-#{object.id and object.website_published and 'success' or 'default'}" t-att-id="'dopprod-%s' % object.id" role="button" data-toggle="dropdown">Options <span class="caret"></span></a>
|
||||
<a t-attf-class="btn btn-xs btn-#{object.id and object.website_published and 'success' or 'default'}" t-att-id="'dopprod-%s' % object.id" role="button" data-toggle="dropdown">Options <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu" t-att-aria-labelledby="'dopprod-%s' % object.id">
|
||||
<t t-raw="0"/>
|
||||
<li>
|
||||
<a href="#" class="js_publish_btn css_unpublish">Unpublish</a>
|
||||
<a href="#" class="js_publish_btn css_publish">Publish</a>
|
||||
</li>
|
||||
<li class="divider"/>
|
||||
<li>
|
||||
<a t-att-href="'/admin/#model=%s&id=%s' % (object._name, object.id)">Edit</a>
|
||||
<a href="#" class="js_publish_btn css_unpublish"><small>Unpublish</small></a>
|
||||
<a href="#" class="js_publish_btn css_publish"><small>Publish</small></a>
|
||||
</li>
|
||||
<t t-if="publish_edit">
|
||||
<li class="divider"/>
|
||||
<li>
|
||||
<a t-att-href="'/admin/#model=%s&id=%s' % (object._name, object.id)"><small>Edit</small></a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="publish_short">
|
||||
<t t-if="editable" t-ignore="true">
|
||||
<a href="#" t-att-data-id="object.id" t-att-data-object="object._name"
|
||||
t-att-data-publish="object.id and object.website_published and 'on' or 'off'"
|
||||
class="pull-right js_publish">
|
||||
<span t-attf-class="text-success css_publish glyphicon glyphicon-ok"></span>
|
||||
<span t-attf-class="text-danger css_unpublish glyphicon glyphicon-remove-circle"></span>
|
||||
<span t-attf-class="text-muted css_published glyphicon glyphicon-ok"></span>
|
||||
<span t-attf-class="text-muted css_unpublished glyphicon glyphicon-remove-circle"></span>
|
||||
</a>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="kanban">
|
||||
<t t-set="step"><t t-esc="step or 0"/></t>
|
||||
<t t-set="scope"><t t-esc="scope or 0"/></t>
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
<!-- Blog Post Complete -->
|
||||
<template id="view_blog_post" name="Blog Post">
|
||||
<div>
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="blog_post"/></t>
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="blog_post"/>
|
||||
<t t-set="publish_edit" t-value="true"/>
|
||||
</t>
|
||||
</div><div class="clearfix"/>
|
||||
|
||||
<h1 class="text-center" t-field="blog_post.name"/>
|
||||
@@ -77,7 +80,9 @@
|
||||
<div class="media-body">
|
||||
<img class="media-object pull-left" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(message.author_id.id)" style="width: 50px; margin-right: 10px;"/>
|
||||
<div class="media-body">
|
||||
<t t-call="website.publish_management"><t t-set="object" t-value="message"/></t>
|
||||
<t t-call="website.publish_short">
|
||||
<t t-set="object" t-value="message"/>
|
||||
</t>
|
||||
<h5 class="media-heading">
|
||||
<span t-field="message.author_id"/> <small>on <span t-field="message.date"/></small>
|
||||
</h5>
|
||||
|
||||
Reference in New Issue
Block a user