common view class
bzr revid: al@openerp.com-20110511144910-09jk4zrl00msgh93
This commit is contained in:
parent
e1fea6060a
commit
c72aa9bd1c
|
@ -24,10 +24,10 @@
|
||||||
<script type="text/javascript" src="/base/static/src/js/dates.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/dates.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/chrome.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/chrome.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/data.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/data.js"></script>
|
||||||
|
<script type="text/javascript" src="/base/static/src/js/views.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/form.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/form.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/list.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/list.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/search.js"></script>
|
<script type="text/javascript" src="/base/static/src/js/search.js"></script>
|
||||||
<script type="text/javascript" src="/base/static/src/js/views.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css" />
|
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui/css/smoothness/jquery-ui-1.8.9.custom.css" />
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui.notify/css/ui.notify.css" />
|
<link rel="stylesheet" type="text/css" media="screen" href="/base/static/lib/jquery.ui.notify/css/ui.notify.css" />
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
openerp.base.form = function (openerp) {
|
openerp.base.form = function (openerp) {
|
||||||
|
|
||||||
openerp.base.views.add('form', 'openerp.base.FormView');
|
openerp.base.views.add('form', 'openerp.base.FormView');
|
||||||
openerp.base.FormView = openerp.base.Controller.extend( /** @lends openerp.base.FormView# */{
|
openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormView# */{
|
||||||
/**
|
/**
|
||||||
* Indicates that this view is not searchable, and thus that no search
|
* Indicates that this view is not searchable, and thus that no search
|
||||||
* view should be displayed (if there is one active).
|
* view should be displayed (if there is one active).
|
||||||
|
@ -365,7 +365,8 @@ openerp.base.form.compute_domain = function(expr, fields) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _.indexOf(stack, false) == -1;
|
return _.indexOf(stack, false) == -1;
|
||||||
},
|
}
|
||||||
|
|
||||||
openerp.base.form.Widget = openerp.base.Controller.extend({
|
openerp.base.form.Widget = openerp.base.Controller.extend({
|
||||||
init: function(view, node) {
|
init: function(view, node) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
@ -532,7 +533,7 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
||||||
on_confirmed: function() {
|
on_confirmed: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.execute_action(
|
this.view.execute_action(
|
||||||
this.node.attrs, this.view.dataset, this.session.action_manager,
|
this.node.attrs, this.view.dataset, this.session.action_manager,
|
||||||
this.view.datarecord.id, function (result) {
|
this.view.datarecord.id, function (result) {
|
||||||
self.log("Button returned", result);
|
self.log("Button returned", result);
|
||||||
|
@ -540,9 +541,6 @@ openerp.base.form.WidgetButton = openerp.base.form.Widget.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// let WidgetButton execute actions
|
|
||||||
_.extend(openerp.base.form.WidgetButton.prototype,
|
|
||||||
openerp.base.ActionExecutor);
|
|
||||||
|
|
||||||
openerp.base.form.WidgetLabel = openerp.base.form.Widget.extend({
|
openerp.base.form.WidgetLabel = openerp.base.form.Widget.extend({
|
||||||
init: function(view, node) {
|
init: function(view, node) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
openerp.base.list = function (openerp) {
|
openerp.base.list = function (openerp) {
|
||||||
openerp.base.views.add('list', 'openerp.base.ListView');
|
openerp.base.views.add('list', 'openerp.base.ListView');
|
||||||
openerp.base.ListView = openerp.base.Controller.extend(
|
openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListView# */ {
|
||||||
/** @lends openerp.base.ListView# */ {
|
|
||||||
defaults: {
|
defaults: {
|
||||||
// records can be selected one by one
|
// records can be selected one by one
|
||||||
'selectable': true,
|
'selectable': true,
|
||||||
|
@ -361,10 +360,7 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
||||||
}
|
}
|
||||||
// TODO: implement reorder (drag and drop rows)
|
// TODO: implement reorder (drag and drop rows)
|
||||||
});
|
});
|
||||||
_.extend(openerp.base.ListView.prototype, openerp.base.ActionExecutor);
|
openerp.base.ListView.List = Class.extend( /** @lends openerp.base.ListView.List# */{
|
||||||
|
|
||||||
openerp.base.ListView.List = Class.extend(
|
|
||||||
/** @lends openerp.base.ListView.List# */{
|
|
||||||
/**
|
/**
|
||||||
* List display for the ListView, handles basic DOM events and transforms
|
* List display for the ListView, handles basic DOM events and transforms
|
||||||
* them in the relevant higher-level events, to which the list view (or
|
* them in the relevant higher-level events, to which the list view (or
|
||||||
|
@ -476,8 +472,7 @@ openerp.base.ListView.List = Class.extend(
|
||||||
// drag and drop
|
// drag and drop
|
||||||
// editable?
|
// editable?
|
||||||
});
|
});
|
||||||
openerp.base.ListView.Groups = Class.extend(
|
openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Groups# */{
|
||||||
/** @lends openerp.base.ListView.Groups# */{
|
|
||||||
/**
|
/**
|
||||||
* Grouped display for the ListView. Handles basic DOM events and interacts
|
* Grouped display for the ListView. Handles basic DOM events and interacts
|
||||||
* with the :js:class:`~openerp.base.DataGroup` bound to it.
|
* with the :js:class:`~openerp.base.DataGroup` bound to it.
|
||||||
|
@ -525,9 +520,6 @@ openerp.base.ListView.Groups = Class.extend(
|
||||||
return this.make_level(this.datagroup);
|
return this.make_level(this.datagroup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
openerp.base.TreeView = openerp.base.Controller.extend({
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||||
|
|
|
@ -70,63 +70,6 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Mixin for action-executing objects, provides handling of OpenERP actions to
|
|
||||||
* all clients.
|
|
||||||
*
|
|
||||||
* Mix into existing classes via ``_.extend`` of the class's prototype.
|
|
||||||
*
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
openerp.base.ActionExecutor =
|
|
||||||
/**
|
|
||||||
* @lends openerp.base.ActionExecutor#
|
|
||||||
*/ {
|
|
||||||
/**
|
|
||||||
* Fetches and executes the action identified by ``action_data``.
|
|
||||||
*
|
|
||||||
* @param {Object} action_data the action descriptor data
|
|
||||||
* @param {String} action_data.name the action name, used to uniquely identify the action to find and execute it
|
|
||||||
* @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``)
|
|
||||||
* @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'``
|
|
||||||
* @param {Object} [action_data.context=null] additional action context, to add to the current context
|
|
||||||
* @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server
|
|
||||||
* @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched
|
|
||||||
* @param {Number} [record_id] the identifier of the object on which the action is to be applied
|
|
||||||
* @param {Function} on_no_action callback to execute if the action does not generate any result (no new action)
|
|
||||||
*/
|
|
||||||
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
|
||||||
var handler = function (r) {
|
|
||||||
if (r.result && r.result.constructor == Object) {
|
|
||||||
action_manager.do_action(r.result);
|
|
||||||
} else {
|
|
||||||
on_no_action(r.result);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (action_data.special) {
|
|
||||||
handler({
|
|
||||||
result : { type: 'ir.actions.act_window_close' }
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var context = _.extend({}, dataset.context, action_data.context || {});
|
|
||||||
switch(action_data.type) {
|
|
||||||
case 'object':
|
|
||||||
return dataset.call(action_data.name, [record_id], [context], handler);
|
|
||||||
case 'action':
|
|
||||||
return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10) }, handler);
|
|
||||||
default:
|
|
||||||
return dataset.exec_workflow(record_id, action_data.name, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registry for all the main views
|
|
||||||
*/
|
|
||||||
openerp.base.views = new openerp.base.Registry();
|
|
||||||
|
|
||||||
openerp.base.ViewManager = openerp.base.Controller.extend({
|
openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||||
init: function(session, element_id, dataset, views) {
|
init: function(session, element_id, dataset, views) {
|
||||||
this._super(session, element_id);
|
this._super(session, element_id);
|
||||||
|
@ -367,64 +310,51 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
openerp.base.views.add('calendar', 'openerp.base.CalendarView');
|
openerp.base.View = openerp.base.Controller.extend({
|
||||||
openerp.base.CalendarView = openerp.base.Controller.extend({
|
/**
|
||||||
start: function () {
|
* Fetches and executes the action identified by ``action_data``.
|
||||||
this._super();
|
*
|
||||||
this.$element.append('Calendar view');
|
* @param {Object} action_data the action descriptor data
|
||||||
},
|
* @param {String} action_data.name the action name, used to uniquely identify the action to find and execute it
|
||||||
do_show: function () {
|
* @param {String} [action_data.special=null] special action handlers (currently: only ``'cancel'``)
|
||||||
this.$element.show();
|
* @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'``
|
||||||
},
|
* @param {Object} [action_data.context=null] additional action context, to add to the current context
|
||||||
do_hide: function () {
|
* @param {openerp.base.DataSet} dataset a dataset object used to communicate with the server
|
||||||
this.$element.hide();
|
* @param {openerp.base.ActionManager} action_manager object able to actually execute the action, if any is fetched
|
||||||
|
* @param {Number} [record_id] the identifier of the object on which the action is to be applied
|
||||||
|
* @param {Function} on_no_action callback to execute if the action does not generate any result (no new action)
|
||||||
|
*/
|
||||||
|
execute_action: function (action_data, dataset, action_manager, record_id, on_no_action) {
|
||||||
|
var handler = function (r) {
|
||||||
|
if (r.result && r.result.constructor == Object) {
|
||||||
|
action_manager.do_action(r.result);
|
||||||
|
} else {
|
||||||
|
on_no_action(r.result);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (action_data.special) {
|
||||||
|
handler({
|
||||||
|
result : { type: 'ir.actions.act_window_close' }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var context = _.extend({}, dataset.context, action_data.context || {});
|
||||||
|
switch(action_data.type) {
|
||||||
|
case 'object':
|
||||||
|
return dataset.call(action_data.name, [record_id], [context], handler);
|
||||||
|
case 'action':
|
||||||
|
return this.rpc('/base/action/load', { action_id: parseInt(action_data.name, 10) }, handler);
|
||||||
|
default:
|
||||||
|
return dataset.exec_workflow(record_id, action_data.name, handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
openerp.base.views.add('gantt', 'openerp.base.GanttView');
|
|
||||||
openerp.base.GanttView = openerp.base.Controller.extend({
|
|
||||||
start: function () {
|
|
||||||
this._super();
|
|
||||||
this.$element.append('Gantt view');
|
|
||||||
},
|
|
||||||
do_show: function () {
|
|
||||||
this.$element.show();
|
|
||||||
},
|
|
||||||
do_hide: function () {
|
|
||||||
this.$element.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
openerp.base.views.add('tree', 'openerp.base.TreeView');
|
|
||||||
openerp.base.TreeView = openerp.base.Controller.extend({
|
|
||||||
/**
|
/**
|
||||||
* Genuine tree view (the one displayed as a tree, not the list)
|
* Registry for all the main views
|
||||||
*/
|
*/
|
||||||
start: function () {
|
openerp.base.views = new openerp.base.Registry();
|
||||||
this._super();
|
|
||||||
this.$element.append('Tree view');
|
|
||||||
},
|
|
||||||
do_show: function () {
|
|
||||||
this.$element.show();
|
|
||||||
},
|
|
||||||
do_hide: function () {
|
|
||||||
this.$element.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
openerp.base.views.add('graph', 'openerp.base.GraphView');
|
|
||||||
openerp.base.GraphView = openerp.base.Controller.extend({
|
|
||||||
start: function () {
|
|
||||||
this._super();
|
|
||||||
this.$element.append('Graph view');
|
|
||||||
},
|
|
||||||
do_show: function () {
|
|
||||||
this.$element.show();
|
|
||||||
},
|
|
||||||
do_hide: function () {
|
|
||||||
this.$element.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
openerp.base.ProcessView = openerp.base.Controller.extend({
|
openerp.base.ProcessView = openerp.base.Controller.extend({
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
'static/src/js/web_chat.js'
|
'static/src/js/web_chat.js'
|
||||||
],
|
],
|
||||||
"css": [],
|
"css": [],
|
||||||
|
# 'active': True,
|
||||||
'active': False,
|
'active': False,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue