I wanted to have an option whereby you could decide to have an end time or not. Would be more than happy to work on this if one of the maintainers could confirm that they would be willing to commit it.

Comments

mchampsee created an issue. See original summary.

Frando’s picture

This is already supported, just not very obvious: If you do not enter an end date, the end date is set to the same as the start date. Upon display, the end date is ommitted if it is the same as the start date.

I'd be willing to commit a configuration option in the widget to optionally hide the end date.

realityloop’s picture

Assigned: mchampsee » Unassigned

@frando

We've just been discussing through this and it would be great if there was an option to hide the end date field (but still show the end time part).

realityloop’s picture

StatusFileSize
new1.16 KB

Here is a start at implementing this

realityloop’s picture

StatusFileSize
new1.7 KB

I know this is nowhere near generic enough yet.

thinkV’s picture

This might need work, when an existing end date has been set.

realityloop’s picture

StatusFileSize
new1.77 KB

just re-rolling for myself.

borisson_’s picture

Issue tags: -options, -date

The hide_end_date.js file has empty lines with spaces included, those should be removed from the patch.

+++ b/date_recur.module
@@ -88,6 +88,10 @@ function date_recur_field_storage_config_delete(FieldStorageConfigInterface $fie
+function date_recur_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
+  $form['#attached']['library'][] = 'assets/hide_end_date';
+}

Needs a docblock with Implements hook_form_alter().

borisson_’s picture

Status: Active » Needs work

NW per #8, also - should we postpone this on #2866563: [Ideas] New interactive widget and use the actual form api to do the heavy lifting here?

realityloop’s picture

Title: Option to not have ending time » Option to hide end date, keeping time
realityloop’s picture

chop’s picture

+++ b/date_recur.module
@@ -88,6 +88,10 @@ function date_recur_field_storage_config_delete(FieldStorageConfigInterface $fie
+function date_recur_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
+  $form['#attached']['library'][] = 'assets/hide_end_date';
+}
+

Does this need a hook_form_alter() implementation? Isn't the assets/hide_end_date.js added already wherever the date_recur libraries are used?

chop’s picture

+++ b/assets/hide_end_date.js
@@ -0,0 +1,24 @@
+    var updateEndDate = function() {
+        $('#edit-field-date-0-end-value-date').val($('#edit-field-date-0-value-date').val());
+    };

When a time is set as after midnight, the end date value should be the next day.

chop’s picture

+++ b/assets/hide_end_date.js
@@ -0,0 +1,24 @@
+        $('#edit-field-date-0-end-value-date').css({

The field ID may change, so usually we'd get this ID or name from a data property.

+++ b/assets/hide_end_date.js
@@ -0,0 +1,24 @@
+    $(document).ready(function() {

Should we use a Drupal behavior for this?

mrpauldriver’s picture

What is the latest on this please?

dpi’s picture

Component: Code » Widget
dpi’s picture

Project: Recurring Dates Field » Interactive widget for Recurring Dates Field
Version: 8.x-1.x-dev »
Component: Widget » Code