Added notes presets BOD-227

This commit is contained in:
Patrick Fic
2020-08-04 10:28:46 -07:00
parent 470f69b11c
commit 0a7305ff8e
16 changed files with 407 additions and 4 deletions

View File

@@ -1400,6 +1400,48 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>noteslabel</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>
<concept_node>
<name>notestext</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>
<concept_node>
<name>partslocation</name>
<definition_loaded>false</definition_loaded>

View File

@@ -1,8 +1,9 @@
import { Form, Input, Switch } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import NotesPresetButton from "../notes-preset-button/notes-preset-button.component";
export default function NoteUpsertModalComponent() {
export default function NoteUpsertModalComponent({ form }) {
const { t } = useTranslation();
return (
@@ -27,8 +28,8 @@ export default function NoteUpsertModalComponent() {
rules={[
{
required: true,
message: t("general.validation.required")
}
message: t("general.validation.required"),
},
]}
>
<Input.TextArea
@@ -36,6 +37,7 @@ export default function NoteUpsertModalComponent() {
placeholder={t("notes.labels.newnoteplaceholder")}
/>
</Form.Item>
<NotesPresetButton form={form} />
</div>
);
}

View File

@@ -91,7 +91,7 @@ export function NoteUpsertModalContainer({
destroyOnClose
>
<Form form={form} onFinish={handleFinish} initialValues={existingNote}>
<NoteUpsertModalComponent />
<NoteUpsertModalComponent form={form} />
</Form>
</Modal>
);

View File

@@ -0,0 +1,50 @@
import { DownOutlined } from "@ant-design/icons";
import { Dropdown, Menu } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setMessage } from "../../redux/messaging/messaging.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
});
export function NotesPresetButton({ bodyshop, form }) {
const { t } = useTranslation();
const handleSelect = (item) => {
form.setFieldsValue({ text: item.text });
};
const menu = (
<Menu>
{bodyshop.md_notes_presets.map((i, idx) => (
<Menu.Item onClick={() => handleSelect(i)} onItemHover key={idx}>
{i.label}
</Menu.Item>
))}
</Menu>
);
return (
<div>
<Dropdown trigger={["click"]} overlay={menu}>
<a
className="ant-dropdown-link"
href="# "
onClick={(e) => e.preventDefault()}
>
{t("messaging.labels.presets")} <DownOutlined />
</a>
</Dropdown>
</div>
);
}
export default connect(mapStateToProps, mapDispatchToProps)(NotesPresetButton);

View File

@@ -275,6 +275,68 @@ export default function ShopInfoComponent({ form, saveLoading }) {
}}
</Form.List>
<Form.List name={["md_notes_presets"]}>
{(fields, { add, remove }) => {
return (
<div>
{fields.map((field, index) => (
<Form.Item
key={field.key}
style={{ padding: 0, margin: 2 }}
>
<div style={{ display: "flex" }}>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.noteslabel")}
key={`${index}label`}
name={[field.name, "label"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.notestext")}
key={`${index}text`}
name={[field.name, "text"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<DeleteFilled
onClick={() => {
remove(field.name);
}}
/>
</div>
</Form.Item>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => {
add();
}}
style={{ width: "100%" }}
>
{t("general.actions.add")}
</Button>
</Form.Item>
</div>
);
}}
</Form.List>
<Form.List name={["md_parts_locations"]}>
{(fields, { add, remove, move }) => {
return (

View File

@@ -49,6 +49,7 @@ export const QUERY_BODYSHOP = gql`
intakechecklist
speedprint
md_parts_locations
md_notes_presets
employees {
id
first_name
@@ -106,6 +107,7 @@ export const UPDATE_SHOP = gql`
intakechecklist
speedprint
md_parts_locations
md_notes_presets
employees {
id
first_name

View File

@@ -101,6 +101,8 @@
"md_referral_sources": "Referral Sources",
"messaginglabel": "Messaging Preset Label",
"messagingtext": "Messaging Preset Text",
"noteslabel": "Note Label",
"notestext": "Note Text",
"partslocation": "Parts Location",
"responsibilitycenter": "Responsibility Center",
"responsibilitycenter_accountdesc": "Account Description",

View File

@@ -101,6 +101,8 @@
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",
"noteslabel": "",
"notestext": "",
"partslocation": "",
"responsibilitycenter": "",
"responsibilitycenter_accountdesc": "",

View File

@@ -101,6 +101,8 @@
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",
"noteslabel": "",
"notestext": "",
"partslocation": "",
"responsibilitycenter": "",
"responsibilitycenter_accountdesc": "",

View File

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

View File

@@ -0,0 +1,6 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "md_notes_presets" jsonb NULL
DEFAULT jsonb_build_array();
type: run_sql

View File

@@ -0,0 +1,59 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- production_config
- region_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,60 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- production_config
- region_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,53 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- production_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -0,0 +1,54 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- production_config
- scoreboard_target
- shopname
- shoprates
- speedprint
- ssbuckets
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -474,6 +474,7 @@ tables:
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources
@@ -521,6 +522,7 @@ tables:
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_notes_presets
- md_order_statuses
- md_parts_locations
- md_referral_sources