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

Group Fields in JSON column #410

Merged
merged 3 commits into from
Nov 12, 2019
Merged

Group Fields in JSON column #410

merged 3 commits into from
Nov 12, 2019

Conversation

yanhao-li
Copy link

This PR is intended to provide a solution per discussion in #162.

A new trait HandleFieldsGroup was added, users have to create new json columns manually on the table, and for each column, the fields that needed to saved as group should be declared as $fieldsGroups in the repository, as the below example demonstrated.

class ProjectRepository extends ModuleRepository
{
    protected $fieldsGroups = [
        'fields_group' => [
            'field1',
            'field2',
            'field3'
        ]
    ];
}

Supported Fields:

  • input
  • wysiwyg
  • date_picker
  • select
  • multi_select
  • map (haven't tested, but should work)
  • color
  • checkbox
  • checkboxes

Further improvements

  • Support Browsers and Repeaters
  • Added the fieldsGroups attribute to repository.stub
  • Added it as a new option on ModuleMake CLI to add the json column automatically

Any comments/thoughts are welcomed!

Co-Authored-By: Quentin Renard <quentin@area17.com>
@yanhao-li
Copy link
Author

Because of the design of MultiSelected component, the stored json data for multi_select and checkboxes must be casted into the form in order to be displayed on the form

[
  ['id' => 'new york'],
  ['id' => 'london']
]

It's obviously not ideal, but may not in the scope of this PR, we should open another issue to improve the component.

@ifox ifox merged commit 5564e48 into area17:1.2 Nov 12, 2019
m4n1ok added a commit to m4n1ok/twill that referenced this pull request Nov 14, 2019
* 1.2:
  Add style for subscript into wysiwyg (area17#450)
  Add a default value for `$fieldsGroups` to prevent error from repositories which extend ModuleRepository. (area17#452)
  fixed the http & https issue from APP URL (area17#431)
  Add a feature to group fields in a JSON column (area17#410)
  Replace bcrypt() with Hash::make in CreateSuperAdmin command (area17#445)
  Fixed the issue that 'delete' => true not working in indexOptions, refs area17#289 (area17#446)
  Fix « Handle Repeater » feature compatibility with Laravel 5.6 (area17#449)
  Revert "Add quotes when populating store from form field (area17#416)"
  Fix media and file libraries upload endpoint logic
  Properly support fileupload for Azure (area17#443)
  Invert sorting order in ModuleRepository.
  Support azure storage (area17#424)
@yanhao-li yanhao-li deleted the feature/fields-group branch April 6, 2020 13:35
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