From dec4036dafcc7b7f03f8ffe2402e63ff3007e76a Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Wed, 21 Aug 2024 10:18:43 +0200 Subject: [PATCH 1/2] feat(salaryAndBenefits): schema option to toggle salary calculator --- studio/schemas/deskStructure.ts | 16 ++++----- studio/schemas/documents/salaryAndBenefits.ts | 34 ++++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index ed7e5daca..023bad74c 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -14,7 +14,7 @@ import { soMeLinksID } from "./documents/socialMediaProfiles"; import { siteSettingsID } from "./documents/siteSettings"; import { postId } from "./documents/post"; import { legalDocumentID } from "./documents/legalDocuments"; -import { salaryAndBenefitsId } from './documents/salaryAndBenefits'; +import { salaryAndBenefitsId } from "./documents/salaryAndBenefits"; export default (S: StructureBuilder) => S.list() @@ -27,7 +27,7 @@ export default (S: StructureBuilder) => S.document() .schemaType(siteSettingsID) .documentId(siteSettingsID) - .title("Site Settings") + .title("Site Settings"), ), S.listItem() .title("Legal Documents") @@ -44,7 +44,7 @@ export default (S: StructureBuilder) => S.document() .schemaType("navigationManager") .documentId("navigationManager") - .title("Navigation Manager") + .title("Navigation Manager"), ), S.listItem() .title("Pages") @@ -64,21 +64,21 @@ export default (S: StructureBuilder) => S.document() .schemaType(blogId) .documentId(blogId) - .title("Blog Overview & Settings") + .title("Blog Overview & Settings"), ), S.listItem() .title("Posts") .icon(ComposeIcon) .child(S.documentTypeList(postId).title("Posts")), - ]) + ]), ), S.listItem() .title("Salary and Benefits") .icon(HeartIcon) .child( S.document() - .schemaType(salaryAndBenefitsId) - .documentId(salaryAndBenefitsId) - .title("Salary and Benefits") + .schemaType(salaryAndBenefitsId._root) + .documentId(salaryAndBenefitsId._root) + .title("Salary and Benefits"), ), ]); diff --git a/studio/schemas/documents/salaryAndBenefits.ts b/studio/schemas/documents/salaryAndBenefits.ts index bcfeb4ecc..8c3bb4b7c 100644 --- a/studio/schemas/documents/salaryAndBenefits.ts +++ b/studio/schemas/documents/salaryAndBenefits.ts @@ -1,27 +1,37 @@ -import { defineField, defineType } from 'sanity'; -import { pageSlug } from '../schemaTypes/slug'; -import seo from '../objects/seo'; -import { title } from '../fields/text'; -import { benefitId } from './benefit'; +import { defineField, defineType } from "sanity"; +import { pageSlug } from "../schemaTypes/slug"; +import seo from "../objects/seo"; +import { title } from "../fields/text"; +import { benefitId } from "./benefit"; -export const salaryAndBenefitsId = "salaryAndBenefits"; +export const salaryAndBenefitsId = { + _root: "salaryAndBenefits", + showSalaryCalculator: "showSalaryCalculator", +}; const salaryAndBenefits = defineType({ - name: salaryAndBenefitsId, + name: salaryAndBenefitsId._root, type: "document", title: "Salary and Benefits", fields: [ title, pageSlug, seo, - defineField(({ + defineField({ + name: salaryAndBenefitsId.showSalaryCalculator, + title: "Show Salary Calculator", + description: "Should the salary calculator be visible on the page?", + type: "boolean", + initialValue: true, + }), + defineField({ name: "benefits", title: "Benefits", description: "Manage benefits for the salary and benefits page", type: "array", - of: [{ type: benefitId }] - })) - ] + of: [{ type: benefitId }], + }), + ], }); -export default salaryAndBenefits; \ No newline at end of file +export default salaryAndBenefits; From 79e2765ce8ed818c7ffaf44300718e96c211a3a5 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Wed, 21 Aug 2024 13:08:57 +0200 Subject: [PATCH 2/2] refactor(salaryAndBenefits): revert id object --- studio/schemas/deskStructure.ts | 4 ++-- studio/schemas/documents/salaryAndBenefits.ts | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 023bad74c..cd2b9ae34 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -77,8 +77,8 @@ export default (S: StructureBuilder) => .icon(HeartIcon) .child( S.document() - .schemaType(salaryAndBenefitsId._root) - .documentId(salaryAndBenefitsId._root) + .schemaType(salaryAndBenefitsId) + .documentId(salaryAndBenefitsId) .title("Salary and Benefits"), ), ]); diff --git a/studio/schemas/documents/salaryAndBenefits.ts b/studio/schemas/documents/salaryAndBenefits.ts index 8c3bb4b7c..483d3d761 100644 --- a/studio/schemas/documents/salaryAndBenefits.ts +++ b/studio/schemas/documents/salaryAndBenefits.ts @@ -4,13 +4,10 @@ import seo from "../objects/seo"; import { title } from "../fields/text"; import { benefitId } from "./benefit"; -export const salaryAndBenefitsId = { - _root: "salaryAndBenefits", - showSalaryCalculator: "showSalaryCalculator", -}; +export const salaryAndBenefitsId = "salaryAndBenefits"; const salaryAndBenefits = defineType({ - name: salaryAndBenefitsId._root, + name: salaryAndBenefitsId, type: "document", title: "Salary and Benefits", fields: [ @@ -18,7 +15,7 @@ const salaryAndBenefits = defineType({ pageSlug, seo, defineField({ - name: salaryAndBenefitsId.showSalaryCalculator, + name: "showSalaryCalculator", title: "Show Salary Calculator", description: "Should the salary calculator be visible on the page?", type: "boolean",