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

First version of support for form:Scope and form:Listing #60

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cecemel
Copy link
Member

@cecemel cecemel commented Dec 4, 2024

Description

The service didn't support form:Scope and form:Listing. This a first attempt at adding this support. I felt a bit like an elephant while implementing as I don't have a lot of ts experience.

Status

  • It still doesn't support the full form:Scope resource, i.e. form:constraint path is not supported. When fetching data, that won't be too problematic, deleting data however, will, because too much data risk to be deleted.
    So I am reluctant to merge this PR in current state.
  • There's bit of the codes I still need to understand, like why generators are fetched when loading the form.

How to test

  • Check if old forms still work with this PR.

sample data

@prefix ext: <http://mu.semte.ch/vocabularies/ext/> .

<http://ember-submission-form-fields/source-node> a ext:Book;
  ext:title "Book 1";
  ext:chapter <http://chapter/1>;
  ext:chapter <http://chapter/2>.

<http://chapter/1> a ext:BookChapter;
  ext:title "Chapter 1".

<http://chapter/2> a ext:BookChapter;
  ext:title "Chapter 2".

<http://review/1> a ext:Review;
  ext:reviews <http://ember-submission-form-fields/source-node>;
  ext:comment "What a great book!".

<http://review/2> a ext:Review;
  ext:reviews <http://ember-submission-form-fields/source-node>;
  ext:comment "What a terrible book...".

sample form

@prefix form: <http://lblod.data.gift/vocabularies/forms/> .
@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix mu: <http://mu.semte.ch/vocabularies/core/> .
@prefix displayTypes: <http://lblod.data.gift/display-types/> .
@prefix ext: <http://mu.semte.ch/vocabularies/ext/> .
@prefix schema: <http://schema.org/>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix nie: <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#>.

##########################################################
# form
##########################################################
ext:form a form:Form, form:TopLevelForm ;
    form:includes ext:reviewsL;
    form:includes ext:chaptersL;
    form:includes ext:bookTitleF.

##########################################################
#  property-group
##########################################################
ext:mainPg a form:PropertyGroup;
    sh:description "[PROPERTY GROUP] book title";
    sh:name "[PROPERTY GROUP] book title" ;
    sh:order 1 .

##########################################################
#  listing-scope: chapter
##########################################################
ext:chapterListingS a form:Scope;
  sh:path ext:chapter.

##########################################################
#  Listing: chapter
##########################################################
ext:chaptersL a form:Listing;
  sh:name "[LISTING] Chapters listing";
  form:each ext:chapterFormItem;
  form:scope ext:chapterListingS;
  form:createGenerator ext:chapterGenerator;
  form:canRemove true;
  form:canAdd true;
  form:canChangeOrder true;
  form:addLabel "Add chapter";
  sh:group ext:mainPg;
  sh:order 2 .

##########################################################
#  Subform: chapter
##########################################################
ext:chapterFormItem a form:SubForm;
   sh:name "[SUBFORM] chapter" ;
   form:removeLabel "Remove chapter";
   form:includes ext:chapterTitleF;
   form:hasFieldGroup ext:mainPg.

##########################################################
#  listing-scope: review
##########################################################
ext:reviewListingS a form:Scope;
  sh:path ( [ sh:inversePath ext:reviews ] ).

##########################################################
#  Listing: review
##########################################################
ext:reviewsL a form:Listing;
  sh:name "[LISTING] Reviews listing";
  form:each ext:reviewSubform;
  form:scope ext:reviewListingS;
  form:createGenerator ext:reviewGenerator;
  sh:group ext:mainPg;
  form:canAdd false;
  form:canRemove true;
  sh:order 3 .

##########################################################
#  Subform: review
##########################################################
ext:reviewSubform a form:SubForm;
   sh:name "[SUBFORM] Review" ;
   form:removeLabel "Remove review";
   form:includes ext:reviewCommentF;
   form:hasFieldGroup ext:mainPg.

##########################################################
# Field: book title
##########################################################
ext:bookTitleF a form:Field ;
    sh:name "Book title" ;
    sh:order 1 ;
    sh:path ext:title ;
    form:displayType displayTypes:defaultInput ;
    sh:group ext:mainPg .

##########################################################
# Field: chapter title
##########################################################
ext:chapterTitleF a form:Field ;
    sh:name "Chapter title" ;
    sh:order 1 ;
    sh:path ext:title ;
    form:displayType displayTypes:defaultInput ;
    sh:group ext:mainPg .

##########################################################
# Field: review
##########################################################
ext:reviewCommentF a form:Field ;
    sh:name "Review comment" ;
    sh:order 1 ;
    sh:path ext:comment ;
    form:displayType displayTypes:defaultInput ;
    sh:group ext:mainPg .

##########################################################
#  Generator: Chapter
##########################################################
ext:chapterGenerator a form:Generator;
  form:prototype [
    form:shape [
      a ext:BookChapter ;
      ext:title ""
    ]
  ];
  form:dataGenerator form:addMuUuid.

##########################################################
#  Generator: Review
##########################################################
ext:reviewGenerator a form:Generator;
  form:prototype [
    form:shape [
      a ext:Review ;
      ext:comment ""
    ]
  ];
  form:dataGenerator form:addMuUuid.

Links to other PR's

@cecemel cecemel marked this pull request as draft December 4, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant