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

feat(examples): forms #2604

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Conversation

agherasie
Copy link
Contributor

@agherasie agherasie commented Jul 18, 2024

As part of the student contributor program, I attempted to create a new example realm that allows the creation and submission of forms on gno !

Features

  • Form Creation: Create new forms with specified titles, descriptions, and fields.
    CreateForm(...)
  • Form Submission: Submit answers to forms.
    SubmitForm(...)
  • Form Retrieval: Retrieve existing forms and their submissions.
    GetForms(...), GetFormByID(...), GetAnswer(...)
  • Form Deadline: Set a precise time range during which a form can be interacted with.

Field Types

The system supports the following field types:

type example
string {"label": "Name", "fieldType": "string", "required": true}
number {"label": "Age", "fieldType": "number", "required": true}
boolean {"label": "Is Student?", "fieldType": "boolean", "required": false}
choice `{"label": "Favorite Food", "fieldType": "[Pizza
multi-choice `{"label": "Hobbies", "fieldType": "{Reading

Demo

The external repo where the initial development took place and where you can find the frontend is here.

The web app itself is hosted here

And the most recent test4 version of the contract is forms2


Screenshots :

gnoweb Render() image
a form response in the web interface image
creating a form in the web interface image

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Jul 18, 2024
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.15%. Comparing base (25f1c92) to head (39c8bcb).
Report is 78 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2604      +/-   ##
==========================================
- Coverage   60.15%   60.15%   -0.01%     
==========================================
  Files         561      561              
  Lines       74999    74999              
==========================================
- Hits        45117    45113       -4     
- Misses      26505    26507       +2     
- Partials     3377     3379       +2     
Flag Coverage Δ
contribs/gnodev 61.40% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
gno.land 64.75% <ø> (ø)
gnovm 64.13% <ø> (ø)
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (-0.36%) ⬇️
tm2 62.03% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leohhhn leohhhn marked this pull request as ready for review July 21, 2024 00:07
@leohhhn leohhhn requested review from a team as code owners July 21, 2024 00:07
@leohhhn leohhhn requested review from jaekwon and gfanton and removed request for a team July 21, 2024 00:07
Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! I've left some comments, try to address them 🙏

examples/gno.land/p/demo/forms/forms.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/create.gno Show resolved Hide resolved
examples/gno.land/p/demo/forms/create_test.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Show resolved Hide resolved
examples/gno.land/p/demo/forms/submit_test.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/submit_test.gno Outdated Show resolved Hide resolved
Copy link
Member

@gfanton gfanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm (after formatting the markdown table)

examples/gno.land/p/demo/forms/README.md Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/create.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/forms/forms.gno Outdated Show resolved Hide resolved
@Kouteki Kouteki added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 3, 2024
@thehowl
Copy link
Member

thehowl commented Oct 4, 2024

@leohhhn @gfanton do you think this can be merged or do you want another review?

@jefft0 jefft0 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Oct 4, 2024
@jefft0
Copy link
Contributor

jefft0 commented Oct 4, 2024

Removed the "review team" label because this is already reviewed by core devs.

Comment on lines +18 to +47
type times struct {
openAt *time.Time
closeAt *time.Time
}

func parseDates(openAt string, closeAt string) (times, error) {
var openAtTime, closeAtTime *time.Time

const dateFormat = "2006-01-02T15:04:05Z"

// Parse openAt if it's not empty
if openAt != "" {
res, err := time.Parse(dateFormat, openAt)
if err != nil {
return times{}, errInvalidDate
}
openAtTime = &res
}

// Parse closeAt if it's not empty
if closeAt != "" {
res, err := time.Parse(dateFormat, closeAt)
if err != nil {
return times{}, errInvalidDate
}
closeAtTime = &res
}

return times{openAtTime, closeAtTime}, nil
}
Copy link
Contributor

@ltzmaxwell ltzmaxwell Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. this(times) seems to be a redundant design;
  2. using time.Time directly (without a pointer) is perfectly fine.
    @leohhhn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: In Review
Status: In Review
Development

Successfully merging this pull request may close these issues.

7 participants