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')
->setID('comment-content')
->setLabel('Comment')
->setValue($this->draft ? $this->draft->getDraft() : null))
->setValue($this->draft ? $this->draft->getDraft() : null)
->setUser($this->user))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Clowncopterize'));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,6 +23,8 @@ final class PhabricatorSettingsPanelDisplayPreferences
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
$pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS;
$pref_monospaced_textareas =
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
if ($request->isFormPost()) {
$monospaced = $request->getStr($pref_monospaced);
@ -32,9 +34,13 @@ final class PhabricatorSettingsPanelDisplayPreferences
$preferences->setPreference($pref_titles, $request->getStr($pref_titles));
$preferences->setPreference($pref_editor, $request->getStr($pref_editor));
$preferences->setPreference($pref_symbols,
$preferences->setPreference(
$pref_symbols,
$request->getStr($pref_symbols));
$preferences->setPreference($pref_monospaced, $monospaced);
$preferences->setPreference(
$pref_monospaced_textareas,
$request->getStr($pref_monospaced_textareas));
$preferences->save();
return id(new AphrontRedirectResponse())
@ -60,6 +66,11 @@ EXAMPLE;
$font_default = phutil_escape_html($font_default);
$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())
->setUser($user)
@ -108,6 +119,14 @@ EXAMPLE;
'Use this setting to disable linking symbol names in Differential '.
'and Diffusion to their definitions. This is enabled by default.')
->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(
id(new AphrontFormSubmitControl())
->setValue('Save Preferences'));

View file

@ -2,22 +2,23 @@
final class PhabricatorUserPreferences extends PhabricatorUserDAO {
const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_TITLES = 'titles';
const PREFERENCE_MONOSPACED = 'monospaced';
const PREFERENCE_EDITOR = 'editor';
const PREFERENCE_TITLES = 'titles';
const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas';
const PREFERENCE_RE_PREFIX = 're-prefix';
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
const PREFERENCE_MAILTAGS = 'mailtags';
const PREFERENCE_VARY_SUBJECT = 'vary-subject';
const PREFERENCE_RE_PREFIX = 're-prefix';
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
const PREFERENCE_MAILTAGS = 'mailtags';
const PREFERENCE_VARY_SUBJECT = 'vary-subject';
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
const PREFERENCE_DIFFUSION_SYMBOLS = 'diffusion-symbols';
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
const PREFERENCE_DIFFUSION_SYMBOLS = 'diffusion-symbols';
const PREFERENCE_NAV_WIDTH = 'nav-width';
const PREFERENCE_NAV_WIDTH = 'nav-width';
protected $userPHID;
protected $preferences = array();

View file

@ -2,6 +2,17 @@
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() {
$id = $this->getID();
if (!$id) {
@ -119,7 +130,22 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
),
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(
'div',