-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
web_chatter_right/README.rst
Outdated
WEB CHATTER RIGHT | ||
================= | ||
|
||
Put chatter right |
There was a problem hiding this comment.
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
web_chatter_right/__init__.py
Outdated
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all of this.
web_chatter_right/__manifest__.py
Outdated
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## |
There was a problem hiding this comment.
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.
web_chatter_right/__manifest__.py
Outdated
'name': 'Web Chatter Right', | ||
'version': '11.0.1.0.0', | ||
'author': "Odoo Community Association (OCA), Alexandre Díaz <dev@redneboa.es>", | ||
'website': '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put oca repo website
web_chatter_right/__manifest__.py
Outdated
], | ||
'qweb': [], | ||
'test': [ | ||
], |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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> | ||
*/ |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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:
============== | ||
Web Responsive | ||
============== | ||
|
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove from here...
|
||
Usage | ||
===== | ||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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:
-
Call once, cache request. Similar to what's done in [FIX] web_dialog_size: Fix usage for non-admins and reduce calls #954.
-
Manage this from the backend. Overwrite template
web.webclient_bootstrap
, by adding a class such aschatter-position-#{user.chatter_position}
.Then, no JS is needed at all; you can reposition it through Less directly.
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> |
There was a problem hiding this comment.
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.
web_responsive/__init__.py
Outdated
@@ -1,4 +1,4 @@ | |||
# Copyright 2018 Tecnotel - Alexandre Díaz | |||
# Copyright 2018 Alexandre Díaz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces?
web_responsive/models/__init__.py
Outdated
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import inherited_res_users | ||
from . import inherited_ir_http |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces?
web_responsive/readme/USAGE.rst
Outdated
@@ -0,0 +1,13 @@ | |||
Keyboard Shortcuts | |||
------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this header please.
web_responsive/readme/USAGE.rst
Outdated
|
||
.. 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 |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
web_responsive/views/web.xml
Outdated
@@ -94,6 +94,10 @@ | |||
|
|||
</xpath> | |||
|
|||
<xpath expr="//div[@class='o_main']" position="attributes"> |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
Thanks for all the help @yajo , now i know how flex property works xD and like chatter toolbar solution too! |
There was a problem hiding this 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.
I would suggest to keep travis green otherwise it will pollute the repo |
2de0fb6
to
f5729e4
Compare
I have cleaned the branch and rebase this one, so it should be all correct now. |
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: 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: Possible solutions to this are:
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.o_form_sheet_bg { | ||
border-right: 1px solid @table-border-color; | ||
overflow: auto; | ||
flex: 1 1 auto; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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. 😇
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
OK, I see it now perfect! @Tardo do you agree also? Should we merge? Do you have Twitter for announcing the improvement there? |
7a6f7b0
to
ab24dcf
Compare
For me all ok to merge. Yes i have an twitter account. |
Thanks for the work. Please tell me which one for mentioning you for giving some way thanks. |
My twitter account is: NoMoreButtons ;) |
The preferences option is only available for users with administration rights. It is right? |
Add option in user settings to select chatter position.
Usage: