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

UI: an Input ModeViewControl #8350

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

nhaagen
Copy link
Contributor

@nhaagen nhaagen commented Nov 6, 2024

We do have a mode view control in the non-input view controls, but we do not for the input ones.
That's obviously missing.

Styling is missing from this PR, but should not be hard to do for @catenglaender , e.g.

@klees
Copy link
Member

klees commented Nov 25, 2024

Hi @thibsy and @Amstutz,

could you have a look here?

Kind regards!

Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

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

Hi @nnhaagen,

Thx a lot for your contribution to the UI framework.

This review will only focus on the public interface, so this can go to JF first. We will review the implementation once it has been accepted.

About the concrete changes, answer the following questions:

  • Legacy ViewControl\Mode: the proposed interface looks a lot smaller than the old one. Is this on purpose? I distinctly remember an issue which has been addressed for the old ones, which should probably be considered here too. Something about the label. Also, why not adopt the old factory description?

Please implement the following changes:

  • PHPDoc: please provide a PHPDoc annotation for the $options parameter, describing the possible values (corresponding to Mode::isClientSideValueOk()).
  • Deprecation: please deprecate the legacy ViewControl\Mode viewcontrol (on the factory).

Kind regards,
@thibsy

@nhaagen
Copy link
Contributor Author

nhaagen commented Dec 3, 2024

Hi @thibsy,

  • Legacy ViewControl\Mode: the proposed interface looks a lot smaller than the old one. Is this on purpose? I distinctly remember an issue which has been addressed for the old ones, which should probably be considered here too. Something about the label. Also, why not adopt the old factory description?

There's not much beside the options a consumer could or should do with the control itself.
I think that the public interface of the older control is too broad, too (in terms of getAriaLabel/getLabeledActions), but
the main difference is that with the input view controls we have a container properly tending to states and values.

  • Deprecation: please deprecate the legacy ViewControl\Mode viewcontrol (on the factory).

Ultimately: yes. But then we should deprecated all of them, aye?
The non-input view controls are still used, e.g. by PresentationTable.

Best regards,
Nils

Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

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

Hi @nhaagen,

Thx for your explanation. I agree that we should deprecate the entire legacy view control namespace at once. Could you create a roadmap entry for this? If you have the time, another PR would be highly appreciated of course.

I also realised, I was thinking about the wrong labelling issue (it concerned C\Table\Column\Column::getOrderingLabels()) - sry about that.

The interface LGTM now, so we can pass this through JF. The implementation contains some minor issues, which need to be addressed once this has been accepted.

Please consider the following suggestions. You do not need to follow them:

  • Inline JavaScript: we try to keep inline JavaScript to a minimum. I suggest to create a file with a function that contains the logic registered inside the renderer, which is populated as e.g. il.UI.viewcontrol.createMode() or similar.

Please implement the following changes:

  • Probable bug: you have several usages of array_keys($options)[0], which I think will break if one passes an empty array to create an instance. I am not sure if we really want to enforce an array entry, therefore I suggest to simply address these places by using array_key_first() with a null-coalesce where necessary.
  • Optional ID: the template file contains an optional block for the ID attribute. The attribute is always required though, therefore please remove it (not the variable).

Kind regards,
@Amstutz and @thibsy

@nhaagen
Copy link
Contributor Author

nhaagen commented Dec 5, 2024

Hi @thibsy ,

  • Inline JavaScript: we try to keep inline JavaScript to a minimum. I suggest to create a file with a function that contains the logic registered inside the renderer, which is populated as e.g. il.UI.viewcontrol.createMode() or similar.

There already is a roadmap entry on this (concerning all other VCs, too), I'll see to it.

  • Optional ID: the template file contains an optional block for the ID attribute. The attribute is always required though, therefore please remove it (not the variable).

Actually, with ModeVC, the id is indeed optional (I removed the other ones, though): the JS is on the buttons it generates, not the component itself.
I'll amend when I externalize the JS.

Best,
Nils

@dsstrassner
Copy link
Contributor

This has been postponed to the next JourFixe.

@matthiaskunkel
Copy link
Member

Jour Fixe, 06 JAN 2025: We highly appreciate this suggestion and accept the PR for trunk.

@thibsy
Copy link
Contributor

thibsy commented Jan 14, 2025

@nhaagen I assign this back to you while you are refining the JS. Feel free to pass back once this is ready!

@thibsy thibsy assigned nhaagen and unassigned thibsy Jan 14, 2025
@nhaagen nhaagen force-pushed the 11/UI/InputVC/Mode branch 2 times, most recently from 972ca11 to 4aeb9f9 Compare January 20, 2025 08:07
@nhaagen nhaagen force-pushed the 11/UI/InputVC/Mode branch from 4aeb9f9 to 91c96fd Compare January 20, 2025 08:28
@nhaagen
Copy link
Contributor Author

nhaagen commented Jan 20, 2025

Hi @thibsy , I externalized the JS, maybe you want to take a look?

@thibsy thibsy assigned thibsy and unassigned nhaagen Jan 20, 2025
Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

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

Hi @nhaagen,

Thanks a lot for externalising the JavaScript of all the new view controls!

I assumed the actual JavaScript code of the other view controls was simply copied from the renderer, so I only checked the new mode more closely. Let me know if there was a relevant change in some of the other ones.

About the concrete changes, please answer the following questions:

  • Styling: is the styling already covered by the legacy view controls? If not, when/how will this be added?

Please consider the following suggestions. You do not need to follow them, but please indicate shortly why you prefer to do otherwise:

  • File names: just for future reference, this is currently optional: but according to our JavaScript code-style, file names must reflect their default export, if there is any - with a few exceptions for e.g. generated files or configs.

Please implement the following changes:

  • Event.srcElement: this property has been deprecated, please use Event.target instead.
  • Optional chaining: please use ?. for all chained function calls when setting the optValue.

Kind regards,

@Amstutz and @thibsy

@nhaagen
Copy link
Contributor Author

nhaagen commented Jan 28, 2025

This is what it looks like:

Screenshot from 2025-01-28 13-09-27

Screenshot from 2025-01-28 13-17-10

@nhaagen
Copy link
Contributor Author

nhaagen commented Jan 28, 2025

Optional chaining: please use ?. for all chained function calls when setting the optValue.

Rollup does not like that chaining:
RollupError: src/mode.js (44:8): The left-hand side of an assignment expression must be a variable or a property access.

In this case, I'd also not expect any of the elements to not be there, they are quite integral to the view control.

@klees
Copy link
Member

klees commented Jan 28, 2025

@thibsy Please iterate =)

Copy link
Contributor

@thibsy thibsy left a comment

Choose a reason for hiding this comment

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

This LGTM now, you're right about the invalid syntax of course. Thx a lot @nhaagen for this contribution!

@thibsy thibsy merged commit 8374987 into ILIAS-eLearning:trunk Feb 3, 2025
3 checks passed
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.

8 participants