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

Allow date custom field to be blank

Summary:
Currently it's not allowed to be left blank (even with required: false)

Fixes T3343

Test Plan: Use the custom date field.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, chad

Maniphest Tasks: T3343

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

authored by

Gareth Evans and committed by
epriestley
64bfd763 8e8057c6

+21 -10
+11 -8
src/applications/maniphest/auxiliaryfield/ManiphestAuxiliaryFieldDefaultSpecification.php
··· 100 100 case self::TYPE_DATE: 101 101 $control = new AphrontFormDateControl(); 102 102 $control->setUser($this->getUser()); 103 + if (!$this->isRequired()) { 104 + $control->setAllowNull(true); 105 + } 103 106 break; 104 107 case self::TYPE_REMARKUP: 105 108 $control = new PhabricatorRemarkupControl(); ··· 132 135 (bool)$this->getValue()); 133 136 break; 134 137 case self::TYPE_DATE: 135 - $control->setValue($this->getValue()); 138 + if ($this->getValue() > 0) { 139 + $control->setValue($this->getValue()); 140 + } 136 141 $control->setName('auxiliary_date_'.$this->getAuxiliaryKey()); 137 142 break; 138 143 case self::TYPE_USER: ··· 201 206 case self::TYPE_USERS: 202 207 return json_encode($this->getValue()); 203 208 default: 204 - return $this->getValue(); 209 + return (int)$this->getValue(); 205 210 } 206 211 } 207 212 ··· 216 221 break; 217 222 case self::TYPE_DATE: 218 223 $value = (int)$value; 219 - if ($value <= 0) { 220 - return $this->setDefaultValue($value); 221 - } 224 + $this->setDefaultValue($value); 222 225 break; 223 226 default: 224 227 break; ··· 243 246 case self::TYPE_SELECT: 244 247 return true; 245 248 case self::TYPE_DATE: 246 - if ((int)$this->getValue() <= 0) { 249 + if ((int)$this->getValue() <= 0 && $this->isRequired()) { 247 250 throw new ManiphestAuxiliaryFieldValidationException( 248 251 pht( 249 252 '%s must be a valid date.', ··· 367 370 // fields normally, users can change the type of an existing field and 368 371 // leave us with uninterpretable data in old transactions. 369 372 if ((int)$new <= 0) { 370 - $new_display = "(invalid epoch timestamp: {$new})"; 373 + $new_display = "none"; 371 374 } else { 372 375 $new_display = phabricator_datetime($new, $this->getUser()); 373 376 } ··· 375 378 $desc = "set field '{$label}' to '{$new_display}'"; 376 379 } else { 377 380 if ((int)$old <= 0) { 378 - $old_display = "(invalid epoch timestamp: {$old})"; 381 + $old_display = "none"; 379 382 } else { 380 383 $old_display = phabricator_datetime($old, $this->getUser()); 381 384 }
+8 -1
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 123 123 $errors[] = pht('Title is required.'); 124 124 } 125 125 126 - foreach ($aux_fields as $aux_field) { 126 + foreach ($aux_fields as $aux_arr_key => $aux_field) { 127 127 $aux_field->setValueFromRequest($request); 128 + $aux_key = $aux_field->getAuxiliaryKey(); 129 + $aux_old_value = $task->getAuxiliaryAttribute($aux_key); 130 + 131 + if ((int)$aux_old_value === $aux_field->getValueForStorage()) { 132 + unset($aux_fields[$aux_arr_key]); 133 + continue; 134 + } 128 135 129 136 if ($aux_field->isRequired() && !$aux_field->getValue()) { 130 137 $errors[] = pht('%s is required.', $aux_field->getLabel());
+2 -1
webroot/rsrc/css/phui/phui-form.css
··· 129 129 } 130 130 131 131 132 - select[disabled="disabled"] { 132 + select[disabled="disabled"], 133 + input[disabled="disabled"] { 133 134 opacity: 0.5; 134 135 }