vidhin mehta[Open Erp] has proposed merging
lp:~openerp-dev/openerp-web/shortcut-vme into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/shortcut-vme/+merge/69270
Add functionality of add and remove shortcut same as trunk and when click on
shortcut opens related views of object.
--
https://code.launchpad.net/~openerp-dev/openerp-web/shortcut-vme/+merge/69270
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/shortcut-vme.
=== modified file 'addons/base/controllers/main.py'
--- addons/base/controllers/main.py 2011-07-25 11:37:40 +0000
+++ addons/base/controllers/main.py 2011-07-26 12:49:27 +0000
@@ -428,6 +428,7 @@
actions = load_actions_from_ir_values(req,'action', 'tree_but_open',
[('ir.ui.menu', menu_id)], False,
req.session.eval_context(req.context))
+
return {"action": actions}
class DataSet(openerpweb.Controller):
=== modified file 'addons/base/static/src/css/base.css'
--- addons/base/static/src/css/base.css 2011-07-15 12:50:44 +0000
+++ addons/base/static/src/css/base.css 2011-07-26 12:49:27 +0000
@@ -1092,3 +1092,81 @@
font-size: 1.2em;
font-weight: bold;
}
+
+/* Shortcuts*/
+#shortcut_add_remove {
+ height: 20px;
+ padding: 0;
+ width: 24px;
+ cursor: pointer;
+ display: inline; /*IE7 */
+ display: inline-block;
+}
+
+.shortcut-add {
+ background: url(../img/add-shortcut.png) no-repeat;
+ background-position: bottom;
+}
+.shortcut-remove{
+ background: url(../img/remove-shortcut.png) no-repeat;
+ background-position: bottom;
+}
+
+/* ================ */
+#shortcuts {
+ position: absolute;
+
+ margin: 0;
+ padding: 6px 5px;
+ top: 40px;
+ left: 207px;
+ right: 0;
+ height: 17px;
+ line-height: 1.2;
+}
+#shortcuts.scrolling {
+ padding: 6px 14px !important;
+}
+
+#shortcuts ul {
+ display: block;
+ overflow: hidden;
+ list-style: none;
+ white-space: nowrap;
+ padding: 0;
+ margin: 0;
+}
+
+#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-left: 2px;
+
+}
+
+#shortcuts li:first-child,
+#shortcuts li.first {
+ border-left: none;
+ padding-left: 0;
+}
+
+#shortcuts a {
+ display: inline; /*IE7 */
+ display: inline-block;
+ padding: 0;
+ margin: 0;
+}
+
+#shortcuts a span {
+ display: inline; /*IE7 */
+ display: inline-block;
+ line-height: 18px;
+ padding: 0 2px;
+}
+
+
=== added file 'addons/base/static/src/img/add-shortcut.png'
Binary files addons/base/static/src/img/add-shortcut.png 1970-01-01 00:00:00 +0000 and addons/base/static/src/img/add-shortcut.png 2011-07-26 12:49:27 +0000 differ
=== added file 'addons/base/static/src/img/remove-shortcut.png'
Binary files addons/base/static/src/img/remove-shortcut.png 1970-01-01 00:00:00 +0000 and addons/base/static/src/img/remove-shortcut.png 2011-07-26 12:49:27 +0000 differ
=== modified file 'addons/base/static/src/js/chrome.js'
--- addons/base/static/src/js/chrome.js 2011-07-26 10:01:36 +0000
+++ addons/base/static/src/js/chrome.js 2011-07-26 12:49:27 +0000
@@ -135,7 +135,6 @@
_.extend({}, this.map, mapping || {}));
}
});
-
/**
* OpenERP session aware controller
* a controller takes an already existing dom element and manage it
@@ -259,7 +258,7 @@
this.module_list = [];
this.module_loaded = {"base": true};
this.context = {};
- },
+ },
start: function() {
this.session_restore();
},
@@ -382,9 +381,11 @@
self.uid = result.uid;
self.session_save();
self.on_session_valid();
+
if (success_callback)
success_callback();
});
+
},
session_logout: function() {
this.uid = false;
@@ -398,6 +399,7 @@
// we should do an rpc to confirm that this session_id is valid and if it is retrieve the information about db and login
// then call on_session_valid
this.on_session_valid();
+
},
/**
* Saves the session id and uid locally
@@ -462,8 +464,10 @@
self.do_load_js(["/base/webclient/js?mods="+modules]);
}
openerp._modules_loaded = true;
+
});
},
+
do_load_css: function (files) {
_.each(files, function (file) {
$('head').append($('<link>', {
@@ -506,6 +510,7 @@
}
});
+
openerp.base.Notification = openerp.base.Controller.extend({
init: function(parent, element_id) {
this._super(parent, element_id);
@@ -760,16 +765,22 @@
do_update: function() {
this.$element.html(QWeb.render("Header", this));
this.$element.find(".logout").click(this.on_logout);
+
},
on_logout: function() {}
});
+
openerp.base.Menu = openerp.base.Controller.extend({
init: function(parent, element_id, secondary_menu_id) {
+
this._super(parent, element_id);
this.secondary_menu_id = secondary_menu_id;
this.$secondary_menu = $("#" + secondary_menu_id);
this.menu = false;
+ var check_shortcut_id = 0; //used in search.js for shortcut
+ var shortcut_data = {}; //used in search.js for shortcut
+
},
start: function() {
this.rpc("/base/menu/load", {}, this.on_loaded);
@@ -823,6 +834,7 @@
$secondary.show();
if (id) {
+ check_shortcut_id = id; // Assign id for check in search.js
this.rpc('/base/menu/action', {'menu_id': id},
this.on_menu_action_loaded);
}
@@ -836,7 +848,9 @@
},
on_menu_action_loaded: function(data) {
var self = this;
+
if (data.action.length) {
+ shortcut_data = data;// Assing for name used in create in search.js
var action = data.action[0][2];
self.on_action(action);
}
@@ -845,6 +859,51 @@
}
});
+openerp.base.shortcut = openerp.base.Menu.extend({
+
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
+ },
+
+ start: function() {
+ this.shortcut_load();
+ },
+
+ shortcut_load: function() {
+ self = this;
+ this.rpc('/base/session/sc_list', {}, function(sc_list_data){
+
+ self.session.sc_list = sc_list_data
+ sc_list = sc_list_data //used in search.js
+ self.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': sc_list_data}));
+ self.$element.find('#shortcuts').find('ul li').click(function(ev, id){
+ if(this.id){
+ check_shortcut_id = this.id //used in search.js
+ self.rpc('/base/menu/action', {'menu_id':this.id},function(ir_menu_data){
+ if (ir_menu_data.action.length){
+ shortcut_data = ir_menu_data; //used in search.js
+ this.action_manager = new openerp.base.ActionManager(self, "oe_app");
+ this.action_manager.do_action(ir_menu_data.action[0][2]);
+ }
+ });
+ }
+ });
+ });
+ },
+ remove:function(){
+ sc_list_data = {}
+ sc_list ={}
+ self.$element.find('#shortcuts').html(QWeb.render('Shortcuts', {'shortcuts_pass': sc_list_data}));
+ },
+
+ on_action: function(action) {
+ }
+
+});
+
+
+
+
openerp.base.Homepage = openerp.base.Controller.extend({
});
@@ -876,10 +935,14 @@
this.header = new openerp.base.Header(this, "oe_header");
this.login = new openerp.base.Login(this, "oe_login");
this.header.on_logout.add(this.login.on_logout);
-
+ this.shortcut = new openerp.base.shortcut(this,"oe_header");
this.session.on_session_invalid.add(this.login.do_ask_login);
this.session.on_session_valid.add_last(this.header.do_update);
this.session.on_session_valid.add_last(this.on_logged);
+ this.header.on_logout.add(this.shortcut.remove);
+
+
+
this.menu = new openerp.base.Menu(this, "oe_menu", "oe_secondary_menu");
this.menu.on_action.add(this.on_menu_action);
@@ -889,6 +952,7 @@
this.header.start();
this.login.start();
this.menu.start();
+ this.shortcut.start();
this.notification.notify("OpenERP Client", "The openerp client has been initialized.");
},
on_logged: function() {
=== modified file 'addons/base/static/src/js/list.js'
--- addons/base/static/src/js/list.js 2011-07-25 14:11:03 +0000
+++ addons/base/static/src/js/list.js 2011-07-26 12:49:27 +0000
@@ -200,13 +200,12 @@
on_loaded: function(data, grouped) {
var self = this;
this.fields_view = data.fields_view;
- //this.log(this.fields_view);
+ this.log(this.fields_view);
this.name = "" + this.fields_view.arch.attrs.string;
this.setup_columns(this.fields_view.fields, grouped);
-
+
this.$element.html(QWeb.render("ListView", this));
-
// Head hook
this.$element.find('.oe-list-add')
.click(this.do_add_record)
=== modified file 'addons/base/static/src/js/search.js'
--- addons/base/static/src/js/search.js 2011-07-25 12:18:23 +0000
+++ addons/base/static/src/js/search.js 2011-07-26 12:49:27 +0000
@@ -119,7 +119,6 @@
var ext = new openerp.base.search.ExtendedSearch(this, this.model);
lines.push([ext]);
this.inputs.push(ext);
-
var render = QWeb.render("SearchView", {
'view': data.fields_view['arch'],
'lines': lines,
@@ -129,10 +128,13 @@
// We don't understand why the following commented line does not work in Chrome but
// the non-commented line does. As far as we investigated, only God knows.
//this.$element.html(render);
+
jQuery(render).appendTo(this.$element);
+ this.shortcut_add = new openerp.base.shortcut_add(self,"oe_header");
+ this.shortcut_add.start(self);
this.$element.find(".oe_search-view-custom-filter-btn").click(ext.on_activate);
- var f = this.$element.find('form');
+ var f = this.$element.find('form');
this.$element.find('form')
.submit(this.do_search)
.bind('reset', this.do_clear);
@@ -347,6 +349,63 @@
}
});
+openerp.base.shortcut_add = openerp.base.shortcut.extend({
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
+ },
+ start: function(session) {
+ this.check_shortcut();
+ this.shortcut_add_remove(session);
+ },
+
+ check_shortcut:function(){
+ var self = this;
+ var img = "shortcut-add";
+ var value = "";
+ for(var list_shortcut=0; list_shortcut<sc_list.length; list_shortcut++) {
+ value = sc_list[list_shortcut]['res_id'];
+ if (value == check_shortcut_id)
+ {img = "shortcut-remove"}
+ }
+ $('#shortcut_add_remove').html(QWeb.render('shortcut_image'));
+ $('#shortcut_add_remove').addClass(img);
+ },
+
+ shortcut_add_remove : function(session){
+ self = this;
+ $('#shortcut_add_remove').click(function (ev,id){
+
+ if($('#shortcut_add_remove').hasClass("shortcut-remove")){
+ var unlink_id = 0;
+ unlink_id = self.$element.find('li[id='+check_shortcut_id+']').attr('data-shortcut');
+ self.rpc('/base/dataset/unlink', {
+ model : 'ir.ui.view_sc',
+ ids : [parseInt(unlink_id)]},function(r){
+ self.shortcut_load();
+ $('#shortcut_add_remove').html(QWeb.render('shortcut_image'));
+ $('#shortcut_add_remove').removeClass("shortcut-remove");
+ $('#shortcut_add_remove').addClass("shortcut-add");
+ });
+ }
+ else
+ {
+ self.rpc('/base/dataset/create',{'model':'ir.ui.view_sc','data':{'user_id': self.uid, 'res_id': check_shortcut_id, 'resource': 'ir.ui.menu', 'name': shortcut_data.action[0][2]['name']}},function(r){
+ self.shortcut_load();
+ $('#shortcut_add_remove').html(QWeb.render('shortcut_image'));
+ $('#shortcut_add_remove').removeClass("shortcut-add");
+ $('#shortcut_add_remove').addClass("shortcut-remove");
+ });
+ }
+ });
+ }
+
+});
+
+
+
+
+
+
/** @namespace */
openerp.base.search = {};
/**
=== modified file 'addons/base/static/src/js/views.js'
--- addons/base/static/src/js/views.js 2011-07-25 14:28:05 +0000
+++ addons/base/static/src/js/views.js 2011-07-26 12:49:27 +0000
@@ -132,11 +132,11 @@
this.$element.html(QWeb.render("ViewManager", {"prefix": this.element_id, views: this.views_src}));
this.$element.find('.oe_vm_switch button').click(function() {
self.on_mode_switch($(this).data('view-type'));
- });
+ });11
_.each(this.views_src, function(view) {
self.views[view.view_type] = $.extend({}, view, {controller: null});
- });
- if (this.flags.views_switcher === false) {
+ });1
+ if (this.flags.views_switcher === false) {1
this.$element.find('.oe_vm_switch').hide();
}
// switch to the first one in sequence
@@ -284,6 +284,7 @@
init: function(parent, element_id, action) {
this.session = parent.session;
var dataset;
+
if (!action.res_id) {
dataset = new openerp.base.DataSetSearch(this, action.res_model, action.context || null);
} else {
=== modified file 'addons/base/static/src/xml/base.xml'
--- addons/base/static/src/xml/base.xml 2011-07-25 12:22:31 +0000
+++ addons/base/static/src/xml/base.xml 2011-07-26 12:49:27 +0000
@@ -169,6 +169,18 @@
</div>
</div>
+<div id="shortcuts" >
+
+</div>
+</t>
+<t t-name="Shortcuts">
+ <ul>
+ <t t-foreach="shortcuts_pass" t-as="sc" class="first" >
+ <li t-att-id="sc.res_id" t-att-data-shortcut= "sc.id">
+ <a><t t-esc="sc.name"/></a>
+ </li>
+ </t>
+ </ul>
</t>
<t t-name="Menu">
<table align="center">
@@ -176,7 +188,7 @@
<t t-foreach="data.children" t-as="menu">
<td>
<a href="#" t-att-data-menu="menu.id">
- <t t-esc="menu.name"/>
+ <t t-esc="menu.name" />
</a>
</td>
</t>
@@ -214,9 +226,11 @@
</t>
</div>
</t>
+dd
<t t-name="ViewManager">
<table class="view-manager-main-table">
<tr>
+ <td> </td>
<td class="view-manager-main-content">
<!-- TODO prefix id with the element_id of the controller t-attf-id="#{prefix}_localid" -->
<div class="oe_vm_switch">
@@ -655,8 +669,18 @@
<span t-if="widget.string"><t t-esc="widget.string"/></span>
</button>
</t>
+
+<t t-name="shortcut_image">
+ <a href="javascript: void(0)"></a>
+</t>
+
+
<t t-name="SearchView">
- <h2 class="oe_view_title"><t t-esc="view.attrs['string']"/></h2>
+ <table>
+ <td><div id = "shortcut_add_remove" >
+ </div></td>
+ <td><h2 class="oe_view_title"><t t-esc="view.attrs['string']"/></h2></td>
+ </table>
<form>
<t t-call="SearchView.render_lines"/>
<div class="oe_search-view-buttons" style="text-align: right;">
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp