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

Fix/toegankelijkheid 15 11 #688

Merged
merged 3 commits into from
Nov 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import { EditFieldProps } from '@/lib/form-widget-helpers/EditFieldProps';
import { useCallback, useEffect, useState } from 'react';
import { FormObjectSelectField } from '@/components/ui/form-object-select-field';
import { useFieldDebounce } from '@/hooks/useFieldDebounce';
import { YesNoSelect, undefinedToTrueOrProp } from '@/lib/form-widget-helpers';


const formSchema = z.object({
pageTitle: z.boolean().optional(),
resourceId: z.string().optional(),
resourceIdRelativePath: z
.string()
Expand Down Expand Up @@ -53,9 +56,11 @@ export default function WidgetResourceDetailGeneral(
const defaults = useCallback(
() => ({
resourceId: props?.resourceId || undefined,
resourceIdRelativePath: props?.resourceIdRelativePath || undefined
resourceIdRelativePath: props?.resourceIdRelativePath || undefined,
pageTitle: undefinedToTrueOrProp(props?.pageTitle),

}),
[props?.resourceId, props?.resourceIdRelativePath]
[props?.resourceId, props?.resourceIdRelativePath, props?.pageTitle]
);

const form = useForm<FormData>({
Expand Down Expand Up @@ -110,6 +115,18 @@ export default function WidgetResourceDetailGeneral(
/>
) : null}

<FormField
control={form.control}
name="pageTitle"
render={({ field }) => (
<FormItem>
<FormLabel>Inzending titel gebruiken als pagina titel</FormLabel>
{YesNoSelect(field, props)}
<FormMessage />
</FormItem>
)}
/>

<Button className="w-fit col-span-full" type="submit">
Opslaan
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-server/public/javascripts/jquery.validate.nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
jQuery.extend(jQuery.validator.messages, {
required: "Dit is een verplicht veld.",
remote: "Controleer dit veld.",
email: "Er is een ongeldig e-mailadres ingevuld.",
email: "Controleer of het e-mailadres het volgende formaat heeft: [email protected].",
url: "Er is een ongeldige url ingevuld.",
date: "Er is een ongeldige datum ingevuld.",
dateISO: "Vul hier een geldige datum in (ISO-formaat).",
Expand Down
4 changes: 2 additions & 2 deletions packages/apostrophe-widgets/share-links/src/share-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function ShareLinks({ title }: Item) {
external
href={'https://twitter.com/intent/tweet?text=' + encodeURIComponent(location.href)}
target="_blank"
title={'Twitter'}
title={'X'}
>
<i className='icon --twitter'></i>
<span className='sr-only'>Twitter</span>
<span className='sr-only'>X</span>
</LinkSocial>

<LinkSocial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export type ResourceDetailMapWidgetProps = BaseProps &
marker?: MarkerProps;
markerIcon?: MarkerIconType;
resourceIdRelativePath?: string;
pageTitle?: boolean;
};
29 changes: 19 additions & 10 deletions packages/resource-detail/src/resource-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import '@utrecht/design-tokens/dist/root.css';
import {
Paragraph, Link, Heading, Heading2, ButtonGroup, ButtonLink,
} from '@utrecht/component-library-react';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Likes, LikeWidgetProps } from '@openstad-headless/likes/src/likes';
import {
Comments,
Expand All @@ -27,7 +27,7 @@ import { ResourceDetailMapWidgetProps } from '@openstad-headless/leaflet-map/src
import { ResourceDetailMap } from '@openstad-headless/leaflet-map/src/resource-detail-map';
import { ShareLinks } from '../../apostrophe-widgets/share-links/src/share-links';
import { Button } from '@utrecht/component-library-react';
import {hasRole} from '../../lib';
import { hasRole } from '../../lib';

type booleanProps = {
[K in
Expand Down Expand Up @@ -59,6 +59,7 @@ export type ResourceDetailWidgetProps = {
resourceId?: string;
resourceIdRelativePath?: string;
backUrlIdRelativePath?: string;
pageTitle?: boolean;
backUrlText?: string;
} & booleanProps & {
likeWidget?: Omit<
Expand All @@ -70,9 +71,9 @@ export type ResourceDetailWidgetProps = {
keyof BaseProps | keyof ProjectSettingProps | 'resourceId'
>;
commentsWidget_multiple?: Omit<
CommentsWidgetProps,
keyof BaseProps | keyof ProjectSettingProps | 'resourceId'
>;
CommentsWidgetProps,
keyof BaseProps | keyof ProjectSettingProps | 'resourceId'
>;
resourceDetailMap?: Omit<
ResourceDetailMapWidgetProps,
keyof BaseProps | keyof ProjectSettingProps | 'resourceId'
Expand Down Expand Up @@ -186,7 +187,7 @@ function ResourceDetail({
if (window.location.hash.includes('#doc')) {
let url = '/' + window.location.hash.split('=')[1] + (window.location.hash.split('=')[2] !== undefined ? '=' + window.location.hash.split('=')[2] : '');

if ( backUrlIdRelativePath ) {
if (backUrlIdRelativePath) {
const backUrlId = getIdFromHash();

if (backUrlId) {
Expand Down Expand Up @@ -254,6 +255,14 @@ function ResourceDetail({
}
};


useEffect(() => {
if (props.pageTitle === true && resource.title !== undefined) {
const current = document.title.includes(' - ') && document.title.split(' - ')[0].length ? ' - '+ document.title.split(' - ')[0] : '';
document.title = resource.title + current;
}
}, [resource]);

return (
<section>
<div
Expand All @@ -276,7 +285,7 @@ function ResourceDetail({
)}

{displayTitle && resource.title && (
<Heading level={1} appearance="utrecht-heading-2" dangerouslySetInnerHTML={{__html: resource.title}}></Heading>
<Heading level={1} appearance="utrecht-heading-2" dangerouslySetInnerHTML={{ __html: resource.title }}></Heading>
)}

{displayModBreak && resource.modBreak && (
Expand All @@ -294,7 +303,7 @@ function ResourceDetail({
{displayUser && resource?.user?.displayName && (
<div>
<Heading level={2} appearance='utrecht-heading-6' className="osc-resource-detail-content-item-title">
Ingediend door
Ingediend door
</Heading>
<span className="osc-resource-detail-content-item-text">
{resource.user.displayName}
Expand Down Expand Up @@ -323,9 +332,9 @@ function ResourceDetail({
)}
</div>
<div className="resource-detail-content">
{displaySummary && <Heading level={2} appearance='utrecht-heading-4' dangerouslySetInnerHTML={{__html: resource.summary}}></Heading>}
{displaySummary && <Heading level={2} appearance='utrecht-heading-4' dangerouslySetInnerHTML={{ __html: resource.summary }}></Heading>}
{displayDescription && (
<Paragraph dangerouslySetInnerHTML={{__html: resource.description}}></Paragraph>
<Paragraph dangerouslySetInnerHTML={{ __html: resource.description }}></Paragraph>
)}
</div>
{displayLocation && resource.location && (
Expand Down
Loading