Comments

tacituseu created an issue. See original summary.

sam152’s picture

Version: » 8.x-1.x-dev

This is a great idea, will this allow us to remove the custom widget?

tacituseu’s picture

Assigned: Unassigned » tacituseu

Yes it will.

tacituseu’s picture

Could at the same time get rid of the custom formatter and replace it with 'list_default' but Drupal\options\Plugin\Field\FieldFormatter\OptionsDefaultFormatter hardcoded the property name to 'value', so would have to change the property name from the current 'state'.

sam152’s picture

Would that work if state is the machine name and we want to show the label?

tacituseu’s picture

Yes, it gets the labels via OptionsProviderInterface::getPossibleOptions() so it turns out just fine.

sam152’s picture

Okay, I say it's probably worth updating the column name.

tacituseu’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new12.51 KB

Here's an initial patch, mostly based on state_machine, so all credit to @bojanz.

Notes:
1. to preserve relative ordering of states used WorkflowTypeInterface::getStates() and filtered it with StateInterface::canTransitionTo(), instead of using WorkflowTypeInterface::getTransitionsForState() approach
2. WorkflowsFieldItem::getWorkflow() gets called from WorkflowsFieldItem::applyDefaultValue() quite early (at FieldItemInterface::storageSettingsForm() stage) so changed its implementation to return NULL when it is unknown, will need to look more into it to make sure ::applyDefaultValue() does what I think it does ;)
3. keeping current state needs explicit 'keep at' transitions (as is the case in core now)

Should work, but still needs work, will get back to it in a week or so, NR just for testing.

Status: Needs review » Needs work

The last submitted patch, 8: 2907517-8-options-provider.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tacituseu’s picture

Status: Needs work » Needs review
StatusFileSize
new13.28 KB
new1.46 KB

Status: Needs review » Needs work

The last submitted patch, 10: 2907517-10-options-provider.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tacituseu’s picture

Status: Needs work » Needs review
StatusFileSize
new13.91 KB
new930 bytes

This should do it.

Status: Needs review » Needs work

The last submitted patch, 12: 2907517-12-options-provider.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
new15.24 KB

Test fixes.

Status: Needs review » Needs work

The last submitted patch, 14: 2907517-14-options-provider.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

sam152’s picture

Status: Needs work » Fixed

Test fixed on commit.

  • Sam152 committed 5fdb8c3 on 8.x-1.x
    Issue #2907748 by tacituseu, Sam152: Make WorkflowsFieldItem implement...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.