forked from GNUsocial/gnu-social
[UI] Settings routes refactor, avatar and misc settings added.
This commit is contained in:
parent
6dd966bd3f
commit
d6320943ce
@ -38,6 +38,7 @@ use App\Core\Form;
|
|||||||
use function App\Core\I18n\_m;
|
use function App\Core\I18n\_m;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
@ -88,23 +89,33 @@ class UserPanel extends AbstractController
|
|||||||
[_m('emailnotifyfav'), CheckboxType::class, ['help' => 'Send me email when someone adds my notice as a favorite.', 'label_format' => 'Notify favorites']],
|
[_m('emailnotifyfav'), CheckboxType::class, ['help' => 'Send me email when someone adds my notice as a favorite.', 'label_format' => 'Notify favorites']],
|
||||||
['save', SubmitType::class, ['label' => _m('Save')]], ]);
|
['save', SubmitType::class, ['label' => _m('Save')]], ]);
|
||||||
|
|
||||||
$acc->handleRequest($request);
|
|
||||||
if ($acc->isSubmitted()) {
|
|
||||||
$data = $acc->getData();
|
|
||||||
if ($prof->isValid()) {
|
|
||||||
$user = DB::find('\App\Entity\User', ['id' => 2]);
|
|
||||||
foreach (['outgoing_email', 'password', 'emailnotifysub', 'emailnotifymsg', 'emailnotifyattn', 'emailnotifynudge', 'emailnotifyfav'] as $key) {
|
|
||||||
$method = "set{$key}";
|
|
||||||
$user->{$method}($data[_m($key)]);
|
|
||||||
}
|
|
||||||
DB::flush();
|
|
||||||
} else {
|
|
||||||
// Display error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('settings/account.html.twig', [
|
return $this->render('settings/account.html.twig', [
|
||||||
'acc' => $acc->createView(),
|
'acc' => $acc->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function avatar(Request $request)
|
||||||
|
{
|
||||||
|
$avatar = Form::create([
|
||||||
|
[_m('avatar'), FileType::class, ['help' => 'You can upload your personal avatar. The maximum file size is 64MB.', 'label_format' => 'Avatar']],
|
||||||
|
['save', SubmitType::class, ['label' => _m('Submit')]], ]);
|
||||||
|
|
||||||
|
return $this->render('settings/avatar.html.twig', [
|
||||||
|
'avatar' => $avatar->createView(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function misc(Request $request)
|
||||||
|
{
|
||||||
|
$misc = Form::create([
|
||||||
|
[_m('transport'), TextType::class, ['help' => 'Address used to send and receive notices through IM.', 'label_format' => 'XMPP/Jabber']],
|
||||||
|
[_m('post_on_status_change'), CheckboxType::class, ['help' => 'Post a notice when my status changes.', 'label_format' => 'Status change']],
|
||||||
|
[_m('mention'), CheckboxType::class, ['help' => 'Send me replies from people I\'m not subscribed to.', 'label_format' => 'Mentions']],
|
||||||
|
[_m('posts_by_followed'), CheckboxType::class, ['help' => 'Send me notices.', 'label_format' => 'Notices']],
|
||||||
|
['save', SubmitType::class, ['label' => _m('Save')]], ]);
|
||||||
|
|
||||||
|
return $this->render('settings/misc.html.twig', [
|
||||||
|
'misc' => $misc->createView(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
@ -48,12 +48,22 @@ abstract class Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Settings pages
|
// Settings pages
|
||||||
foreach (['profile', 'avatar'] as $s) {
|
foreach (['profile', 'avatar', 'misc', 'account'] as $s) {
|
||||||
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'profile']);
|
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'profile']);
|
||||||
}
|
switch ($s) {
|
||||||
|
case 'profile':
|
||||||
foreach (['account'] as $s) {
|
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'profile']);
|
||||||
|
break;
|
||||||
|
case 'avatar':
|
||||||
|
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'avatar']);
|
||||||
|
break;
|
||||||
|
case 'misc':
|
||||||
|
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'misc']);
|
||||||
|
break;
|
||||||
|
case 'account':
|
||||||
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'account']);
|
$r->connect('settings_' . $s, 'settings/' . $s, [C\UserPanel::class, 'account']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
|
<a href="{{ path('settings_misc') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_misc' %}active{% endif %}'>Misc</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -6,17 +6,23 @@
|
|||||||
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
|
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block nav %}
|
{% block title %}Avatar Settings{% endblock %}
|
||||||
|
|
||||||
|
{% block header %}{{ parent() }}{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class='content'>
|
||||||
<nav class='set-nav'>
|
<nav class='set-nav'>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('settings_profile') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
|
<a href="{{ path('settings_profile') }}" class='hover-effect {% if (app.request.attributes.get('_route') starts with 'settings_profile') or (app.request.attributes.get('_route') starts with 'settings_avatar')%}active{% endif %}'>Settings</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('account_settings') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'account_settings' %}active{% endif %}'>Account</a>
|
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
|
<a href="{{ path('settings_misc') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_misc' %}active{% endif %}'>Misc</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
@ -29,29 +35,11 @@
|
|||||||
<a href="{{ path('settings_avatar') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_avatar' %}active{% endif %}'>Avatar</a>
|
<a href="{{ path('settings_avatar') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_avatar' %}active{% endif %}'>Avatar</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% block form %}
|
||||||
|
<div class='form'>
|
||||||
{% block body %}
|
{{ form(avatar) }}
|
||||||
<div class='content'>
|
|
||||||
<div id='nickname'>
|
|
||||||
<div class='label'> {{ form_label(prof.Nickname) }} </div> {{ form_widget(prof.Nickname) }}
|
|
||||||
</div>
|
|
||||||
<div id='name'>
|
|
||||||
<div class='label'> {{ form_label(prof.FullName) }} </div> {{ form_widget(prof.FullName) }}
|
|
||||||
</div>
|
|
||||||
<div id='homepage'>
|
|
||||||
<div class='label'> {{ form_label(prof.Homepage) }} </div> {{ form_widget(prof.Homepage) }}
|
|
||||||
</div>
|
|
||||||
<div id='bio'>
|
|
||||||
<div class='label'> {{ form_label(prof.Bio) }} </div> {{ form_widget(prof.Bio) }}
|
|
||||||
</div>
|
|
||||||
<div id='location'>
|
|
||||||
<div class='label'> {{ form_label(prof.Location) }} </div> {{ form_widget(prof.Location) }}
|
|
||||||
</div>
|
|
||||||
<div id='save'>
|
|
||||||
{{ form_widget(prof.save) }}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
39
templates/settings/misc.html.twig
Normal file
39
templates/settings/misc.html.twig
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
{% block stylesheets %}
|
||||||
|
{{ parent() }}
|
||||||
|
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}" media="screen and (min-width: 1300px)">
|
||||||
|
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_mid.css') }}" media="screen and (max-width: 1300px)">
|
||||||
|
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings_small.css') }}" media="screen and (max-width: 750px)">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Misc Settings{% endblock %}
|
||||||
|
|
||||||
|
{% block header %}{{ parent() }}{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class='content'>
|
||||||
|
<nav class='set-nav'>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('settings_profile') }}" class='hover-effect {% if (app.request.attributes.get('_route') starts with 'settings_profile') or (app.request.attributes.get('_route') starts with 'settings_avatar')%}active{% endif %}'>Settings</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('settings_misc') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_misc' %}active{% endif %}'>Misc</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{% block form %}
|
||||||
|
|
||||||
|
<div class='form-single'>
|
||||||
|
{{ form(misc) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -22,7 +22,7 @@
|
|||||||
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
<a href="{{ path('settings_account') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_account' %}active{% endif %}'>Account</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('doc_tags') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'doc_tags' %}active{% endif %}'>Misc</a>
|
<a href="{{ path('settings_misc') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_misc' %}active{% endif %}'>Misc</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
Loading…
Reference in New Issue
Block a user