Skip to content

Commit

Permalink
feat(card): added enable link option for card model
Browse files Browse the repository at this point in the history
- this way a user can create a card that simply displays things without taking you anywhere
  useful if you want to have an avatar card or something that is rounded without any links
  • Loading branch information
ichim-david committed Dec 6, 2022
1 parent c74e07f commit 71bf4db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/blocks/Listing/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const setCardModelSchema = (args) => {
const itemModelSchema = schema.properties.itemModel.schema;
itemModelSchema.fieldsets[0].fields = [
...itemModelSchema.fieldsets[0].fields,
'hasLink',
'maxTitle',
'hasDate',
'hasDescription',
Expand All @@ -107,6 +108,11 @@ export const setCardModelSchema = (args) => {
];
itemModelSchema.properties = {
...itemModelSchema.properties,
hasLink: {
title: 'Enable link',
description: 'Link to source content',
type: 'boolean',
},
hasDate: {
title: 'Publication date',
type: 'boolean',
Expand Down
8 changes: 6 additions & 2 deletions src/components/UniversalCard/fragments/CardImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ const getLabel = (props) => {
};

const CardImage = (props) => {
const { item, isEditMode, preview_image } = props;
const { item, isEditMode, preview_image, itemModel } = props;
const label = getLabel(props);

return (
<ConditionalLink className="image" item={item} condition={!isEditMode}>
<ConditionalLink
className="image"
item={item}
condition={!isEditMode && itemModel?.hasLink}
>
{!isEditMode ? (
<PreviewImage
item={item}
Expand Down
4 changes: 2 additions & 2 deletions src/components/UniversalCard/fragments/CardTitle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card as UiCard } from 'semantic-ui-react';
import { ConditionalLink } from '@plone/volto/components';

const CardTitle = (props) => {
const { item, isEditMode } = props;
const { item, isEditMode, itemModel } = props;
const { title, Title } = item;
const t = title || Title;

Expand All @@ -12,7 +12,7 @@ const CardTitle = (props) => {
<ConditionalLink
className="header-link"
item={item}
condition={!isEditMode}
condition={!isEditMode && itemModel?.hasLink}
>
{t}
</ConditionalLink>
Expand Down

0 comments on commit 71bf4db

Please sign in to comment.