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

[FIX] web: Expose datepicker configuration to view declarations #25044

Closed

Conversation

yajo
Copy link
Contributor

@yajo yajo commented Jun 4, 2018

The lower-level widget itself supports passing options to the underlying datepicker library, but this is not exposed to higher-level view declaration.

With this patch, one can declare a field in a view such as:

<field name="datefield" options='{"datepicker": {"daysOfWeekDisabled": [0, 6]}}'/>

That option would land in the widget and disable those weekdays.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
@Tecnativa @ged-odoo

The lower-level widget itself supports passing options to the underlying datepicker library, but this is not exposed to higher-level view declaration.

With this patch, one can declare a field in a view such as:

```xml
<field name="datefield" options='{"daysOfWeekDisabled": [0, 6]}'/>
```

That option would land in the widget and disable those weekdays.
@tde-banana-odoo
Copy link
Contributor

Hello,

Changes look goot to me, except that I would make them in master as this is not really a bugfix. Just to be sure I would ask for @ged-odoo review.

@tde-banana-odoo tde-banana-odoo self-assigned this Jun 11, 2018
@yajo
Copy link
Contributor Author

yajo commented Jun 11, 2018

I proposed it for v11 because it means no backwards compatibility problems. However, if you prefer for master, it would be good too 😊

@yajo yajo changed the base branch from 11.0 to master June 12, 2018 09:26
@tivisse tivisse added the Framework General frontend/backend framework issues label Jun 12, 2018
@tivisse tivisse requested a review from ged-odoo June 12, 2018 09:54
@yajo
Copy link
Contributor Author

yajo commented Jun 13, 2018

Weird, I can't imagine how this change is breaking the test... 😕

return new datepicker.DateWidget(this, {defaultDate: this.value});
var datepicker_options;
try {
datepicker_options = this.attrs.options.datepicker;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it simpler to do datepicker_options = this.attrs.options.datepicker || {} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm it must be that.

Copy link
Contributor

Choose a reason for hiding this comment

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

tde is right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was worried about this.attrs.options being undefined, but I didn't know about this.nodeOptions. It's changed now.

Copy link
Contributor

@ged-odoo ged-odoo left a comment

Choose a reason for hiding this comment

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

also, this should be documented in javascript_reference, in the section about fielddate/fielddatetime at the end

@yajo yajo changed the base branch from master to 11.0 June 13, 2018 10:14
@yajo yajo force-pushed the 11.0-web-datetimepicker_configurable branch from 37c3d23 to 51d3a98 Compare June 13, 2018 10:21
@yajo
Copy link
Contributor Author

yajo commented Jun 13, 2018

Docs added

tde-banana-odoo pushed a commit that referenced this pull request Jun 13, 2018
The lower-level widget itself supports passing options to the underlying
datepicker library. However this is not exposed to higher-level view
declaration. With this patch, one can declare a field in a view such as:

```xml
<field name="datefield" options='{"daysOfWeekDisabled": [0, 6]}'/>
```

That option would land in the widget and disable those weekdays.

Documentation has been updated accordingly.

Closes #25044.
@tde-banana-odoo
Copy link
Contributor

Landed in 11 at 71334b1 . Thanks to everybody !

@yajo yajo deleted the 11.0-web-datetimepicker_configurable branch June 13, 2018 13:56
yajo added a commit to Tecnativa/web that referenced this pull request Jun 13, 2018
This addon is no longer needed since odoo/odoo#25044 (comment), so I remove it.
yajo added a commit to Tecnativa/web that referenced this pull request Mar 7, 2019
This addon is no longer needed since odoo/odoo#25044 (comment), so I remove it.
yajo added a commit to Tecnativa/web that referenced this pull request Mar 7, 2019
This addon is no longer needed since odoo/odoo#25044 (comment), so I remove it.
yajo added a commit to Tecnativa/web that referenced this pull request Mar 7, 2019
eilst pushed a commit to savoirfairelinux/web that referenced this pull request Apr 4, 2019
@yajo yajo mentioned this pull request Jul 24, 2019
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework General frontend/backend framework issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants