sowell-models 1.31.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sowell-models",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
4
4
  "description": "SoWell models",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -25,3 +25,5 @@ export * from './models/Location';
25
25
  export * from './models/Origin';
26
26
  export * from './models/Provider';
27
27
  export * from './models/UnseenIssue';
28
+ export * from './models/Form';
29
+ export * from './models/FormAnswer';
@@ -0,0 +1,41 @@
1
+ import { Attr, Model } from 'spraypaint'
2
+ import { ApplicationRecord } from '../ApplicationRecord'
3
+
4
+ export interface IFormQuestionOption {
5
+ label: string
6
+ value: string
7
+ }
8
+
9
+ export interface IFormQuestion {
10
+ id: string
11
+ name: string
12
+ label?: string
13
+ export?: boolean
14
+ validation?: "required"
15
+ description?: string
16
+ // rating
17
+ max?: number
18
+ // selection
19
+ options?: IFormQuestionOption[]
20
+ // toggle
21
+ type?: "boolean"
22
+ // image / number-with-img / input-with-img / rating-with-img
23
+ imgs?: boolean | []
24
+ // sw-image
25
+ limit?: number
26
+ multiple?: boolean
27
+ }
28
+
29
+ export interface IForm {
30
+ id?: string
31
+ name?: string
32
+ questions?: IFormQuestion[]
33
+ }
34
+
35
+
36
+ @Model()
37
+ export class SPForm extends ApplicationRecord implements IForm {
38
+ static jsonapiType = 'forms'
39
+ @Attr() name!: string
40
+ @Attr() questions!: IFormQuestion[]
41
+ }
@@ -0,0 +1,41 @@
1
+ import { Attr, BelongsTo, Model } from 'spraypaint'
2
+ import { ApplicationRecord } from '../ApplicationRecord'
3
+ import { IUser, SPUserItem } from '../User'
4
+ import { IForm, SPForm } from '../Form'
5
+ import { SPResidenceItem } from '../Residence'
6
+ import { SPPlaceItem } from '../Place'
7
+ import { SPSpotItem } from '../Spot'
8
+ import { SPAgencyItem } from '../Agency'
9
+
10
+ export interface IFormAnswerData {
11
+ data: any[]
12
+ agency?: string
13
+ residence?: string
14
+ place?: string
15
+ spot?: string
16
+ }
17
+
18
+ export interface IFormAnswer {
19
+ id?: string
20
+ createdAt?: string
21
+ answers?: IFormAnswerData
22
+ author?: IUser
23
+ form?: IForm
24
+ agency?: SPAgencyItem
25
+ residence?: SPResidenceItem
26
+ place?: SPPlaceItem
27
+ spot?: SPSpotItem
28
+ }
29
+
30
+ @Model()
31
+ export class SPFormAnswer extends ApplicationRecord implements IFormAnswer {
32
+ static jsonapiType = 'form_answers'
33
+ @Attr() createdAt!: string
34
+ @Attr() answers!: IFormAnswerData
35
+ @BelongsTo() author!: SPUserItem
36
+ @BelongsTo() form!: SPForm
37
+ @BelongsTo() agency!: SPAgencyItem
38
+ @BelongsTo() residence!: SPResidenceItem
39
+ @BelongsTo() place!: SPPlaceItem
40
+ @BelongsTo() spot!: SPSpotItem
41
+ }