Skip to content

Commit

Permalink
0.7.4: Got column sorting that ignores blanks working properly now.
Browse files Browse the repository at this point in the history
  • Loading branch information
classaxe committed Jun 27, 2018
1 parent 4083367 commit 46e0b36
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/Entity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ public function getFormattedNdbWeblogLink(): ?string
$popup_url = "https://www.classaxe.com/dx/ndb/rna/export_ndbweblog_index/{$this->id}";
$popup_name = "nwl_{$this->id}";
$popup_args = "width=640,height=480,status=1,scrollbars=1,resizable=1";
return "<a href=\"$popup_url\" rel=\"popup|{$popup_name}|{$popup_args}\">NWL</a>";
return "<a href=\"$popup_url\" rel=\"popup|{$popup_name}|{$popup_args}\">NWL</a>";
}

/**
Expand Down
57 changes: 48 additions & 9 deletions src/Repository/ListenerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ListenerRepository extends ServiceEntityRepository
'label' => 'Name',
'order' => 'a',
'sort' => 'l.name',
'td_class' => '{% if listener.PrimaryQth %}primaryQth{% else %}secondaryQth{% endif %}',
'td_class' => '(handled by twig)',
'th_class' => '',
'tooltip' => '',
],
Expand Down Expand Up @@ -208,6 +208,29 @@ class ListenerRepository extends ServiceEntityRepository
'th_class' => 'txt_vertical',
'tooltip' => 'Total number of signals of all types',
],
'website' => [
'admin' => false,
'arg' => '',
'field' => 'formattedWebsiteLink',
'label' => 'WWW',
'sortBy' => [['l.wn','DESC'],['l.website', 'DIR']],
'order' => 'a',
'sort' => 'l.website',
'td_class' => '',
'th_class' => '',
'tooltip' => '',
],
'nwl' => [
'admin' => false,
'arg' => '',
'field' => 'formattedNdbWeblogLink',
'label' => 'NWL',
'order' => '',
'sort' => '',
'td_class' => '',
'th_class' => '',
'tooltip' => 'NDB Weblog for Listener',
],
'mapPos' => [
'admin' => true,
'arg' => '',
Expand Down Expand Up @@ -245,6 +268,12 @@ public function getColumns()
public function getFilteredListeners($system, $args)
{
$qb = $this->createQueryBuilder('l');
if ($this->columns[$args['sort']]['sort']) {
$qb
->addSelect(
"(CASE WHEN (".$this->columns[$args['sort']]['sort'].")='' THEN 1 ELSE 0 END) AS _blank"
);
}
switch($system) {
case "reu":
$qb
Expand Down Expand Up @@ -277,15 +306,25 @@ public function getFilteredListeners($system, $args)
->setParameter('region', $args['region'])
;
}
$qb
->orderBy(
($this->columns[$args['sort']]['sort']),
($args['order'] == 'd' ? 'DESC' : 'ASC')
);
return
if ($this->columns[$args['sort']]['sort']) {
$qb
->getQuery()
->execute();
->orderBy(
'_blank',
'ASC'
)
->addOrderBy(
($this->columns[$args['sort']]['sort']),
($args['order'] == 'd' ? 'DESC' : 'ASC')
);

}
$result = $qb->getQuery()->execute();
// Necessary to resolve extra nesting in results caused by extra select to ignore empty fields in sort order
$out = [];
foreach ($result as $key => $value) {
$out[] = $value[0];
}
return $out;
}

public function getTotalListeners($system)
Expand Down
1 change: 1 addition & 0 deletions templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script src="{{ asset('js/jquery-3.3.1.min.js') }}"></script>
<script src="{{ asset('js/functions.js') }}"></script>
</head>

<body class="{{ system|lower }}">
{% block body_head %}{% endblock %}
{% block body %}{% endblock %}
Expand Down
26 changes: 13 additions & 13 deletions templates/footer/footer.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
<strong>Your {{ system|upper }} Editors are:</strong>
</p>
{% set credits = ['editors', 'awards', 'authors'] %}
{% for credit in credits %}
{% for credit in credits %}

<p>
{% for person in systems[system][credit] %}
{% for person in systems[system][credit] %}
<strong>
{% if person.email %}
<script>
document.write(
">'metsyS02%{{ system|upper|reverse }}=tcejbus?{{ person.email|reverse }}:otliam'=ferh a<".split('').reverse().join('')
);
</script>{{ person.name }}</a>
{% else %}
{{ person.name }}
{% endif %}
</strong> {{ person.role }}{% if not loop.last %}<br />{% endif %}
{% endfor %}
{% if person.email %}
<script>document.write(">'metsyS02%{{ system|upper|reverse }}=tcejbus?{{ person.email|reverse }}:otliam'=ferh a<".split('').reverse().join(''));</script>{{ person.name }}</a>
{% else %}
{{ person.name }}
{% endif %}
</strong> {{ person.role }}{% if not loop.last %}<br />

{% endif %}
{% endfor %}

</p>
{% endfor %}
<p class="copyright"><strong>&copy;{{ "now"|date("Y") }} Martin Francis</strong></p>
Expand Down
4 changes: 0 additions & 4 deletions templates/forms/form.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{# Include our twig widget customisations #}
{% form_theme form 'forms/custom_form_div_layout.html.twig' %}

<div class="controlPanel {{ form_class }}">
<div class="header">{{ form_title }}</div>
<div class="controls clearfix">
Expand All @@ -9,6 +8,3 @@
{{ form_end(form) }}
</div>
</div>



7 changes: 1 addition & 6 deletions templates/grids/listeners.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
<tr>
{% for key, column in columns %}
{% if ((not column.admin or isAdmin) and (not column.arg or (column.arg and column.arg in args.types))) %}
{% if key == 'name' %}
<td class="{% if listener.PrimaryQth %}primaryQth{% else %}secondaryQth{% endif %}">
{% else %}
<td{% if column.td_class %} class="{{ column.td_class }}"{% endif %}>
{% endif %}
{{ attribute(listener, column.field)|raw }}</td>
<td{% if key == 'name' and listener.PrimaryQth is defined %} class="{% if listener.PrimaryQth %}primaryQth{% else %}secondaryQth{% endif %}">{% else %}{% if column.td_class %} class="{{ column.td_class }}"{% endif %}>{% endif %}{{ attribute(listener, column.field)|raw }}</td>
{% endif %}
{% endfor %}
</tr>
Expand Down
7 changes: 4 additions & 3 deletions templates/listeners/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<div class="main">
<h1>{{ mode }}</h1>
{{ text|raw }}
{% set form_title='Customise ' ~ system|upper ~ ' Listener Report' %}
{% set form_class='listener_list' %}
{% include 'forms/form.html.twig' %}
{% set form_title='Customise ' ~ system|upper ~ ' Listener Report' %}
{% set form_class='listener_list' %}
{% include 'forms/form.html.twig' %}
</div>

{% include 'grids/listeners.html.twig' %}

<script>
Expand Down
17 changes: 8 additions & 9 deletions templates/menu/menu.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div class="menu-centered">
<ul class="menu header">
<li><h2>{{ systems[system]['title'] }}</h2></li>
Expand All @@ -21,13 +20,13 @@
</ul>
{% if isAdmin %}
<ul class="menu mode">
{% for key, modeRepo in modes[1] %}
{% if ((isAdmin and modeRepo.admin) or (not isAdmin and modeRepo.guest))%}
<li{% if (app.request.get('_route') == key) %} class="is-active"{% endif %}>
<a href="{{ url(key, { 'system' : system }) }}">{{ modeRepo['menu'] }}</a>
</li>
{% endif %}
{% endfor %}
{% for key, modeRepo in modes[1] %}
{% if ((isAdmin and modeRepo.admin) or (not isAdmin and modeRepo.guest))%}
<li{% if (app.request.get('_route') == key) %} class="is-active"{% endif %}>
<a href="{{ url(key, { 'system' : system }) }}">{{ modeRepo['menu'] }}</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
</div>
</div>

0 comments on commit 46e0b36

Please sign in to comment.