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

[9.0][MIG] web_widget_x2many_2d_matrix: Migration and enhancement #427

Merged
merged 11 commits into from
Sep 30, 2016

Conversation

pedrobaeza
Copy link
Member

Migration of the module to v9 with these features:

  • New JS API
  • Solved problem with data feed from onchanges.
  • Changes in structure.

There's also this improvement:

  • Add 2 new attributes for the clickable possibility in the axis: x_axis_clickable and y_axis_clickable

oca-transbot and others added 6 commits September 21, 2016 18:39
* README update to newest OCA template
* Example in README
* Massive performance boost for big matrices, specially on Firefox
* Assign id on row in order to find it back in all cases
* Fix OCA#321, choked on cached writes
Declare as many options prefixed with this string as you need for binding
a field value with an HTML node attribute (disabled, class, style...)
called as the `<name>` passed in the option.

NOTE: This doesn't prevent to require to fill the full matrix with
all the combination records.
…s_clickable attrs

XML attributes for the widget that allows to configure if the axis will be clickable
or not in case the source field is a many2one field.
@pedrobaeza pedrobaeza added this to the 9.0 milestone Sep 21, 2016
@pedrobaeza
Copy link
Member Author

cc @Tecnativa

@pedrobaeza
Copy link
Member Author

@hbrunn you'll be interested in this one too.

Copy link
Member

@hbrunn hbrunn left a comment

Choose a reason for hiding this comment

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

looks good! But the onchange-story bothers me a bit. I must admit I never tried this on 8, do we have the same problem there? For my feeling, if a widget needs help here, the widget is wrong. Can't we make this behave exactly as a standard one2many in this respect?
did you also consider having the widget generate empty records as necessary to get the full Cartesian product of the values available? Then using the widget would be a lot simpler.
I also experimented a bit with injecting fields here instead of using custom inputs, this turned out to be quite a hassle in 8. I think (didn't try yet) this should be a lot simpler in 9
[the last two are just ideas of course, not in any way blocking]

@pedrobaeza
Copy link
Member Author

About the field injection and the Cartesian product, I have exhausted the development time (and also my spirit for trying something more in JS), so that can go better to roadmap section. It's of course very interesting.

The problem with onchange seems something inherent to ORM. We have found the same problem on one2many fields and in onchange OCA/server-tools#492 (comment), so we need to see if we can patch it at one2many general widget or at ORM.

@pedrobaeza
Copy link
Member Author

@hbrunn I'm facing a problem resolving name of many2one fields when using a default value. Do you figure out why it's not resolved in that case?

From onchange:

seleccion_002

From default:

seleccion_003

@@ -50,10 +53,18 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
this.field_y_axis = node.attrs.field_y_axis || this.field_y_axis;
this.field_label_x_axis = node.attrs.field_label_x_axis || this.field_x_axis;
this.field_label_y_axis = node.attrs.field_label_y_axis || this.field_y_axis;
this.x_axis_clickable = node.attrs.x_axis_clickable != undefined ? this.parse_boolean(node.attrs.x_axis_clickable) : this.x_axis_clickable;
this.y_axis_clickable = node.attrs.y_axis_clickable != undefined ? this.parse_boolean(node.attrs.y_axis_clickable) : this.y_axis_clickable;
Copy link
Member

Choose a reason for hiding this comment

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

To feed your love for JS a bit more... null != undefined is false.
Maybe you will want to use !==.

Copy link
Member

Choose a reason for hiding this comment

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

how about this.parse_boolean(node.attrs.x_axis_clickable || (this.x_axis_clickable ? '1': '0'))?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, in this case I think it can't be null. It exists or not, but not assigned to null. Am I wrong?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hbrunn what do we win with that expression? Take into account that this.x_axis_clickable has been declared a couple lines above, and its value is fixed to true

Copy link
Member

Choose a reason for hiding this comment

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

then this.parse_boolean(node.attrs.x_axis_clickable || '1') would be simpler. The proposal is mainly about using javascript's notion of truthyness as we'd do in Python

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 be cautious about 'correctly', there are a lot of weirdnesses like empty arrays not being falsy and similar things. But for checking if something is set value || default works perfectly fine, and then you don't need to go into the details of undefined, null, false etc, as all of those are falsy

Copy link
Member Author

Choose a reason for hiding this comment

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

But for this case I think it is. I'm making tests right now to check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried in all cases and it's working correctly, so I let Holger's version.

Copy link
Member

Choose a reason for hiding this comment

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

Like in Python, "0" is true. Not sure if it applies here, otherwise ignore this 😁

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it doesn't apply here. We only want to have a default in case you don't specify this attribute in the XML. If the widget user is putting specifically "0" in the option, then it should be passed to parseBoolean function, which is what is done right now.

@hbrunn
Copy link
Member

hbrunn commented Sep 22, 2016

@pedrobaeza I'd put a breakpoint at https://github.com/OCA/web/pull/427/files/00ab29fbe49960abdd66c1f77b71923b9fd6961c#diff-d25cee8c92486a0e4cbf5ba21a360bbaR156 to check if the value there is something funny in the case of a default value. Probably you need an extra check for some other data type

@pedrobaeza
Copy link
Member Author

@yajo, can you make the final check and approve this?

@pedrobaeza
Copy link
Member Author

@hbrunn can we proceed with the merge?

@hbrunn hbrunn merged commit a30b907 into OCA:9.0 Sep 30, 2016
@pedrobaeza pedrobaeza deleted the 9.0-web_widget_x2many_2d_matrix branch September 30, 2016 09:32
@pedrobaeza
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants