Skip to content

Commit

Permalink
Reconfigure filter warning messages
Browse files Browse the repository at this point in the history
Set up three filter-message sections (only one of which is
displayed) and modify the form-panel descriptions depending
on the event state.

Bug: T218340
  • Loading branch information
samwilson committed Mar 25, 2019
1 parent a43b77d commit 66430ff
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 52 deletions.
40 changes: 36 additions & 4 deletions app/Resources/assets/css/events.scss
Expand Up @@ -23,16 +23,48 @@
}

// Event metadata (shows dates and wikis).
.event-metadata th {
padding-right: 10px;
.event-metadata {
margin-bottom: 1em;
th {
padding-right: 10px;
}
}

.event-metric-desc {
cursor: help;
}

.event-wiki-stats--empty {
margin: 36px 0;
.event-errorbox {
padding: 20px;
margin: 0 0 10px 0;
border: 1px solid #eee;
border-left-width: 5px;
border-radius: 3px;
h3 {
margin-top: 0 !important;
}
&.warn {
border-left-color: #eea236;
}
&.warn h3 {
color: #eea236;
}
&.error {
border-left-color: #d9534f;
}
&.error h3 {
color: #d9534f;
}
}
.panel-heading .glyphicon {
display: inline-block;
margin-left: 1em;
&.error {
color: #d9534f;
}
&.warn {
color: #f0ad4e;
}
}

// Remove space above the 'Statistics' H2, and reduce the margin between it and the following element.
Expand Down
4 changes: 3 additions & 1 deletion app/Resources/assets/js/eventshow.js
Expand Up @@ -51,12 +51,14 @@ eventmetrics.eventshow.setupCalculateStats = function () {

// Continually check the progress of the job and update the view accordingly.
eventmetrics.eventshow.pollJob($(this).data('event-id'));

// Also hide the 'not updated yet' message box.
$('.event-wiki-stats--empty').slideUp();
});

// Link to process event in message shown when stats have not yet been generated.
$('.event-process-link').on('click', function (e) {
$('.event-process-btn').trigger('click');
$('.event-wiki-stats--empty').html(' ');
e.preventDefault();
});
};
Expand Down
15 changes: 8 additions & 7 deletions app/Resources/views/events/_categories.html.twig
Expand Up @@ -73,10 +73,11 @@
{{ form_end(form, {'render_rest': false}) }}
{% endset %}

{{
layout.panel(
'categories',
event.numCategories(true) ~ ' ' ~ msg('num-categories', [event.numCategories(true)]),
content
)
}}
{% if filtersMissing %}
{% set panelDesc = msg('no-categories') ~ ' <span class="error glyphicon glyphicon-asterisk"></span>' %}
{% elseif event.numParticipants == 0 and wikisWithoutCats.count %}
{% set panelDesc = msg('not-all-wikis-have-cats') ~ ' <span class="warn glyphicon glyphicon-warning-sign"></span>' %}
{% else %}
{% set panelDesc = msg('num-categories', [event.numCategories(true)]) %}
{% endif %}
{{ layout.panel('categories-panel-title', panelDesc, content) }}
17 changes: 10 additions & 7 deletions app/Resources/views/events/_participants.html.twig
Expand Up @@ -79,10 +79,13 @@
{% endset %}

{# Here we use event.participants.count, ensuring it's the number of manually entered participants (and not derived). #}
{{
layout.panel(
'participants',
event.participants.count ~ ' ' ~ msg('num-participants', [event.participants.count]),
content
)
}}
{% if event.participants.count == 0 and event.wikiByDomain('www.wikidata') %}
{% set panel_desc = msg('error-filters-wikidata-panel') ~ ' <span class="error glyphicon glyphicon-asterisk"></span>' %}
{% elseif not filtersMissing and event.participants.count == 0 and wikisWithoutCats.count %}
{% set panel_desc = msg('no-participants') ~ ' <span class="warn glyphicon glyphicon-warning-sign"></span>' %}
{% elseif filtersMissing %}
{% set panel_desc = msg('no-participants') ~ ' <span class="error glyphicon glyphicon-asterisk"></span>' %}
{% else %}
{% set panel_desc = msg('num-participants', [event.participants.count]) %}
{% endif %}
{{ layout.panel('participants-panel-title', panel_desc, content) }}
86 changes: 66 additions & 20 deletions app/Resources/views/events/show.html.twig
Expand Up @@ -26,6 +26,72 @@

{% include 'events/_metadata.html.twig' with {'event': event} %}

{% if filtersMissing %}
<section class="event-errorbox error">
<h3>{{ msg('error-filters-header') }}</h3>
<p>
{{ msg('error-filters-desc') }}
<a href="https://meta.wikimedia.org/wiki/Special:MyLanguage/Event_Metrics#adding-participants"
title="{{ msg('error-filters-desc-tooltip') }}">
<span class="glyphicon glyphicon-question-sign"></span>
</a>
</p>
<ul>
<li>{{ msg('error-filters-participants-or-categories') }}</li>
<li>{{ msg('error-filters-every-wiki') }}</li>
<li>{{ msg('error-filters-participants-desc') }}</li>
<li>{{ msg('error-filters-categories-desc') }}</li>
<li>{{ msg('error-filters-combination') }}</li>
</ul>
</section>

{% elseif event.participants.count == 0 and wikisWithoutCats.count %}
<section class="event-errorbox warn">
<h3>{{ msg('category-warning-header') }}</h3>
<p>
{{ msg('category-warning-desc', ['<a href="#" class="event-process-link">'~msg('update-data')~'</a>'])|raw }}
<a href="https://meta.wikimedia.org/wiki/Special:MyLanguage/Event_Metrics#adding-categories"
title="{{ msg('category-warning-desc-tooltip') }}">
<span class="glyphicon glyphicon glyphicon-question-sign"></span>
</a>
</p>
<ul>
<li>
{{ msg('error-filters-categories-missing') }}
<strong>
{% for noCatWiki in wikisWithoutCats %}
{{ noCatWiki.domain }}{% if not loop.last %},{% endif %}
{% endfor %}
</strong>
</li>
<li>{{ msg('error-filters-every-wiki') }}</li>
{% if event.wikiByDomain('www.wikidata') %}
<li>{{ msg('error-filters-wikidata') }}</li>
{% endif %}
<li>{{ msg('error-filters-participants-desc') }}</li>
<li>{{ msg('error-filters-categories-desc') }}</li>
<li>{{ msg('error-filters-combination') }}</li>
</ul>
</section>

{% elseif not event.updated and not event.hasJob %}
<div class="alert alert-success event-wiki-stats--empty">
{% if event.startUTC > date() %}
{{ msg('event-in-future') }}
(<a href="{{ path('EditEvent', {'programId': program.id, 'eventId': event.id}) }}">{{ msg('settings')|lower }}</a>)
{% else %}
{{ msg('event-no-data') }}
<a href="#" class="event-process-link">{{ msg('calculate-totals') }}</a>.
{% endif %}
</div>
{% endif %}

{### FORMS ###}
{% for formType, form in forms %}
{% form_theme form 'blocks/forms.html.twig' %}
{% include ('events/_' ~ formType|lower ~ '.html.twig') %}
{% endfor %}

<section id="stats">
{% if event.updated is not null %}
{% if event.wikis|length > 1 %}
Expand Down Expand Up @@ -63,28 +129,8 @@
{% else %}
{% include 'events/_stats_summary.html.twig' with {'event': event} %}
{% endif %}
{% else %}
<div class="text-center event-wiki-stats--empty">
{% if event.hasJob %}
&nbsp;
{% elseif event.numParticipants == 0 and event.numCategories == 0 %}
{{ msg('event-misconfig', [[msg('participants'), msg('categories')]|list_format]) }}
{% elseif event.startUTC > date() %}
{{ msg('event-in-future') }}
(<a href="{{ path('EditEvent', {'programId': program.id, 'eventId': event.id}) }}">{{ msg('settings')|lower }}</a>)
{% else %}
{{ msg('event-no-data') }}
<a href="#" class="event-process-link">{{ msg('calculate-totals') }}</a>.
{% endif %}
</div>
{% endif %}
</section><!-- #stats -->

{### FORMS ###}

{% for formType, form in forms %}
{% form_theme form 'blocks/forms.html.twig' %}
{% include ('events/_' ~ formType|lower ~ '.html.twig') with {'form': form, 'event': event, 'isOrganizer': isOrganizer} %}
{% endfor %}
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion app/Resources/views/macros/layout.html.twig
Expand Up @@ -15,7 +15,7 @@
</a>
</h3>
<div class="panel-description text-right">
{{ description }}
{{ description|raw }}
</div>
</div>
<div id="panelBody{{ title|ucfirst }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="panelHeading{{ title|ucfirst }}">
Expand Down
25 changes: 22 additions & 3 deletions i18n/en.json
Expand Up @@ -22,8 +22,12 @@
"calculate-totals": "Calculate totals",
"cancel": "Cancel",
"categories": "Categories",
"categories-panel-title": "Categories filter",
"categories-description": "Enter categories (with wiki names) to limit metrics to pages in those categories",
"categories-commons-explanation": "On Commons only, use this to filter files (images, videos, etc.), instead of pages.",
"category-warning-header": "Event partially configured",
"category-warning-desc": "You will get metrics for some but not all of the wikis specified for the event. To calculate figures, you may need to $1.",
"category-warning-desc-tooltip": "Read more about how to enter categories",
"category-name": "Category name",
"close": "Close",
"confirm-deletion": "Are you sure you want to delete '$1'?",
Expand All @@ -48,6 +52,18 @@
"error-event-retry-link": "report this issue",
"error-event-timeout": "This process took too long and was stopped.",
"error-event-undeletable": "This event cannot be deleted because it has one or more participants.",
"error-filters-categories-desc": "Category filters are specific to individual wikis.",
"error-filters-categories-missing": "The following wikis require filtering:",
"error-filters-combination": "If you combine Categories and Participants, the system will provide metrics for contributions that satisfy both filters (i.e., Category AND Participants).",
"error-filters-desc": "Event setup isn't complete yet. Please use one or both of the filters below to more narrowly focus your metrics.",
"error-filters-desc-tooltip": "Read more about how to enter participant usernames",
"error-filters-every-wiki": "You must provide filtering for every wiki for which you want metrics.",
"error-filters-header": "Filters required",
"error-filters-participants-desc": "Participants filtering applies to all wikis and satisfies all filtering requirements.",
"error-filters-participants-none": "No participants supplied",
"error-filters-participants-or-categories": "You can filter by Participants or Categories—or combine the two.",
"error-filters-wikidata": "To get metrics about <strong>Wikidata</strong>, you must supply Participants. (Categories don't exist on Wikidata.)",
"error-filters-wikidata-panel": "Required for Wikidata",
"error-invalid": "This value is not valid.",
"error-non-organizer": "You are not authorized to view this program because you are not an organizer.",
"error-not-found": "The request program or event was not found. It may have been deleted or renamed.",
Expand All @@ -73,7 +89,6 @@
"event-list": "Event list",
"event-metrics": "Event Metrics",
"event-metrics-welcome": "Welcome to Event Metrics",
"event-misconfig": "This event has not been completely configured. In order to generate statistics, you must add one of the following: $1",
"event-no-data": "Statistics have not yet been generated for this event.",
"event-settings": "Event settings",
"event-summary": "Event summary",
Expand Down Expand Up @@ -102,18 +117,21 @@
"my-programs": "My programs",
"new-editors": "New editors",
"new-editors-desc": "The number of new accounts created, including users that registered up to $1 {{PLURAL:$1|day|days}} before the event (on any wiki).",
"no-categories": "No categories supplied",
"no-events": "No events in this program yet!",
"no-participants": "No participants supplied",
"no-programs": "You have not created any programs.",
"no-results": "No results found",
"metadata-categories-label": "{{PLURAL:$1|Category|Categories}}:",
"metadata-end-date": "End date:",
"metadata-start-date": "Start date:",
"metadata-wikis-label": "{{PLURAL:$1|Wiki|Wikis}}:",
"num-categories": "{{PLURAL:$1|category|categories}}",
"not-all-wikis-have-cats": "Categories not supplied for some wikis",
"num-categories": "$1 {{PLURAL:$1|category|categories}}",
"num-days": "{{PLURAL:$1|day|days}}",
"num-hours": "{{PLURAL:$1|hour|hours}}",
"num-minutes": "{{PLURAL:$1|minute|minutes}}",
"num-participants": "{{PLURAL:$1|participant|participants}}",
"num-participants": "$1 {{PLURAL:$1|participant|participants}}",
"num-revisions": "{{PLURAL:$1|revision|revisions}}",
"num-seconds": "{{PLURAL:$1|second|seconds}}",
"num-wikis": "{{PLURAL:$1|wiki|wikis}}",
Expand All @@ -133,6 +151,7 @@
"pageviews-average": "Avg. daily pageviews",
"pageviews-cumulative": "Pageviews, cumulative",
"participants": "Participants",
"participants-panel-title": "Participants filter",
"please-login": "Please login to continue.",
"program": "Program",
"program-created": "The program '$1' was successfully created.",
Expand Down

0 comments on commit 66430ff

Please sign in to comment.