@@ -48,6 +48,8 @@ class RotationConfigForm extends CompatForm
48
48
*/
49
49
public const EXPERIMENTAL_OVERRIDES = false ;
50
50
51
+ protected const DAY_END = 'dayEnd ' ;
52
+
51
53
/** @var ?int The ID of the affected schedule */
52
54
protected $ scheduleId ;
53
55
@@ -895,14 +897,15 @@ protected function assembleMultiDayOptions(FieldsetElement $options): DateTime
895
897
$ toDays [$ i ] = sprintf ('%s (%s) ' , $ day , $ this ->translate ('Next week ' ));
896
898
}
897
899
898
- $ options ->addElement ('select ' , 'to_day ' , [
900
+ $ options ->addElement ('select ' , 'to_day_ignored ' , [
899
901
'class ' => 'autosubmit ' ,
900
902
'required ' => true ,
903
+ 'ignore ' => true ,
901
904
'options ' => $ toDays ,
902
- 'value ' => 7 ,
905
+ 'value ' => $ options -> getPopulatedValue ( ' to_day ' , 7 ) ,
903
906
'label ' => $ this ->translate ('To ' , 'notifications.rotation ' )
904
907
]);
905
- $ to = $ options ->getElement ('to_day ' );
908
+ $ to = $ options ->getElement ('to_day_ignored ' );
906
909
907
910
$ options ->addElement ('number ' , 'interval ' , [
908
911
'required ' => true ,
@@ -920,19 +923,42 @@ protected function assembleMultiDayOptions(FieldsetElement $options): DateTime
920
923
]);
921
924
$ options ->registerElement ($ fromAt );
922
925
923
- if ($ selectedFromDay === (int ) $ to ->getValue ()) {
926
+ $ timeOptionsFirstKey = array_key_first ($ timeOptions );
927
+ $ selectedToDay = (int ) $ to ->getValue ();
928
+ if ($ selectedFromDay === $ selectedToDay ) {
924
929
$ selectedFromAt = $ fromAt ->getValue ();
925
930
$ keyIndex = array_search ($ selectedFromAt , array_keys ($ timeOptions ));
926
931
$ timeOptions = array_slice ($ timeOptions , 0 , $ keyIndex + 1 , true );
932
+ } else {
933
+ $ timeOptions [self ::DAY_END ] = sprintf (
934
+ '%s (%s) ' ,
935
+ $ timeOptions [$ timeOptionsFirstKey ],
936
+ $ this ->translate ('End of day ' )
937
+ );
927
938
}
928
939
929
- $ toAt = $ options ->createElement ('select ' , 'to_at ' , [
940
+ $ toAt = $ options ->createElement ('select ' , 'to_at_ignored ' , [
930
941
'class ' => 'autosubmit ' ,
931
942
'required ' => true ,
932
- 'options ' => $ timeOptions
943
+ 'ignore ' => true ,
944
+ 'options ' => $ timeOptions ,
945
+ 'value ' => $ options ->getPopulatedValue ('to_at ' ),
933
946
]);
934
947
$ options ->registerElement ($ toAt );
935
948
949
+ $ selectedToAt = $ toAt ->getValue ();
950
+
951
+ if ($ selectedToAt === self ::DAY_END ) {
952
+ ++$ selectedToDay ;
953
+ $ selectedToAt = $ timeOptionsFirstKey ;
954
+ }
955
+
956
+ $ options ->clearPopulatedValue ('to_day ' );
957
+ $ options ->clearPopulatedValue ('to_at ' );
958
+
959
+ $ options ->addElement ('hidden ' , 'to_day ' , ['value ' => $ selectedToDay ]);
960
+ $ options ->addElement ('hidden ' , 'to_at ' , ['value ' => $ selectedToAt ]);
961
+
936
962
$ from ->prependWrapper (
937
963
(new HtmlDocument ())->addHtml (
938
964
$ from ,
0 commit comments