[imp] further more into the refactoring

bzr revid: nicolas.vanhoren@openerp.com-20120417122611-ftc4vuct77bldhts
This commit is contained in:
niv-openerp 2012-04-17 14:26:11 +02:00
parent 53c0d46e79
commit 13e6438824
3 changed files with 62 additions and 62 deletions

View File

@ -2,12 +2,12 @@
* OpenERP web_calendar
*---------------------------------------------------------*/
openerp.web_calendar = function(openerp) {
var _t = openerp.web._t,
_lt = openerp.web._lt;
var QWeb = openerp.web.qweb;
openerp.web.views.add('calendar', 'openerp.web_calendar.CalendarView');
openerp.web_calendar.CalendarView = openerp.web.View.extend({
openerp.web_calendar = function(instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
instance.web.views.add('calendar', 'instance.web_calendar.CalendarView');
instance.web_calendar.CalendarView = instance.web.View.extend({
display_name: _lt('Calendar'),
// Dhtmlx scheduler ?
init: function(parent, dataset, view_id, options) {
@ -22,7 +22,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
this.has_been_loaded = $.Deferred();
this.creating_event_id = null;
this.dataset_events = [];
this.form_dialog = new openerp.web_calendar.CalendarFormDialog(this, {
this.form_dialog = new instance.web_calendar.CalendarFormDialog(this, {
destroy_on_close: false,
width: '80%',
min_width: 850
@ -103,7 +103,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
this.init_scheduler();
if (this.options.sidebar) {
this.sidebar = new openerp.web_calendar.Sidebar(this);
this.sidebar = new instance.web_calendar.Sidebar(this);
this.has_been_loaded.pipe(this.sidebar.appendTo(this.$element));
}
@ -207,10 +207,10 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
}
if (this.fields[this.date_start]['type'] == 'date') {
evt[this.date_start] = openerp.web.auto_str_to_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');
evt[this.date_start] = instance.web.auto_str_to_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');
}
if (this.date_stop && evt[this.date_stop] && this.fields[this.date_stop]['type'] == 'date') {
evt[this.date_stop] = openerp.web.auto_str_to_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');
evt[this.date_stop] = instance.web.auto_str_to_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');
}
res_events.push(this.convert_event(evt));
}
@ -222,8 +222,8 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
}
},
convert_event: function(evt) {
var date_start = openerp.web.str_to_datetime(evt[this.date_start]),
date_stop = this.date_stop ? openerp.web.str_to_datetime(evt[this.date_stop]) : null,
var date_start = instance.web.str_to_datetime(evt[this.date_start]),
date_stop = this.date_stop ? instance.web.str_to_datetime(evt[this.date_stop]) : null,
date_delay = evt[this.date_delay] || 1.0,
res_text = '',
res_description = [];
@ -354,9 +354,9 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
var data = {
name: event_obj.text
};
data[this.date_start] = openerp.web.datetime_to_str(event_obj.start_date);
data[this.date_start] = instance.web.datetime_to_str(event_obj.start_date);
if (this.date_stop) {
data[this.date_stop] = openerp.web.datetime_to_str(event_obj.end_date);
data[this.date_stop] = instance.web.datetime_to_str(event_obj.end_date);
}
if (this.date_delay) {
var diff_seconds = Math.round((event_obj.end_date.getTime() - event_obj.start_date.getTime()) / 1000);
@ -383,7 +383,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
});
},
get_range_domain: function() {
var format = openerp.web.date_to_str,
var format = instance.web.date_to_str,
domain = this.last_search[0].slice(0);
domain.unshift([this.date_start, '>=', format(this.range_start.clone().addDays(-6))]);
domain.unshift([this.date_start, '<=', format(this.range_stop.clone().addDays(6))]);
@ -402,7 +402,7 @@ openerp.web_calendar.CalendarView = openerp.web.View.extend({
}
});
openerp.web_calendar.CalendarFormDialog = openerp.web.Dialog.extend({
instance.web_calendar.CalendarFormDialog = instance.web.Dialog.extend({
init: function(view, options, view_id, dataset) {
this._super(view, options);
this.dataset = dataset;
@ -412,7 +412,7 @@ openerp.web_calendar.CalendarFormDialog = openerp.web.Dialog.extend({
start: function() {
var self = this;
this._super();
this.form = new openerp.web.FormView(this, this.dataset, this.view_id, {
this.form = new instance.web.FormView(this, this.dataset, this.view_id, {
sidebar: false,
pager: false
});
@ -440,7 +440,7 @@ openerp.web_calendar.CalendarFormDialog = openerp.web.Dialog.extend({
}
});
openerp.web_calendar.Sidebar = openerp.web.Widget.extend({
instance.web_calendar.Sidebar = instance.web.Widget.extend({
template: 'CalendarView.sidebar',
start: function() {
this._super();
@ -452,11 +452,11 @@ openerp.web_calendar.Sidebar = openerp.web.Widget.extend({
scheduler.setCurrentView(date, 'day');
}
});
this.filter = new openerp.web_calendar.SidebarFilter(this, this.getParent());
this.filter = new instance.web_calendar.SidebarFilter(this, this.getParent());
this.filter.appendTo(this.$element.find('.oe_calendar_filter'));
}
});
openerp.web_calendar.SidebarFilter = openerp.web.Widget.extend({
instance.web_calendar.SidebarFilter = instance.web.Widget.extend({
init: function(parent, view) {
this._super(parent);
this.view = view;

View File

@ -1,13 +1,13 @@
openerp.web_dashboard = function(openerp) {
var QWeb = openerp.web.qweb,
_t = openerp.web._t;
openerp.web_dashboard = function(instance) {
var QWeb = instance.web.qweb,
_t = instance.web._t;
if (!openerp.web_dashboard) {
if (!instance.web_dashboard) {
/** @namespace */
openerp.web_dashboard = {};
instance.web_dashboard = {};
}
openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
instance.web.form.DashBoard = instance.web.form.Widget.extend({
init: function(view, node) {
this._super(view, node);
this.form_template = 'DashBoard';
@ -56,7 +56,7 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
var qdict = {
current_layout : this.$element.find('.oe-dashboard').attr('data-layout')
};
var $dialog = openerp.web.dialog($('<div>'), {
var $dialog = instance.web.dialog($('<div>'), {
modal: true,
title: _t("Edit Layout"),
width: 'auto',
@ -188,7 +188,7 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
selectable: false
}
};
var am = new openerp.web.ActionManager(this),
var am = new instance.web.ActionManager(this),
// FIXME: ideally the dashboard view shall be refactored like kanban.
$action = $('#' + this.view.element_id + '_action_' + index);
$action.parent().data('action_attrs', action_attrs);
@ -249,7 +249,7 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({
action_manager.do_action(view_manager.action);
}
});
openerp.web.form.DashBoardLegacy = openerp.web.form.DashBoard.extend({
instance.web.form.DashBoardLegacy = instance.web.form.DashBoard.extend({
renderElement: function() {
if (this.node.tag == 'hpaned') {
this.node.attrs.style = '2-1';
@ -273,25 +273,25 @@ openerp.web.form.DashBoardLegacy = openerp.web.form.DashBoard.extend({
}
});
openerp.web.form.tags.add('hpaned', 'openerp.web.form.DashBoardLegacy');
openerp.web.form.tags.add('vpaned', 'openerp.web.form.DashBoardLegacy');
openerp.web.form.tags.add('board', 'openerp.web.form.DashBoard');
instance.web.form.tags.add('hpaned', 'instance.web.form.DashBoardLegacy');
instance.web.form.tags.add('vpaned', 'instance.web.form.DashBoardLegacy');
instance.web.form.tags.add('board', 'instance.web.form.DashBoard');
/*
* ConfigOverview
* This client action designed to be used as a dashboard widget display
* ir.actions.todo in a fancy way
*/
openerp.web.client_actions.add( 'board.config.overview', 'openerp.web_dashboard.ConfigOverview');
openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({
instance.web.client_actions.add( 'board.config.overview', 'instance.web_dashboard.ConfigOverview');
instance.web_dashboard.ConfigOverview = instance.web.View.extend({
template: 'ConfigOverview',
init: function (parent) {
this._super(parent);
this.user = _.extend(new openerp.web.DataSet(this, 'res.users'), {
this.user = _.extend(new instance.web.DataSet(this, 'res.users'), {
index: 0,
ids: [this.session.uid]
});
this.dataset = new openerp.web.DataSetSearch(this, 'ir.actions.todo');
this.dataset = new instance.web.DataSetSearch(this, 'ir.actions.todo');
},
start: function () {
var self = this;
@ -363,15 +363,15 @@ openerp.web_dashboard.ConfigOverview = openerp.web.View.extend({
* This client action designed to be used as a dashboard widget display
* the html content of a res_widget given as argument
*/
openerp.web.client_actions.add( 'board.home.widgets', 'openerp.web_dashboard.Widget');
openerp.web_dashboard.Widget = openerp.web.View.extend(/** @lends openerp.web_dashboard.Widgets# */{
instance.web.client_actions.add( 'board.home.widgets', 'instance.web_dashboard.Widget');
instance.web_dashboard.Widget = instance.web.View.extend(/** @lends instance.web_dashboard.Widgets# */{
template: 'HomeWidget',
/**
* Initializes a "HomeWidget" client widget: handles the display of a given
* res.widget objects in an OpenERP view (mainly a dashboard).
*
* @constructs openerp.web_dashboard.Widget
* @extends openerp.web.View
* @constructs instance.web_dashboard.Widget
* @extends instance.web.View
*
* @param {Object} parent
* @param {Object} options
@ -382,7 +382,7 @@ openerp.web_dashboard.Widget = openerp.web.View.extend(/** @lends openerp.web_da
this.widget_id = options.widget_id;
},
start: function () {
var ds = new openerp.web.DataSet(this, 'res.widget');
var ds = new instance.web.DataSet(this, 'res.widget');
return ds.read_ids([this.widget_id], ['title']).then(this.on_widget_loaded);
},
on_widget_loaded: function (widgets) {
@ -401,8 +401,8 @@ openerp.web_dashboard.Widget = openerp.web.View.extend(/** @lends openerp.web_da
* HomeTiles this client action display either the list of application to
* install (if none is installed yet) or a list of root menu items
*/
openerp.web.client_actions.add('default_home', 'session.web_dashboard.ApplicationTiles');
openerp.web_dashboard.ApplicationTiles = openerp.web.OldWidget.extend({
instance.web.client_actions.add('default_home', 'session.web_dashboard.ApplicationTiles');
instance.web_dashboard.ApplicationTiles = instance.web.OldWidget.extend({
template: 'web_dashboard.ApplicationTiles',
init: function(parent) {
this._super(parent);
@ -410,7 +410,7 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.OldWidget.extend({
start: function() {
var self = this;
var domain = [['application','=',true], ['state','=','installed'], ['name', '!=', 'base']];
var ds = new openerp.web.DataSetSearch(this, 'ir.module.module',{},domain);
var ds = new instance.web.DataSetSearch(this, 'ir.module.module',{},domain);
ds.read_slice(['id']).then(function(result) {
if(result.length) {
self.on_installed_database();
@ -420,17 +420,17 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.OldWidget.extend({
});
},
on_uninstalled_database: function() {
installer = new openerp.web_dashboard.ApplicationInstaller(this);
installer = new instance.web_dashboard.ApplicationInstaller(this);
installer.appendTo(this.$element);
},
on_installed_database: function() {
var self = this;
self.rpc('/web/menu/get_user_roots', {}).then(function (menu_ids) {
var menuds = new openerp.web.DataSet(this, 'ir.ui.menu',{})
var menuds = new instance.web.DataSet(this, 'ir.ui.menu',{})
.read_ids(menu_ids, ['name', 'web_icon_data', 'web_icon_hover_data', 'module']).then(function (applications) {
var tiles = QWeb.render('ApplicationTiles.content', {applications: applications});
$(tiles).appendTo(self.$element).find('.oe_install-module-link').click(function () {
openerp.webclient.menu.on_menu_click(null, $(this).data('menu'))
instance.webclient.menu.on_menu_click(null, $(this).data('menu'))
});
});
});
@ -441,13 +441,13 @@ openerp.web_dashboard.ApplicationTiles = openerp.web.OldWidget.extend({
* ApplicationInstaller
* This client action display a list of applications to install.
*/
openerp.web.client_actions.add( 'board.application.installer', 'openerp.web_dashboard.ApplicationInstaller');
openerp.web_dashboard.ApplicationInstaller = openerp.web.OldWidget.extend({
instance.web.client_actions.add( 'board.application.installer', 'instance.web_dashboard.ApplicationInstaller');
instance.web_dashboard.ApplicationInstaller = instance.web.OldWidget.extend({
template: 'web_dashboard.ApplicationInstaller',
start: function () {
// TODO menu hide
var r = this._super();
this.action_manager = new openerp.web.ActionManager(this);
this.action_manager = new instance.web.ActionManager(this);
this.action_manager.appendTo(this.$element.find('.oe_installer'));
this.action_manager.do_action({
type: 'ir.actions.act_window',

View File

@ -2,12 +2,12 @@
* OpenERP diagram library
*---------------------------------------------------------*/
openerp.web_diagram = function (openerp) {
var QWeb = openerp.web.qweb,
_t = openerp.web._t,
_lt = openerp.web._lt;
openerp.web.views.add('diagram', 'openerp.web.DiagramView');
openerp.web.DiagramView = openerp.web.View.extend({
openerp.web_diagram = function (instance) {
var QWeb = instance.web.qweb,
_t = instance.web._t,
_lt = instance.web._lt;
instance.web.views.add('diagram', 'instance.web.DiagramView');
instance.web.DiagramView = instance.web.View.extend({
display_name: _lt('Diagram'),
searchable: false,
init: function(parent, dataset, view_id, options) {
@ -194,7 +194,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
if(!confirm(_t("Deleting this node cannot be undone.\nIt will also delete all connected transitions.\n\nAre you sure ?"))){
return $.Deferred().reject().promise();
}
return new openerp.web.DataSet(self,self.node).unlink([cutenode.id]);
return new instance.web.DataSet(self,self.node).unlink([cutenode.id]);
};
CuteEdge.double_click_callback = function(cuteedge){
self.edit_connector(cuteedge.id);
@ -212,7 +212,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
if(!confirm(_t("Deleting this transition cannot be undone.\n\nAre you sure ?"))){
return $.Deferred().reject().promise();
}
return new openerp.web.DataSet(self,self.connector).unlink([cuteedge.id]);
return new instance.web.DataSet(self,self.connector).unlink([cuteedge.id]);
};
},
@ -221,7 +221,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
edit_node: function(node_id){
var self = this;
var title = _t('Activity');
var pop = new openerp.web.form.FormOpenPopup(self);
var pop = new instance.web.form.FormOpenPopup(self);
pop.show_element(
self.node,
@ -254,7 +254,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
add_node: function(){
var self = this;
var title = _t('Activity');
var pop = new openerp.web.form.SelectCreatePopup(self);
var pop = new instance.web.form.SelectCreatePopup(self);
pop.select_element(
self.node,
{
@ -286,7 +286,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
edit_connector: function(connector_id){
var self = this;
var title = _t('Transition');
var pop = new openerp.web.form.FormOpenPopup(self);
var pop = new instance.web.form.FormOpenPopup(self);
pop.show_element(
self.connector,
parseInt(connector_id,10), //FIXME Isn't connector_id supposed to be an int ?
@ -305,7 +305,7 @@ openerp.web.DiagramView = openerp.web.View.extend({
add_connector: function(node_source_id, node_dest_id, dummy_cuteedge){
var self = this;
var title = _t('Transition');
var pop = new openerp.web.form.SelectCreatePopup(self);
var pop = new instance.web.form.SelectCreatePopup(self);
pop.select_element(
self.connector,