@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.

Make the "All Day Event" control use a checkbox instead of a dropdown

Summary:
This feels a little cleaner:

- Clean up transaction log a bit.
- Use a checkbox instead of a two-option dropdown.

This is a little messy because the browser doesn't send anything if the user submits a form with an un-clicked checkbox.

We now send a dummy value ("Hey, there's definitely a checkbox in this form!") so the server can figure out what to do.

Test Plan:
- Edited all-dayness of an event.
- Viewed transaction log.

Reviewers: chad

Reviewed By: chad

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

+86 -10
+2 -2
resources/celerity/map.php
··· 382 382 'rsrc/js/application/aphlict/behavior-desktop-notifications-control.js' => 'edd1ba66', 383 383 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 384 384 'rsrc/js/application/calendar/behavior-day-view.js' => '4b3c4443', 385 - 'rsrc/js/application/calendar/behavior-event-all-day.js' => '937bb700', 385 + 'rsrc/js/application/calendar/behavior-event-all-day.js' => 'b41537c9', 386 386 'rsrc/js/application/calendar/behavior-month-view.js' => 'fe33e256', 387 387 'rsrc/js/application/calendar/behavior-recurring-edit.js' => '5f1c4d5f', 388 388 'rsrc/js/application/config/behavior-reorder-fields.js' => 'b6993408', ··· 651 651 'javelin-behavior-editengine-reorder-configs' => 'd7a74243', 652 652 'javelin-behavior-editengine-reorder-fields' => 'b59e1e96', 653 653 'javelin-behavior-error-log' => '6882e80a', 654 - 'javelin-behavior-event-all-day' => '937bb700', 654 + 'javelin-behavior-event-all-day' => 'b41537c9', 655 655 'javelin-behavior-fancy-datepicker' => '568931f3', 656 656 'javelin-behavior-global-drag-and-drop' => '960f6a39', 657 657 'javelin-behavior-herald-rule-editor' => '7ebaeed3',
+18 -1
src/aphront/httpparametertype/AphrontBoolHTTPParameterType.php
··· 3 3 final class AphrontBoolHTTPParameterType 4 4 extends AphrontHTTPParameterType { 5 5 6 + protected function getParameterExists(AphrontRequest $request, $key) { 7 + if ($request->getExists($key)) { 8 + return true; 9 + } 10 + 11 + $checkbox_key = $this->getCheckboxKey($key); 12 + if ($request->getExists($checkbox_key)) { 13 + return true; 14 + } 15 + 16 + return false; 17 + } 18 + 6 19 protected function getParameterValue(AphrontRequest $request, $key) { 7 - return $request->getBool($key); 20 + return (bool)$request->getBool($key); 8 21 } 9 22 10 23 protected function getParameterTypeName() { ··· 24 37 'v=1', 25 38 'v=0', 26 39 ); 40 + } 41 + 42 + public function getCheckboxKey($key) { 43 + return "{$key}.exists"; 27 44 } 28 45 29 46 }
+1 -1
src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
··· 90 90 ->setValue($object->getName()), 91 91 id(new PhabricatorBoolEditField()) 92 92 ->setKey('isAllDay') 93 - ->setLabel(pht('All Day')) 94 93 ->setOptions(pht('Normal Event'), pht('All Day Event')) 94 + ->setAsCheckbox(true) 95 95 ->setTransactionType( 96 96 PhabricatorCalendarEventAllDayTransaction::TRANSACTIONTYPE) 97 97 ->setDescription(pht('Marks this as an all day event.'))
+1 -1
src/applications/calendar/xaction/PhabricatorCalendarEventAllDayTransaction.php
··· 39 39 public function getTitle() { 40 40 if ($this->getNewValue()) { 41 41 return pht( 42 - '%s changed this as an all day event.', 42 + '%s changed this to an all day event.', 43 43 $this->renderAuthor()); 44 44 } else { 45 45 return pht(
+26 -2
src/applications/transactions/editfield/PhabricatorBoolEditField.php
··· 4 4 extends PhabricatorEditField { 5 5 6 6 private $options; 7 + private $asCheckbox; 7 8 8 9 public function setOptions($off_label, $on_label) { 9 10 $this->options = array( ··· 17 18 return $this->options; 18 19 } 19 20 21 + public function setAsCheckbox($as_checkbox) { 22 + $this->asCheckbox = $as_checkbox; 23 + return $this; 24 + } 25 + 26 + public function getAsCheckbox() { 27 + return $this->asCheckbox; 28 + } 29 + 20 30 protected function newControl() { 21 31 $options = $this->getOptions(); 22 32 ··· 27 37 ); 28 38 } 29 39 30 - return id(new AphrontFormSelectControl()) 31 - ->setOptions($options); 40 + if ($this->getAsCheckbox()) { 41 + $key = $this->getKey(); 42 + $value = $this->getValueForControl(); 43 + $checkbox_key = $this->newHTTPParameterType() 44 + ->getCheckboxKey($key); 45 + $id = $this->getControlID(); 46 + 47 + $control = id(new AphrontFormCheckboxControl()) 48 + ->setCheckboxKey($checkbox_key) 49 + ->addCheckbox($key, '1', $options['1'], $value, $id); 50 + } else { 51 + $control = id(new AphrontFormSelectControl()) 52 + ->setOptions($options); 53 + } 54 + 55 + return $control; 32 56 } 33 57 34 58 protected function newHTTPParameterType() {
+10 -2
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 553 553 return true; 554 554 } 555 555 556 - if (!is_array($old) && !strlen($old)) { 557 - return true; 556 + if (!is_array($old)) { 557 + if (!strlen($old)) { 558 + return true; 559 + } 560 + 561 + // The integer 0 is also uninteresting by default; this is often 562 + // an "off" flag for something like "All Day Event". 563 + if ($old === 0) { 564 + return true; 565 + } 558 566 } 559 567 560 568 break;
+27
src/view/form/control/AphrontFormCheckboxControl.php
··· 3 3 final class AphrontFormCheckboxControl extends AphrontFormControl { 4 4 5 5 private $boxes = array(); 6 + private $checkboxKey; 7 + 8 + public function setCheckboxKey($checkbox_key) { 9 + $this->checkboxKey = $checkbox_key; 10 + return $this; 11 + } 12 + 13 + public function getCheckboxKey() { 14 + return $this->checkboxKey; 15 + } 6 16 7 17 public function addCheckbox( 8 18 $name, ··· 52 62 phutil_tag('th', array(), $label), 53 63 )); 54 64 } 65 + 66 + // When a user submits a form with a checkbox unchecked, the browser 67 + // doesn't submit anything to the server. This hidden key lets the server 68 + // know that the checkboxes were present on the client, the user just did 69 + // not select any of them. 70 + 71 + $checkbox_key = $this->getCheckboxKey(); 72 + if ($checkbox_key) { 73 + $rows[] = phutil_tag( 74 + 'input', 75 + array( 76 + 'type' => 'hidden', 77 + 'name' => $checkbox_key, 78 + 'value' => 1, 79 + )); 80 + } 81 + 55 82 return phutil_tag( 56 83 'table', 57 84 array('class' => 'aphront-form-control-checkbox-layout'),
+1 -1
webroot/rsrc/js/application/calendar/behavior-event-all-day.js
··· 6 6 var all_day = JX.$(config.allDayID); 7 7 8 8 JX.DOM.listen(all_day, 'change', null, function() { 9 - var is_all_day = !!parseInt(all_day.value, 10); 9 + var is_all_day = !!all_day.checked; 10 10 11 11 for (var ii = 0; ii < config.controlIDs.length; ii++) { 12 12 var control = JX.$(config.controlIDs[ii]);