Change Drupal's submit action buttons to simple workflow state based buttons, including replacing Delete link with delete to Trash state button

Making our Delete button look like Drupal’s Delete button (with the cool trash icon that Claro provides) is complicated by the fact that in Drupal core the delete button is actually a link, and input buttons don’t allow the :before or :after pseudoclasses, which are used to add the trashcan icon.

Another related issue, this one, to actually stop supporting Internet Explorer 6 in the very heart of our Form API, by using (themable) button elements instead of (nearly unstylable) submit, is merely seven and a half years old: https://www.drupal.org/project/drupal/issues/1671190

Rather than doing this anything close to the right way, since the truly right way seemed to high a lift, why go with half-measures? Do it completely the wrong way!

/**
 * Finagle the pseudo :before added trashcan icon, itself hung on a span added
 * with #prefix, inside our safe, send-to-Trash-state delete button.
 *
 * We can rationalize this after button element submit buttons get into core in
 * https://www.drupal.org/project/drupal/issues/1671190 or otherwise, see
 * https://agaric.gitlab.io/raw-notes/notes/2019-10-31-change-drupal-s-submit-action-buttons-to-simple-workflow-state-based-buttons-including-replacing-delete-link-with-delete-to-trash-state-button/
 */
.submit-trash.action-link::before {
  margin: 0;
  z-index: 100;
}
.submit-trash.action-link--icon-trash {
  position: relative;
  left: 1.5em;
  padding-left: 0;
  padding-right: 0;
}
.submit-trash.button {
  padding-left: 2em;
  background-color: white;
  position: relative;
  left: -1em;
}
$entity->setPublished(false);

Here’s the opposite… will it work to say TRUE here?

https://drupal.stackexchange.com/questions/236508/programmatically-created-revision-set-as-the-main-node-instead-of-revision

Prior art:

Workflow buttons module

Here’s the module i created to do this: Workflow buttons (not dropdown) | Drupal.org

And the initial module description:

Provides buttons for content moderation, with each button based on configured workflow transitions, instead of a select dropdown of states.

Each transition available for a piece of content in the current workflow state it is in, that the person editing has permission to access given their user role, will be presented as buttons replacing the Save button, the workflow dropdown, and the Publish checkbox.

For example, the Find It program locator platform and distribution has nine workflow transitions configured, including a delete-to-trash and restore-from-trash transitions that we use to replace the usual delete button with one that uses workflows to make a soft delete functionality, but at any given moment only three or four can apply, for example for a currently-published piece of content:

  1. Update
  2. Save draft (leave current version published)
  3. Unpublish
  4. Delete

Note that it replaces the usual save/submit button. (And in this case, it replaces the usual delete button-styled link, simply by not giving people permission to hard (“true”) delete.) Nor do we place “Save and” in front of every transition, the way Publishing dropdown buttons does (the module from which this one is forked); if you would like to emphasize that each button on the edit form will in fact save any changes you have made, you can simply rename your transitions to include the word Save.

This approach works best if each transition is non-ambiguous in that it does not need the “Published” checkbox to be used. This may involve configuring more states than one is used to. For instance, you’ll need a separate Unpublished state rather than re-using Draft, in order to configure Unpublished state to make itself the default revision, so you always go from Published to Unpublished without creating a new draft instead.

Supporting organizations: 

Agaric

provided the idea and the primary development.

Find It Cambridge

provided the initial need and some funding.