Skip to content

Commit

Permalink
feat(studio): add singleGroupPage page (#44)
Browse files Browse the repository at this point in the history
### **User description**
closes: #22


___

### **PR Type**
Enhancement


___

### **Description**
- Added `singleGroupPage` document type with fields and preview configuration.
- Included `singleGroupPage` in plugin configuration and schema types.
- Defined `contactPersons` and `gallery` groups.
- Defined `galleryField` with validation rules.
- Fixed a typo in the comment of `news-article.ts`.


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement
</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>index.ts</strong><dd><code>Include `singleGroupPage` in plugin configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/plugins/index.ts
<li>Added import and inclusion of <code>singleGroupPage</code> in plugin configuration.<br> <br>


</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-9dd45aa1302024e77ddf2cd3b3b0aebe803247d15997cb5b9424788204fc7c48">+3/-0</a>&nbsp; &nbsp; &nbsp; </td>
</tr>                    

<tr>
  <td>
    <details>
      <summary><strong>index.ts</strong><dd><code>Add `singleGroupPage` to schema types</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/schemas/index.ts
- Added import and inclusion of `singleGroupPage` in schema types.



</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-0b99cc8331c92bfa2c0470d04d7a359ab75283efa85f9fc1d5bf716b9e35c60c">+2/-0</a>&nbsp; &nbsp; &nbsp; </td>
</tr>                    

<tr>
  <td>
    <details>
      <summary><strong>_groups.ts</strong><dd><code>Define `contactPersons` and `gallery` groups</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/schemas/single-pages/single-group/_groups.ts
- Added definitions for `contactPersons` and `gallery` groups.



</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-054a38a6f7aefbbc81f3633a91cad281dd251f0ecbd8a2a25aae033b6983f905">+9/-0</a>&nbsp; &nbsp; &nbsp; </td>
</tr>                    

<tr>
  <td>
    <details>
      <summary><strong>groups.ts</strong><dd><code>Define `galleryField` with validation rules</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/schemas/single-pages/single-group/groups.ts
- Defined `galleryField` with validation rules.



</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-a1f1fcc8705b7623cd5313e3f662fcb5b1f2a6fcbe76df25d7aab9e4dccf8df2">+28/-0</a>&nbsp; &nbsp; </td>
</tr>                    

<tr>
  <td>
    <details>
      <summary><strong>index.ts</strong><dd><code>Add `singleGroupPage` document type</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/schemas/single-pages/single-group/index.ts
<li>Added <code>singleGroupPage</code> document type with fields and preview <br>configuration.<br>


</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-3654a0c465da4010c6435cd25ca080c45f291c81629d996561efb35c049dd9f5">+44/-0</a>&nbsp; &nbsp; </td>
</tr>                    
</table></td></tr><tr><td><strong>Miscellaneous
</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>news-article.ts</strong><dd><code>Fix typo in comment</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

apps/studio/schemas/single-pages/news-article.ts
- Fixed a typo in the comment.



</details>
    

  </td>
  <td><a href="https://github.com/mheob/tsg-irlich-web/pull/44/files#diff-896cf5ad41d24c12ba8e91e3a20f1a0ca3ac5119a7453491cd53ad906147d5f9">+1/-1</a>&nbsp; &nbsp; &nbsp; </td>
</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**:
>Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
  • Loading branch information
mheob committed Jun 22, 2024
1 parent a0488d5 commit a18fcb7
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/studio/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import membershipPage from '@/schemas/single-pages/membership';
import newsArticlePage from '@/schemas/single-pages/news-article';
import newOverviewPage from '@/schemas/single-pages/news-overview';
import privacyPage from '@/schemas/single-pages/privacy';
import singleGroupPage from '@/schemas/single-pages/single-group';
import siteSettings from '@/schemas/singletons/site-settings';

import { assistWithPresets } from './assist';
Expand All @@ -30,6 +31,7 @@ export function getPlugins() {
newsArticlePage,
newOverviewPage,
groupsPage,
singleGroupPage,
privacyPage,
imprintPage,
siteSettings,
Expand All @@ -44,6 +46,7 @@ export function getPlugins() {
newsArticlePage.name,
newOverviewPage.name,
groupsPage.name,
singleGroupPage.name,
privacyPage.name,
imprintPage.name,
siteSettings.name,
Expand Down
2 changes: 2 additions & 0 deletions apps/studio/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import membershipPage from './single-pages/membership';
import newsArticlePage from './single-pages/news-article';
import newsOverviewPage from './single-pages/news-overview';
import privacyPage from './single-pages/privacy';
import singleGroupPage from './single-pages/single-group';
import siteSettings from './singletons/site-settings';

export const schemaTypes = [
Expand Down Expand Up @@ -68,4 +69,5 @@ export const schemaTypes = [
newsArticlePage,
newsOverviewPage,
privacyPage,
singleGroupPage,
];
2 changes: 1 addition & 1 deletion apps/studio/schemas/single-pages/news-article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const newsArticlePage = defineType({
icon: RiBookletLine,
groups: [general, content],
fields: [
// ?: the "slug" and `meta` comes from the news article itself; this page os rather the layout
// ?: the "slug" and `meta` comes from the news article itself; this page is rather the layout

// general
...defaultPageFields,
Expand Down
9 changes: 9 additions & 0 deletions apps/studio/schemas/single-pages/single-group/_groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const contactPersons = {
title: 'ContactPersons',
name: 'contactPersons',
};

export const gallery = {
title: 'Galerie',
name: 'gallery',
};
28 changes: 28 additions & 0 deletions apps/studio/schemas/single-pages/single-group/groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { RiLinksLine } from 'react-icons/ri';
import { defineField } from 'sanity';

import { getDefaultPageFieldsWithGroup } from '@/shared/fields/general';
import { getMaxLengthRule, getMinLengthRule } from '@/shared/validation-rules';

export const galleryField = defineField({
title: 'Galerie',
name: 'gallerySection',
type: 'object',
icon: RiLinksLine,
group: 'gallery',
fields: [
...getDefaultPageFieldsWithGroup(),

defineField({
title: 'Bilder',
name: 'venues',
type: 'array',
of: [{ type: 'extendedImage' }],
description: 'Diese gewählten Bilder werden in der gewünschten Reihenfolge angezeigt.',
validation: rule => [
getMinLengthRule(rule, 2, 'Es muss mindestens ein Bild ausgewählt werden.'),
getMaxLengthRule(rule, 4, 'Es dürfen maximal vier Bilder ausgewählt werden.'),
],
}),
],
});
44 changes: 44 additions & 0 deletions apps/studio/schemas/single-pages/single-group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// cSpell:words angebot
import { RiBookletLine, RiLinksLine } from 'react-icons/ri';
import { defineField, defineType } from 'sanity';

import { content, general, meta } from '@/shared/field-groups';
import { defaultPageFields } from '@/shared/fields/general';
import { metaField } from '@/shared/fields/meta';
import { contactPersonsSectionField } from '@/shared/sections/contact-persons';

import { contactPersons, gallery } from './_groups';
import { galleryField } from './groups';

const singleGroupPage = defineType({
title: 'Einzel-Gruppe',
name: 'singleGroupPage',
type: 'document',
icon: RiBookletLine,
groups: [general, meta, content],
fields: [
// ?: the "slug" and `meta` comes from the news article itself; this page is rather the layout

// general
...defaultPageFields,

// meta
metaField,

// content
defineField({
title: 'Inhalte',
name: 'content',
type: 'object',
icon: RiLinksLine,
group: 'content',
groups: [gallery, contactPersons],
fields: [galleryField, contactPersonsSectionField],
}),
],
preview: {
prepare: () => ({ title: 'Einzel-Gruppe' }),
},
});

export default singleGroupPage;

0 comments on commit a18fcb7

Please sign in to comment.