Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entity field support #416

Merged
merged 11 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/app.js

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions public/tests/aasanjose-gsheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@
<body>
<div
id="tsml-ui"
data-src="https://docs.google.com/spreadsheets/d/12Ga8uwMG4WJ8pZ_SEU7vNETp_aQZ-2yNVsYDFqIwHyE/edit#gid=0"
data-src="https://docs.google.com/spreadsheets/d/17hg4oj-V_tnRJn5zrRbAAtlEsDM9pN_KeQBUu7QLfy4/edit?gid=0#gid=0"
data-mapbox="pk.eyJ1Ijoiam9zaHJlaXNuZXIiLCJhIjoiY2tvYXA0YnZxMGRldDJxbzdta25uNGphdiJ9.eay-UKgIT99ALmdw08xBPw"
data-google="AIzaSyCS9M8Dqk5cMFqA7xvUrQEzT1u5IvcbT7c"
data-timezone="America/Los_Angeles"
></div>
<script src="/app.js" async></script>
<script>
var tsml_react_config = {
feedback_emails: ['[email protected]'],
};
</script>
</body>
</html>
66 changes: 43 additions & 23 deletions src/components/Meeting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Link as RouterLink } from 'react-router-dom';

import {
formatDirectionsUrl,
formatFeedbackEmail,
formatIcs,
formatString as i18n,
formatUrl,
Expand All @@ -28,12 +27,10 @@ import Map from './Map';
import type { Meeting as MeetingType, State } from '../types';

export default function Meeting({
feedback_emails = [],
mapbox,
setState,
state,
}: {
feedback_emails?: string[];
mapbox?: string;
setState: Dispatch<SetStateAction<State>>;
state: State;
Expand Down Expand Up @@ -116,16 +113,6 @@ export default function Meeting({
document.title = meeting.name;
}

// feedback URL link
if (!meeting.feedback_url && feedback_emails.length) {
meeting.feedback_url = formatFeedbackEmail(
settings.feedback_emails,
meeting,
settings,
strings
);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to keep this page a little simpler we're forming the feedback_url in load-meeting-data

const contactButtons: {
href: string;
icon: keyof typeof icons;
Expand Down Expand Up @@ -428,18 +415,51 @@ export default function Meeting({
{formatWeekdays(groupWeekdays, meeting.slug, state, setState)}
</div>
)}
{meeting.updated && (
<div>{i18n(strings.updated, { updated: meeting.updated })}</div>
{(meeting.updated || meeting.feedback_url || meeting.entity) && (
<div>
{meeting.entity && (
<>
<small>{strings.provided_by}</small>
<header>
<h2>{meeting.entity}</h2>
{meeting.entity_location && (
<p>{meeting.entity_location}</p>
)}
</header>
{meeting.entity_phone && (
<Button
href={`tel:${meeting.entity_phone}`}
text={meeting.entity_phone}
icon="phone"
/>
)}
{meeting.entity_url && (
<Button
href={meeting.entity_url}
text={new URL(meeting.entity_url).host.replace(
'www.',
''
)}
icon="link"
/>
)}
</>
)}

{meeting.feedback_url && (
<Button
href={meeting.feedback_url}
icon="edit"
text={strings.feedback}
/>
)}

{meeting.updated && (
<p>{i18n(strings.updated, { updated: meeting.updated })}</p>
)}
</div>
)}
</div>

{meeting.feedback_url && (
<Button
href={meeting.feedback_url}
icon="edit"
text={strings.feedback}
/>
)}
</div>
<div
css={
Expand Down
7 changes: 1 addition & 6 deletions src/components/TsmlUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,7 @@ export default function TsmlUI({
{!state.ready ? (
<Loading />
) : state.input.meeting && state.input.meeting in state.meetings ? (
<Meeting
feedback_emails={settings.feedback_emails}
mapbox={mapbox}
setState={setState}
state={state}
/>
<Meeting mapbox={mapbox} setState={setState} state={state} />
) : (
<>
{settings.show.title && <Title state={state} />}
Expand Down
27 changes: 16 additions & 11 deletions src/helpers/format-feedback-email.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { Meeting } from '../types';

import { formatArray } from './format-array';
import { formatString as i18n } from './format-string';
import { formatUrl } from './format-url';
import { getQueryString } from './query-string';

// send back a mailto link to a feedback email
export function formatFeedbackEmail(
feedback_emails: TSMLReactConfig['feedback_emails'],
meeting: Meeting,
settings: TSMLReactConfig,
strings: Translation
) {
export function formatFeedbackEmail({
feedback_emails,
edit_url,
name,
settings,
strings,
}: {
feedback_emails: string[];
edit_url?: string;
name?: string;
settings: TSMLReactConfig;
strings: Translation;
}) {
// remove extra query params from meeting URL
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to pass the whole meeting in

const input = getQueryString(settings);
const meetingUrl = formatUrl({ meeting: input.meeting }, settings);
Expand All @@ -24,13 +29,13 @@ export function formatFeedbackEmail(
'-----',
i18n(strings.email_public_url, { url: meetingUrl }),
];
if (meeting.edit_url) {
lines.push(i18n(strings.email_edit_url, { url: meeting.edit_url }));
if (edit_url) {
lines.push(i18n(strings.email_edit_url, { url: edit_url }));
}

// build mailto link
return `mailto:${formatArray(feedback_emails).join()}?${new URLSearchParams({
subject: i18n(strings.email_subject, { name: meeting.name }),
subject: i18n(strings.email_subject, { name }),
body: lines.join('\n'),
})
.toString()
Expand Down
28 changes: 27 additions & 1 deletion src/helpers/load-meeting-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DateTime, WeekdayNumbers } from 'luxon';
import { flattenAndSortIndexes } from './flatten-and-sort-indexes';
import { formatAddress } from './format-address';
import { formatConferenceProvider } from './format-conference-provider';
import { formatFeedbackEmail } from './format-feedback-email';
import { formatSlug } from './format-slug';

import type { JSONData, JSONDataFlat, State, Meeting, Index } from '../types';
Expand Down Expand Up @@ -42,7 +43,10 @@ export function loadMeetingData(
district,
edit_url,
email,
feedback_url,
entity,
entity_location,
entity_phone,
entity_url,
group,
group_notes,
location,
Expand Down Expand Up @@ -72,6 +76,7 @@ export function loadMeetingData(
conference_phone,
conference_phone_notes,
conference_url_notes,
feedback_url,
formatted_address,
regions,
} = meeting;
Expand Down Expand Up @@ -398,6 +403,23 @@ export function loadMeetingData(
.join('\t')
.toLowerCase();

const feedback_emails = meeting.feedback_emails
? meeting.feedback_emails
.split(',')
.map(e => e.trim())
.filter(e => e)
: settings.feedback_emails;

if (!feedback_url && feedback_emails.length) {
feedback_url = formatFeedbackEmail({
feedback_emails,
name,
edit_url,
settings,
strings,
});
}

meetings[slug] = {
address,
approximate,
Expand All @@ -418,6 +440,10 @@ export function loadMeetingData(
district,
edit_url,
email,
entity,
entity_location,
entity_phone,
entity_url,
end,
feedback_url,
formatted_address,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const en: Translation = {
not_found: 'Meeting not found.',
night: 'Night',
phone: 'Phone',
provided_by: 'This listing is provided by:',
region: 'Region',
region_any: 'Anywhere',
remove: 'Remove %filter%',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const es: Translation = {
not_found: 'Reunión no encontrada.',
night: 'Noche',
phone: 'Teléfono',
provided_by: 'Este listado es proporcionado por:',
region: 'Región',
region_any: 'Todos lados',
remove: 'Quitar %filter%',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const fr: Translation = {
not_found: 'Réunion introuvable.',
night: 'Nuit',
phone: 'Téléphone',
provided_by: 'Cette liste est fournie par :',
region: 'Région',
region_any: 'Partout',
remove: 'Supprimer %filter%',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const ja: Translation = {
},
night: '夜',
phone: '電話',
provided_by: 'このリストは以下によって提供されています:',
region: '区域',
region_any: '区域指定無し',
remove: '%filter% を削除',
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/nl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTypesForLanguage } from '@code4recovery/spec';

export const nl = {
export const nl: Translation = {
add_to_calendar: 'Toevoegen aan agenda',
address: 'Addres',
appointment: 'Afspraak',
Expand Down Expand Up @@ -50,6 +50,7 @@ export const nl = {
not_found: 'Meeting niet gevonden.',
night: 'Nacht',
phone: 'Telefoon',
provided_by: 'Deze lijst wordt aangeboden door:',
region: 'Plaats',
region_any: 'Overal',
remove: 'Verwijder %filter%',
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/pt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTypesForLanguage } from '@code4recovery/spec';

export const pt = {
export const pt: Translation = {
add_to_calendar: 'Adicionar ao calendário',
address: 'Endereço / Plataforma',
appointment: 'Marcação',
Expand Down Expand Up @@ -50,6 +50,7 @@ export const pt = {
not_found: 'Reunião não encontrada.',
night: 'Noite',
phone: 'Telefone',
provided_by: 'Este anúncio é fornecido por:',
region: 'Região',
region_any: 'Qualquer Local',
remove: 'Remover %filter%',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const sk: Translation = {
not_found: 'Stretnutia sa nenašli.',
night: 'Noc',
phone: 'Telefón',
provided_by: 'Tento zoznam poskytuje:',
region: 'Kraj',
region_any: 'Kdekoľvek',
remove: 'Zmazať %filter%',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const sv: Translation = {
not_found: 'Hittade inte mötet.',
night: 'Natt',
phone: 'Telefon',
provided_by: 'Denna lista tillhandahålls av:',
region: 'Region',
region_any: 'Överallt',
remove: 'Ta bort %filter%',
Expand Down
6 changes: 6 additions & 0 deletions src/styles/meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export const meetingColumnsCss = css`
}
}

header {
text-align: center;
display: grid;
gap: ${size.gutter / 2}px;
}

h3 {
font-size: var(--font-size);
font-weight: 500;
Expand Down
5 changes: 5 additions & 0 deletions src/types/JSONData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export type JSONData = {
edit_url?: string;
email?: string;
end_time?: string;
entity?: string;
entity_location?: string;
entity_phone?: string;
entity_url?: string;
feedback_emails?: string;
feedback_url?: string;
formatted_address?: string;
group?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/types/Meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export interface Meeting {
edit_url?: string;
email?: string;
end?: DateTime;
entity?: string;
entity_location?: string;
entity_phone?: string;
entity_url?: string;
feedback_emails?: string[];
feedback_url?: string;
formatted_address: string;
group?: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/Translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface Translation {
};
night: string;
phone: string;
provided_by: string;
region: string;
region_any: string;
remove: string;
Expand Down
Loading
Loading