Skip to content

Commit

Permalink
[FixaMinGata] Add various updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkri committed Jul 7, 2024
1 parent ce80472 commit aedbdd2
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 64 deletions.
27 changes: 19 additions & 8 deletions perllib/FixMyStreet/Cobrand/FixaMinGata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sub language_override { 'sv' }

sub enter_postcode_text {
my ( $self ) = @_;

return _('Enter a nearby postcode, or street name and area');
}

Expand Down Expand Up @@ -87,43 +88,54 @@ sub geocoder_munge_results {

sub area_types {
my $self = shift;

return $self->next::method() if FixMyStreet->staging_flag('skip_checks');

[ 'KOM' ];
}

sub geocode_postcode {
my ( $self, $s ) = @_;

# Most people write Swedish postcodes like this:
# XXX XX, so let's remove the space
$s =~ s/\ //g;

if ($s =~ /^\d{5}$/) {
my $location = mySociety::MaPit::call('postcode', $s);

if ($location->{error}) {
return {
error => $location->{code} =~ /^4/
? _('That postcode was not recognised, sorry.')
: $location->{error}
};
}

return {
latitude => $location->{wgs84_lat},
longitude => $location->{wgs84_lon},
};
}

return {};
}

# Vad gör den här funktionen? Är "Sverige" rätt här?
sub geocoded_string_check {
my ( $self, $s ) = @_;

return 1 if $s =~ /, Sverige/;

return 0;
}

sub find_closest {
my ( $self, $problem ) = @_;

$problem = $problem->{problem} if ref $problem eq 'HASH';
return FixMyStreet::Geocode::OSM->closest_road_text( $self, $problem->latitude, $problem->longitude );

return FixMyStreet::Geocode::OSM::closest_road_text( $self, $problem->latitude, $problem->longitude );
}

# Used by send-reports, calling find_closest, calling OSM geocoding
Expand All @@ -132,13 +144,15 @@ sub guess_road_operator {

my $highway = $inforef->{highway} || "unknown";
my $refs = $inforef->{ref} || "unknown";

return "Trafikverket"
if $highway eq "trunk" || $highway eq "primary";

for my $ref (split(/;/, $refs)) {
return "Trafikverket"
if $ref =~ m/E ?\d+/ || $ref =~ m/Fv\d+/i;
}

return '';
}

Expand Down Expand Up @@ -167,9 +181,13 @@ sub filter_all_council_ids_list {
# confirmed state), and red otherwise.
sub pin_colour {
my ( $self, $p, $context ) = @_;

return 'green' if $p->is_closed;

return 'green' if $p->is_fixed;

return 'yellow' if $p->is_in_progress;

return 'red';
}

Expand All @@ -181,11 +199,6 @@ sub state_groups_inspect {
]
}

sub always_view_body_contribute_details {
my ( $self, $contributed_as ) = @_;
return $contributed_as eq '';
}

# Average responsiveness will only be calculated if a body
# has at least this many fixed reports.
# (Used in the Top 5 list in /reports)
Expand All @@ -195,6 +208,4 @@ sub body_responsiveness_threshold {

sub suggest_duplicates { 1 }

sub default_show_name { 1 }

1;
2 changes: 1 addition & 1 deletion templates/email/fixamingata/submit.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2 style="[% h2_style %]">[% report.title | html %]</h2>
<a href="[% osm_url %]" title="Se den här platsen på OpenStreetMap">
[%~ report.latitude %], [% report.longitude ~%]
</a>
[% IF closest_address %]<br>[% closest_address | trim | replace("\n\n", "<br>") %][% END %]
[% IF closest_address %]<br>[% closest_address | trim | replace("\n\n", " ") %][% END %]
</p>
[% END %]

Expand Down
9 changes: 3 additions & 6 deletions templates/web/fixamingata/about/faq-sv.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[% INCLUDE 'header.html', title => loc('Frequently Asked Questions'), bodyclass => 'twothirdswidthpage' %]

[% INCLUDE 'about/_sticky-button-content-navbar.html' %]

<div class="sticky-sidebar">
<aside>
<ul class="plain-list">
Expand Down Expand Up @@ -36,15 +34,14 @@ <h1><a name="faq"></a>Vanliga frågor</h1>
<dt>Vad är inte FixaMinGata till för?</dt>
<dd>
FixaMinGata är inte lämpligt för andra typer av problem än de som anges ovan. Du måste kontakta din kommun eller fastighetsägare direkt för problem i stil med:
<ul>
<ul style="margin-bottom: 0;">
<li>Brådskande och akuta problem</li>
<li>Oljud i din närmiljö</li>
<li>Brand och rök</li>
<li>Förslag på nya vägar, farthinder, etc.</li>
<li>Klaga på dina grannar</li>
<li>Klaga på din kommun</li>
<li>Droger, djurplågeri, stöld, eller andra kriminella aktiviteter.</li>
</ul>
<p style="margin-bottom: 2em;">Vid pågående brott och vid fara för liv, hälsa eller egendom ska du ringa 112.</p>
</dd>

<dt>Hur använder jag e-tjänsten?</dt>
Expand Down Expand Up @@ -87,4 +84,4 @@ <h2><a name="privacy"></a>Sekretess och kakor</h2>
<dd>Läs vår information om <a href="/about/privacy">Sekretess och kakor</a>.</dd>
</dl>

[% INCLUDE 'footer.html' %]
[% INCLUDE 'footer.html' pagefooter = 'yes' %]
19 changes: 2 additions & 17 deletions templates/web/fixamingata/about/privacy.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
[% INCLUDE 'header.html', title => loc('Vanliga Frågor'), bodyclass => 'twothirdswidthpage' %]

[% INCLUDE 'about/_sticky-button-content-navbar.html' %]

<div class="sticky-sidebar">
<aside>
<ul class="plain-list">
<li><a href="/faq#faq">Vanliga frågor</a></li>
<li><a href="/faq#practical">Praktiska frågor</a></li>
<li><a href="/faq#organisation">Organisation</a></li>
<li><a href="/faq#pul">Dataskyddsombud</a></li>
<li><a href="about/privacy">Sekretess och kakor</a></li>
</ul>
</aside>
</div>


<h1>Sekretess och kakor</h1>
<p><strong>Vår användning av din information och vad du behöver veta.</strong></p>
<p>Offentlighetsprincipen är en viktig del i det demokratiska samhället. Genom tryckfrihetsförordningen och offentlighetslagen har du rätt att ta del av allmänna offentliga handlingar hos statliga och kommunala myndigheter. Det kan ge dig insyn i hur förtroendevalda (politiker) och tjänstemän handlägger ärenden, vilka handlingar som kommit in till kommunens olika förvaltningar och vilka som skickats ut.</p>
Expand Down Expand Up @@ -67,7 +52,7 @@ <h2>Kakor</h2>

<dl>
<dt>Vad är <em>INTE</em> FixaMinGata till för?</dt>
<dd>FixaMinGata är inte lämpligt för andra typer av problem än de som anges ovan. Du måste kontakta din kommun eller fastighetsägare direkt för problem i stil med:<ul><li>Brådskande och akuta problem</li><li>Oljud i din närmiljö</li><li>Brand och rök</li><li>Förslag på nya vägar, farthinder, etc.</li><li>Klaga på dina grannar</li><li>Klaga på din kommun</li><li>Droger, djurplågeri, stöld, eller andra kriminella aktiviteter.</li><li>Information kring brott/överträdelser eller misstanke om detsamma</li></ul></dd>
<dd>FixaMinGata är inte lämpligt för andra typer av problem än de som anges ovan. Du måste kontakta din kommun eller fastighetsägare direkt för problem i stil med:<ul style="margin-bottom: 0;"><li>Brådskande och akuta problem</li><li>Oljud i din närmiljö</li><li>Förslag på nya vägar, farthinder, etc.</li><li>Klaga på dina grannar</li><li>Klaga på din kommun</li><li>Information kring brott/överträdelser eller misstanke om detsamma</li></ul><p style="margin-bottom: 2em;">Vid pågående brott och vid fara för liv, hälsa eller egendom ska du ringa 112.</p></dd>
</dl>

[% INCLUDE 'footer.html' %]
[% INCLUDE 'footer.html' pagefooter = 'yes' %]
5 changes: 3 additions & 2 deletions templates/web/fixamingata/contact/address.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Du kan kontakta Föreningen Sambruk via post:</p>

<p>Föreningen Sambruk<br>
c/o Sandvikens kommun<br>
811 80 Sandviken</p>
Sandbacka Park<br>
Högbovägen 45<br>
811 32 Sandviken</p>
</div>
17 changes: 10 additions & 7 deletions templates/web/fixamingata/contact/blurb.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<p>
Rapportera <strong>inte</strong> problem i din närmiljö genom det här formuläret. Breven går till FixaMinGata i stället för din kommun. Vill du rapportera ett problem i din närmiljö måste du <a href="/">gå till framsidan</a> och följa instruktionerna där.
</p>

<p>
Vi vill gärna höra vad du tycker om FixaMinGata. Fyll i formuläret nedan och skicka in.
</p>
<p>Rapportera <strong>inte</strong> problem i din närmiljö genom det här
formuläret. Breven går till FixaMinGata i stället för din kommun. Vill du
rapportera ett problem i din närmiljö måste du <a href="/">gå till framsidan</a>
och följa instruktionerna där.</p>
<p>Vi vill gärna höra vad du tycker om FixaMinGata. Fyll i formuläret nedan och
skicka in.</p>
<p>Du kan även begära att få ditt konto borttaget via detta formulär. När kontot
raderas anonymiseras dina uppgifter, inklusive din ditt namn, e-postadress och
eventuella telefonnummer. Rapporter och uppdateringar finns dock kvar för
statistik.</p>
22 changes: 11 additions & 11 deletions templates/web/fixamingata/footer_extra.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ <h2 class="mysoc-footer__site-name">FixaMinGata</h2>
<div class="col-sm-5">
<nav class="mysoc-footer__links">
<ul>
<li><[% IF c.req.uri.path == '/' %]span[% ELSE %]a href="/"[% END %] class="report-a-problem-btn"
<li><[% IF c.req.uri.path == '/' %]span[% ELSE %]a href="[% base %]/"[% END %] class="report-a-problem-btn"
>[% loc("Report a problem") %]</[% c.req.uri.path == '/' ? 'span' : 'a' %]></li>
<li><[% IF c.req.uri.path == '/my' %]span[% ELSE %]a href="/my"[% END
<li><[% IF c.req.uri.path == '/my' %]span[% ELSE %]a href="[% base %]/my"[% END
%]>[% loc("Your reports") %]</[% c.req.uri.path == '/my' ? 'span' : 'a' %]></li>
<li><[% IF c.req.uri.path == '/reports' %]span[% ELSE %]a href="/reports"[% END
<li><[% IF c.req.uri.path == '/reports' %]span[% ELSE %]a href="[% base %]/reports"[% END
%]>[% loc("All reports") %]</[% c.req.uri.path == '/reports' ? 'span' : 'a' %]></li>
<li><[% IF c.req.uri.path == '/alert' %]span[% ELSE %]a href="/alert[% pc ? '/list?pc=' : '' %][% pc | uri %]"[% END
<li><[% IF c.req.uri.path == '/alert' %]span[% ELSE %]a href="[% base %]/alert[% pc ? '/list?pc=' : '' %][% pc | uri %]"[% END
%]>[% loc("Local alerts") %]</[% c.req.uri.path == '/alert' ? 'span' : 'a' %]></li>
</ul>
<ul>
<!-- <li><[% IF c.req.uri.path == '/posters' %]span[% ELSE %]a href="/posters"[% END
<!-- <li><[% IF c.req.uri.path == '/posters' %]span[% ELSE %]a href="[% base %]/posters"[% END
%]>[% loc("FixMyStreet Goodies") %]</[% c.req.uri.path == '/posters' ? 'span' : 'a' %]></li> -->
<!-- <li><[% IF c.req.uri.path == '/contact' %]span[% ELSE %]a href="/contact"[% END
<!-- <li><[% IF c.req.uri.path == '/contact' %]span[% ELSE %]a href="[% base %]/contact"[% END
%]>[% loc("Contact") %]</[% c.req.uri.path == '/contact' ? 'span' : 'a' %]></li> -->
<li><[% IF c.req.uri.path == '/contact' %]span[% ELSE %]a href="/contact"[% END
<li><[% IF c.req.uri.path == '/contact' %]span[% ELSE %]a href="[% base %]/contact"[% END
%]>Kontakt</[% c.req.uri.path == '/contact' ? 'span' : 'a' %]></li>
<li><[% IF c.req.uri.path == '/faq' %]span[% ELSE %]a href="/faq"[% END
<li><[% IF c.req.uri.path == '/faq' %]span[% ELSE %]a href="[% base %]/faq"[% END
%]>[% loc("Help") %]</[% c.req.uri.path == '/faq' ? 'span' : 'a' %]></li>
<!-- <li><[% IF c.req.uri.path == '/privacy' %]span[% ELSE %]a href="/privacy"[% END
<!-- <li><[% IF c.req.uri.path == '/privacy' %]span[% ELSE %]a href="[% base %]/privacy"[% END
%]>[% loc("Privacy") %]</[% c.req.uri.path == '/privacy' ? 'span' : 'a' %]></li> -->
<li><[% IF c.req.uri.path == '/about/privacy' %]span[% ELSE %]a href="/about/privacy"[% END
<li><[% IF c.req.uri.path == '/about/privacy' %]span[% ELSE %]a href="[% base %]/about/privacy"[% END
%]>Sekretess</[% c.req.uri.path == '/about/privacy' ? 'span' : 'a' %]></li>
<li><a href="https:/Sambruk/fixmystreet">Öppen källkod</a></li>
<li><[% IF c.req.uri.path == '/about/accessibility' %]span[% ELSE %]a href="/about/accessibility"[% END
<li><[% IF c.req.uri.path == '/about/accessibility' %]span[% ELSE %]a href="[% base %]/about/accessibility"[% END
%]>Tillgänglighet</[% c.req.uri.path == '/about/accessibility' ? 'span' : 'a' %]></li>
</ul>
</nav>
Expand Down
3 changes: 1 addition & 2 deletions templates/web/fixamingata/report/new/inline-tips.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div class="description_tips">
<h4>Tips för bra rapporter:</h4>
<div class="description_tips" aria-label="Tips för bra rapporter:">
<ul class="do">
<li>Var trevlig</li>
<li>Ange platser noggrant</li>
Expand Down
12 changes: 12 additions & 0 deletions web/cobrands/fixamingata/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ $grid-breakpoint-sm: $mysoc-footer-breakpoint-sm;
padding-top: 0;
}

#geolocate_link {
margin-top: 2em !important;
}

.mobile #geolocate_link {
margin-top: 15px !important;
}

#pc-hint {
display: none;
}

.sticky-sidebar li:last-child {
margin-bottom: 0;
}
24 changes: 14 additions & 10 deletions web/cobrands/fixamingata/js.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
fixmystreet.inspect_form_no_scroll_on_load = 1;

// Chrome ignores autocomplete="off" on the title input,
// and incorrectly autocompletes it with the user's email address.
// For now we'll reset the title to empty if it contains
// an email address when the user has selected a category.
// Hopefully we can get rid of this eventually if Chrome changes
// its behaviour.
// Chrome ignores autocomplete="off" on the title input, and incorrectly
// autocompletes it with the user's email address. For now we'll reset the title
// to empty if it contains an email address when the user has selected a
// category. Hopefully we can get rid of this eventually if Chrome changes its
// behaviour.
fixmystreet.fixChromeAutocomplete = function() {
var title = document.getElementById("form_title");

if (title) {
if (title.value == "" ||
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test(title.value)) {
if (
title.value == "" ||
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:\S{1,63})$/.test(title.value)
) {
title.value = "";
}
}
};

// jQuery is not imported on every page
// jQuery is not imported on every page.
if (window.$) {
$(fixmystreet).on('report_new:category_change', fixmystreet.fixChromeAutocomplete);
$(fixmystreet).on(
"report_new:category_change",
fixmystreet.fixChromeAutocomplete
);
}

0 comments on commit aedbdd2

Please sign in to comment.