summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/view_manager.js
AgeCommit message (Collapse)Author
2016-04-21[REF] web: stop duplicating webAaron Bohy
Avoid duplicating web addon in enterprise by extracting a common basis. Enterprise features stay in enterprise, but use that common basis. Mainly: - JS refactoring and linting - Conversion of .sass into .less split into multiple files - Templates cleaning and DOM simplification - Re-generation of web.pot, and update of .po files
2016-03-18[IMP] openerp,web: cache of actions, fields(_views) and filtersAaron Bohy
Introduction of 'data_manager' service which handles meta-data related to actions and views (fields_views, fields and filters). Ideally, all RPCs to get that kind of information should go through data_manager, as it holds an internal cache.
2016-03-18[IMP] openerp, web(_*): batch views RPCsAaron Bohy
Load the fields_view of all views of the action together. If a searchview is required, also load its fields_view and its filters. Use lazy-loading for fields as they are required for the Pivot and Graph views only, and may be used by Filters and GroupBy menus of the Search view if the users clicks on 'Add a custom Filter/Group'. The fields are thus also loaded directly if the first view of the action is Pivot or Graph, and otherwise, they are lazy-loaded when/if the user opens a Pivot or Graph view, or if he wants to add a custom Filter/Group. Some refactoring of views API as well: - Views must now be instantiated with their fields_view - Move code requiring fields_view from start() to init(), or willStart() for heavy processing. - Remove view_type attribute from views as it was used to call fields_view_get. - Remove view_id parameter to views' init as it is no longer used. - Move duplicate code from various views' init to the View widget. - Remove view_loading() function from views as they now follow the classical lifecycle of widgets (init -> willStart -> start -> destroy). - Searchview now extends View like all other views. - Remove useless function guard_active() as it was used for the form_view's action buttons to wrap handlers to ensure that they are executed only if the form_view is the current active view. This is not useful anymore as from v9, views and their control panel are appended in the DOM simultaneously, so one can't click on a button of a view which is not the current active view.
2016-03-09[IMP] board,web: view_manager: lazy loading of default multi-record viewAaron Bohy
After a refresh or when opening odoo in a new tab, if view_type="form" is specified in the url, RPCs to load the default multi-record view will be performed if/when the user clicks on the breadcrumbs. Moreover, the view manager is directly initialized with the res_id to load after a refresh on a form view, to prevent the form view to fetch the defaults values, to render in 'create' more, and then load the requested record and switch back to 'view' mode. Some code refactoring as well: - don't propagate state to the view_manager, but directly the view_type and res_id - remove unused argument no_store from switch_mode() - view_registry.get(): remove unused second argument - no need to switch_mode in do_load_state() as the correct mode is now loaded directly, even if it is a mono-record view Also adapt code in dashboard.js according to changes in view_manager.
2016-03-09[REF] web: view_manager's initAaron Bohy
Always initialize a view_manager with its dataset and views, but without the action (at least explicitely, as the action might still be given within the options). This is a backport of changes in enterprise to keep the view_manager's API similar in both repository, which is required the large refactoring that will arrive.
2016-02-29[FIX] web(_*): views: render action buttons in dialogsAaron Bohy
Commit 516b1a6c72dde46f3f0c7d4f86a9b8265b4153a1 fixes a bug with action buttons not being displayed when they should in dialogs. However, it makes the assumption that either $node or this.options.$buttons exist, which is not always the case (e.g. dashboard). This rev. moves that logic out of the views to the view_manager, and protects the call of empty() on this.options.$buttons.
2016-01-18[FIX] web: view manager: overlapping switches between viewsAaron Bohy
The problem occured when the user quickly clicked several times on the view switcher or the breadcrumbs. The function switch_mode() of the view manager was called once per click. This function's role is to prepare the requested view, and once it is ready, to remove the former one from the DOM and insert the new one instead. It is thus asynchronous as it waits for the fields_view_get and search_read RPCs' response. Unfortunately, when those calls to switch_mode() overlapped, the former view reference was lost and it was thus never removed, producing a weird situation where two views were displayed one above the other. This may happen when a view takes a while to load, or simply when the user double-clicks on the breadcrumbs or view switcher. This rev. makes sure that calls to switch_mode() can never overlap by refusing any other call when there is still one processing. We also added a protection against breadcrumbs and view switcher double-clicks. opw 658924
2016-01-18[FIX] web: view_manager: restore internal state on switch view failureAaron Bohy
When an error occured when switching from a view to another (e.g. switching to a form view for an id that doesn't exist, by editing the url), active_view and view_stack were updated even though the switch failed. The view manager thus lost the reference to the real current active view, which couldn't be detached anymore. This resulted in two views being displayed at the same time if the user kept navigating through this view manager. This is a backport of odoo/enterprise@0b1aafa6b and odoo/enterprise@8e691be.
2016-01-05[FIX] web: refresh in form view when first view mode is calendarMohammed Shekha
When you are in form view and came from calendar, a screen refresh throwed an error from fullcalendar lib. Also when going back to the calendar view, it would not be loaded. It is due to fullcalendar not being rendered if it is not visible, and other part of the Odoo code are dependent on it having been rendered. This commit hide the calendar after having been rendered. closes #10253 opw-659314
2015-10-13[FIX] web: view_manager: correctly return rejected deferredAaron Bohy
The problem was that the action manager wasn't notified at all when something went wrong with the view manager as the deferred returned by appendTo was in that case never resolved nor rejected.
2015-09-03[FIX] web: view manager: sanitize typeSimon Lejeune
by ignoring the views which types aren't in the view registry
2015-08-28[IMP] web: add attribute searchview_hidden to views.Martin Geubelle
This attribute can be used when the view needs a searchview but wants it to be hidden.
2015-08-07[REF] web(_*): views: view_switcher iconAaron Bohy
Add a key icon in the view's prototype corresponding to the font-awesome icon to display in the view switcher.
2015-07-30[FIX] web: view_manager: update control panel on title changeAaron Bohy
only if the control panel if visible. This fixes a bug on the settings view (form view), on which the control panel is hidden (the bar containing 'Apply' and 'Cancel' is unfortunately not a true control panel). When clicking on 'Apply', for some weird reason, the event 'change:title' is triggered and the control panel is updated with the new title ('New'). However, as the flags hidden isn't mentionned, the control panel visibility is toggled.
2015-07-23[IMP] web(_kanban): accesskeys for switch buttonsAaron Bohy
More elegant solution to add accesskeys on switch buttons for list, kanban and form views.
2015-07-15[IMP] web: trigger an event when webclient is readyAaron Bohy
The main purpose of this commit is to be consistent with the enterprise edition, in which the event 'DOM_updated' is triggered when new content is inserted in the DOM. This way, addons that need to know when a view has been attached in the DOM (e.g. web_tip) can listen to this event and will work fine with both editions of the web addon. With the actual structure of the webclient (action_manager, view_manager), there is no easy way to decide whether or not a view is attached in the DOM, because every rendering is performed in a detached element. For instance, when a view_manager instantiates a new view, it appends it in its $el once the view is ready, but it can't know if its $el is attached in the DOM (it is only the case if the view_manager is the current action of the action manager). This rev. introduces utility functions to centralize the appending/prepending of content, so that an event can be triggered (at a unique place) when the content is really in the DOM. These functions are used by the the action_manager and the view_manager. Another change is that the action_manager keeps the view_manager informed when they are attached in/detached from the DOM, through the variable is_in_DOM.
2015-07-10[IMP] web: split model.js into model.js and data_model.js. Web js modules ↵Christophe Matthieu
must call web.DataModel.
2015-07-07[REF] web: ControlPanelAaron Bohy
Adds the option clear so that, if set to false, only some elements of the control panel can be updated while keeping the other ones unchanged. The breadcrumbs can then be updated by simply calling update_control_panel(), instead of triggering a specific event to do it. A bit of documentation and refactoring as well, mainly for the breadcrumbs to be handled as other control panel's elements.
2015-06-25[MERGE] forward port of branch saas-6 up to 81b5c60Christophe Simonis
2015-06-17[IMP] web, web_*, mail, board : New modals and dialogsqsm-odoo
2015-06-16[FIX] web: view_manager: instantiate sidebar before calling do_showAaron Bohy
In google_drive, the sidebar is extended and listens to the event load_record triggered when do_show of form_view is performed. The sidebar should thus be instantiated before calling do_show, otherwise the gdrive button is not available for the first record displayed in a form_view.
2015-04-03[FIX] web: don't crash when switching views in firefoxGéry Debongnie
For some weird reasons, IE and Chrome (or jquery?) bind the global variable 'event' to the last triggered event (I guess). Of course, our code depended on that behavior, but Firefox does not like it and crashes when we try to read the 'event' variable. This fix simply gets the variable as first argument.
2015-03-24[IMP] Web, Web_diagram: better integration of the Diagram viewAaron Bohy
The 'New node' button is inserted in the ControlPanel. Breadcrumbs are now handled as well. The 'multi_record' flag has been added to the views to distinguish views displaying several records, like the List view, from views displaying a single record like the Form view and the Diagram view. This flag is used by the ViewManager to manage its view stack. Fixes the breadcrumb bug when switching between Form view and Diagram view (the last element of the view stack is now replaced by the new one in that case).
2015-03-20[ADD] Web: ControlPanelMixinAaron Bohy
Creation of the ControlPanelMixin that should be used by widgets needing a ControlPanel. It facilitates the way those widgets communicate with the ControlPanel to update it according to their status. From now on, client action widgets can easily use the main ControlPanel.
2015-03-20[IMP] Web: Use of a ControlPanel in One2Many FieldsAaron Bohy
Creation of the One2ManyControlPanel template. The One2ManyControlPanel can only contain action_buttons and a pager. Typically, in One2Many Kanban, buttons are displayed (in edit mode) and in One2Many Lists, the pager is displayed. Improvement of all Views.buttons templates so that if there is no button to render, it does not render an empty div. This was necessary for Kanban buttons to prevent padding when there is no button displayed. Changes in the other views were motivated by uniformity concerns. This prevents to add empty div in the DOM as well. Exception for FormView where the outer div is required for the option footer_to_buttons to work. This fixes a bug as the pager is now available in One2Many Lists, which was not the case before, even if there were more than 80 items in the list, i.e. some items were unreachable. cp_bus argument in ViewManager init() is now required. If there is no ControlPanel to communicate with, a dummy Bus should be given ot the ViewManager.
2015-03-20[REF] Web: Actions, ActionManager, ViewManager, Controlpanel refactoringAaron Bohy
Big refactoring of Action, WidgetAction and ViewManagerAction to clean their API. Mainly, renamming from State to Action and removal of unused functions (or functions that are only used by the DebugManager, for which we tolerate introspection). Some logic has also been moved from the ActionManager to the Actions themselves. The specific behavior of each type of Action is now handled in the implementation of those Actions. In ActionManager, this.states is renammed to this.action_stack to be consistent with view_stack in ViewManager. The setup_search_view() and render_switch_buttons() functions have been moved from ControlPanel to ViewManager as it was before, since actual design allows it and it makes more sense. The ControlPanel API has also been simplified as some functions were not used anymore. The ControlPanel is now updated directly by the widgets using it, bypassing the ActionManager. The control panel elements are stored by the widgets themselves to allow restoring them later.
2015-03-20[IMP] Web and all views: ControlPanel atomic updateAaron Bohy
Change the logic of rendering and displaying/hidding the control elements (buttons, sidebar and pager) of all views. The views do no more render automatically their elements as this is rather done through the render_[element] function called by the ViewManager. This function only appends the element to the $node given as argument. If no argument is given, then it may appends it to the DOM directly, within the adequate div of its template. This allows the ViewManager to attach/detach all elements of the ControlPanel in an atomic may, to prevent the ControlPanel from flickering. Also detach the contents of the ControlPanel in headless mode. Headless means that the ControlPanel exists, but is hidden. Detaching its contents permits to have a cleaner DOM. Also remove the oe_form_dirty class on the buttons in the FormView, as this class is only used on the view itself. Side changes: * base_import: import.js: Extend render_buttons function to be compliant with the new buttons rendering logic * board: dashboard.js: Set flag search_view to True as the searchview is needed for the Views displayed in the Dashboard to retrieve the records to display. Necessary since we do no more construct the searchview when this is set to false * google_drive: drive.js, share: share.js: Module extending the Sidebar widget often add their own buttons by extending the start(), which is called each time the Widget is appended to the DOM. With our new design, this could be done in start() anymore as it should be done only one. It is now done in init() instead.
2015-03-20[IMP] Web: views.js, view_editor.js: DebugManagerAaron Bohy
Creation of a widget for the DebugManager and move it from the ControlPanel to the Systray. Refactoring of the widget to improve/facilitate the way of adding options in the DebugManager as the view_editor does. Add a do_action() function in the WebClient that forwards the action to the main ActionManager so that widget that are not in the scope of the ActionManager (e.g. Menu) can performed actions as well. Note: The DebugManager is currently in the Systray but it will finally be moved to a dedicated spot above the ControlPanel.
2015-03-20[IMP] Web et al.: unique main ControlPanelAaron Bohy
A unique main ControlPanel is instantiated by the ActionManager and it is updated each time the state changes (i.e. when an action is performed on the ActionManager or when switch_mode() is called on the ViewManager). Introduction of State classes to facilitate the way of restoring previously rendered states in ControlPanel. The notion of widgets previously used in the ActionManager is now encapsulated in the notion of states. The search() function has been moved from ControlPanel to ViewManager as it makes more sense like this. The ViewManager doesn't have the reference to the ControlPanel but rather communicate with it through a dedicated bus. Some refactoring has been done on the ControlPanel as well so that it doesn't need to know the ActionManager and the current Action anymore (it communicates with the AM with events, and it updates itself using information passed in arguments). Improves the way the ViewManager requests the ControlPanel to instantiate a SearchView, and how it waits for this SearchView to be corretly loaded. Move back the views logic to the ViewManager which directly asks the ControlPanel to render the buttons and switch-buttons areas with the views passed in arguments. Removes option replace_breadcrumb in push_state() of ActionManager as it is not used. Side changes: * Account: account_widget.js: Adapt code to retrieve the current state of the ActionManager. Required due to the introduction of State classes that encapsulate the notions of widgets and inner_widget in the ActionManager. * Board: dashboard.js: Some refactoring to adapt the code according to the new Widgets structure. Several dependencies (e.g. searchview, action) were unnecessary. Do not append the "add to dashboard" option to the Favorite menu if there is no ViewManager available (e.g. in Messaging) instead of hidding it with a CSS rule, as a ViewManager required to retrieve the active_view. * Google_spreadsheet: search.js: Change the way to retrieve the list_view_id s.t. it does not rely on parent of the SearchView anymore. * Web: search.js: Change the way to retrieve the title in search.js for Favorites s.t. it does not rely on the parent of the SearchView anymore. Doing so, the ControlPanel does not need the title attribute anymore.
2015-03-20[IMP] Web et al.: ControlPanel extracted from ViewManagerAaron Bohy
The ControlPanel is still instantiated by the ViewManager. Changes details: * web: views.js: Code related to views header is extracted from the ViewManager to a new Widget named ControlPanel. Also uses the headless flag to tell the inner view not to put its buttons (use case: kanban) or pager (use case: list) in the header as it is hidden. * web: view_form.js, base.xml: Uses the headless flag at initialization of the One2ManyViewManager widget instead of extending the ViewManager template (which doesn't handle the header anymore). * web: view_list.js: Test on this.options.$pager instead of this.options.$buttons when dealing with pager. Note: the behavior for list view is unchanged and has a bug. If there are more then 80 records to display, only the 80th first are display, and as there is no pager, there is no way to see the remaining ones. A fix for this would be to use a light ControlPanel in One2Many views as well. With this, there won't be duplicated .oe-'view'-buttons/sidebar/pager anymore. * web: view_graph.js, view_pivot.js: Only render buttons in non-headless mode * web_dashboard: dashboard.js: Fix some references that were broken with ControlPanel extraction * web_view_editor: web_view_editor.js: Extend ControlPanel instead of ViewManager * Changes in selector of ControlPanel elements in several addons: * base_import * mail * web
2015-03-18[IMP] web+addons: improvement to module systemGéry Debongnie
The module system needs to know the dependencies of a given module before executing the function. This is why the dependencies were defined once in an array, and then were described one more times in the call to require. But a trick can simplify this: the boot function can parse the string representation of the module and extract the calls to require from it. It is more work for the processor, but it leads to simpler module definitions.
2015-03-18[REF] web: add module system to the web clientGéry Debongnie
This commit introduces a new module system for the javascript code. Instead of using global (namespaced) variables everywhere (like openerp.web.whatever, ...), each file declare one (or more) module with its dependencies. Each module will be loaded after its dependencies, and will be given a reference to the return values. This change is a massive departure from the way the client worked previously. It will sadly break some/most history, but I am sure that the future git ecosystem will allow you to easily browse the history past this revision (one can dream). This commit feature: * main namespace is now odoo instead of openerp * a way to define modules and dependencies (inspired by requirejs) * many files have been splitted in simpler subfiles * basic support for debugging in odoo.__DEBUG__ * no global variable (i.e. nothing in window.openerp) * many bug fixes, many new bugs Future vision: this modularization should simplify future code development, simplify debugging and will allow a serious testing effort