Since you must select at least one Published and one Non-published state, we should separate those in the UI.

Further, if only one option is present, that should be a preselected radio button or preselected, disabled checkbox.

Separate the UX of the state options

Comments

agentrickard created an issue. See original summary.

agentrickard’s picture

Issue summary: View changes
Crell’s picture

Assigned: Unassigned » agentrickard
Status: Active » Needs review
StatusFileSize
new7.41 KB

Something like this, testbot willing?

(It doesn't pre-select a value in the select box, because since the select box is now based on 2 checkboxes I don't know if it's possible to now filter it by the checked values. If it is, it's probably hard. :-) But it still validates server-side as before.)

Status: Needs review » Needs work

The last submitted patch, 3: 2651084-split-moderation-checkboxes.patch, failed testing.

The last submitted patch, 3: 2651084-split-moderation-checkboxes.patch, failed testing.

The last submitted patch, 3: 2651084-split-moderation-checkboxes.patch, failed testing.

Crell’s picture

Status: Needs work » Needs review
StatusFileSize
new13.51 KB
new7.31 KB

Badly written tests are badly written.

agentrickard’s picture

Just looking at the patch, we are now mixing t() and $this->t().

+    $form['allowed_moderation_states_published'] = [
+      '#type' => 'checkboxes',
+      '#title' => t('Allowed moderation states (Published)'),
+      '#description' => t('The allowed published moderation states this content-type can be assigned.'),
+      '#default_value' => $bundle->getThirdPartySetting('workbench_moderation', 'allowed_moderation_states', array_keys($options_published)),
+      '#options' => $options_published,
+      '#required' => TRUE,
+      '#states' => [
+        'visible' => [
+          ':input[name=enable_moderation_state]' => ['checked' => TRUE],
+        ],
+      ],
+    ];
+
+    // This is screwy, but the key of the array needs to be a user-facing string
+    // so we have to fully render the translatable string to a real string, or
+    // else PHP chokes on an object used as an array key.
+    $options = [
+      $this->t('Unpublished')->render() => $options_unpublished,
+      $this->t('Published')->render() => $options_published,
+    ];
+
     $form['default_moderation_state'] = [
       '#type' => 'select',
       '#title' => t('Default moderation state'),
-      '#empty_option' => t('-- Select --'),
       '#options' => $options,
       '#description' => t('Select the moderation state for new content'),
       '#default_value' => $bundle->getThirdPartySetting('workbench_moderation', 'default_moderation_state', 'draft'),

There may be more t() invocations in the form code.

Crell’s picture

Issue summary: View changes
StatusFileSize
new15 KB
new4.22 KB
new60.52 KB
new72.65 KB

Bah. Lots of left over t() in there, which means it goes all the way back to larowlan's original moderation_state module. Fixed all t()s in forms.

Also, as requested, here's 2 screencaps. One with the select box open, one closed. (To show the optgroup.) (I tried to embed them but the Embed button seems to be malfunctioning.)

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

Alright, alright, alright.

++

  • Crell committed 6f29a32 on 8.x-1.x
    Issue #2651084 by Crell, agentrickard: Allowed moderation states should...
Crell’s picture

Title: Allowed moderattion states should be split » Allowed moderation states should be split
Status: Reviewed & tested by the community » Fixed

Thanks. :-) Merged and pushed.

Status: Fixed » Closed (fixed)

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