Issue #2827055: Add option to show only start or end date in the DateTime Range custom formatter
Merge request reports
Activity
- Resolved by Srishti Bankar
- Resolved by Srishti Bankar
- Resolved by Srishti Bankar
- Resolved by catch
added 42 commits
-
91dc7e2c...6950ec5b - 32 commits from branch
project:11.x
- 22e8208c - patch#93
- 6e316cf3 - Added an update path test
- 58892b19 - Update path for 'from_to'
- 7db99db7 - Added test group
- f9846356 - fix test
- 5674e1ee - Moved post update logic to presave
- 9cca3ff9 - Replaced strings with constants
- 3a2688d1 - use statement
- a0770243 - Move the constants to DateRangeItem class
- 34049afc - New class for constants
Toggle commit list-
91dc7e2c...6950ec5b - 32 commits from branch
- Resolved by Srishti Bankar
added 48 commits
-
34049afc...753bac68 - 37 commits from branch
project:11.x
- 5f3a067c - 1 earlier commit
- 03f90e4f - Added an update path test
- 49eaf9bf - Update path for 'from_to'
- 5e787b76 - Added test group
- 5319e1ec - fix test
- 670fc5f7 - Moved post update logic to presave
- f2843219 - Replaced strings with constants
- ad94eb5d - use statement
- 3f15fb11 - Move the constants to DateRangeItem class
- 8cb70b56 - New class for constants
- 782c1a2e - Fixed descriptions
Toggle commit list-
34049afc...753bac68 - 37 commits from branch
added 109 commits
-
782c1a2e...529c7932 - 98 commits from branch
project:11.x
- 333728f9 - 1 earlier commit
- ea207e7f - Added an update path test
- e24b9f79 - Update path for 'from_to'
- 4188b551 - Added test group
- 5bca9783 - fix test
- e1a956fe - Moved post update logic to presave
- 403f181e - Replaced strings with constants
- 4e1589c0 - use statement
- cefcf937 - Move the constants to DateRangeItem class
- f9a2ea60 - New class for constants
- a2e999b7 - Fixed descriptions
Toggle commit list-
782c1a2e...529c7932 - 98 commits from branch
- Resolved by Srishti Bankar
- Resolved by Srishti Bankar
- Resolved by Srishti Bankar
added 33 commits
-
a2e999b7...3d917f37 - 18 commits from branch
project:11.x
- 3d917f37...e9d08af4 - 5 earlier commits
- 5394c007 - Moved post update logic to presave
- 64db8877 - Replaced strings with constants
- 3432f725 - use statement
- c269b76f - Move the constants to DateRangeItem class
- d6a35031 - New class for constants
- 4c173699 - Fixed descriptions
- b1ddfc7e - Fix states for separator element
- 4e50319a - Updated post update hook to use config_entity_updater
- 152c571b - Added 'Choice' constraint
- 417bdfe2 - Added test for date separator visibility
Toggle commit list-
a2e999b7...3d917f37 - 18 commits from branch
14 17 'datetime_range_post_update_views_string_plugin_id' => '9.0.0', 15 18 ]; 16 19 } 20 21 /** 22 * Updates date range field formatter configuration by adding a "from_to" setting to flagged entity view displays. 23 * 24 * @see \datetime_range_entity_view_display_presave 25 */ 26 function datetime_range_post_update_from_to_configuration(array &$sandbox = NULL): void { 27 $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class); 28 29 $callback = function (EntityViewDisplayInterface $entity_view_display) { 30 return $entity_view_display->get('datetime_range_updated') === TRUE; This is run before
datetime_range_entity_view_display_presave
so this would actually never trigger the entity to save. The reason the test is passing is because there are other post update hooks triggeringentity_view_display
config entities to resave.This will need to be updated to check the same condition as the post update hook for determining if an update is needed, i.e.
!isset($component['settings']['from_to'])
.changed this line in version 12 of the diff
added 133 commits
-
417bdfe2...d5d6431e - 117 commits from branch
project:11.x
- d5d6431e...32a33d26 - 6 earlier commits
- 5980bf6d - Replaced strings with constants
- d0b5b413 - use statement
- 82614903 - Move the constants to DateRangeItem class
- a00b7984 - New class for constants
- 9753a67e - Fixed descriptions
- 815526c3 - Fix states for separator element
- 7929148c - Updated post update hook to use config_entity_updater
- c34e5dd6 - Added 'Choice' constraint
- c20f70b5 - Added test for date separator visibility
- d3f7f28c - added condition in post_update hook
Toggle commit list-
417bdfe2...d5d6431e - 117 commits from branch
72 '#description' => $this->t('The string to separate the start and end dates'), 73 '#default_value' => $this->getSetting('separator'), 74 '#states' => [ 75 'visible' => [ 76 'select[name="fields[' . $field_name . '][settings_edit_form][settings][from_to]"]' => ['value' => DateTimeRangeConstants::BOTH], 77 ], 78 ], 79 ]; 80 81 return $form; 82 } 83 84 /** 85 * {@inheritdoc} 86 */ 87 public function dateTimeRangeSettingsSummary() { changed this line in version 18 of the diff
108 */ 109 protected function getFromToOptions() { 110 return [ 111 DateTimeRangeConstants::BOTH => $this->t('Display both start and end dates'), 112 DateTimeRangeConstants::START_DATE => $this->t('Display start date only'), 113 DateTimeRangeConstants::END_DATE => $this->t('Display end date only'), 114 ]; 115 } 116 117 /** 118 * Returns whether or not the start date should be displayed. 119 * 120 * @return bool 121 * True if the start date should be displayed. False otherwise. 122 */ 123 public function startDateIsDisplayed() { changed this line in version 18 of the diff
124 switch ($this->getSetting('from_to')) { 125 case DateTimeRangeConstants::BOTH: 126 case DateTimeRangeConstants::START_DATE: 127 return TRUE; 128 } 129 130 return FALSE; 131 } 132 133 /** 134 * Returns whether or not the end date should be displayed. 135 * 136 * @return bool 137 * True if the end date should be displayed. False otherwise. 138 */ 139 public function endDateIsDisplayed() { changed this line in version 18 of the diff
- Resolved by quietone
2 2 3 3 namespace Drupal\datetime_range; 4 4 5 use Drupal\Core\Datetime\DrupalDateTime; 5 6 use Drupal\Core\Field\FieldItemListInterface; 7 use Drupal\Core\Form\FormStateInterface; 6 8 7 9 /** 8 10 * Provides friendly methods for datetime range. 9 11 */ 10 12 trait DateTimeRangeTrait { 11 13 14 /** 15 * {@inheritdoc} 16 */ 17 public static function dateTimeRangeDefaultSettings() { changed this line in version 18 of the diff
64 ]; 65 66 if (!in_array($plugin_definition['class'], $daterange_formatter_classes, FALSE)) { 67 continue; 68 } 69 70 if (!isset($component['settings']['from_to'])) { 71 // Existing daterange formatters don't have 'from_to'. 72 $component['settings']['from_to'] = DateTimeRangeConstants::BOTH; 73 $entity_view_display->setComponent($name, $component); 74 $update = TRUE; 75 } 76 } 77 78 if ($update) { 79 $entity_view_display->set('datetime_range_updated', TRUE); changed this line in version 18 of the diff
1 <?php 2 3 namespace Drupal\datetime_range; 4 5 /** 6 * Declares constants used in the datetime range module. 7 */ 8 class DateTimeRangeConstants { changed this line in version 19 of the diff
103 /** 104 * Returns a list of possible values for the 'from_to' setting. 105 * 106 * @return array 107 * A list of 'from_to' options. 108 */ 109 protected function getFromToOptions() { 110 return [ 111 DateTimeRangeConstants::BOTH => $this->t('Display both start and end dates'), 112 DateTimeRangeConstants::START_DATE => $this->t('Display start date only'), 113 DateTimeRangeConstants::END_DATE => $this->t('Display end date only'), 114 ]; 115 } 116 117 /** 118 * Returns whether or not the start date should be displayed. changed this line in version 18 of the diff
added 42 commits
-
e60de758...2f071240 - 20 commits from branch
project:11.x
- 2f071240...70417a66 - 12 earlier commits
- 89593061 - Updated post update hook to use config_entity_updater
- 5d243a13 - Added 'Choice' constraint
- 0f0236a7 - Added test for date separator visibility
- 4e6a8f34 - added condition in post_update hook
- 50c95db5 - iterated over components
- 8a77f12f - phpcs fix
- affeb716 - saved form_to config in post_update
- e9980ac8 - removed settings from_to
- d3f58c93 - decluttered
- 418515c1 - addressed nits
Toggle commit list-
e60de758...2f071240 - 20 commits from branch
added 41 commits
-
418515c1...b20ec518 - 18 commits from branch
project:11.x
- b20ec518...0bc703e9 - 13 earlier commits
- 31a98be9 - Added 'Choice' constraint
- 24f4c4ce - Added test for date separator visibility
- 0d762d45 - added condition in post_update hook
- 9719c64a - iterated over components
- 614030e2 - phpcs fix
- eecfba6e - saved form_to config in post_update
- ddd96ab7 - removed settings from_to
- c72bb4da - decluttered
- 3ad25168 - addressed nits
- b737434d - changed DateTimeRangeConstants to an intereface
Toggle commit list-
418515c1...b20ec518 - 18 commits from branch
1 <?php 2 3 namespace Drupal\datetime_range; 4 5 /** 6 * Declares constants used in the datetime range module. 7 */ 8 enum DateTimeRangeConstants: string { changed this line in version 21 of the diff
added 29 commits
-
50bbdd28...67dbfb98 - 4 commits from branch
project:11.x
- 67dbfb98...69ffa8cc - 15 earlier commits
- 24746e3c - added condition in post_update hook
- d5e7bd75 - iterated over components
- 6b773a8a - phpcs fix
- a351c919 - saved form_to config in post_update
- a9f661ae - removed settings from_to
- f5e7c12f - decluttered
- f54821b9 - addressed nits
- 10c894cd - changed DateTimeRangeConstants to an intereface
- 8fe5e8e0 - changed it to enum
- ef33bc2d - chagned enum name
Toggle commit list-
50bbdd28...67dbfb98 - 4 commits from branch
- Resolved by quietone
added 146 commits
-
ef33bc2d...c271adbb - 144 commits from branch
project:11.x
- f11fdd87 - Merge branch '11.x' into 2827055-add-option-to
- 7e75361e - uncommented update hook
-
ef33bc2d...c271adbb - 144 commits from branch
27 32 return $output; 28 33 } 29 34 } 35 36 /** 37 * Implements hook_ENTITY_TYPE_presave() for entity_view_display entities. 38 */ 39 function datetime_range_entity_view_display_presave(EntityViewDisplayInterface $entity_view_display): void { This should either have a @todo, or maybe be moved to a helper function, so that it's easy to identify and remove when we remove the post update. Views has its own ConfigUpdater class for this, but tbh I think _datetime_range_post_update_from_to_configuration() or something would be fine here?
added 407 commits
-
7df4b258...b3c74ca1 - 379 commits from branch
project:11.x
- b3c74ca1...70ca7e68 - 18 earlier commits
- 505e3410 - saved form_to config in post_update
- 34559d5d - removed settings from_to
- 543808a4 - decluttered
- 4c78da09 - addressed nits
- c3c1699d - changed DateTimeRangeConstants to an intereface
- e9cdd5a4 - changed it to enum
- e97eb71f - chagned enum name
- ca4ca6d6 - phpcs fix
- 82bba5d0 - added return type, shortened summary line
- 9aaa1c4c - removed paramter from func calls
Toggle commit list-
7df4b258...b3c74ca1 - 379 commits from branch
added 1 commit
- b94e605d - Convert the enum back to interface so it's 8.1 compatible