Problem/Motivation

From https://www.drupal.org/node/2787105#comment-11869670

OTOH while I was looking at this, I found that datetime.schema.yml does not use the "built-in" date_format type, so it would not show up with the proper preview/help in config translation. If that switches to use the date_format type, then the UI is better as well for this pattern. We can move this to a different issue if repurposing this one is too much of a headache.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mpdonadio created an issue. See original summary.

mpdonadio’s picture

1. Please make sure Gábor gets credit here, and this was his find/patch from #2787105: Add RTL support for daterange formatters.

2. I assume we need an empty post update hook to trigger the schema being re-read to make this work? Will add that shortly.

Gábor Hojtsy’s picture

I don't know what is needed to make the schema re-read. Also cannot RTBC myself since its my patch :D

This improved the date format translation editing experience in date and date range modules, because config_translation hangs a specific widget on the date_format type:

function config_translation_config_schema_info_alter(&$definitions) {
  $map = array(
    'label' => '\Drupal\config_translation\FormElement\Textfield',
    'text' => '\Drupal\config_translation\FormElement\Textarea',
    'date_format' => '\Drupal\config_translation\FormElement\DateFormat',
    'text_format' => '\Drupal\config_translation\FormElement\TextFormat',
    'mapping' => '\Drupal\config_translation\FormElement\ListElement',
    'sequence' => '\Drupal\config_translation\FormElement\ListElement',
    'plural_label' => '\Drupal\config_translation\FormElement\PluralVariants',
  );

  // Enhance the text and date type definitions with classes to generate proper
  // form elements in ConfigTranslationFormBase. Other translatable types will
  // appear as a one line textfield.
  foreach ($definitions as $type => &$definition) {
    if (isset($map[$type]) && !isset($definition['form_element_class'])) {
      $definition['form_element_class'] = $map[$type];
    }
  }
}

So using the string type does not get the right form class in config translation. While it gets the same treatment in terms of translatability and the translation context that are both manually defined here, it should just use the date_format type which carry both AND comes with the right form class assigned.

mpdonadio’s picture

Crosspost. Here is an update hook, which will force a rebuild which will pick up the schema change.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me.

Gábor Hojtsy’s picture

Issue tags: +SprintWeekend2017
mpdonadio’s picture

Version: 8.4.x-dev » 8.3.x-dev

This is a bug, so it should be 8.3.x eligible.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2843934-03.patch, failed testing.

mpdonadio’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2843934-03.patch, failed testing.

mpdonadio’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC after a CI error, https://www.drupal.org/pift-ci-job/587861

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2843934-03.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community

Failed in database prefix handling. Unrelated. https://www.drupal.org/pift-ci-job/595248

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 2843934-03.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community

CI error:

08:34:50 PHP Fatal error:  Uncaught Error: Call to a member function exec() on null in /opt/drupalci/testrunner/src/DrupalCI/Build/Environment/Database.php:263
08:34:50 Recording test results
08:34:50 ERROR: Step ?Publish JUnit test result report? failed: No test report files were found. Configuration error?
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

As this is going into 8.3.0 and that's not out yet the update function is not needed - there's plenty in existence already.

Committed and pushed 3404c72 to 8.4.x and 1129fa2 to 8.3.x. Thanks!

  • alexpott committed 3404c72 on 8.4.x
    Issue #2843934 by mpdonadio, Gábor Hojtsy: datetime.schema.yml does not...

  • alexpott committed 1129fa2 on 8.3.x
    Issue #2843934 by mpdonadio, Gábor Hojtsy: datetime.schema.yml does not...
Gábor Hojtsy’s picture

Yay, thanks!

Gábor Hojtsy’s picture

Edited the wrong tag :/

Status: Fixed » Closed (fixed)

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