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

[3.x] Add selectable prop on VueSelect component #1619

Merged
merged 4 commits into from
May 23, 2022

Conversation

kallefrombosnia
Copy link
Contributor

Description

Twill uses Vue Select component which is extended in the Twill vselect component. From 3.3.0 Vue Select, there is a new component prop selectable which allows us to set the disabled state on specific select options.

If we don't pass any value (default case), all options would be available in the select.

Usage:
form.blade.php

@formField('select', [
    'name' => 'office',
    'label' => 'Office',
    'placeholder' => 'Select an office',
    'options' => [
        [
            'value' => 1,
            'label' => 'New York'
        ],
        [
            'value' => 2,
            'label' => 'London'
        ],
        [
            'value' => 3,
            'label' => 'Berlin',
            'selectable' => false
        ]
    ]
])

Note on the third item we have new property selectable which allows us to set a boolean value regarding should be option selectable or not.

test6

It's hard to see the change here since Lightshot doesn't capture the icon which is shown over the non-selectable option.

Also, it creates some CSS class conflict in which the -1 element keeps a hover state.
I will inspect this and create documentation in the next commits.

Related Issues

Fixes #1266

@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #1619 (da47346) into 3.x (acbcf55) will increase coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff            @@
##                3.x    #1619   +/-   ##
=========================================
  Coverage     56.33%   56.33%           
- Complexity     3020     3024    +4     
=========================================
  Files           239      239           
  Lines          9248     9255    +7     
=========================================
+ Hits           5210     5214    +4     
- Misses         4038     4041    +3     
Impacted Files Coverage Δ
src/Services/Forms/Option.php 0.00% <0.00%> (ø)
src/TwillRoutes.php 77.77% <0.00%> (-0.49%) ⬇️
src/Models/Behaviors/HasTranslation.php 20.00% <0.00%> (-0.34%) ⬇️
src/Helpers/Capsule.php 74.28% <0.00%> (+0.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acbcf55...da47346. Read the comment docs.

@kallefrombosnia kallefrombosnia changed the base branch from 2.x to 3.x April 26, 2022 23:35
@haringsrob
Copy link
Contributor

👍
Looks good and simple enough. Please however, for now do not included the compiled css/js as we are still doing many changes and want to avoid conflicts there.

@kallefrombosnia kallefrombosnia force-pushed the disabled-select-options branch from 957133e to 83c3efe Compare April 27, 2022 19:34
@kallefrombosnia
Copy link
Contributor Author

kallefrombosnia commented Apr 27, 2022

@haringsrob Thanks, compiled stuff is removed from PR.

Also, documentation is added, which looks like this. I have separated them from the main prop list since this is an item prop.
Let me know if this is good.

test7

@haringsrob
Copy link
Contributor

I have updated the pr to change the form doc and also added this selectable prop to the formbuilder option object.

@haringsrob haringsrob merged commit f51ab4a into area17:3.x May 23, 2022
@kallefrombosnia kallefrombosnia deleted the disabled-select-options branch May 23, 2022 08:40
@haringsrob haringsrob mentioned this pull request May 23, 2022
@haringsrob haringsrob added this to the 3.x initial release milestone May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabled options in select form field
3 participants