Added framework for CSI questions & viewing. Schema changes to allow anon viewing of survey BOD-98

This commit is contained in:
Patrick Fic
2020-05-22 13:36:25 -07:00
parent d8c159cde0
commit f7cc4cffa4
64 changed files with 1345 additions and 45 deletions

View File

@@ -3804,6 +3804,37 @@
</folder_node>
</children>
</folder_node>
<folder_node>
<name>csi</name>
<children>
<folder_node>
<name>labels</name>
<children>
<concept_node>
<name>title</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
</children>
</folder_node>
<folder_node>
<name>documents</name>
<children>

View File

@@ -29,7 +29,8 @@ const wsLink = new WebSocketLink({
reconnect: true,
connectionParams: async () => {
//const token = localStorage.getItem("token");
const token = await auth.currentUser.getIdToken(true);
const token =
auth.currentUser && (await auth.currentUser.getIdToken(true));
if (token) {
return {
headers: {
@@ -42,7 +43,8 @@ const wsLink = new WebSocketLink({
});
const subscriptionMiddleware = {
applyMiddleware: async (options, next) => {
options.authToken = await auth.currentUser.getIdToken(true);
options.authToken =
auth.currentUser && (await auth.currentUser.getIdToken(true));
next();
},
};
@@ -70,18 +72,21 @@ const link = split(
);
const authLink = setContext((_, { headers }) => {
return auth.currentUser.getIdToken().then((token) => {
if (token) {
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
};
} else {
return { headers };
}
});
return (
auth.currentUser &&
auth.currentUser.getIdToken().then((token) => {
if (token) {
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
};
} else {
return { headers };
}
})
);
});
const retryLink = new RetryLink({

View File

@@ -18,12 +18,13 @@ const SignInPage = lazy(() => import("../pages/sign-in/sign-in.page"));
const Unauthorized = lazy(() =>
import("../pages/unauthorized/unauthorized.component")
);
const CsiPage = lazy(() => import("../pages/csi/csi.container.page"));
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser
currentUser: selectCurrentUser,
});
const mapDispatchToProps = dispatch => ({
checkUserSession: () => dispatch(checkUserSession())
const mapDispatchToProps = (dispatch) => ({
checkUserSession: () => dispatch(checkUserSession()),
});
export default connect(
@@ -48,9 +49,8 @@ export default connect(
<Suspense fallback={<LoadingSpinner message='App.Js Suspense' />}>
<Route exact path='/' component={LandingPage} />
<Route exact path='/unauthorized' component={Unauthorized} />
<Route exact path='/signin' component={SignInPage} />
<Route exact path='/csi/:surveyId' component={CsiPage} />
<PrivateRoute
isAuthorized={currentUser.authorized}
path='/manage'

View File

@@ -0,0 +1,29 @@
import React from "react";
import CheckboxFormItem from "./checkbox/checkbox.component";
import Slider from "./slider/slider.component";
import Text from "./text/text.component";
import Textarea from "./textarea/textarea.component";
import Rate from "./rate/rate.component";
export default function ConfirmFormComponents({ componentList }) {
return (
<div>
{componentList.map((f, idx) => {
switch (f.type) {
case "checkbox":
return <CheckboxFormItem key={idx} formItem={f} />;
case "slider":
return <Slider key={idx} formItem={f} />;
case "text":
return <Text key={idx} formItem={f} />;
case "textarea":
return <Textarea key={idx} formItem={f} />;
case "rate":
return <Rate key={idx} formItem={f} />;
default:
return <div key={idx}>Error</div>;
}
})}
</div>
);
}

View File

@@ -0,0 +1,21 @@
import React from "react";
import { Form, Rate } from "antd";
import { useTranslation } from "react-i18next";
export default function JobIntakeFormCheckboxComponent({ formItem }) {
const { name, label, required } = formItem;
const { t } = useTranslation();
return (
<Form.Item
name={name}
label={label}
rules={[
{
required: required,
message: t("general.validation.required"),
},
]}>
<Rate allowHalf />
</Form.Item>
);
}

View File

@@ -0,0 +1,21 @@
import { Form, Slider } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
export default function JobIntakeFormCheckboxComponent({ formItem }) {
const { name, label, required, min, max } = formItem;
const { t } = useTranslation();
return (
<Form.Item
name={name}
label={label}
rules={[
{
required: required,
message: t("general.validation.required"),
},
]}>
<Slider min={min || 0} max={max || 10} />
</Form.Item>
);
}

View File

@@ -0,0 +1,21 @@
import React from "react";
import { Form, Input } from "antd";
import { useTranslation } from "react-i18next";
export default function JobIntakeFormCheckboxComponent({ formItem }) {
const { name, label, required } = formItem;
const { t } = useTranslation();
return (
<Form.Item
name={name}
label={label}
rules={[
{
required: required,
message: t("general.validation.required"),
},
]}>
<Input />
</Form.Item>
);
}

View File

@@ -0,0 +1,21 @@
import React from "react";
import { Form, Input } from "antd";
import { useTranslation } from "react-i18next";
export default function JobIntakeFormCheckboxComponent({ formItem }) {
const { name, label, required, rows } = formItem;
const { t } = useTranslation();
return (
<Form.Item
name={name}
label={label}
rules={[
{
required: required,
message: t("general.validation.required"),
},
]}>
<Input.TextArea rows={rows || 4} />
</Form.Item>
);
}

View File

@@ -1,18 +1,16 @@
import React from "react";
import { Form, Button, Switch, DatePicker, notification } from "antd";
import CheckboxFormItem from "../job-intake-form-checkbox/job-itnake-form-checkbox.component";
import { useTranslation } from "react-i18next";
import { useMutation } from "@apollo/react-hooks";
import { UPDATE_JOB } from "../../../../graphql/jobs.queries";
import { MARK_LATEST_APPOINTMENT_AS_ARRIVED } from "../../../../graphql/appointments.queries";
import { useParams } from "react-router-dom";
import { selectBodyshop } from "../../../../redux/user/user.selectors";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { useHistory } from "react-router-dom";
import { Button, Form, notification, Switch } from "antd";
import queryString from "query-string";
import { useLocation } from "react-router-dom";
import DateTimePicker from '../../../form-date-time-picker/form-date-time-picker.component'
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useHistory, useLocation, useParams } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { MARK_LATEST_APPOINTMENT_AS_ARRIVED } from "../../../../graphql/appointments.queries";
import { UPDATE_JOB } from "../../../../graphql/jobs.queries";
import { selectBodyshop } from "../../../../redux/user/user.selectors";
import DateTimePicker from "../../../form-date-time-picker/form-date-time-picker.component";
import ConfigFormComponents from "../../../config-form-components/config-form-components.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -80,14 +78,9 @@ export function JobIntakeForm({ formItems, bodyshop }) {
onFinish={handleFinish}
initialValues={{ addToProduction: true }}>
{t("intake.labels.checklist")}
{formItems.map((f, idx) => {
switch (f.type) {
case "checkbox":
return <CheckboxFormItem key={idx} formItem={f} />;
default:
return <div key={idx}>Error</div>;
}
})}
<ConfigFormComponents componentList={formItems} />
<Form.Item
name='addToProduction'
valuePropName='checked'

View File

@@ -1,9 +1,9 @@
import { Checkbox, Col, DatePicker, Row, Tabs, TimePicker } from "antd";
import { Checkbox, Col, Row, Tabs } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component";
import ScheduleDayViewContainer from "../schedule-day-view/schedule-day-view.container";
import ScheduleExistingAppointmentsList from "../schedule-existing-appointments-list/schedule-existing-appointments-list.component";
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component";
export default function ScheduleJobModalComponent({
existingAppointments,

View File

@@ -0,0 +1,16 @@
import gql from "graphql-tag";
export const QUERY_SURVEY = gql`
query QUERY_SURVEY($surveyId: uuid!) {
csi_by_pk(id: $surveyId) {
relateddata
valid
validuntil
id
csiquestion {
id
config
}
}
}
`;

View File

@@ -0,0 +1,128 @@
import { useQuery } from "@apollo/react-hooks";
import { Form, Layout, Typography, Button } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
import AlertComponent from "../../components/alert/alert.component";
import ConfigFormComponents from "../../components/config-form-components/config-form-components.component";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import { QUERY_SURVEY } from "../../graphql/csi.queries";
export default function CsiContainerPage() {
const { surveyId } = useParams();
const [form] = Form.useForm();
const { loading, error, data } = useQuery(QUERY_SURVEY, {
variables: { surveyId },
});
const { t } = useTranslation();
if (loading) return <LoadingSpinner />;
if (error) return <AlertComponent message={error.message} type='error' />;
const handleFinish = (values) => {
console.log("values", values);
};
//const { relateddata } = data.csi_by_pk;
const { bodyshop, job, csiquestion } = relateddata;
return (
<Layout
style={{ height: "100vh", display: "flex", flexDirection: "column" }}>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
}}>
<div style={{ display: "flex", alignItems: "center" }}>
{bodyshop.logo_img_path ? (
<img src={bodyshop.logo_img_path} alt='Logo' />
) : null}
<div>
<strong>{bodyshop.shopname || ""}</strong>
<div>{`${bodyshop.address1 || ""}`}</div>
<div>{`${bodyshop.address2 || ""}`}</div>
<div>{`${bodyshop.city || ""} ${bodyshop.state || ""} ${
bodyshop.zip_post || ""
}`}</div>
</div>
</div>
<Typography.Title>{t("csi.labels.title")}</Typography.Title>
<strong>{`Hi ${job.ownr_fn || ""}!`}</strong>
<Typography.Paragraph>
At {bodyshop.shopname || ""}, we value our customer's feedback. We
would love to hear what you have to say. Please fill out the form
below.
</Typography.Paragraph>
</div>
<Layout.Content
style={{ backgroundColor: "#fff", margin: "2em 4em", padding: "2em" }}>
<Form form={form} onFinish={handleFinish}>
<ConfigFormComponents componentList={csiquestion} />
<Button type='primary' htmlType='submit'>
{t("general.actions.submit")}
</Button>
</Form>
</Layout.Content>
<Layout.Footer>
Copyright ImEX.Online. Survey ID: {surveyId}
</Layout.Footer>
</Layout>
);
}
const relateddata = {
bodyshop: {
logo_img_path: "https://via.placeholder.com/150",
shopname: "Kavia Test Autobody",
address1: "123 Fake St",
address2: "Unit #100",
city: "Vancouver",
state: "BC",
zip_post: "V6B 1M9",
country: "Canada",
email: "snaptsoft@gmail.com",
},
job: {
id: "1234",
ro_number: "RO102384",
ownr_fn: "Patrick",
v_make_desc: "Toyota",
v_model_desc: "Camry",
v_model_yr: "2019",
},
csiquestion: [
{
name: "item1",
type: "checkbox",
label: "Checklist Item 1",
required: true,
},
{
name: "item2",
type: "slider",
label: "Checklist Item 2",
min: 0,
max: 5,
required: true,
},
{
name: "item3",
type: "textarea",
label: "Checklist Item 3",
required: true,
},
{
name: "item4",
type: "text",
label: "Checklist Item 4",
required: true,
},
{
name: "item5",
type: "rate",
label: "Checklist Item 4",
required: true,
},
],
};

View File

@@ -11,8 +11,8 @@ export default function LandingPage() {
<HeaderContainer landingHeader />
</Header>
<Content className="content-container" style={{ padding: "0em 4em 4em" }}>
<Typography.Title>Welcome to bodyshop.app.</Typography.Title>
<Content className='content-container' style={{ padding: "0em 4em 4em" }}>
<Typography.Title>ImEX.Online</Typography.Title>
</Content>
</Layout>
);

View File

@@ -249,6 +249,11 @@
"saved": "Courtesy Car saved successfully."
}
},
"csi": {
"labels": {
"title": "Customer Satisfaction Survey"
}
},
"documents": {
"actions": {
"delete": "Delete Selected Documents",
@@ -333,7 +338,7 @@
"no": "No",
"out": "Out",
"search": "Search...",
"selectdate": "Select date",
"selectdate": "Select date...",
"unknown": "Unknown",
"yes": "Yes"
},

View File

@@ -249,6 +249,11 @@
"saved": ""
}
},
"csi": {
"labels": {
"title": ""
}
},
"documents": {
"actions": {
"delete": "",

View File

@@ -249,6 +249,11 @@
"saved": ""
}
},
"csi": {
"labels": {
"title": ""
}
},
"documents": {
"actions": {
"delete": "",

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."csiinvites";
type: run_sql

View File

@@ -0,0 +1,27 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"csiinvites\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"jobid\" uuid NOT NULL, \"valid\" boolean NOT NULL
DEFAULT true, \"relateddata\" jsonb, \"bodyshopid\" uuid NOT NULL, \"validuntil\"
date, PRIMARY KEY (\"id\") , FOREIGN KEY (\"jobid\") REFERENCES \"public\".\"jobs\"(\"id\")
ON UPDATE restrict ON DELETE restrict, FOREIGN KEY (\"bodyshopid\") REFERENCES
\"public\".\"bodyshops\"(\"id\") ON UPDATE restrict ON DELETE restrict);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_csiinvites_updated_at\"\nBEFORE
UPDATE ON \"public\".\"csiinvites\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_csiinvites_updated_at\" ON \"public\".\"csiinvites\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: csiinvites
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,24 @@
- args:
relationship: csiinvites
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: csiinvites
schema: public
type: drop_relationship
- args:
relationship: job
table:
name: csiinvites
schema: public
type: drop_relationship
- args:
relationship: csiinvites
table:
name: jobs
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: csiinvites
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: csiinvites
schema: public
type: create_array_relationship
- args:
name: bodyshop
table:
name: csiinvites
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship
- args:
name: job
table:
name: csiinvites
schema: public
using:
foreign_key_constraint_on: jobid
type: create_object_relationship
- args:
name: csiinvites
table:
name: jobs
schema: public
using:
foreign_key_constraint_on:
column: jobid
table:
name: csiinvites
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiinvites
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,30 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- valid
- relateddata
- bodyshopid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiinvites
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiinvites
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,28 @@
- args:
permission:
allow_aggregations: false
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: csiinvites
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiinvites
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,29 @@
- args:
permission:
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiinvites
schema: public
type: create_update_permission

View File

@@ -0,0 +1,6 @@
- args:
role: anonymous
table:
name: csiinvites
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,16 @@
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csiinvites
schema: public
type: create_select_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csi" rename to "csiinvites";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiinvites" rename to "csi";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" DROP COLUMN "response";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" ADD COLUMN "response" jsonb NULL;
type: run_sql

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- id
- created_at
- updated_at
- jobid
- valid
- relateddata
- bodyshopid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,33 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,34 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
role: user
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,36 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,35 @@
- args:
role: user
table:
name: csi
schema: public
type: drop_insert_permission
- args:
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- updated_at
- valid
- validuntil
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csi
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,22 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,24 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- id
- relateddata
- valid
- validuntil
computed_fields: []
filter:
valid:
_eq: true
limit: 1
role: anonymous
table:
name: csi
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,17 @@
- args:
permission:
columns:
- response
- updated_at
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

@@ -0,0 +1,23 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission
- args:
permission:
columns:
- response
- updated_at
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

@@ -0,0 +1,22 @@
- args:
role: anonymous
table:
name: csi
schema: public
type: drop_update_permission
- args:
permission:
columns:
- response
filter:
valid:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: anonymous
table:
name: csi
schema: public
type: create_update_permission

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: DROP TABLE "public"."csiquestion";
type: run_sql

View File

@@ -0,0 +1,25 @@
- args:
cascade: false
read_only: false
sql: CREATE EXTENSION IF NOT EXISTS pgcrypto;
type: run_sql
- args:
cascade: false
read_only: false
sql: "CREATE TABLE \"public\".\"csiquestion\"(\"id\" uuid NOT NULL DEFAULT gen_random_uuid(),
\"created_at\" timestamptz NOT NULL DEFAULT now(), \"updated_at\" timestamptz
NOT NULL DEFAULT now(), \"bodyshopid\" uuid NOT NULL, \"current\" boolean NOT
NULL DEFAULT true, \"config\" jsonb, PRIMARY KEY (\"id\") , FOREIGN KEY (\"bodyshopid\")
REFERENCES \"public\".\"bodyshops\"(\"id\") ON UPDATE restrict ON DELETE restrict);\nCREATE
OR REPLACE FUNCTION \"public\".\"set_current_timestamp_updated_at\"()\nRETURNS
TRIGGER AS $$\nDECLARE\n _new record;\nBEGIN\n _new := NEW;\n _new.\"updated_at\"
= NOW();\n RETURN _new;\nEND;\n$$ LANGUAGE plpgsql;\nCREATE TRIGGER \"set_public_csiquestion_updated_at\"\nBEFORE
UPDATE ON \"public\".\"csiquestion\"\nFOR EACH ROW\nEXECUTE PROCEDURE \"public\".\"set_current_timestamp_updated_at\"();\nCOMMENT
ON TRIGGER \"set_public_csiquestion_updated_at\" ON \"public\".\"csiquestion\"
\nIS 'trigger to set value of column \"updated_at\" to current timestamp on
row update';"
type: run_sql
- args:
name: csiquestion
schema: public
type: add_existing_table_or_view

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" DROP COLUMN "questionset";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."csi" ADD COLUMN "questionset" uuid NULL;
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiquestions" rename to "csiquestion";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csiquestion" rename to "csiquestions";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: alter table "public"."csi" drop constraint "csi_questionset_fkey";
type: run_sql

View File

@@ -0,0 +1,10 @@
- args:
cascade: false
read_only: false
sql: |-
alter table "public"."csi"
add constraint "csi_questionset_fkey"
foreign key ("questionset")
references "public"."csiquestions"
("id") on update restrict on delete restrict;
type: run_sql

View File

@@ -0,0 +1,24 @@
- args:
relationship: csiquestions
table:
name: bodyshops
schema: public
type: drop_relationship
- args:
relationship: csiquestion
table:
name: csi
schema: public
type: drop_relationship
- args:
relationship: bodyshop
table:
name: csiquestions
schema: public
type: drop_relationship
- args:
relationship: csis
table:
name: csiquestions
schema: public
type: drop_relationship

View File

@@ -0,0 +1,40 @@
- args:
name: csiquestions
table:
name: bodyshops
schema: public
using:
foreign_key_constraint_on:
column: bodyshopid
table:
name: csiquestions
schema: public
type: create_array_relationship
- args:
name: csiquestion
table:
name: csi
schema: public
using:
foreign_key_constraint_on: questionset
type: create_object_relationship
- args:
name: bodyshop
table:
name: csiquestions
schema: public
using:
foreign_key_constraint_on: bodyshopid
type: create_object_relationship
- args:
name: csis
table:
name: csiquestions
schema: public
using:
foreign_key_constraint_on:
column: questionset
table:
name: csi
schema: public
type: create_array_relationship

View File

@@ -0,0 +1,6 @@
- args:
role: anonymous
table:
name: csiquestions
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,14 @@
- args:
permission:
allow_aggregations: false
columns:
- config
- id
computed_fields: []
filter: {}
limit: 1
role: anonymous
table:
name: csiquestions
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiquestions
schema: public
type: drop_insert_permission

View File

@@ -0,0 +1,28 @@
- args:
permission:
allow_upsert: true
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiquestions
schema: public
type: create_insert_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiquestions
schema: public
type: drop_select_permission

View File

@@ -0,0 +1,26 @@
- args:
permission:
allow_aggregations: false
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
computed_fields: []
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
limit: null
role: user
table:
name: csiquestions
schema: public
type: create_select_permission

View File

@@ -0,0 +1,6 @@
- args:
role: user
table:
name: csiquestions
schema: public
type: drop_update_permission

View File

@@ -0,0 +1,22 @@
- args:
permission:
columns:
- current
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
localPresets:
- key: ""
value: ""
set: {}
role: user
table:
name: csiquestions
schema: public
type: create_update_permission

View File

@@ -384,6 +384,20 @@ tables:
table:
schema: public
name: courtesycars
- name: csiinvites
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: csi
- name: csiquestions
using:
foreign_key_constraint_on:
column: bodyshopid
table:
schema: public
name: csiquestions
- name: employees
using:
foreign_key_constraint_on:
@@ -869,6 +883,175 @@ tables:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: csi
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
- name: csiquestion
using:
foreign_key_constraint_on: questionset
- name: job
using:
foreign_key_constraint_on: jobid
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- updated_at
- valid
- validuntil
select_permissions:
- role: anonymous
permission:
columns:
- id
- relateddata
- valid
- validuntil
filter:
valid:
_eq: true
limit: 1
- role: user
permission:
columns:
- bodyshopid
- created_at
- id
- jobid
- relateddata
- response
- updated_at
- valid
- validuntil
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
update_permissions:
- role: anonymous
permission:
columns:
- response
filter:
valid:
_eq: true
- role: user
permission:
columns:
- valid
- validuntil
- relateddata
- created_at
- updated_at
- bodyshopid
- id
- jobid
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: csiquestions
object_relationships:
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
array_relationships:
- name: csis
using:
foreign_key_constraint_on:
column: questionset
table:
schema: public
name: csi
insert_permissions:
- role: user
permission:
check:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
select_permissions:
- role: anonymous
permission:
columns:
- config
- id
filter: {}
limit: 1
- role: user
permission:
columns:
- current
- config
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
update_permissions:
- role: user
permission:
columns:
- current
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
- table:
schema: public
name: documents
@@ -1624,6 +1807,13 @@ tables:
table:
schema: public
name: cccontracts
- name: csiinvites
using:
foreign_key_constraint_on:
column: jobid
table:
schema: public
name: csi
- name: documents
using:
foreign_key_constraint_on: