Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP][11.0][web_responsive] Add option to select chatter position #951

Merged
merged 1 commit into from
Jun 22, 2018

Conversation

Tardo
Copy link
Member

@Tardo Tardo commented Jun 11, 2018

Add option in user settings to select chatter position.

Usage:

  • Go to user preferences and select "Chatter Position"

@yajo yajo added this to the 11.0 milestone Jun 12, 2018
WEB CHATTER RIGHT
=================

Put chatter right
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use new split readme system

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all of this.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Use short license headers, as found in the official template.

'name': 'Web Chatter Right',
'version': '11.0.1.0.0',
'author': "Odoo Community Association (OCA), Alexandre Díaz <dev@redneboa.es>",
'website': '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put oca repo website

],
'qweb': [],
'test': [
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty keys

.oe_chatter.o_chatter_right {
display: inline-block !important;
width: 390px !important;
min-width: 390px !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use !important. Those rules are extremely hard to theme. Better, use more specific selectors if you need to override some odoo css.

Also, use Less if possible.

}

.o_web_client > .o_main > .o_main_content > .o_content .table-responsive {
overflow-x: auto !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

* Theme Chatter Right
* GNU Public License
* Alexandre Díaz <dev@redneboa.es>
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use short headers as in template.

@@ -0,0 +1,30 @@
odoo.define('web_chatter_right.Chatter', function (require) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 options:

a. call it web_chatter_side. Arabic readers may want it left.

b. Do not use a new addon. Instead, add the features to web_responsive. (I prefer this one)

var $chatter = this.$el.find('.oe_chatter');
if (this.has_sheet && $chatter.length !== 0) {
if ($chatter.css('visibility') === 'hidden' || $chatter.css('display') === 'none') {
this.$el.find('.o_form_sheet_bg').removeClass("o_form_sheet_chatter_right");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly you could do all of this overriding the XML template instead, and it would be more clear.

Also, users should be able to choose these settings.

@Tardo Tardo changed the title [ADD][11.0] web_chatter_right [IMP][11.0][web_responsive] Add option to select chatter position Jun 12, 2018
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on code below. But it's awesome!

I've been comparing it with how web_enterprise makes it, and I noticed a couple of little UI/UX details that would be IMHO important:

  1. Add some separation between the form and the chatter. Just 1px line, like in the picture:
    captura de pantalla de 2018-06-13 11-13-14

  2. Separate scroll bars for form and chatter. With your patch, user scrolls both or none, but separate scrolling is useful:
    captura de pantalla de 2018-06-13 11-13-33

==============
Web Responsive
==============

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all until here. The new split readme system generates all this boilerplate.

* Keyboard shortcuts for easier navigation
* Display kanban views for small screens if an action or field One2x
* Set chatter side (Optional per user)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove from here...


Usage
=====

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... until here.

Usage
=====

Keyboard Shortcuts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this section to readme/USAGE.rst

* Navigate Apps Drawer - Arrow Keys
* Type to select App Links
* ``esc`` to close App Drawer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove from here to the end.

var self = this;
var $chatter = this.$el.find('.oe_chatter');
if (this.has_sheet && $chatter.length !== 0) {
Rpc.query({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the good hook to call for this. You're asking for the setting before you render each form. A normal user session renders many forms, so we should try to save requests whenever possible, as they affect directly to the performance. You have 2 options, to avoid doing so many calls:

IMHO I'd go for 2nd option. I think it will be faster for the user and easier to maintain. But you choose 😉

<field name="chatter_position" />
</xpath>
</field>
</record>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 4 spaces for indentation, to be consistent with other files.

@@ -1,4 +1,4 @@
# Copyright 2018 Tecnotel - Alexandre Díaz
# Copyright 2018 Alexandre Díaz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 spaces?

# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import inherited_res_users
from . import inherited_ir_http
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to prefix with inherited_

@@ -1,4 +1,4 @@
# Copyright 2018 Tecnotel - Alexandre Díaz
# Copyright 2018 Alexandre Díaz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 spaces?

@@ -0,0 +1,13 @@
Keyboard Shortcuts
------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this header please.


.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/11.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the runbot stuff please. It should be autofilled.

_updateView: function ($newContent) {
this._super($newContent);
var $chatter = this.$el.find('.oe_chatter');
if ($chatter.length === 0 || $chatter.css('visibility') === 'hidden' || $chatter.css('display') === 'none') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use $chatter.is(":hidden")

if ($chatter.length === 0 || $chatter.css('visibility') === 'hidden' || $chatter.css('display') === 'none') {
this.$el.find('.o_form_sheet_bg').removeClass("o_form_sheet_bg_chatter_visible");
} else {
this.$el.find('.o_form_sheet_bg').addClass("o_form_sheet_bg_chatter_visible");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if do we need all of this now. 🤔

You are now adding a class to the whole web client that indicates the chatter position. Can't we use that class directly in Less to change the chatter position, and remove all related JS code?

I see that the point is to have 100% width in forms without chatter, but see suggestions below on Less code.

@@ -94,6 +94,10 @@

</xpath>

<xpath expr="//div[@class='o_main']" position="attributes">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the v11 new hasclass() method instead.

* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */

@sheet-margin: @sheet-padding;
@chatter-side-width: 390px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use some variable from current bootstrap theme. i.e. @screen-md / 3

@chatter-side-width: 390px;

// Sided Chatter
.o_chatter_position_sided {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to use flexbox here. You have a playground in https://demo.agektmr.com/flexbox/. If I'm not wrong, this should do the trick (or almost):

@media (min-width: @screen-md) {
.o_chatter_position_sided {
  .o_form_view {
    display: flex;
    flex-flow: row;
    height: 100%;
    align-items: stretch;

    .o_form_sheet_bg {
      border-right: 1px solid @table-border-color;
      overflow: auto;
      flex: 3 0 auto;
    }

    .o_chatter {
      overflow: auto;
      flex: 1 1 @chatter-side-width;

      .o_chatter_topbar {
        height: auto;
        flex-wrap: wrap;
      }
    }
  }
}
}

The benefits:

  • No JS needed. Thus, more fast.
  • Adaptable to any size.
  • Autofills if no chatter available.
  • Cleaner, IMHO.

@Tardo
Copy link
Member Author

Tardo commented Jun 19, 2018

Thanks for all the help @yajo , now i know how flex property works xD and like chatter toolbar solution too!

Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks perfect, and functionality too. Thanks for the hard job!

The Travis ❌ is due to new linters that affect other files in the addon, so the fault is not yours. If you want to fix it, that'd be OK, but not a requirement IMHO.

@elicoidal
Copy link

I would suggest to keep travis green otherwise it will pollute the repo

@pedrobaeza
Copy link
Member

I have cleaned the branch and rebase this one, so it should be all correct now.

@pedrobaeza
Copy link
Member

Good work with this, @Tardo !

Using the new feature, I see that it's better than enterprise one, not using too much width, but sometimes this can be short for showing large content, like embedded large images. Do you think it's possible to make the width configurable through the typical arrows?

Another thing I have seen. With this width, not everything fits on the first line:

seleccion_005

making a visual inconsistency, not having connected the opened tab with the rest of the content, which is very important IMO for identifying easily if you are sending an internal message or a public one. See the difference with the right normal one:

seleccion_006

Possible solutions to this are:

  • Make the width bigger, but this depends on the translation of the elements.
  • Put the followers up. My colleague @yajo said to me that it's very easy with flexbox.

@pedrobaeza
Copy link
Member

Ah, another thing abusing a bit 👼

On previous versions, if the chatter in bottom, the content was fit to 100%. Is it possible that you change also this thing in this PR?

Thanks again.

Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes I suggest below, you get this behavior, automatically, depending on user screen width:

captura de pantalla de 2018-06-20 10-07-27

captura de pantalla de 2018-06-20 10-07-36

.o_form_sheet_bg {
border-right: 1px solid @table-border-color;
overflow: auto;
flex: 1 1 auto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 0 auto, which means: give him 3/4 of the space when growing, but not let it shrink less than 1/2 of the space

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use different grow & shrink values for me makes the view "inconsistent" ...
2018-06-20-153006_1366x768_scrot
2018-06-20-153003_1366x768_scrot
2018-06-20-153000_1366x768_scrot
2018-06-20-152927_1366x768_scrot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the point is that i.e. here I'm working with an ultrawide monitor. Under this circumstance, when window is full width, the chatter is extremely small. Emails sometimes have fixed widths, and with such a big monitor, it seems more comfortable to make it grow a little bit when the screen is big enough. Instead of making it feel unconsistent, here it feels more responsive.

However, if you prefer, you can combine flex with min-width and max-width. Play with those as you like. For instance, setting the chatter as 1/3 of the window, with min-width: @chatter-side-width. Do you prefer if I add the commit myself, since I have this monitor to test with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i changed width to use percentage instead fixed width...
Feel free to commit changes what you think appropriate.


.o_chatter {
overflow: auto;
flex: 0 0 @chatter-side-width;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 1 @chatter-side-width, which means: give him 1/4 of the space when growing, also when shrinking, and start with @chatter-side-width to make computations.

flex-wrap: wrap;
}
}
.oe_chatter:empty {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put this inside the .o_chatter block and use &:empty instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The element only have the class "oe_chatter" when it's empty ... perhaps best use oe_chatter for all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that. Then maybe yes, we can use oe_chatter for both.

.o_chatter_topbar {
height: auto;
flex-wrap: wrap;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside this block, add this other one:

.o_followers {
    order: -10;
    flex: 2 0 @chatter-side-width;
}

That means: Put this element before the other ones (that default to order: 0); then, give him the double than the other ones when growing (because it has 2 buttons), but do not let it shrink smaller than @chatter-side-width

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018-06-20-160030_1366x768_scrot

I have better results (if chatter have fixed size) with:

.o_followers {
    order: -10;
    flex: 0 1 @chatter-side-width;
 }

Use all the chatter width (no more, but if needed less)
2018-06-20-155938_1366x768_scrot

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, seems legit.

var ViewManager = require('web.ViewManager');
var Chattter = require('mail.Chatter');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do this, you must depend on mail. Check runbot, it's not loading this file.

var self = ev.data;
if (self._mousePosX !== -1) {
var wDiff = self._mousePosX - ev.pageX;
self.$el.css('flex-basis', self._origWidth + wDiff + 'px');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I prefer you to add the dependency on mail, or better just remove this feature. I think this feature is too complex and nobody will care about resizing that column if it has a sane and properly responsive default.

You know, the famous debate between configurability vs. sane defaults... I think this is a good case for sane defaults. If you need to see wider mails, the officially supported answer should be: "configure your chatter in the bottom; it will have full width", don't you think?

Besides, by reading the code I'd say you are not storing this anywhere... So each time I press F5 I lose my custom width? And if I resize the window up and down, do I have to be dragging it all the time? It seems one of those features that nobody will care if it's not present, but yes if it's incomplete.

Just some thoughts, please don't take this badly. 😇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have to add the dependency, I agree it's better to stick to a sane fixed width that can vary according screen size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you agree, since you originated the request, I'm gonna remove this. Let's see how it works after that.

@pedrobaeza
Copy link
Member

OK, I see it now perfect! @Tardo do you agree also? Should we merge?

Do you have Twitter for announcing the improvement there?

@Tardo
Copy link
Member Author

Tardo commented Jun 22, 2018

For me all ok to merge. Yes i have an twitter account.

@pedrobaeza
Copy link
Member

Thanks for the work. Please tell me which one for mentioning you for giving some way thanks.

@pedrobaeza pedrobaeza merged commit e5e109e into OCA:11.0 Jun 22, 2018
@Tardo
Copy link
Member Author

Tardo commented Jun 22, 2018

My twitter account is: NoMoreButtons ;)

@LRovira-PlanetaTIC
Copy link
Member

The preferences option is only available for users with administration rights. It is right?

@yajo
Copy link
Member

yajo commented Jun 25, 2018

Yikes, true, that's a bug we didn't find at time for release:

captura de pantalla de 2018-06-25 09-13-37

@Tardo Tardo deleted the web_chatter_right branch July 3, 2018 17:34
yajo pushed a commit to Tecnativa/web that referenced this pull request Oct 5, 2018
yajo pushed a commit to Tecnativa/web that referenced this pull request Dec 10, 2018
tschanzt pushed a commit to camptocamp/web that referenced this pull request Jun 19, 2019
Tardo added a commit to Tecnativa/web that referenced this pull request Sep 30, 2019
Tardo added a commit to Tecnativa/web that referenced this pull request Oct 13, 2019
TesaLazarenko pushed a commit to TesaLazarenko/oca_web that referenced this pull request Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants