summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/abstract_controller.js
AgeCommit message (Collapse)Author
2018-05-29[MERGE] forward port branch saas-11.2 up to a2f275dfc48Christophe Simonis
2018-05-28[FIX] web: Controller: concurrent control panel updatesAaron Bohy
Let's assume the following scenario: in a kanban view with a domain, remove that domain and quickly click on a record to open it in form view. On a slow network, it may happen that the reload of the kanban view (triggered by the domain change) returns after the load of the form view. Before this rev., when this happened, the form view was correctly displayed but the control panel contained the buttons, searchview, pager... of the kanban view. Note that this fix is quite ugly, but it won't be necessary anymore as soon as the control panel won't be shared between actions and controllers, i.e. as soon as each controller will have its own control panel.
2018-05-25[MERGE] forward port branch saas-11.2 up to 58e35522468Christophe Simonis
2018-05-25[MERGE] forward port branch 11.0 up to 2ca72960001Christophe Simonis
2018-05-25[FIX] web: AbstractController: handle concurrent reloadsAaron Bohy
Let's assume the following scenario in a Kanban view with a default filter. The user removes the filter, and quickly adds a new one. On a slow network, it may happen that the second reload request returns before the first one. On odoo.com, this is easy to reproduce on the tasks Kanban view. Before this rev., when this occured, the result of the first request was displayed, whereas it should have been ignored as another request was done later on.
2018-04-17[FIX] web: focus the search box in kanban viewVincent Schippefilt
Before this fix, the focus was not set when opening a kanban view After this fix, the focus is set on the search view (unless there is a quick create, in which case the focus will be on the quick create)
2018-04-16[MERGE] forward port branch 11.0 up to ad825b673b5Christophe Simonis
2018-04-11[FIX] web: graph rendering when in DOMAlexandre Kühn
Backported fixes: 1. [IMP] web: GraphView: remove hack to render in DOM - ref. 166319fa4a31c0105d786c1e8b8d0228ff45bd14 - fully backported. This commit backports the fix that removes the hack for rendering graphs (delay in a setTimeout), so that the graph is rendered when it is in the DOM. 2. [IMP] web: restore scroll position - ref. 4e204ed2233ccd36b2eb7d3e56bfa741b9cb3e14 - partially backported: only keeps `on_attach_callback` and `on_detach_callback` in the abstract_controller and in the abstract_renderer. This commit backports the use of the hooks methods `on_attach_callback` and `on_detach_callback` in abstract controller and renderer, so that the controller of any view warns the renderer when it has been attached in (or detach from) the DOM. Also, this commit adds `on_attach_callback` and `on_detach_callback` for the dashboard app, so that the graph view is correctly rendered. Fixes #24092
2018-04-10[IMP] web: keyboard navigation in kanban viewVincent Schippefilt
1. Added the ability to navigate within the kanban view using UP, DOWN, LEFT and RIGHT keys. 2. By defaults, the focus should be set on the search input field. 3. From the search input field, using the DOWN key, the focus goes to the first card of the kanban 4. From the search input field, using TAB key, the focus goes to the create button 5. From the create/import buttons, using TAB or DOWN key goes to the first card of the kanban, then UP and DOWN keys moves the focus from card to card in the same column or if it is not a grouped view from left to right. 6. In grouped view, LEFT and RIGHT keys moves the focus to the next column 7. When on a card, hitting ENTER opens the view of that card. Not included in this commit 1. Memorize the position on the kanban when opening an card, than restoring when going back to that kanban
2018-04-10[IMP] web: keyboard navigation in form viewVincent Schippefilt
1. Added the ability to navigate within the List view using UP and DOWN keys. 2. By defaults, the focus should be set on the search input field. 3. From the search input field, using the DOWN key, the focus goes to the list 4. From the search input field, using TAB key, the focus goes to the create button 5. From the create/import buttons, using TAB or DOWN key goes to the first row of the list, then UP and DOWN keys moves the focus from item to item in the list. 6. When on a row, hitting ENTER opens the view of that row. Also in this commit 1. When on the first row, hitting the UP key does nothing 2. When on the last row, hitting the DOWN key does nothing Not included in this commit 1. Memorize the position on the list when opening an row, than restoring when going back to that list 2. Navigation on grouped list using the keyboard
2018-03-21[MERGE] forward port branch saas-11.2 up to 500e3f49705Christophe Simonis
2018-03-19[FIX] web: search menus always availableAaron Bohy
Before this rev., the search menus (Filters, Group By, Favorites) were lost when the user came back to an action with the breadcrumbs (e.g. go to My pipeline, open a lead, click on the Meetings stat button, go back to My pipeline). This was because the two searchviews shared the same jQuery element containing their dropdowns. This behavior is there for a long time, but the bug has been revealed by 7b6056a0, which changes the way the action manager and controllers interact with the control panel. Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2018-03-10[IMP] web: restore scroll positionAaron Bohy
This rev. improves the way the scroll position is restored when coming back to a view (e.g. open a kanban view, scroll, click on a record to open it in a form view, go back to kanban using the breadcrumbs): - generalize the scroll position handling from web_enterprise to web to make it available in the community webclient as well - also restore left scroll position, not only top (especially useful for grouped Kanban views with a lot of columns) - handle the case where the scrolling area is a sub element of the view (e.g. the grouped Kanban view in mobile). Task 34037 Co-authored-by: Mohammed Shekha <msh@openerp.com> Co-authored-by: Ankit Sathvara <asa@odoo.com>
2018-03-08[REF] web,*: introduce the concept of AbstractActionGéry Debongnie
Before this commit, a client action was simply a subclass of Widget. This is quite simple, but not really enough for the ActionManager. The ActionManager needs to handle client actions in a different way that view actions. Sometimes, it needs to check if a method exists before calling it. With this commit, we introduce a new abstraction: the AbstractAction class, which defines a common API for all actions managed by the web client. Note that the API proposed in this commit is just the beginning. We will introduce other methods in the future, to manage the focus, or the scroll position, for example.
2018-01-25[IMP] web: hide group by option in search view for calendar viewPrakash Prajapati
2018-01-16[REF] web,*: ActionManager/ViewManager refactoringAaron Bohy
This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction.
2017-07-27[FIX] web,*: display dashboard panel if no contentAaron Bohy
*board,crm Before this rev., the dashboard panel (e.g. of the sales team dashboard) wasn't displayed when there were no record to display, whereas it should. Only the nocontent helper was displayed. This was a bug introduced with the new view: the views' controller was in charge to display the renderer (if there were data to display) xor the nocontent helper. As the dashboard panel was rendered by the renderer, it couldn't be displayed alongside the nocontent helper. This rev. moves this logic to the renderer. So now, the controller always contains the renderer, which decides what to render (the data or the nocontent helper). This way, the dashboards can display their panel and the nocontent helper.
2017-05-02[FIX] web: support anchor tags with action type in viewsDavid Monjoie
2017-04-28[REF] web: restore editable list views behaviorsqsm-odoo
Since the new views, the editable list view lost some behaviors. These behaviors were indeed implemented in the form controller/renderer but as the new editable list view does not use an inline form view, these behaviors had to be implemented in the basic controller/renderer. For this to work, the list editable renderer had to be changed as it was doing work that should be done by the controller. The problem is even more complex because the x2m fields are using a list renderer but not a list controller. So moving code from the renderer to the controller obviously broke the x2m fields. Right now, the problem is solved by catching renderer events and forwarding new ones to the form controller (which handles the x2m specifically). The initial goal of this commit was to share the validation of records on save. Indeed, the fields were marked as invalid in the form view but not in the list view. Also, before the new views, the editable list view had different behaviors if they were used for a x2m field or not. As these behaviors are making sense, this commit tries to restore them. Basically, what we want is: - When a record is saved (form view save or list view line leaving), the invalid fields are marked (in red), the names of the related fields are notified to the user and the record is not left. - When a record is discarded (form view discard or list view discard), the user is asked to confirm if the record is dirty before making the record readonly. - When a record is discarded, if the record is a new one, then the record should be abandoned (removed as if never existed). In the form view this induces to go back in the history and in the list view, to remove a row. - For x2m fields, the notification of invalid fields is not triggered but the user is instead asked if he wants to discard the changes made to the row (indeed, this replaces the list "Discard" button, as non existent for x2m lists). - ... Saving, discarding, marking the fields as invalid and other behaviors are thus now shared behavior of basic views. The management of the dirty flag has also been moved to the model as it was handle by the controller for the form view but by the renderer for the list view. Now this flag is directly managed in the basic model (the model can have changes thanks to the `_changes` property but not be dirty (this is the case for creations)). This change however created a problem. The view manager is currently keeping asking if there are changes to discard at each action which might lead to leave a dirty record (appswitcher / url change / ...). It however did not discard anything as leaving if the user is ok with it will lead to an implicit discard. However, as the view manager might ask for this discard multiple times by second, the controller was marking the record as not dirty the first time but without discarding the changes. This is more complex to do now, as the dirty state is part of the model and that the renderer should match the model data. To solve this problem, the view manager now actually discard changes explicitely when asked to. Even though this had been optimized to not cause any rerender in some cases where it is not needed, this could cause some performance decreasing. However, this makes some cases more logical (opening the app switcher on a dirty form view then going back to the form view by hitting the "go back" button left the form view untouched although the user asked to discard it). This solution will be improved with the view manager refactoring. This commit is also making use of the `commitChanges` system which had been implemented for HTML fields. Indeed, these fields cannot know about all of their changes, so when hitting the save button, we asked those fields to commit their value. Using this system is a great way to make the `isValid` method of x2m fields synchronous. Indeed, before this commit, the method was sometimes asking the user if he wants to discard an invalid line before save. That case can be handled by the x2m `commitChanges` method: we consider that saving the lines of x2m is an operation that has to be done before considering the save, so we ask all the x2m fields to do so at that time. Also, the system was broken since a recent commit: we indeed protected the changes - save order with a mutex but unfortunately, the `commitChanges` method was part of the save and the changes it triggered were not able to be considered because of this mutex. This had not been detected by tests as there is not current way to test html fields.
2017-04-11[REF] web: remove old commented codeGéry Debongnie
Also, add some docstring tags.
2017-04-11[REF] board: update dashboards to new js frameworkGéry Debongnie
With the new views, we totally broke the dashboard. This commit rewrites all the code to comply with our new coding guidelines, and make sure it works, with some tests. Note that a big change is that we don't instantiate an action manager and a view manager, we directly instantiate the views. Also, this is not the best way to organize the dashboard. I think that it should be a client action, not a form view, so we don't have to overload all the form view classes and we don't depend on form view behaviour/view caches/...
2017-04-11[REF] web: views: refactor $buttons handler unbindingAaron Bohy
2017-04-11[FIX] web: check if changes can be discarded before leaving viewGéry Debongnie
Before this commit, we did not check if the changes can be discarded when opening the app switcher. This is now done. Note that this check was formerly done in the form view, and we moved this to the view manager. This now means that all views have the power to decide if they can be discarded.
2017-04-11[FIX] web: don't display nocontent helper if no help messageGéry Debongnie
Without help message, it looks silly
2017-04-11[REF] web, *: redesign all JS viewsGéry Debongnie
This commit introduce a full redesign of all JS views. We started basically from scratch. The goal was to unify all the various views under a common framework, to make them testable, to make then usable in different conditions (in studio, or in the frontend), and to make our lives easier. Some important points are: - we introduced new coding guidelines (camelCase, 80 chars width, ...) - we have a brand new testing framework (still QUnit based) - kanban view moved to the web addon - calendar view (formerly web_calender) moved to web as well - the tree view was removed - all new code should be documented We hope that this code is the start of a new era for the Odoo web client, we want to have a high quality codebase, well documented, well tested, well designed. Work done by the framework team: mostly aab, ged, chm, dmo, qsm