Skip to content

Commit

Permalink
Merge pull request #168 from countable-web/master
Browse files Browse the repository at this point in the history
flag modal and help button changes
  • Loading branch information
jrcarretas authored Nov 13, 2023
2 parents 1570278 + 5325a42 commit 9b09d01
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 27 deletions.
Binary file modified frontend/assets/images/help-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions frontend/components/Flag/FlagModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
style="fill: white;"
></MdFlagIcon
>{{ title || 'Flag' }}
<b-modal v-model="modalShow" hide-header centered @ok="handleSubmit">
<b-modal
v-model="modalShow"
hide-header
centered
:ok-disabled="!isValid"
ok-title="Submit"
@ok="handleSubmit"
>
<b-alert
v-if="errorMessage"
show
variant="danger"
class="font-08 padding-05"
>{{ errorMessage }}</b-alert
>
<h5 class="font-08">Select a reason</h5>
<h4 class="font-08">Select a reason</h4>
<b-form-select
v-model="selected"
:options="options"
size="sm"
></b-form-select>
<div>
<h5 class="font-08 mt-3">State a reason</h5>
<h4 class="font-08 mt-3">State a reason</h4>
<b-form-textarea
id="textarea"
v-model="text"
Expand Down Expand Up @@ -77,10 +84,15 @@ export default {
errorMessage: null
}
},
computed: {
isValid() {
return this.selected && this.text
}
},
methods: {
async handleSubmit(e) {
e.preventDefault()
if (!this.selected || !this.text) {
if (!this.selected && !this.text) {
this.errorMessage = 'Please select an option, and state your reason.'
return false
}
Expand Down
23 changes: 0 additions & 23 deletions frontend/components/MapControls/MapControlFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
v-if="$route.path !== '/splashscreen' && !isEmbed"
class="map-controls-overlay"
>
<div v-if="$route.path !== '/page/how-to-use'" class="help-icon">
<nuxt-link to="/page/how-to-use">
<img src="@/assets/images/help-icon.png" alt="Help" width="15px"
/></nuxt-link>
</div>
<Zoom class="zoom-control mr-2 hide-mobile"></Zoom>
<ResetMap class="reset-map-control mr-2 hide-mobile"></ResetMap>
<CurrentLocation class="current-location-control mr-2"></CurrentLocation>
Expand Down Expand Up @@ -46,21 +41,3 @@ export default {
}
}
</script>

<style>
.help-icon {
background-color: #fff;
border: 1px solid #ddd5cc;
cursor: pointer;
padding: 0.5em 0.75em;
margin-right: auto;
margin-left: 2.5em;
display: flex;
align-content: center;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 15px;
text-transform: uppercase;
}
</style>
26 changes: 26 additions & 0 deletions frontend/components/NavigationBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<template>
<div class="nav-container">
<div class="navigation-container hide-mobile">
<div
v-if="$route.path !== '/page/how-to-use'"
class="nav-item-container cursor-pointer hide-mobile"
>
<nuxt-link class="text-dark" to="/page/how-to-use">
<nav>
<span>HELP</span>
<img src="@/assets/images/help-icon.png" alt="Help" width="20px" />
</nav>
</nuxt-link>
</div>
<Event />
<div
v-if="isLoggedIn"
Expand Down Expand Up @@ -624,4 +635,19 @@ export default {
padding: 0.75em;
}
}
.help-icon {
background-color: #fff;
border: 1px solid #ddd5cc;
cursor: pointer;
padding: 0.5em 0.75em;
margin-right: auto;
margin-left: 2.5em;
display: flex;
align-content: center;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 15px;
text-transform: uppercase;
}
</style>
53 changes: 53 additions & 0 deletions web/language/management/commands/update_language_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pandas as pd

from django.core.management.base import BaseCommand

from language.models import Language, Community, CommunityLanguageStats


class Command(BaseCommand):
def handle(self, *args, **options):
filename = options["filename"]
check = options["check"] or 1
update_language_stats(filename, check)

def add_arguments(self, parser):
parser.add_argument(
"--filename", nargs="?", type=str, help="Specify the filename"
)
parser.add_argument(
"--check",
nargs="?",
type=int,
help="Check if there are no missing data from the database",
)


def update_language_stats(filename, check=1):
print("Reading ", filename)
print("Check ", check)

df = pd.read_csv(filename)

if check:
error = False

for index, row in df.iterrows():
row_number = index + 1
current_community = row["Community"]
current_language = row["Language"]

try:
Community.objects.get(name__unaccent__iexact=current_community)
except Community.DoesNotExist:
error = True
print(f"Row {row_number} - Community not found: {current_community}")

try:
Language.objects.get(name__unaccent__iexact=current_language)
except Language.DoesNotExist:
error = True
print(f"Row {row_number} - Language not found: {current_language}")

if not error:
print("File check passed")
12 changes: 12 additions & 0 deletions web/language/migrations/0142_auto_20231113_0627.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Django 2.2.13 on 2023-11-13 06:27

from django.db import migrations
from django.contrib.postgres.operations import UnaccentExtension


class Migration(migrations.Migration):
dependencies = [
("language", "0141_auto_20230811_0256"),
]

operations = [UnaccentExtension()]
1 change: 1 addition & 0 deletions web/web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"django.contrib.gis",
"django.contrib.sites",
"django.contrib.sitemaps",
"django.contrib.postgres",
'django_filters',
"rest_framework",
"rest_framework.authtoken",
Expand Down

0 comments on commit 9b09d01

Please sign in to comment.