1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Allow users to set whether or not textareas are monospaced.

Summary:
Some users like monospaced textareas and others don't.
This introduces an option to set this as a user preference.

Test Plan: Enabled and saw monospaced textareas, disabled and saw non-monospaced textareas.

Reviewers: epriestley

CC: aran, Korvin

Maniphest Tasks: T2114

Differential Revision: https://secure.phabricator.com/D4037
This commit is contained in:
Ricky Elrod 2012-11-27 14:06:31 -08:00 committed by epriestley
parent 71c170661b
commit 416d26b621
14 changed files with 80 additions and 24 deletions

View file

@ -118,7 +118,8 @@ final class DifferentialAddCommentView extends AphrontView {
->setName('comment') ->setName('comment')
->setID('comment-content') ->setID('comment-content')
->setLabel('Comment') ->setLabel('Comment')
->setValue($this->draft ? $this->draft->getDraft() : null)) ->setValue($this->draft ? $this->draft->getDraft() : null)
->setUser($this->user))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Clowncopterize')); ->setValue($is_serious ? 'Submit' : 'Clowncopterize'));

View file

@ -575,7 +575,8 @@ final class DiffusionCommitController extends DiffusionController {
->setLabel('Comments') ->setLabel('Comments')
->setName('content') ->setName('content')
->setValue($draft) ->setValue($draft)
->setID('audit-content')) ->setID('audit-content')
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Cook the Books')); ->setValue($is_serious ? 'Submit' : 'Cook the Books'));

View file

@ -415,7 +415,8 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setLabel('Comments') ->setLabel('Comments')
->setName('comments') ->setName('comments')
->setValue($draft_text) ->setValue($draft_text)
->setID('transaction-comments')) ->setID('transaction-comments')
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormDragAndDropUploadControl()) id(new AphrontFormDragAndDropUploadControl())
->setLabel('Attached Files') ->setLabel('Attached Files')

View file

@ -487,7 +487,8 @@ final class ManiphestTaskEditController extends ManiphestController {
->setLabel('Description') ->setLabel('Description')
->setName('description') ->setName('description')
->setID('description-textarea') ->setID('description-textarea')
->setValue($task->getDescription()); ->setValue($task->getDescription())
->setUser($user);
$form $form
->appendChild($description_control); ->appendChild($description_control);

View file

@ -122,7 +122,7 @@ final class PhameBlogEditController
->setName('description') ->setName('description')
->setValue($blog->getDescription()) ->setValue($blog->getDescription())
->setID('blog-description') ->setID('blog-description')
) ->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setUser($user) ->setUser($user)

View file

@ -132,6 +132,7 @@ final class PhamePostEditController
->setValue($post->getBody()) ->setValue($post->getBody())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setID('post-body') ->setID('post-body')
->setUser($user)
) )
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())

View file

@ -193,7 +193,8 @@ final class PholioMockEditController extends PholioController {
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setName('description') ->setName('description')
->setValue($v_desc) ->setValue($v_desc)
->setLabel(pht('Description'))) ->setLabel(pht('Description'))
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormDragAndDropUploadControl($request)) id(new AphrontFormDragAndDropUploadControl($request))
->setName('file_phids') ->setName('file_phids')

View file

@ -194,7 +194,8 @@ final class PholioMockViewController extends PholioController {
->appendChild( ->appendChild(
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setName('comment') ->setName('comment')
->setLabel(pht('Comment'))) ->setLabel(pht('Comment'))
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($action)); ->setValue($action));

View file

@ -222,7 +222,8 @@ final class PhrictionEditController
->setValue($content_text) ->setValue($content_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content') ->setName('content')
->setID('document-textarea')) ->setID('document-textarea')
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Edit Notes') ->setLabel('Edit Notes')

View file

@ -68,7 +68,8 @@ final class PonderQuestionAskController extends PonderController {
->setName('content') ->setName('content')
->setID('content') ->setID('content')
->setValue($question->getContent()) ->setValue($question->getContent())
->setLabel(pht('Description'))) ->setLabel(pht('Description'))
->setUser($user))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Ask Away!')); ->setValue('Ask Away!'));

View file

@ -44,7 +44,8 @@ final class PonderAddAnswerView extends AphrontView {
->setName('answer') ->setName('answer')
->setLabel('Answer') ->setLabel('Answer')
->setError(true) ->setError(true)
->setID('answer-content')) ->setID('answer-content')
->setUser($this->user))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Make it so.')); ->setValue($is_serious ? 'Submit' : 'Make it so.'));

View file

@ -23,6 +23,8 @@ final class PhabricatorSettingsPanelDisplayPreferences
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR; $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES; $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
$pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS; $pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS;
$pref_monospaced_textareas =
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
if ($request->isFormPost()) { if ($request->isFormPost()) {
$monospaced = $request->getStr($pref_monospaced); $monospaced = $request->getStr($pref_monospaced);
@ -32,9 +34,13 @@ final class PhabricatorSettingsPanelDisplayPreferences
$preferences->setPreference($pref_titles, $request->getStr($pref_titles)); $preferences->setPreference($pref_titles, $request->getStr($pref_titles));
$preferences->setPreference($pref_editor, $request->getStr($pref_editor)); $preferences->setPreference($pref_editor, $request->getStr($pref_editor));
$preferences->setPreference($pref_symbols, $preferences->setPreference(
$pref_symbols,
$request->getStr($pref_symbols)); $request->getStr($pref_symbols));
$preferences->setPreference($pref_monospaced, $monospaced); $preferences->setPreference($pref_monospaced, $monospaced);
$preferences->setPreference(
$pref_monospaced_textareas,
$request->getStr($pref_monospaced_textareas));
$preferences->save(); $preferences->save();
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
@ -60,6 +66,11 @@ EXAMPLE;
$font_default = phutil_escape_html($font_default); $font_default = phutil_escape_html($font_default);
$pref_symbols_value = $preferences->getPreference($pref_symbols); $pref_symbols_value = $preferences->getPreference($pref_symbols);
$pref_monospaced_textareas_value = $preferences
->getPreference($pref_monospaced_textareas);
if (!$pref_monospaced_textareas_value) {
$pref_monospaced_textareas_value = 'disabled';
}
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
@ -108,6 +119,14 @@ EXAMPLE;
'Use this setting to disable linking symbol names in Differential '. 'Use this setting to disable linking symbol names in Differential '.
'and Diffusion to their definitions. This is enabled by default.') 'and Diffusion to their definitions. This is enabled by default.')
->addButton('disabled', 'Disabled', null)) ->addButton('disabled', 'Disabled', null))
->appendChild(
id(new AphrontFormRadioButtonControl())
->setLabel('Monospaced Textareas')
->setName($pref_monospaced_textareas)
->setValue($pref_monospaced_textareas_value)
->addButton('enabled', 'Enabled',
'Show all textareas using the monospaced font defined above.')
->addButton('disabled', 'Disabled', null))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Save Preferences')); ->setValue('Save Preferences'));

View file

@ -5,6 +5,7 @@ final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_MONOSPACED = 'monospaced'; const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_EDITOR = 'editor'; const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_TITLES = 'titles'; const PREFERENCE_TITLES = 'titles';
const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas';
const PREFERENCE_RE_PREFIX = 're-prefix'; const PREFERENCE_RE_PREFIX = 're-prefix';
const PREFERENCE_NO_SELF_MAIL = 'self-mail'; const PREFERENCE_NO_SELF_MAIL = 'self-mail';

View file

@ -2,6 +2,17 @@
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
private $user;
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
public function getUser() {
return $this->user;
}
protected function renderInput() { protected function renderInput() {
$id = $this->getID(); $id = $this->getID();
if (!$id) { if (!$id) {
@ -119,7 +130,22 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
), ),
implode('', $buttons)); implode('', $buttons));
$this->setCustomClass('remarkup-assist-textarea'); $monospaced_textareas = null;
$monospaced_textareas_class = null;
$user = $this->getUser();
if ($user) {
$monospaced_textareas = $user
->loadPreferences()
->getPreference(
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
if ($monospaced_textareas == 'enabled') {
$monospaced_textareas_class = 'PhabricatorMonospaced';
}
}
$this->setCustomClass(
'remarkup-assist-textarea '.$monospaced_textareas_class);
return javelin_render_tag( return javelin_render_tag(
'div', 'div',