1 Adding a sidebar to a view
2 ==========================
7 Each view has the responsibility to create its sidebar (or not) if and only if
8 the ``sidebar`` flag is set in its options.
10 In that case, it should use the ``sidebar_id`` value (from its options) to
11 initialize the sidebar at the right position in the DOM:
13 .. code-block:: javascript
15 if (this.options.sidebar && this.options.sidebar_id) {
16 this.sidebar = new openerp.web.Sidebar(this, this.options.sidebar_id);
20 Because the sidebar is an old-style widget, it must be started after being
23 Sidebar communication protocol
24 ------------------------------
26 In order to behave correctly, a sidebar needs informations from its parent
29 This information is extracted via a very basic protocol consisting of a
30 property and two methods:
32 .. js:attribute:: dataset
34 the view's dataset, used to fetch the currently active model and provide it
35 to remote action handlers as part of the basic context
37 .. js:function:: get_selected_ids()
39 Used to query the parent view for the set of currently available record
40 identifiers. Used to setup the basic context's ``active_id`` and
45 :js:func:`get_selected_ids` must return at least one id
47 :returns: an array of at least one id
50 .. js:function:: sidebar_context()
52 Queries the view for additional context data to provide to the sidebar.
54 :js:class:`~openerp.base.View` provides a default NOOP implementation,
55 which simply resolves to an empty object.
57 :returns: a promise yielding an object on success, this object is mergeed
58 into the sidebar's own context
59 :rtype: $.Deferred<Object>
61 Programmatic folding and unfolding
62 ----------------------------------
64 The sidebar object starts folded. It provides three methods to handle its
67 .. js:function:: do_toggle
69 Toggles the status of the sidebar
71 .. js:function:: do_fold
73 Forces the sidebar closed if it's currently open
75 .. js:function:: do_unfold
77 Forces the sidebar open if it's currently closed