[MERGE] Shortcut extracted to a module
bzr revid: fme@openerp.com-20120503131830-ld7rcpr4xtagajhm
This commit is contained in:
commit
ff3eb28fe3
|
@ -440,13 +440,6 @@
|
|||
background-image: -o-linear-gradient(top, #646060, #262626);
|
||||
background-image: linear-gradient(to bottom, #646060, #262626);
|
||||
}
|
||||
.openerp .oe_topbar .oe_systray {
|
||||
float: right;
|
||||
}
|
||||
.openerp .oe_topbar .oe_systray > div {
|
||||
float: left;
|
||||
padding: 0 4px 0 4px;
|
||||
}
|
||||
.openerp .oe_topbar .oe_topbar_item li {
|
||||
float: left;
|
||||
}
|
||||
|
@ -606,6 +599,68 @@
|
|||
border-top: 1px solid #999999;
|
||||
border-bottom: 0;
|
||||
}
|
||||
.openerp .oe_systray > div {
|
||||
float: left;
|
||||
padding: 0 4px 0 4px;
|
||||
}
|
||||
.openerp .oe_systray {
|
||||
float: right;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown {
|
||||
position: relative;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown:hover .oe_systray_dropdown_options {
|
||||
display: block;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown_options {
|
||||
background: #333333;
|
||||
background: rgba(37, 37, 37, 0.9);
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 900;
|
||||
border: 0;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
padding: 6px 0;
|
||||
border-color: #999999;
|
||||
border-color: rgba(0, 0, 0, 0.2);
|
||||
border-style: solid;
|
||||
border-width: 0 1px 1px;
|
||||
-moz-border-radius: 0 0 6px 6px;
|
||||
-webkit-border-radius: 0 0 6px 6px;
|
||||
border-radius: 0 0 6px 6px;
|
||||
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding-box;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown_options li {
|
||||
float: none;
|
||||
display: block;
|
||||
background-color: none;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown_options li a {
|
||||
display: block;
|
||||
padding: 4px 15px;
|
||||
clear: both;
|
||||
font-weight: normal;
|
||||
line-height: 18px;
|
||||
color: #eeeeee;
|
||||
}
|
||||
.openerp .oe_systray .oe_systray_dropdown_options li a:hover {
|
||||
background-color: #292929;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#292929), to(#191919));
|
||||
background-image: -webkit-linear-gradient(top, #292929, #191919);
|
||||
background-image: -moz-linear-gradient(top, #292929, #191919);
|
||||
background-image: -ms-linear-gradient(top, #292929, #191919);
|
||||
background-image: -o-linear-gradient(top, #292929, #191919);
|
||||
background-image: linear-gradient(to bottom, #292929, #191919);
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
-box-shadow: none;
|
||||
}
|
||||
.openerp .oe_menu {
|
||||
float: left;
|
||||
padding: 0;
|
||||
|
|
|
@ -358,12 +358,6 @@ $colour4: #8a89ba
|
|||
border-top: solid 1px #d3d3d3
|
||||
@include vertical-gradient(#646060, #262626)
|
||||
|
||||
.oe_systray
|
||||
float: right
|
||||
.oe_systray > div
|
||||
float: left
|
||||
padding: 0 4px 0 4px
|
||||
|
||||
.oe_topbar_item
|
||||
li
|
||||
float: left
|
||||
|
@ -449,6 +443,7 @@ $colour4: #8a89ba
|
|||
float: left
|
||||
.oe_dropdown
|
||||
position: relative
|
||||
|
||||
.oe_dropdown_options
|
||||
float: left
|
||||
background: #333
|
||||
|
@ -488,6 +483,49 @@ $colour4: #8a89ba
|
|||
border-top: 1px solid #999
|
||||
border-bottom: 0
|
||||
// }}}
|
||||
// Systray {{{
|
||||
.oe_systray > div
|
||||
float: left
|
||||
padding: 0 4px 0 4px
|
||||
.oe_systray
|
||||
float: right
|
||||
|
||||
.oe_systray_dropdown
|
||||
position: relative
|
||||
.oe_systray_dropdown:hover .oe_systray_dropdown_options
|
||||
display: block
|
||||
.oe_systray_dropdown_options
|
||||
background: #333
|
||||
background: rgba(37,37,37,0.9)
|
||||
display: none
|
||||
position: absolute
|
||||
z-index: 900
|
||||
border: 0
|
||||
margin-left: 0
|
||||
margin-right: 0
|
||||
padding: 6px 0
|
||||
border-color: #999
|
||||
border-color: rgba(0, 0, 0, 0.2)
|
||||
border-style: solid
|
||||
border-width: 0 1px 1px
|
||||
@include radius(0 0 6px 6px)
|
||||
@include box-shadow(0 1px 4px rgba(0,0,0,0.3))
|
||||
@include background-clip()
|
||||
li
|
||||
float: none
|
||||
display: block
|
||||
background-color: none
|
||||
a
|
||||
display: block
|
||||
padding: 4px 15px
|
||||
clear: both
|
||||
font-weight: normal
|
||||
line-height: 18px
|
||||
color: #eee
|
||||
&:hover
|
||||
@include vertical-gradient(#292929, #191919)
|
||||
@include box-shadow(none)
|
||||
// }}}
|
||||
// Menu {{{
|
||||
.oe_menu
|
||||
float: left
|
||||
|
|
|
@ -880,60 +880,6 @@ label.error {
|
|||
text-align: left;
|
||||
padding: 4px 5px;
|
||||
}
|
||||
/* Shortcuts*/
|
||||
.oe-shortcut-toggle {
|
||||
height: 20px;
|
||||
margin-top: 3px;
|
||||
padding: 0;
|
||||
width: 24px;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
background: url(/web/static/src/img/add-shortcut.png) no-repeat center center;
|
||||
float: left;
|
||||
}
|
||||
.oe-shortcut-remove{
|
||||
background: url(/web/static/src/img/remove-shortcut.png) no-repeat center center;
|
||||
}
|
||||
.oe-shortcuts {
|
||||
position: absolute;
|
||||
margin: 0;
|
||||
padding: 6px 15px;
|
||||
top: 37px;
|
||||
left: 197px;
|
||||
right: 0;
|
||||
height: 17px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.oe-shortcuts ul {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
list-style: none;
|
||||
white-space: nowrap;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.oe-shortcuts li {
|
||||
cursor: pointer;
|
||||
display: -moz-inline-stack;
|
||||
display: inline-block;
|
||||
display: inline; /*IE7 */
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-left: 1px solid #909090;
|
||||
padding: 0 4px;
|
||||
font-size: 80%;
|
||||
font-weight: normal;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.oe-shortcuts li:hover {
|
||||
background-color: #666;
|
||||
}
|
||||
.oe-shortcuts li:first-child {
|
||||
border-left: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
ul.oe-arrow-list {
|
||||
padding-left: 1.1em;
|
||||
margin: 0;
|
||||
|
|
|
@ -762,59 +762,12 @@ instance.web.UserMenu = instance.web.Widget.extend({
|
|||
self.$element.find('.oe_topbar_name').text(topbar_name);
|
||||
var avatar_src = _.str.sprintf('%s/web/binary/image?session_id=%s&model=res.users&field=avatar&id=%s', self.session.prefix, self.session.session_id, self.session.uid);
|
||||
$avatar.attr('src', avatar_src);
|
||||
return self.shortcut_load();
|
||||
});
|
||||
};
|
||||
this.update_promise = this.update_promise.pipe(fct, fct);
|
||||
},
|
||||
on_action: function() {
|
||||
},
|
||||
shortcut_load :function(){
|
||||
var self = this,
|
||||
sc = self.session.shortcuts,
|
||||
shortcuts_ds = new instance.web.DataSet(this, 'ir.ui.view_sc');
|
||||
self.$element.find('.oe_dropdown_options a[data-menu=shortcut]').each(function() {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
// TODO: better way to communicate between sections.
|
||||
// sc.bindings, because jquery does not bind/trigger on arrays...
|
||||
if (!sc.binding) {
|
||||
sc.binding = {};
|
||||
$(sc.binding).bind({
|
||||
'add': function (e, attrs) {
|
||||
shortcuts_ds.create(attrs, function (out) {
|
||||
var shortcut = QWeb.render('UserMenu.shortcut', {
|
||||
shortcuts : [{
|
||||
name : attrs.name,
|
||||
id : out.result,
|
||||
res_id : attrs.res_id
|
||||
}]
|
||||
});
|
||||
$(shortcut).appendTo(self.$element.find('.oe_dropdown_options'));
|
||||
attrs.id = out.result;
|
||||
sc.push(attrs);
|
||||
});
|
||||
},
|
||||
'remove-current': function () {
|
||||
var menu_id = self.session.active_id;
|
||||
var $shortcut = self.$element.find('.oe_dropdown_options li a[data-id=' + menu_id + ']');
|
||||
var shortcut_id = $shortcut.data('shortcut-id');
|
||||
$shortcut.remove();
|
||||
shortcuts_ds.unlink([shortcut_id]);
|
||||
var sc_new = _.reject(sc, function(shortcut){ return shortcut_id === shortcut.id});
|
||||
sc.splice(0, sc.length);
|
||||
sc.push.apply(sc, sc_new);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.rpc('/web/session/sc_list', {}, function(shortcuts) {
|
||||
sc.splice(0, sc.length);
|
||||
sc.push.apply(sc, shortcuts);
|
||||
|
||||
$(QWeb.render('UserMenu.shortcut', {'shortcuts': shortcuts}))
|
||||
.appendTo(self.$element.find('.oe_dropdown_options'));
|
||||
});
|
||||
},
|
||||
on_menu_logout: function() {
|
||||
},
|
||||
on_menu_settings: function() {
|
||||
|
@ -871,16 +824,6 @@ instance.web.UserMenu = instance.web.Widget.extend({
|
|||
modal: true, width: 960, title: _t("About")});
|
||||
});
|
||||
},
|
||||
on_menu_shortcut: function($link) {
|
||||
var self = this,
|
||||
id = $link.data('id');
|
||||
self.session.active_id = id;
|
||||
self.rpc('/web/menu/action', {'menu_id': id}, function(ir_menu_data) {
|
||||
if (ir_menu_data.action.length){
|
||||
self.on_action(ir_menu_data.action[0][2]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
instance.web.WebClient = instance.web.Widget.extend({
|
||||
|
|
|
@ -69,7 +69,6 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
|
|||
self.module_loaded[mod] = true;
|
||||
});
|
||||
this.context = {};
|
||||
this.shortcuts = [];
|
||||
this.active_id = null;
|
||||
return this.session_init();
|
||||
},
|
||||
|
|
|
@ -636,8 +636,6 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
|
|||
var self = this;
|
||||
|
||||
return $.when(this._super(view_type, no_store)).then(function () {
|
||||
self.shortcut_check(self.views[view_type]);
|
||||
|
||||
var controller = self.views[self.active_view].controller,
|
||||
fvg = controller.fields_view,
|
||||
view_id = (fvg && fvg.view_id) || '--';
|
||||
|
@ -672,44 +670,6 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
|
|||
self.views[self.active_view].controller.do_load_state(state, warm);
|
||||
});
|
||||
},
|
||||
shortcut_check : function(view) {
|
||||
var self = this;
|
||||
var grandparent = this.getParent() && this.getParent().getParent();
|
||||
// display shortcuts if on the first view for the action
|
||||
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
|
||||
if (!this.action.name ||
|
||||
!(view.view_type === this.views_src[0].view_type
|
||||
&& view.view_id === this.views_src[0].view_id)) {
|
||||
$shortcut_toggle.hide();
|
||||
return;
|
||||
}
|
||||
$shortcut_toggle.removeClass('oe-shortcut-remove').show();
|
||||
if (_(this.session.shortcuts).detect(function (shortcut) {
|
||||
return shortcut.res_id === self.session.active_id; })) {
|
||||
$shortcut_toggle.addClass("oe-shortcut-remove");
|
||||
}
|
||||
this.shortcut_add_remove();
|
||||
},
|
||||
shortcut_add_remove: function() {
|
||||
var self = this;
|
||||
var $shortcut_toggle = this.$element.find('.oe-shortcut-toggle');
|
||||
$shortcut_toggle
|
||||
.unbind("click")
|
||||
.click(function() {
|
||||
if ($shortcut_toggle.hasClass("oe-shortcut-remove")) {
|
||||
$(self.session.shortcuts.binding).trigger('remove-current');
|
||||
$shortcut_toggle.removeClass("oe-shortcut-remove");
|
||||
} else {
|
||||
$(self.session.shortcuts.binding).trigger('add', {
|
||||
'user_id': self.session.uid,
|
||||
'res_id': self.session.active_id,
|
||||
'resource': 'ir.ui.menu',
|
||||
'name': self.action.name
|
||||
});
|
||||
$shortcut_toggle.addClass("oe-shortcut-remove");
|
||||
}
|
||||
});
|
||||
},
|
||||
display_title: function () {
|
||||
return this.action.name;
|
||||
}
|
||||
|
|
|
@ -326,18 +326,10 @@
|
|||
<li><a href="#" data-menu="about">About OpenERP</a></li>
|
||||
<li><a href="#" data-menu="settings">Preferences</a></li>
|
||||
<li><a href="#" data-menu="logout">Log out</a></li>
|
||||
<li><hr/></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
<t t-name="UserMenu.shortcut">
|
||||
<li t-foreach="shortcuts" t-as="shortcut">
|
||||
<a href="#" data-menu="shortcut" t-att-data-id="shortcut.res_id" t-att-data-shortcut-id="shortcut.id">
|
||||
<t t-esc="shortcut.name"/>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
<t t-name="UserMenu.about">
|
||||
<div>
|
||||
<a class="oe_activate_debug_mode" href="?debug" style="float:right; font-size: 80%;">Activate the developper mode</a>
|
||||
|
@ -455,10 +447,6 @@
|
|||
</div>
|
||||
</t>
|
||||
<t t-name="ViewManagerAction" t-extend="ViewManager">
|
||||
<t t-jquery="h2.oe_view_title" t-operation="prepend">
|
||||
<a t-if="widget.flags.display_title !== false" class="oe-shortcut-toggle" title="Add / Remove Shortcut..."
|
||||
href="javascript: void(0)"> </a>
|
||||
</t>
|
||||
<t t-jquery="h2.oe_view_title" t-operation="before">
|
||||
<select t-if="widget.session.debug" class="oe_debug_view"/>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue