Improve sortability in various lists.

This commit is contained in:
James Cole 2016-11-20 15:30:16 +01:00
parent 78f297e18f
commit 0b613c3b8c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
7 changed files with 83 additions and 55 deletions

View File

@ -57,20 +57,22 @@ class UserController extends Controller
// add meta stuff.
$users->each(
function (User $user) use ($mustConfirmAccount) {
// is user activated?
$isConfirmed = Preferences::getForUser($user, 'user_confirmed', false)->data;
$list = ['user_confirmed', 'twoFactorAuthEnabled', 'twoFactorAuthSecret', 'registration_ip_address', 'confirmation_ip_address'];
$preferences = Preferences::getArrayForUser($user, $list);
$user->activated = true;
if ($isConfirmed === false && $mustConfirmAccount === true) {
if (!($preferences['user_confirmed'] === true) && $mustConfirmAccount === true) {
$user->activated = false;
}
$user->isAdmin = $user->hasRole('owner');
$is2faEnabled = Preferences::getForUser($user, 'twoFactorAuthEnabled', false)->data;
$has2faSecret = !is_null(Preferences::getForUser($user, 'twoFactorAuthSecret'));
$is2faEnabled = $preferences['twoFactorAuthEnabled'] === true;
$has2faSecret = !is_null($preferences['twoFactorAuthSecret']);
$user->has2FA = false;
if ($is2faEnabled && $has2faSecret) {
$user->has2FA = true;
}
$user->prefs = $preferences;
}
);

View File

@ -57,6 +57,30 @@ class Preferences
return $this->getForUser(auth()->user(), $name, $default);
}
/**
* @param User $user
* @param array $list
*
* @return array
*/
public function getArrayForUser(User $user, array $list): array
{
$result = [];
$preferences = Preference::where('user_id', $user->id)->whereIn('name', $list)->get(['id', 'name', 'data']);
/** @var Preference $preference */
foreach ($preferences as $preference) {
$result[$preference->name] = $preference->data;
}
foreach ($list as $name) {
if (!isset($result[$name])) {
$result[$name] = null;
}
}
return $result;
}
/**
* @param \FireflyIII\User $user
* @param string $name

View File

@ -5,19 +5,18 @@
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'all_blocked_domains'|_ }}</h3>
</div>
<div class="box-body table-responsive">
<div class="box-body table-responsive no-padding">
{% if domains|length > 0 %}
<table class="table table-condensed sortable">
<table class="table table-condensed table-hover sortable">
<thead>
<tr>
<th style="width:20%;">&nbsp;</th>
<th>{{ trans('list.domain') }}</th>
<th>{{ trans('list.is_blocked') }}</th>
<th data-defaultsort="disabled" style="width:20%;">&nbsp;</th>
<th data-defaultsign="az">{{ trans('list.domain') }}</th>
</tr>
</thead>
<tbody>
@ -27,9 +26,9 @@
<a href="{{ route('admin.users.domains.block-toggle', [domain]) }}" class="btn btn-sm btn-success"><i
class="fa fa-fw fa-times"></i> unblock</a>
</td>
<td>{{ domain }}</td>
<td>
<small class="text-success"><i class="fa fa-fw fa-check"></i></small>
<td data-value="{{ domain }}">
<a href="http://{{ domain }}/">{{ domain }}</a>
(<a href="http://whois.domaintools.com/{{ domain }}">whois</a>)
</td>
</tr>
{% endfor %}
@ -43,12 +42,9 @@
</div>
</div>
</div>
</div>
<!-- domains found in users (not in top list) -->
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<!-- domains found in users (not in top list) -->
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'all_user_domains'|_ }}</h3>
@ -59,11 +55,11 @@
{{ 'all_domains_is_filtered'|_ }}
</p>
<table class="table table-condensed sortable">
<table class="table table-condensed table-hover sortable">
<thead>
<tr>
<th style="width:20%;">&nbsp;</th>
<th>{{ trans('list.domain') }}</th>
<th data-defaultsort="disabled" style="width:20%;">&nbsp;</th>
<th data-defaultsign="az">{{ trans('list.domain') }}</th>
</tr>
</thead>
<tbody>

View File

@ -14,16 +14,16 @@
<table class="table table-condensed sortable">
<thead>
<tr>
<th class="hidden-xs" colspan="2">&nbsp;</th>
<th>{{ trans('list.email') }}</th>
<th class="hidden-xs">{{ trans('list.registered_at') }}</th>
<th class="hidden-xs">{{ trans('list.registered_from') }}</th>
<th class="hidden-xs">{{ trans('list.confirmed_from') }}</th>
<th data-defaultsign="_19" class="hidden-xs" colspan="2">&nbsp;</th>
<th data-defaultsign="az">{{ trans('list.email') }}</th>
<th data-defaultsign="month" class="hidden-xs">{{ trans('list.registered_at') }}</th>
<th data-defaultsign="az" class="hidden-xs">{{ trans('list.registered_from') }}</th>
<th data-defaultsign="az" class="hidden-xs">{{ trans('list.confirmed_from') }}</th>
<th class="hidden-xs">{{ trans('list.is_admin') }}</th>
<th class="hidden-xs">{{ trans('list.has_two_factor') }}</th>
<th>{{ trans('list.is_activated') }}</th>
<th>{{ trans('list.is_blocked') }}</th>
<th class="hidden-xs">{{ trans('list.blocked_code') }}</th>
<th data-defaultsign="az" class="hidden-xs">{{ trans('list.blocked_code') }}</th>
</tr>
</thead>
<tbody>
@ -41,11 +41,17 @@
{{ user.created_at.formatLocalized(monthAndDayFormat) }}
{{ user.created_at.format('H:i') }}
</td>
<td class="hidden-xs">
{{ Preferences.getForUser(user,"registration_ip_address").data }}
<td data-value="{{ user.prefs.registration_ip_address }}" class="hidden-xs">
{{ user.prefs.registration_ip_address }}
{% if user.prefs.registration_ip_address|length > 0 %}
(<a href="http://whois.domaintools.com/{{ user.prefs.registration_ip_address }}">whois</a>)
{% endif %}
</td>
<td class="hidden-xs">
{{ Preferences.getForUser(user,"confirmation_ip_address").data }}
<td data-value="{{ user.prefs.confirmation_ip_address }}" class="hidden-xs">
{{ user.prefs.confirmation_ip_address }}
{% if user.prefs.confirmation_ip_address|length > 0 %}
(<a href="http://whois.domaintools.com/{{ user.prefs.confirmation_ip_address }}">whois</a>)
{% endif %}
</td>
<td class="hidden-xs" data-value="{% if user.isAdmin %}1{% else %}0{% endif %}">
{% if user.isAdmin %}

View File

@ -2,15 +2,15 @@
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
<th data-defaultsign="az">{{ trans('list.name') }}</th>
{% if what == 'asset' %}
<th class="hidden-sm hidden-xs">{{ trans('list.role') }}</th>
<th data-defaultsign="az" class="hidden-sm hidden-xs">{{ trans('list.role') }}</th>
{% endif %}
<th class="hidden-sm hidden-xs">{{ trans('list.iban') }}</th>
<th>{{ trans('list.currentBalance') }}</th>
<th data-defaultsign="az" class="hidden-sm hidden-xs">{{ trans('list.iban') }}</th>
<th data-defaultsign="_19">{{ trans('list.currentBalance') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.active') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.lastActivity') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.balanceDiff', {'start' : Session.get('start').formatLocalized(monthAndDayFormat),'end' : Session.get('end').formatLocalized(monthAndDayFormat)}) }}</th>
<th data-defaultsign="month" class="hidden-sm hidden-xs">{{ trans('list.lastActivity') }}</th>
<th data-defaultsign="_19" class="hidden-sm hidden-xs">{{ trans('list.balanceDiff', {'start' : Session.get('start').formatLocalized(monthAndDayFormat),'end' : Session.get('end').formatLocalized(monthAndDayFormat)}) }}</th>
</tr>
</thead>
<tbody>
@ -42,11 +42,11 @@
{% endif %}
</td>
{% if account.lastActivityDate %}
<td class="hidden-sm hidden-xs" data-value="{{ account.lastActivityDate.format('U') }} ">
<td class="hidden-sm hidden-xs" data-value="{{ account.lastActivityDate.format('Y-m-d-H-i-s') }} ">
{{ account.lastActivityDate.formatLocalized(monthAndDayFormat) }}
</td>
{% else %}
<td class="hidden-sm hidden-xs" data-value="0">
<td class="hidden-sm hidden-xs" data-value="0000-00-00-00-00-00">
<em>{{ 'never'|_ }}</em>
</td>
{% endif %}

View File

@ -3,13 +3,13 @@
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.matchesOn') }}</th>
<th colspan="2">{{ trans('list.matchingAmount') }}</th>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">{{ trans('list.paid_current_period') }}</th>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">{{ trans('list.next_expected_match') }}</th>
<th data-defaultsign="az" class="hidden-sm hidden-xs">{{ trans('list.matchesOn') }}</th>
<th data-defaultsign="_19" colspan="2">{{ trans('list.matchingAmount') }}</th>
<th data-defaultsign="month" class="hidden-sm hidden-xs">{{ trans('list.paid_current_period') }}</th>
<th data-defaultsign="month" class="hidden-sm hidden-xs">{{ trans('list.next_expected_match') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.active') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.automatch') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.repeat_freq') }}</th>
<th data-defaultsign="az" class="hidden-sm hidden-xs">{{ trans('list.repeat_freq') }}</th>
</tr>
</thead>
<tbody>
@ -37,36 +37,36 @@
</td>
{% if entry.paidDates.count() == 0 and entry.payDates.count() == 0 and entry.active %}
<td class="text-muted">
<td class="text-muted" data-value="0001-00-00-00-00-00">
{{ 'not_expected_period'|_ }}
</td>
<td class=" hidden-sm hidden-xs">
<td class=" hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d-H-i-s') }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }}
</td>
{% endif %}
{% if entry.paidDates.count() == 0 and entry.payDates.count() > 0 and entry.active %}
<td class="text-danger">
<td class="text-danger" data-value="0002-00-00-00-00-00">
{{ 'not_or_not_yet'|_ }}
</td>
<td class=" hidden-sm hidden-xs">
<td class=" hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d-H-i-s') }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }}
</td>
{% endif %}
{% if entry.paidDates.count() == entry.payDates.count() and entry.payDates.count() > 0 and entry.active %}
<td class="text-success">
<td class="text-success" data-value="{{ entry.paidDates.first.format('Y-m-d-H-i-s') }}">
{% for date in entry.paidDates %}
{{ date.formatLocalized(monthAndDayFormat) }}<br/>
{% endfor %}
</td>
<td class=" hidden-sm hidden-xs">
<td class=" hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d-H-i-s') }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }}
</td>
{% endif %}
{% if not entry.active %}
<td class="text-muted">
<td class="text-muted" data-value="0000-00-00-00-00-00">
~
</td>
<td class="text-muted hidden-sm hidden-xs">
<td class="text-muted hidden-sm hidden-xs" data-value="0">
~
</td>
{% endif %}

View File

@ -24,11 +24,11 @@
<a href="{{ route('categories.show', category.id) }}" title="{{ category.name }}">{{ category.name }}</a>
</td>
{% if category.lastActivity.year != "1900" %}
<td class="hidden-sm hidden-xs" data-value="{{ category.lastActivity.format('U') }}">
<td class="hidden-sm hidden-xs" data-value="{{ category.lastActivity.format('Y-m-d-H-i-s') }}">
{{ category.lastActivity.formatLocalized(monthAndDayFormat) }}
</td>
{% else %}
<td class="hidden-sm hidden-xs" data-value="0">
<td class="hidden-sm hidden-xs" data-value="0000-00-00-00-00-00">
<em>{{ 'never'|_ }}</em>
</td>
{% endif %}