@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Hide time controls when editing all-day Calendar events

Summary:
Ref T11326. When an event is all-day, hide the time controls for the start/end dates. These aren't used and aren't helpful/useful.

This got a little more complicated than it used to be because EditEngine forms may have only some of these controls present.

Test Plan: Edited an all-day event; edited a normal event; swapped an event between normal and all-day.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11326

Differential Revision: https://secure.phabricator.com/D16327

+67 -10
+41
src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
··· 212 212 return $fields; 213 213 } 214 214 215 + protected function willBuildEditForm($object, array $fields) { 216 + $all_day_field = idx($fields, 'isAllDay'); 217 + $start_field = idx($fields, 'start'); 218 + $end_field = idx($fields, 'end'); 219 + 220 + if ($all_day_field) { 221 + $is_all_day = $all_day_field->getValueForTransaction(); 222 + 223 + $control_ids = array(); 224 + if ($start_field) { 225 + $control_ids[] = $start_field->getControlID(); 226 + } 227 + if ($end_field) { 228 + $control_ids[] = $end_field->getControlID(); 229 + } 230 + 231 + Javelin::initBehavior( 232 + 'event-all-day', 233 + array( 234 + 'allDayID' => $all_day_field->getControlID(), 235 + 'controlIDs' => $control_ids, 236 + )); 237 + 238 + } else { 239 + $is_all_day = $object->getIsAllDay(); 240 + } 241 + 242 + if ($is_all_day) { 243 + if ($start_field) { 244 + $start_field->setHideTime(true); 245 + } 246 + 247 + if ($end_field) { 248 + $end_field->setHideTime(true); 249 + } 250 + } 251 + 252 + 253 + 254 + return $fields; 255 + } 215 256 }
+6
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1176 1176 $controller = $this->getController(); 1177 1177 $request = $controller->getRequest(); 1178 1178 1179 + $fields = $this->willBuildEditForm($object, $fields); 1180 + 1179 1181 $form = id(new AphrontFormView()) 1180 1182 ->setUser($viewer) 1181 1183 ->addHiddenInput('editEngine', 'true'); ··· 1208 1210 } 1209 1211 1210 1212 return $form; 1213 + } 1214 + 1215 + protected function willBuildEditForm($object, array $fields) { 1216 + return $fields; 1211 1217 } 1212 1218 1213 1219 private function buildEditFormActionButton($object) {
+12 -3
src/applications/transactions/editfield/PhabricatorEpochEditField.php
··· 4 4 extends PhabricatorEditField { 5 5 6 6 private $allowNull; 7 + private $hideTime; 7 8 8 9 public function setAllowNull($allow_null) { 9 10 $this->allowNull = $allow_null; ··· 14 15 return $this->allowNull; 15 16 } 16 17 18 + public function setHideTime($hide_time) { 19 + $this->hideTime = $hide_time; 20 + return $this; 21 + } 22 + 23 + public function getHideTime() { 24 + return $this->hideTime; 25 + } 26 + 17 27 protected function newControl() { 18 28 return id(new AphrontFormDateControl()) 19 29 ->setAllowNull($this->getAllowNull()) 30 + ->setIsTimeDisabled($this->getHideTime()) 20 31 ->setViewer($this->getViewer()); 21 32 } 22 33 ··· 26 37 } 27 38 28 39 protected function newConduitParameterType() { 29 - // TODO: This isn't correct, but we don't have any methods which use this 30 - // yet. 31 - return new ConduitIntParameterType(); 40 + return new ConduitEpochParameterType(); 32 41 } 33 42 34 43 }
+8 -7
webroot/rsrc/js/application/calendar/behavior-event-all-day.js
··· 2 2 * @provides javelin-behavior-event-all-day 3 3 */ 4 4 5 - 6 5 JX.behavior('event-all-day', function(config) { 7 - var checkbox = JX.$(config.allDayID); 8 - JX.DOM.listen(checkbox, 'change', null, function() { 9 - var start = JX.$(config.startDateID); 10 - var end = JX.$(config.endDateID); 6 + var all_day = JX.$(config.allDayID); 7 + 8 + JX.DOM.listen(all_day, 'change', null, function() { 9 + var is_all_day = !!parseInt(all_day.value, 10); 11 10 12 - JX.DOM.alterClass(start, 'no-time', checkbox.checked); 13 - JX.DOM.alterClass(end, 'no-time', checkbox.checked); 11 + for (var ii = 0; ii < config.controlIDs.length; ii++) { 12 + var control = JX.$(config.controlIDs[ii]); 13 + JX.DOM.alterClass(control, 'no-time', is_all_day); 14 + } 14 15 }); 15 16 16 17 });