Created
October 15, 2020 17:55
-
-
Save moxdev/d31423ef19a1cab4a30f57a6832e8537 to your computer and use it in GitHub Desktop.
Revisions
-
brataaaan revised this gist
Feb 14, 2020 . 3 changed files with 62 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import { FaListAlt } from 'react-icons/lib/fa' export default { title: "Category", name: "category", type: "document", icon: FaListAlt, fields: [ { title: "Name", name: "name", type: "string", validation: Rule => [ Rule.required() ] }, { title: "Description", name: "description", description: "Describe, what users can expect to learn from completing this category.", type: "string", validation: Rule => [ Rule.required() ] }, ], //... } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default [ } ], value: parameters => ({ category: {_type: 'reference', _ref: parameters.categoryId} //if i put here the categoryID manually for testing, the templating works (of course only manually for one specific category). So it has to be the parameter-passing from deskStructure to template. }) }) ] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ export default { title: "Lesson", name: "lesson", type: "document", fields: [ { title: "Belongs to Category", name: "category", type: "reference", to: [{type: "category"}], validation: Rule => [ Rule.required() ] }, { title: "Name", name: "name", type: "string", validation: Rule => [ Rule.required() ] }, { title: "Description", name: "description", type: "text", validation: Rule => [ Rule.required() ] }, ], //... } -
brataaaan revised this gist
Feb 14, 2020 . No changes.There are no files selected for viewing
-
brataaaan created this gist
Feb 14, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ import S from "@sanity/desk-tool/structure-builder" import { FaFileText, FaEdit, FaComment, FaPlayCircle, FaQuestionCircle, FaCheckCircle } from 'react-icons/lib/fa' export default () => S.list() .title("App") .items([ S.listItem() .title("Content") .icon(FaFileText) .child( S.documentList() .id('categories') .title('Categories') .schemaType('category') .filter('_type == "category" && !(_id in path("drafts.**"))') .defaultOrdering([{field: 'position', direction: 'asc'}]) .menuItems([ S.orderingMenuItem({title: 'Position ascending', by: [{ field: "position", direction: "asc" }]}), S.orderingMenuItem({title: 'Position descending', by: [{ field: "position", direction: "desc" }]}) ]) .child(categoryId => S.documentList() .id('lessons') .title('Lessons of Category') .schemaType('lesson') .filter('_type == "lesson" && category._ref == $categoryId && !(_id in path("drafts.**"))') .params({types: ['lesson-for-category'], categoryId}) //not this works: .initialValueTemplates([ S.initialValueTemplateItem('lesson-for-category', {categoryId: categoryId}) ]) .defaultOrdering([{field: 'position', direction: 'asc'}]) .menuItems([ //nor this: S.menuItemsFromInitialValueTemplateItems([ S.initialValueTemplateItem('lesson-for-category', {categoryId: categoryId}), ]), S.menuItem() .title('edit category') .icon(FaEdit) .intent({ type: "edit", params: { type: "category", id: categoryId } }), S.orderingMenuItem({title: 'Position ascending', by: [{ field: "position", direction: "asc" }]}), S.orderingMenuItem({title: 'Position descending', by: [{ field: "position", direction: "desc" }]}) ]) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import T from '@sanity/base/initial-value-template-builder' export default [ ...T.defaults(), T.template({ id: 'lesson-for-category', title: 'Lesson for Category', description: 'Creates a lesson for selected category', schemaType: 'lesson', parameters: [ { name: 'categoryId', type: 'string' } ], value: parameters => ({ category: {_type: 'reference', _ref: parameters.categoryId} }) }) ] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ { //... "parts": [ { "name": "part:@sanity/base/schema", "path": "./schemas/schema.js" }, { "name": "part:@sanity/desk-tool/structure", "path": "./deskStructure.js" }, { "name": "part:@sanity/base/initial-value-templates", "path": "./initialValueTemplates.js" } ] }