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 Disabled Inputs #1305

Merged
merged 7 commits into from
Nov 27, 2018
Merged

Conversation

tfamula
Copy link
Contributor

@tfamula tfamula commented Nov 9, 2018

Possibility to make inputs disabled in Forms and (future) Filters.
The need of disabled inputs came up by implementing the Filter

@@ -1,5 +1,5 @@
<div id="container-{ID}" class="form-control form-control-sm il-input-tag">
<input type="text" id="{ID}" value="{VALUE_COMMA_SEPARATED}" class="form-control form-control-sm"/> <input type="hidden" id="template-{ID}" value='{NAME}[]'>
<input type="text" id="{ID}" value="{VALUE_COMMA_SEPARATED}"<!-- BEGIN disabled --> {DISABLED}<!-- END disabled --> class="form-control form-control-sm"/> <input type="hidden" id="template-{ID}" value='{NAME}[]'>
Copy link
Contributor Author

@tfamula tfamula Nov 9, 2018

Choose a reason for hiding this comment

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

Maybe this is not enough here. Technically, the tag-input will be disabled, so that the user cannot modify it. But visually, it still looks enabled because of the < div > over it. The user can also click on it and on the first click, even a pointer comes up.
My idea would be to additionally extend the < div > with a "disabled" class. Adding some css for the color and pointer-event would make the division visually disabled for the user.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tfamula sounds reasonable. @chfsx you have to most know-how about the tax, can you leave a short feedback here?

@klees
Copy link
Member

klees commented Nov 9, 2018

@tfamula Do you possess some mind-reading device? @Amstutz and me talked about this like four hours ago. Thx a lot already, I will have a look into this in the next week. Have a nice weekend later on!

Copy link
Contributor

@Amstutz Amstutz left a comment

Choose a reason for hiding this comment

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

Hi @tfamula really nice work and awsome timing. As @klees pointed out, where where just writting this on a todo list of ours when this came in. Nice. The interface change lgtm. I think we can discuss this directly at the JF since the change of the interface is really small. I'll attach the according label.

Nice work on the examples. Note that for a merge you need to:

  • Add some test coverage of this new "feature".

@@ -1,5 +1,5 @@
<div id="container-{ID}" class="form-control form-control-sm il-input-tag">
<input type="text" id="{ID}" value="{VALUE_COMMA_SEPARATED}" class="form-control form-control-sm"/> <input type="hidden" id="template-{ID}" value='{NAME}[]'>
<input type="text" id="{ID}" value="{VALUE_COMMA_SEPARATED}"<!-- BEGIN disabled --> {DISABLED}<!-- END disabled --> class="form-control form-control-sm"/> <input type="hidden" id="template-{ID}" value='{NAME}[]'>
Copy link
Contributor

Choose a reason for hiding this comment

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

@tfamula sounds reasonable. @chfsx you have to most know-how about the tax, can you leave a short feedback here?

Copy link
Member

@klees klees left a comment

Choose a reason for hiding this comment

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

LGTM in general, and thx a lot again.

As far as I understand investigations of @chfsx into the general state of the disabled-Attribute, not all browsers will properly display all types of disabled fields, so we might need some additional CSS at some point for some browser.

The changes in this PR currently do not cover Group, Section, MultiSelect, Numeric and Password (or I am missing something crucial). These are Inputs (hence get the disabled-property by the base class) but currently do not show any meaningful behaviour when the property is set. For Group and Section users imo would expect, that the contained inputs are disabled, the others should be just disabled like all other fields.

Did you check what happens when you actually process input from disabled fields?

@matthiaskunkel
Copy link
Member

Jour Fixe, 12 NOV 2018 : We accept this PR for trunk. Thomas will tackle Group and Section inputs, Richard will take care of Required inputs before committing it to trunk.

@alex40724
Copy link
Member

alex40724 commented Nov 13, 2018

Did you check what happens when you actually process input from disabled fields?

Imo we should simply skip disabled inputs in the withRequest/withInput loop. We should not try to pass the values somehow through the request, since we cannot ensure that the values are not manipulated. Consumers must not construct the form differently for the initial presentation and the input processing.

This follows up on the content/data discussion. Imo we need a function that runs through the operations without taking the request data.

So basically a withInput without the lines:

$value = $post_input->getOr($this->getName(), "");
$clone = $this->withValue($value);

getData should always deliver all inputs imo.

@klees
Copy link
Member

klees commented Nov 13, 2018

@alex40724 Yes, I agree. We should skip the client-server-roundtrip that ilPropertyFormGUI performs. I do not expect this roundtrip to happen in the current implementation, though. As @tfamula explained in the JF yesterday, the value set on the disabled input server-side seems to be used in processing of the response, without having been passed to the client in the meantime. This behaviour seems to be correct for me.

@tfamula tfamula removed the jour fixe label Nov 14, 2018
@tfamula
Copy link
Contributor Author

tfamula commented Nov 15, 2018

Hi @Amstutz and @klees,
we made some modifications to prevent getting the value for disabled inputs from the post-request and instead getting the value from the client side.

We also added the possibility to make Group, Dependant Group and Section disabled. The Inputs, which are located inside these three types of Inputs, will be made disabled technically and visually.
Let me know if you wish additional visual modification for these Inputs (e.g. greying out the whole division). Please consider this would be possible for Dependant Group and Section, but not for Group, because it has no own template and therefore we have no div which we can adjust. Since this would not be consistent, I would leave it the way it looks now.

As far as I understand investigations of @chfsx into the general state of the disabled-Attribute, not all browsers will properly display all types of disabled fields, so we might need some additional CSS at some point for some browser.

My investigations are different. For all Inputs which we have in the KS currently, the disabled attribute is provided by all common browsers from the beginning. (see here -> Browser Support)

@chfsx
Copy link
Member

chfsx commented Nov 20, 2018

My investigations were for the attribute "readonly" not "disabled": https://www.w3schools.com/tags/att_readonly.asp

@klees
Copy link
Member

klees commented Nov 20, 2018

Hi @tfamula, I'm really busy this week, but I promise you to give a feedback till end of the week. Sorry for the delay.

@tfamula
Copy link
Contributor Author

tfamula commented Nov 21, 2018

Hi @klees, no problem. I just finished everything that was missing in my eyes and made some small changes here and there.

I would like to say a few words about the Tag Input:
After analysing the html, I found at least five different inputs, which take part in the Tag Input. I could not find out which of them is the "main input". Trying to give one or more them the disabled attribute caused strange behaviour. Moreover, this would not solve our problem anyway: making the input disabled visually. For the request, we do not even need this attribute, because this is handled by the methods withDisabled and isDisabled technically.
I decided to remove the disabled attribute from the chosen input and instead extend the class of the div with this property. So my solution is to prevent user changes by styling the disabled (pseudo) input with the same background-color as it would be with the disabled attribute, and making it not usable by mouse, touch and keyboard with the help of css/js.
I hope my proposal is acceptable for you.

Copy link
Member

@klees klees left a comment

Choose a reason for hiding this comment

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

LGTM, besides the two minor issues in the comment. Thx a lot again.

@Amstutz: do you want to have another look?

@@ -42,4 +42,15 @@ public function __construct(
$this->inputs = $inputs;
}

function withDisabled($is_disabled) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add public here.

{
$inputs[$key] = $input->withDisabled($is_disabled);
}
$this->inputs = $inputs;
Copy link
Member

@klees klees Nov 23, 2018

Choose a reason for hiding this comment

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

This violates immutability of the object. Please clone before you assign.

Copy link
Contributor

@Amstutz Amstutz left a comment

Choose a reason for hiding this comment

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

Thx a lot for adding the tests. @klees you may merge as soon as your points are taken care of.

@tfamula
Copy link
Contributor Author

tfamula commented Nov 27, 2018

Hi @klees,
the immutability violation was solved. We are ready to merge :)

Richard will take care of Required inputs before committing it to trunk.

I think this is not part of the PR and will be solved by you separately.

@klees klees merged commit a1bc22b into ILIAS-eLearning:trunk Nov 27, 2018
@tfamula tfamula mentioned this pull request Feb 13, 2019
2 tasks
@tfamula tfamula deleted the 6_0_ks_disabled_input branch February 23, 2023 11:11
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.

6 participants