Skip to content

Commit 3010d02

Browse files
Merge pull request #105 from oneblink/ON-6760
WIP: ON-6760 # Added publish date props and removed isPublished
2 parents 5051407 + 499ca9e commit 3010d02

File tree

7 files changed

+56
-51
lines changed

7 files changed

+56
-51
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- Publish start and end date
78
- Added tags for form def
89
- Types and validation for placeholderValue on form elements
910
- added `overrideLock` parameter to update and delete form functions

docs/forms.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ forms.getForm(formId, injectForms).then((form) => {
266266
"formsAppEnvironmentId": 1,
267267
"elements": [],
268268
"isAuthenticated": false,
269-
"isPublished": true,
270269
"submissionEvents": []
271270
}
272271
```
@@ -322,7 +321,6 @@ forms
322321
"formsAppEnvironmentId": 1,
323322
"elements": [],
324323
"isAuthenticated": false,
325-
"isPublished": true,
326324
"submissionEvents": [],
327325
"postSubmissionAction": "FORMS_LIBRARY",
328326
"isInfoPage": false
@@ -410,7 +408,6 @@ forms
410408
formsAppEnvironmentId: 1,
411409
elements: [],
412410
isAuthenticated: false,
413-
isPublished: true,
414411
submissionEvents: [],
415412
postSubmissionAction: 'FORMS_LIBRARY',
416413
formsAppIds: [1, 2, 3],
@@ -435,7 +432,6 @@ forms
435432
| `elements` | Yes | [`FormElement`](./form-elements/README.md)`[]` | All elements contained within the form itself. |
436433
| `isAuthenticated` | Yes | `boolean` | Whether or not the form can only be viewed by an Authenticated user. |
437434
| `isMultiPage` | Yes | `boolean` | Whether or not the form contains multiple pages. |
438-
| `isPublished` | Yes | `boolean` | Whether or not the form is visible within the Forms Apps it's included in. |
439435
| `submissionEvents` | No | `SubmissionEvent[]` | Events that occur/trigger on a valid successful submission. |
440436
| `submissionEvents[].type` | Yes | `'CALLBACK' | 'PDF' | 'SPOTTO' | 'ONEBLINK_API'` | The type of submission event. |
441437
| `submissionEvents[].configuration` | Yes | `mixed` | Configuration specific to the type of submission event. |
@@ -451,6 +447,8 @@ forms
451447
| `redirectUrl` | No | `string` | The URL the form will redirect to if configured to do so by the `postSubmissionActions`. |
452448
| `isInfoPage` | Yes | `boolean` | Whether or not the Form is an Info Page. |
453449
| `tags` | No | `string[]` | A list of tags used to categorise or describe the form. |
450+
| `publishStartDate` | No | `string` | The date and time (in ISO format) a form becomes available. |
451+
| `publishEndDate` | No | `string` | The date and time (in ISO format) a form becomes unavailable. |
454452

455453
### Result
456454

@@ -463,7 +461,6 @@ forms
463461
"formsAppEnvironmentId": 1,
464462
"elements": [],
465463
"isAuthenticated": false,
466-
"isPublished": true,
467464
"submissionEvents": [],
468465
"postSubmissionAction": "FORMS_LIBRARY",
469466
"formsAppIds": [1, 2, 3],
@@ -488,7 +485,6 @@ forms
488485
formsAppEnvironmentId: 1,
489486
elements: [],
490487
isAuthenticated: false,
491-
isPublished: true,
492488
submissionEvents: [],
493489
postSubmissionAction: 'FORMS_LIBRARY',
494490
formsAppIds: [1, 2, 3],
@@ -523,7 +519,6 @@ forms
523519
| `elements` | Yes | [`FormElement`](./form-elements/README.md)`[]` | All elements contained within the form itself. |
524520
| `isAuthenticated` | Yes | `boolean` | Whether or not the form can only be viewed by an Authenticated user. |
525521
| `isMultiPage` | Yes | `boolean` | Whether or not the form contains multiple pages. |
526-
| `isPublished` | Yes | `boolean` | Whether or not the form is visible within the Forms Apps it's included in. |
527522
| `submissionEvents` | No | `SubmissionEvent[]` | Events that occur/trigger on a valid successful submission. |
528523
| `submissionEvents[].type` | Yes | `'CALLBACK' | 'PDF' | 'SPOTTO' | 'ONEBLINK_API'` | The type of submission event. |
529524
| `submissionEvents[].configuration` | Yes | `mixed` | Configuration specific to the type of submission event. |
@@ -539,6 +534,8 @@ forms
539534
| `redirectUrl` | No | `string` | The URL the form will redirect to if configured to do so by the `postSubmissionActions`. |
540535
| `isInfoPage` | Yes | `boolean` | Whether or not the Form is an Info Page. |
541536
| `tags` | No | `string[]` | A list of tags used to categorise or describe the form. |
537+
| `publishStartDate` | No | `string` | The date and time (in ISO format) a form becomes available. |
538+
| `publishEndDate` | No | `string` | The date and time (in ISO format) a form becomes unavailable. |
542539

543540
### Result
544541

@@ -551,7 +548,6 @@ forms
551548
"formsAppEnvironmentId": 1,
552549
"elements": [],
553550
"isAuthenticated": false,
554-
"isPublished": true,
555551
"submissionEvents": [],
556552
"postSubmissionAction": "FORMS_LIBRARY",
557553
"formsAppIds": [1, 2, 3],
@@ -598,7 +594,6 @@ const form = {
598594
organisationId: '0101010101010',
599595
elements: [],
600596
isAuthenticated: false,
601-
isPublished: true,
602597
submissionEvents: [],
603598
postSubmissionAction: 'FORMS_LIBRARY',
604599
formsAppIds: [1, 2, 3],
@@ -621,7 +616,6 @@ return validatedForm
621616
| `elements` | Yes | [`FormElement`](./form-elements/README.md)`[]` | All elements contained within the form itself. |
622617
| `isAuthenticated` | Yes | `boolean` | Whether or not the form can only be viewed by an Authenticated user. |
623618
| `isMultiPage` | Yes | `boolean` | Whether or not the form contains multiple pages. |
624-
| `isPublished` | Yes | `boolean` | Whether or not the form is visible within the Forms Apps it's included in. |
625619
| `submissionEvents` | No | `SubmissionEvent[]` | Events that occur/trigger on a valid successful submission. |
626620
| `submissionEvents[].type` | Yes | `'CALLBACK' | 'PDF' | 'SPOTTO' | 'ONEBLINK_API'` | The type of submission event. |
627621
| `submissionEvents[].configuration` | Yes | `mixed` | Configuration specific to the type of submission event. |
@@ -637,6 +631,8 @@ return validatedForm
637631
| `redirectUrl` | No | `string` | The URL the form will redirect to if configured to do so by the `postSubmissionActions`. |
638632
| `isInfoPage` | Yes | `boolean` | Whether or not the Form is an Info Page. |
639633
| `tags` | No | `string[]` | A list of tags used to categorise or describe the form. |
634+
| `publishStartDate` | No | `string` | The date and time (in ISO format) a form becomes available. |
635+
| `publishEndDate` | No | `string` | The date and time (in ISO format) a form becomes unavailable. |
640636

641637
### Result
642638

@@ -649,7 +645,6 @@ return validatedForm
649645
"formsAppEnvironmentId": 1,
650646
"elements": [],
651647
"isAuthenticated": false,
652-
"isPublished": true,
653648
"submissionEvents": [],
654649
"postSubmissionAction": "FORMS_LIBRARY",
655650
"formsAppIds": [1, 2, 3],

flow-typed/form-types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ declare type Form = {
435435
elements: Array<FormElement>,
436436
isAuthenticated: boolean,
437437
isMultiPage: boolean,
438-
isPublished: boolean,
438+
publishStartDate: ?string,
439+
publishEndDate: ?string,
439440
isInfoPage: boolean,
440441
postSubmissionAction: FormPostSubmissionAction,
441442
redirectUrl?: ?string,

flow-typed/types.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ declare type FormsSearchResult = {
4444

4545
declare type FormsSearchOptions = {
4646
isAuthenticated?: mixed,
47-
isPublished?: mixed,
4847
name?: mixed,
4948
}
5049

lib/forms-schema.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ module.exports = {
791791
}),
792792
isMultiPage: Joi.bool().default(false).label('Form Is Multi Page'),
793793
isAuthenticated: Joi.bool().default(false).label('Form Authentication'),
794-
isPublished: Joi.bool().default(false).label('Form Publication'),
794+
publishStartDate: Joi.string().isoDate().label('Publish Start Date'),
795+
publishEndDate: Joi.string().isoDate().label('Publish End Date'),
795796
submissionEvents: Joi.array()
796797
.allow(null)
797798
.label('Submission Events')

lib/forms-validation.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ function validateJoiSchema /* :: <T> */(
2222
}
2323

2424
function validateWithFormSchema(form /* : mixed */) /* : Form */ {
25-
const validatedForm = validateJoiSchema(form, formSchema, {
25+
const validatedForm /* : Form */ = validateJoiSchema(form, formSchema, {
2626
stripUnknown: true,
2727
})
28+
29+
const { publishStartDate, publishEndDate } = validatedForm
30+
if (!!publishStartDate && !!publishEndDate) {
31+
const startDate = new Date(publishStartDate)
32+
const endDate = new Date(publishEndDate)
33+
if (startDate >= endDate)
34+
throw new Error('Publish Start Date must be before Publish End Date')
35+
}
2836
return validatedForm
2937
}
3038

0 commit comments

Comments
 (0)