Skip to content

Commit

Permalink
Change design of contribution form (see #841)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanierAvide committed Dec 15, 2020
1 parent 0228a7d commit ff40d48
Show file tree
Hide file tree
Showing 21 changed files with 733 additions and 389 deletions.
178 changes: 95 additions & 83 deletions categories.json

Large diffs are not rendered by default.

437 changes: 257 additions & 180 deletions components/contribute_form.vue

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions components/opening_hours_editor/editor.vue
Expand Up @@ -36,6 +36,7 @@
<v-btn
width="100%"
class="mt-3"
small
@click="openDialog"
>{{ $t('opening_hours_editor.add_new_days') }}</v-btn>
<v-dialog
Expand Down
9 changes: 8 additions & 1 deletion components/place/detail.vue
Expand Up @@ -251,7 +251,7 @@ export default {
},
computed: {
...mapState(['country']),
...mapState(['country', 'isContributing']),
hasVending() {
return this.$te(`details.vending.${this.place.properties.tags.vending}`);
Expand Down Expand Up @@ -304,6 +304,7 @@ export default {
addInfosIfValueYes('tobacco');
addInfosIfValueYes('newsagent');
addInfosDependingOfTagAndStatus('takeaway');
addInfosDependingOfTagAndStatus('pickup');
addInfosDependingOfTagAndStatus('delivery');
addInfosDependingOfTagAndStatus('drive_through');
addInfosDependingOfTagAndStatus('wheelchair');
Expand Down Expand Up @@ -356,6 +357,12 @@ export default {
isMobile() {
this.updateDefaultHeight();
},
isContributing() {
if(this.isContributing && this.isMobile) {
this.moveUp();
}
}
},
Expand Down
1 change: 1 addition & 0 deletions components/place/detail_opening_hours.vue
Expand Up @@ -88,6 +88,7 @@ export default {
return new OpeningHours(this.value, null, { mode: this.mode, locale: this.$i18n.locale });
}
catch(e) {
return null;
}
}
},
Expand Down
15 changes: 12 additions & 3 deletions components/place/detail_state.vue
Expand Up @@ -29,15 +29,14 @@
>
<span class="text-pre">{{ $t('details.signal_done') }}</span>
</v-alert>
<div v-if="contribute">
<v-sheet v-if="contribute" elevation="4" class="ma-3">
<contribute-form
:place="place"
class="pa-2"
@success="success = true; contribute = false"
@close="contribute = false"
/>
<v-divider />
</div>
</v-sheet>
</div>
</template>

Expand Down Expand Up @@ -72,6 +71,12 @@ export default {
};
},
watch: {
contribute() {
this.$store.commit('setIsContributing', this.contribute);
}
},
computed: {
type() {
return colorForStatus(this.status);
Expand All @@ -89,6 +94,10 @@ export default {
const date = this.lastUpdate.toLocaleString(this.$i18n.locale, format);
return this.$t('details.last_update.date', { date });
}
},
beforeDestroy() {
this.$store.commit('setIsContributing', false);
}
};
</script>
2 changes: 1 addition & 1 deletion components/update_detail_dialog.vue
@@ -1,6 +1,6 @@
<template>
<v-list dense two-line>
<v-list-item v-on="on">
<v-list-item>
<v-list-item-icon class="mr-1">
<v-icon>osm-alert</v-icon>
</v-list-item-icon>
Expand Down
4 changes: 2 additions & 2 deletions db/import_brand_rules.sh
Expand Up @@ -6,7 +6,7 @@ DATABASE_URL=${1:-${DATABASE_URL}}

# Import brand rules
brand_rules="/data/download/brand_rules.csv"
if wget "https://github.com/PanierAvide/Covid_enseignes/raw/master/rules.csv" --quiet -O "${brand_rules}"; then
if wget "https://github.com/caresteouvert/Covid_enseignes/raw/master/rules.csv" --quiet -O "${brand_rules}"; then
psql ${DATABASE_URL} -c "DROP TABLE IF EXISTS brand_rules; CREATE TABLE brand_rules(country VARCHAR, category VARCHAR, brand_name VARCHAR, wikidata_id VARCHAR, opening_rule VARCHAR, opening_hours VARCHAR, osm_additional_tags JSON, description VARCHAR, source_url VARCHAR, opening_hours_url VARCHAR);"
psql ${DATABASE_URL} -c "\copy brand_rules FROM '${brand_rules}' CSV DELIMITER ',' HEADER"
psql ${DATABASE_URL} -c "CREATE INDEX brand_rules_country_idx ON brand_rules(country); CREATE INDEX brand_rules_wikidata_id_idx ON brand_rules(wikidata_id); CREATE INDEX brand_rules_brand_name_idx ON brand_rules(brand_name);"
Expand All @@ -16,7 +16,7 @@ fi

# Import legal rules
legal_rules="/data/download/legal_rules.csv"
if wget "https://github.com/PanierAvide/Covid_enseignes/raw/master/legal_rules.csv" --quiet -O "${legal_rules}"; then
if wget "https://github.com/caresteouvert/Covid_enseignes/raw/master/legal_rules.csv" --quiet -O "${legal_rules}"; then
psql ${DATABASE_URL} -c "DROP TABLE IF EXISTS legal_rules; CREATE TABLE legal_rules(country VARCHAR, country_subarea VARCHAR, category VARCHAR, osm_tags JSONB, start_date DATE, end_date DATE, legal_state VARCHAR, details VARCHAR, source_url VARCHAR);"
psql ${DATABASE_URL} -c "\copy legal_rules FROM '${legal_rules}' CSV DELIMITER ',' HEADER"
psql ${DATABASE_URL} -c "DELETE FROM legal_rules WHERE current_date < start_date OR (end_date IS NOT NULL AND current_date > end_date); CREATE INDEX legal_rules_country_idx ON legal_rules(country); CREATE INDEX legal_rules_country_subarea_idx ON legal_rules(country_subarea); CREATE INDEX legal_rules_category_idx ON legal_rules(category); CREATE INDEX legal_rules_legal_state_idx ON legal_rules(legal_state);"
Expand Down
49 changes: 49 additions & 0 deletions db/update_poi.sql
Expand Up @@ -38,6 +38,14 @@ BEGIN
status := 'open_adapted';
END IF;

-- Has any covid19 related service
ELSIF tags->'delivery:covid19' IN ('yes', 'only') OR tags->'drive_through:covid19' IN ('yes', 'only') OR tags->'takeaway:covid19' IN ('yes', 'only') OR tags->'pickup:covid19' IN ('yes', 'only') THEN
status := 'open_adapted';

-- Has access:covid19 explicitly set to yes
ELSIF tags->'access:covid19' = 'yes' THEN
status := 'open';

-- Self-service / vending machines
ELSIF (tags->'amenity' = 'fuel' AND tags->'self_service' = 'yes') OR tags->'amenity' = 'vending_machine' THEN
status := 'open';
Expand Down Expand Up @@ -130,7 +138,9 @@ AS
END,
CASE
WHEN tags->'takeaway:covid19' IN ('yes', 'no', 'only') THEN tags->'takeaway:covid19'
WHEN tags->'pickup:covid19' IN ('yes', 'no', 'only') THEN tags->'pickup:covid19'
WHEN tags->'takeaway' IN ('yes', 'no', 'only') AND opening_state(tags) = 'ouvert' THEN tags->'takeaway'
WHEN tags->'pickup' IN ('yes', 'no', 'only') AND opening_state(tags) = 'ouvert' THEN tags->'pickup'
ELSE 'unknown'
END,
has_contact_tag(tags),
Expand Down Expand Up @@ -166,7 +176,9 @@ SELECT
END,
CASE
WHEN tags->'takeaway:covid19' IN ('yes', 'no', 'only') THEN tags->'takeaway:covid19'
WHEN tags->'pickup:covid19' IN ('yes', 'no', 'only') THEN tags->'pickup:covid19'
WHEN tags->'takeaway' IN ('yes', 'no', 'only') AND opening_state(tags) = 'ouvert' THEN tags->'takeaway'
WHEN tags->'pickup' IN ('yes', 'no', 'only') AND opening_state(tags) = 'ouvert' THEN tags->'pickup'
ELSE 'unknown'
END,
has_contact_tag(tags),
Expand Down Expand Up @@ -251,6 +263,43 @@ WHERE
AND b.opening_rule IS NOT NULL
AND lower(trim(unaccent(name))) = lower(trim(unaccent(b.brand_name)));

UPDATE poi_osm_next
SET
status = 'open',
status_order = status_order_value('open'),
source_status = 'legal'
FROM legal_rules r
WHERE
r.legal_state = 'open'
AND poi_osm_next.status = 'unknown'
AND poi_osm_next.country = r.country
AND (r.country_subarea IS NULL OR poi_osm_next.sub_country = r.country_subarea)
AND (r.category = poi_osm_next.cat OR r.category = poi_osm_next.normalized_cat);

-- Set default
UPDATE poi_osm_next
SET
status = 'open',
status_order = status_order_value(r.legal_state),
source_status = 'legal'
FROM legal_rules r
WHERE
poi_osm_next.status = 'unknown'
AND poi_osm_next.country = r.country
AND (r.country_subarea IS NULL OR poi_osm_next.sub_country = r.country_subarea)
AND r.category = 'default'
AND NOT EXISTS (
-- Exclude states not applyed
SELECT
FROM legal_rules AS rr
WHERE
rr.legal_state NOT IN ('open', 'close')
AND rr.country = r.country
AND rr.country_subarea IS NOT DISTINCT FROM r.country_subarea
AND rr.category != 'default'
AND (rr.category = poi_osm_next.cat OR rr.category = poi_osm_next.normalized_cat)
);

UPDATE poi_osm_next
SET status = 'open', status_order = status_order_value('open'), opening_hours = '24/7'
WHERE status IN ('unknown', 'open_adapted') AND cat = 'fuel' AND tags->>'opening_hours' = '24/7';
Expand Down
46 changes: 46 additions & 0 deletions icons/click_collect.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions icons/closed.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions icons/pencil.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions icons/pickup.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions icons/store_open.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions lib/categories.js
Expand Up @@ -48,7 +48,7 @@ export default function categoriesForArea(data, area) {
}, {});
}

export const SUB_FILTERS = ['delivery', 'takeaway'];
export const SUB_FILTERS = ['delivery', 'takeaway', 'pickup'];

export function availableSubFilters(categories, filter, brand = "DEFAULT") {
const [ category, subcategory ] = filter.split('/');
Expand All @@ -70,5 +70,8 @@ export function availableSubFilters(categories, filter, brand = "DEFAULT") {
});
}
}
return services.filter(s => SUB_FILTERS.includes(s)).concat(brand === "lyon" ? ["lumignon"] : []);
return services
.filter(s => SUB_FILTERS.includes(s))
.concat(brand === "lyon" ? ["lumignon"] : [])
.map(s => s === "pickup" ? "takeaway" : s);
}

0 comments on commit ff40d48

Please sign in to comment.