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

Add new group display mode for quick form widget #63

Merged
merged 31 commits into from
Jun 6, 2022

Conversation

veve40
Copy link
Contributor

@veve40 veve40 commented Jun 2, 2022

  • Add support for grouping properties by the language, for multilingual form properties.
  • Centralize sort by priority comparator functions to minimize duplicate code.

src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Widget/QuickFormWidget.php Outdated Show resolved Hide resolved
templates/charcoal/admin/widget/quick-form.mustache Outdated Show resolved Hide resolved
veve40 and others added 10 commits June 2, 2022 11:40
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Avoid useless ternary expression

Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Avoid useless ternary expression

Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Improve returned data as json for debugging purpose

Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
@mcaskill mcaskill changed the title 1st version of new group_display_mode for quick-form Add new group display mode for quick form widget Jun 2, 2022
@mcaskill
Copy link
Member

mcaskill commented Jun 2, 2022

Summary of a chat between @veve40, @mcaskill, @JoelAlphonso:

  • Add support class Sorter with method sortByPriority().
    • Migrate equivalent methods from other classes:
      • sortLanguagesByPriority()
      • sortItemsByPriority()
      • sortGroupsByPriority()
      • sortActionsByPriority()
      • Note: This could just be done for sortLanguagesByPriority() for now and create another pull request to unify others.
  • Add HasLanguageSwitcherTrait and HasLanguageSwitcherInterface or maybe as a service class?
    • Migrate methods showLanguageSwitch() from:
      • QuickFormWidget
      • FormSidebarWidget
  • Replace method hasL10nFormProperties() on ObjectFormWidget with implementation from QuickFormWidget.

Proposed structure for HasLanguageSwitcherTrait:

`HasLanguageSwitcherTrait`
public function showLanguageSwitch()
{
    if ($this->showLanguageSwitch === null) {
        $this->showLanguageSwitch = $this->resolveShowLanguageSwitch();
    }
    return $this->showLanguageSwitch;
}

abstract protected function resolveShowLanguageSwitch();
`QuickFormWidget` / `ObjectFormWidget`
protected function resolveShowLanguageSwitch()
{
    return $this->hasL10nFormProperties();
}
`FormSidebarWidget`
protected function resolveShowLanguageSwitch()
{
    if ($form) {
        return $form->hasL10nFormProperties();
    }

    return false;
}

Xavier added 3 commits June 2, 2022 15:40
…ed in FormSidebarWidget and QuickFormWidget
…msByPriority, sortGroupsByPriority, sortActionsByPriority into one supportByPriority function
templates/charcoal/admin/widget/quick-form.mustache Outdated Show resolved Hide resolved
src/Charcoal/Admin/Support/Sorter.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Support/Sorter.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Support/Sorter.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Ui/HasLanguageSwitcherTrait.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Ui/HasLanguageSwitcherInterface.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Ui/HasLanguageSwitcherTrait.php Outdated Show resolved Hide resolved
src/Charcoal/Admin/Ui/HasLanguageSwitcherTrait.php Outdated Show resolved Hide resolved
veve40 and others added 8 commits June 3, 2022 11:09
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Co-authored-by: Chauncey McAskill <chauncey@mcaskill.ca>
Copy link
Member

@mcaskill mcaskill left a comment

Choose a reason for hiding this comment

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

Nice work. All that's missing is adding isDisplayModeLang and showLanguageSwitch to a QuickFormWidget::widgetDataForJs() method to wrap the trigger and event lisener that you moved to quickform.js.

@mcaskill mcaskill merged commit d27a30e into master Jun 6, 2022
@mcaskill mcaskill deleted the xav/quick-form-lang-tab branch July 8, 2022 20:20
mcaskill pushed a commit to charcoalphp/charcoal that referenced this pull request Jul 15, 2022
Added support for grouping properties by language, for multilingual form properties:

```json
{
    "type": "charcoal/admin/widget/quick-form",
    "form_ident": "quick-edit",
    "group_display_mode": "lang"
}
```

Merged from locomotivemtl/charcoal-admin#63:

* 1st version of new group_display_mode for quick-form
* add class for specific display mode lang on quick-form widget to improve css trigger
* add use of ModelStructureProperty in QuickFormWidget
* use trans method instead of translate
* move quickform custom lang css
* migrate showLanguageSwith to his own Combo Interface/Trait. Implemented in FormSidebarWidget and QuickFormWidget
* Add support class Sorter and migrate sortLanguagesByPriority, sortItemsByPriority, sortGroupsByPriority, sortActionsByPriority into one supportByPriority function
* change css with new -tabbed-by-lang class for quick form
* build css
* move custom JS file to quickform.js
* replace hasL10nFormProperties method for ObjectFormWidget with implementation from QuickFormWidget
* add getTabbableDisplayModes
* improve quickform JS adding variable for lang switcher in widgetDataForJs
* wrapped the event listener for lang tab on quickform with condition

(cherry picked from commit locomotivemtl/charcoal-admin#d27a30e44b0e6e06899a481322015b09e743dc82)
mcaskill pushed a commit to charcoalphp/charcoal that referenced this pull request Jul 15, 2022
Added support for grouping properties by language, for multilingual form properties:

```json
{
    "type": "charcoal/admin/widget/quick-form",
    "form_ident": "quick-edit",
    "group_display_mode": "lang"
}
```

Merged from locomotivemtl/charcoal-admin#63:

* 1st version of new group_display_mode for quick-form
* add class for specific display mode lang on quick-form widget to improve css trigger
* add use of ModelStructureProperty in QuickFormWidget
* use trans method instead of translate
* move quickform custom lang css
* migrate showLanguageSwith to his own Combo Interface/Trait. Implemented in FormSidebarWidget and QuickFormWidget
* Add support class Sorter and migrate sortLanguagesByPriority, sortItemsByPriority, sortGroupsByPriority, sortActionsByPriority into one supportByPriority function
* change css with new -tabbed-by-lang class for quick form
* build css
* move custom JS file to quickform.js
* replace hasL10nFormProperties method for ObjectFormWidget with implementation from QuickFormWidget
* add getTabbableDisplayModes
* improve quickform JS adding variable for lang switcher in widgetDataForJs
* wrapped the event listener for lang tab on quickform with condition

(cherry picked from commit locomotivemtl/charcoal-admin#d27a30e44b0e6e06899a481322015b09e743dc82)
mcaskill added a commit to charcoalphp/charcoal that referenced this pull request Jul 20, 2022
Added support for grouping properties by language, for multilingual form properties:

```json
{
    "type": "charcoal/admin/widget/quick-form",
    "form_ident": "quick-edit",
    "group_display_mode": "lang"
}
```

Merged from locomotivemtl/charcoal-admin#63:

* 1st version of new group_display_mode for quick-form
* add class for specific display mode lang on quick-form widget to improve css trigger
* add use of ModelStructureProperty in QuickFormWidget
* use trans method instead of translate
* move quickform custom lang css
* migrate showLanguageSwith to his own Combo Interface/Trait. Implemented in FormSidebarWidget and QuickFormWidget
* Add support class Sorter and migrate sortLanguagesByPriority, sortItemsByPriority, sortGroupsByPriority, sortActionsByPriority into one supportByPriority function
* change css with new -tabbed-by-lang class for quick form
* build css
* move custom JS file to quickform.js
* replace hasL10nFormProperties method for ObjectFormWidget with implementation from QuickFormWidget
* add getTabbableDisplayModes
* improve quickform JS adding variable for lang switcher in widgetDataForJs
* wrapped the event listener for lang tab on quickform with condition

(cherry picked from commit locomotivemtl/charcoal-admin#d27a30e44b0e6e06899a481322015b09e743dc82)
charcoal-butler bot pushed a commit to charcoalphp/charcoal that referenced this pull request Jul 20, 2022
## [3.0.0](v2.3.0...v3.0.0) (2022-07-20)

### ⚠ BREAKING CHANGES

* (BC):
- Method `widgetOptions()` now returns an array instead of a JSON serialized string to allow for easier overriding in subclasses.

Added:
- Methods `widgetOptionsAsJson()` and `escapedWidgetOptionsAsJson()` for rendering widget options as JSON.
- Method `widgetDataForJs()` to replace hardcoded widget data options in view file.

Changed:
- Stringify the widget's title.

### Features

* **admin:** Add new group display mode for quick form widget ([524ec25](524ec25)), closes [locomotivemtl/charcoal-admin#63](locomotivemtl/charcoal-admin#63) [locomotivemtl/charcoal-admin#d27a30e44b0e6e06899a481322015b09e743dc82](https://github.com/locomotivemtl/charcoal-admin/issues/d27a30e44b0e6e06899a481322015b09e743dc82)
* **admin:** Improve dialog in widget.js ([1855d3b](1855d3b)), closes [locomotivemtl/charcoal-admin#8eb005a375875a7158537898c357b050ab066050](https://github.com/locomotivemtl/charcoal-admin/issues/8eb005a375875a7158537898c357b050ab066050)
* **admin:** Improve error handling in form.js ([8340eb6](8340eb6)), closes [locomotivemtl/charcoal-admin#6659001b72230e62f353ac533e449ffec40221d4](https://github.com/locomotivemtl/charcoal-admin/issues/6659001b72230e62f353ac533e449ffec40221d4)
* **admin:** Improve generic graph widgets ([b8a03f6](b8a03f6)), closes [locomotivemtl/charcoal-admin#8e482bd13688c8b3d2770078424b6117eba3d0](https://github.com/locomotivemtl/charcoal-admin/issues/8e482bd13688c8b3d2770078424b6117eba3d0)
* **admin:** Improve reloading in widget.js ([f409aac](f409aac)), closes [locomotivemtl/charcoal-admin#d8d977c1609515b144837d1d1ca3f11677972](https://github.com/locomotivemtl/charcoal-admin/issues/d8d977c1609515b144837d1d1ca3f11677972)
* **admin:** Improve showLanguageSwitch integration ([41f341f](41f341f)), closes [locomotivemtl/charcoal-admin#9c436ea57c5a37e90f97f90cf78994ab66cd0083](https://github.com/locomotivemtl/charcoal-admin/issues/9c436ea57c5a37e90f97f90cf78994ab66cd0083)
* **admin:** Improve switch language in form.js ([22c30ec](22c30ec)), closes [locomotivemtl/charcoal-admin#e9d29556820f0b2f4e6a6adc127c31dad86fae04](https://github.com/locomotivemtl/charcoal-admin/issues/e9d29556820f0b2f4e6a6adc127c31dad86fae04)
* **admin:** Improve validate/save in component_manager.js ([423c84b](423c84b)), closes [locomotivemtl/charcoal-admin#1759d2bb90297ff7f03c5c94a0211b22dd2796](https://github.com/locomotivemtl/charcoal-admin/issues/1759d2bb90297ff7f03c5c94a0211b22dd2796) [locomotivemtl/charcoal-admin#e5e0741666cb52ca84a09cabce6619a8ec61c7c2](https://github.com/locomotivemtl/charcoal-admin/issues/e5e0741666cb52ca84a09cabce6619a8ec61c7c2)

### Bug Fixes

* **admin:** Add missing localizations ([9496922](9496922)), closes [locomotivemtl/charcoal-admin#47012a22e696bd090adb08ded9954ac1a50e84](https://github.com/locomotivemtl/charcoal-admin/issues/47012a22e696bd090adb08ded9954ac1a50e84)
* **admin:** Ensure widgetL10n is available with attachment.js ([8cea251](8cea251)), closes [locomotivemtl/charcoal-attachment#496b9bec978bb01065e59c36e4291fe8e3384](https://github.com/locomotivemtl/charcoal-attachment/issues/496b9bec978bb01065e59c36e4291fe8e3384)
* **admin:** Improve hasL10nFormProperties resolution ([3be40b0](3be40b0)), closes [locomotivemtl/charcoal-admin#2c4c3797bb8463241e723e6d157589291c832a0](https://github.com/locomotivemtl/charcoal-admin/issues/2c4c3797bb8463241e723e6d157589291c832a0)
* **admin:** Improve internals of attachment.js ([a387db3](a387db3)), closes [locomotivemtl/charcoal-admin#45135ef015723f319ed246bf28eac4d4d2dccbe4](https://github.com/locomotivemtl/charcoal-admin/issues/45135ef015723f319ed246bf28eac4d4d2dccbe4)
* **admin:** Improve resolveSimpleJsonXhr in charcoal.js ([1eee836](1eee836)), closes [locomotivemtl/charcoal-admin#bc8327e7aadeb57ea6e1ec931051aba4d630d409](https://github.com/locomotivemtl/charcoal-admin/issues/bc8327e7aadeb57ea6e1ec931051aba4d630d409)
* **admin:** Update Bootstrap to v4.6.2 ([1fb8b4a](1fb8b4a)), closes [locomotivemtl/charcoal-admin#e6ac7b6f3b447cf08b7d9578b3d888d178a3639](https://github.com/locomotivemtl/charcoal-admin/issues/e6ac7b6f3b447cf08b7d9578b3d888d178a3639)
* **property:** Fix parsing + error handling in Sprite Property ([831f16d](831f16d)), closes [locomotivemtl/charcoal-property#d1ef3c66122781581a856721fe233a816fc5b0b6](https://github.com/locomotivemtl/charcoal-property/issues/d1ef3c66122781581a856721fe233a816fc5b0b6) [locomotivemtl/charcoal-property#8f3403145b55c43190e447dae1c8f4dea249cc33](https://github.com/locomotivemtl/charcoal-property/issues/8f3403145b55c43190e447dae1c8f4dea249cc33)

### Performance Improvements

* **admin:** Fix and improve event namespacing in JS components ([db46534](db46534)), closes [locomotivemtl/charcoal-admin#738ae375ed4fa92cdd2ddbdadb2dca3cab8bbe96](https://github.com/locomotivemtl/charcoal-admin/issues/738ae375ed4fa92cdd2ddbdadb2dca3cab8bbe96)
* **admin:** Improve elements in form.js and quickform.js ([81b9cad](81b9cad)), closes [locomotivemtl/charcoal-admin#bee1d393d313fdfc0a8b9a5918a7678a46b33d21](https://github.com/locomotivemtl/charcoal-admin/issues/bee1d393d313fdfc0a8b9a5918a7678a46b33d21)
* **admin:** Improve internals of feedback.js ([cb6a4f6](cb6a4f6)), closes [locomotivemtl/charcoal-admin#45b76606fc945ab2526ccdd9db8219b11fb8ca10](https://github.com/locomotivemtl/charcoal-admin/issues/45b76606fc945ab2526ccdd9db8219b11fb8ca10)
* **export:** improve performance of exporter ([9a1de4c](9a1de4c)), closes [locomotivemtl/charcoal-admin#19192817861a2faed50ad7aeb8b10dfbcc63ce25](https://github.com/locomotivemtl/charcoal-admin/issues/19192817861a2faed50ad7aeb8b10dfbcc63ce25)

### Reverts

* **admin:** Disable `will_save` constraint in attachment.js ([3e78bcd](3e78bcd)), closes [locomotivemtl/charcoal-admin#1759d2bb90297ff7f03c5c94a0211b22dd2796](https://github.com/locomotivemtl/charcoal-admin/issues/1759d2bb90297ff7f03c5c94a0211b22dd2796) [locomotivemtl/charcoal-admin#6fb62c401db2192693d09cd42b8b2250d7af57b6](https://github.com/locomotivemtl/charcoal-admin/issues/6fb62c401db2192693d09cd42b8b2250d7af57b6)

### Code Refactoring

* Integration of Attachment widget data and options ([c24ebc7](c24ebc7)), closes [locomotivemtl/charcoal-attachment#994dcc357626c0fd716b864812dffdc1ca742d93](https://github.com/locomotivemtl/charcoal-attachment/issues/994dcc357626c0fd716b864812dffdc1ca742d93)
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.

3 participants