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.5][Feature][Ready] Select_and_order field type #1695

Merged
merged 6 commits into from
Nov 15, 2018

Conversation

tabacitu
Copy link
Member

Merged and polished #1626 . Adds a new field type, select_and_order, which shows two columns:

  • to the left are the items you have selected, and you can reorder them
  • to the right are the items you can select (by dragging to the left column)

Screenshot

screenshot 2018-11-11 at 17 23 49

Definition

As mentioned in the original PR, it can be used exactly like select_from_array:

            [
                'name' => 'featured',
                'label' => 'Featured',
                'type' => 'select_and_order',
                'options' => [
                    1 => "Option 1",
                    2 => "Option 2"
                ]
            ]

Or:

            [
                'name' => 'featured',
                'label' => 'Featured',
                'type' => 'select_and_order',
                'options' => Product::get()->pluck('title','id')->toArray()
            ]

The submitted value (in this case featured) should be casted to an array in the model:

            protected $casts = [
                'featured' => 'array'
            ];

And its value will be stored as JSON in the db: ["3","5","7","6"]

Thoughts, anyone? Is it clear enough from the design that you can drag items from the right to the left? Without having labels for each column? I'd hate to insert new translated lines just for this...

@joaojoyce
Copy link
Contributor

Could an arrow in between the columns help?

I’m not into design so take my suggestions with skepticism.

@tabacitu
Copy link
Member Author

Arrows!! Of course, that’s what was missing :-))

Thank you @joaojoyce - I think you’re right. Even better than between the columns (which would only say “move items between the columns”) I think would be arrows on each element. I expect it to say “move this thing around, or in the other container”.

I’ve polished it a bit more and added arrows, I think we finally have it :-)

screenshot 2018-11-12 at 10 48 14
screenshot 2018-11-12 at 10 49 10

@tabacitu tabacitu changed the title [Feature][3.5][Ready] Select_and_order field type [3.5][Feature][Ready] Select_and_order field type Nov 13, 2018
@tabacitu tabacitu changed the base branch from master to release-3-5 November 15, 2018 09:38
@tabacitu tabacitu merged commit 46e84ae into release-3-5 Nov 15, 2018
@tabacitu tabacitu deleted the joaojoyce-select_and_order branch November 15, 2018 09:38
@tabacitu
Copy link
Member Author

Merged into release 3.5 branch. Can't wait to launch it :-)

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.

2 participants