0.2.7 • Published 2 years ago

@techlution/form-builder v0.2.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Techlution Form Builder

npm

A Form Builder service Powered by Techlution Version: Alpha Snyk Vulnerabilities for npm package

node-current (scoped) npm peer dependency version (scoped)

Install

$ npm install @techlution/form-builder

Setup

At your system entry point, you will have to initiate and provide your API key.

require('@techlution/form-builder').config({
    apiKey: '<your api key>',
    env: 'dev|stag|prod'
})

Quick Start Guide

Form

const { Form } = require('@techlution/form-builder');

// create a Form instance
const form = new Form({
     name: '<form name>', 
     description: '<form description>', 
});

Section

// add a Section with default behaviour
const section = await form.addSection();

// or create a standalone Section and add it to the form
const { Section } = require('@techlution/form-builder');
const section2 = new Section();
await form.addSection(section2);

Question

// finally, add a Question to the Section
const question = await section.addQuestion({
    displayText: 'Testing Question',
    key: 'test',
});

// or, similar to Section, create a Question and add it to the section
const { Question } = require('@techlution/form-builder');
const question2 = new Question({
   displayText: 'Testing Question',
   key: 'test',
});
await section.addQuestion(question2);

// how about a list of questions?
const Questions = await section.addQuestions([
    {
        displayText: 'Testing Question',
        key: 'test',
    },
    new Question({
        displayText: 'Testing Question',
        key: 'test',
    }),
]);

Form Usage

// start a form filling session
const { Session } = require('@techlution/form-builder');

const session = await Session.start({ Form: form.id });

// then get the current section and questions
const section = await session.getSection();
const questions = section.Questions;

// skipping a section
const nextSection = await session.getNextSection();

// go back to the previous section
const previousSection = await nextSection.getPreviousSection();
section.id === previousSection.id // true

// submit answer
const answers = { answer1: true }
await session.submit(answers);

// retrieve all answers
const { Values } = session;

Deletion

await Question.delete(id);
await questionInstance.delete();

await Section.delete(id);
await sectionInstance.delete();

await Form.delete(id);
await formInstance.delete();

await Session.delete(id);
await sessionInstance.delete();

Road Map

  • Create a Form
  • Create Sections in a Form
  • Create Questions in a Section
  • Create a Form filling Session
  • Create a Section in a Form
  • Resume a Section
  • Skip a Section
  • Go back to Previous Section
  • Submit Answers
  • Finish the Form
  • Export the values
  • Delete Resources
  • Create Question Template
  • Create Session Template
0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.1.0

3 years ago

0.0.20

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.3

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago