From 0a7305ff8e5591068e1171474348cd54537ecfff Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 4 Aug 2020 10:28:46 -0700 Subject: [PATCH] Added notes presets BOD-227 --- bodyshop_translations.babel | 42 +++++++++++++ .../note-upsert-modal.component.jsx | 8 ++- .../note-upsert-modal.container.jsx | 2 +- .../notes-preset-button.component.jsx | 50 +++++++++++++++ .../shop-info/shop-info.component.jsx | 62 +++++++++++++++++++ client/src/graphql/bodyshop.queries.js | 2 + client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + .../down.yaml | 5 ++ .../up.yaml | 6 ++ .../down.yaml | 59 ++++++++++++++++++ .../up.yaml | 60 ++++++++++++++++++ .../down.yaml | 53 ++++++++++++++++ .../up.yaml | 54 ++++++++++++++++ hasura/migrations/metadata.yaml | 2 + 16 files changed, 407 insertions(+), 4 deletions(-) create mode 100644 client/src/components/notes-preset-button/notes-preset-button.component.jsx create mode 100644 hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/down.yaml create mode 100644 hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/up.yaml create mode 100644 hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 6963e536d..50edb75af 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1400,6 +1400,48 @@ + + noteslabel + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + notestext + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + partslocation false diff --git a/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx b/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx index 1e7c6c8ce..564421cf8 100644 --- a/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx +++ b/client/src/components/note-upsert-modal/note-upsert-modal.component.jsx @@ -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"), + }, ]} > + ); } diff --git a/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx b/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx index e9803919e..c7832b11e 100644 --- a/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx +++ b/client/src/components/note-upsert-modal/note-upsert-modal.container.jsx @@ -91,7 +91,7 @@ export function NoteUpsertModalContainer({ destroyOnClose > - + ); diff --git a/client/src/components/notes-preset-button/notes-preset-button.component.jsx b/client/src/components/notes-preset-button/notes-preset-button.component.jsx new file mode 100644 index 000000000..5e1dbc943 --- /dev/null +++ b/client/src/components/notes-preset-button/notes-preset-button.component.jsx @@ -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 = ( + + {bodyshop.md_notes_presets.map((i, idx) => ( + handleSelect(i)} onItemHover key={idx}> + {i.label} + + ))} + + ); + + return ( + + + e.preventDefault()} + > + {t("messaging.labels.presets")} + + + + ); +} + +export default connect(mapStateToProps, mapDispatchToProps)(NotesPresetButton); diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index 8a5183d11..fa48a3c00 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -275,6 +275,68 @@ export default function ShopInfoComponent({ form, saveLoading }) { }} + + {(fields, { add, remove }) => { + return ( + + {fields.map((field, index) => ( + + + + + + + + + { + remove(field.name); + }} + /> + + + ))} + + { + add(); + }} + style={{ width: "100%" }} + > + {t("general.actions.add")} + + + + ); + }} + + {(fields, { add, remove, move }) => { return ( diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index ac680777f..6e487752d 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -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 diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 06306cb68..d15746f8c 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -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", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index d2dc257f6..06e0c607a 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -101,6 +101,8 @@ "md_referral_sources": "", "messaginglabel": "", "messagingtext": "", + "noteslabel": "", + "notestext": "", "partslocation": "", "responsibilitycenter": "", "responsibilitycenter_accountdesc": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index c0e8e6021..465fa1c4d 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -101,6 +101,8 @@ "md_referral_sources": "", "messaginglabel": "", "messagingtext": "", + "noteslabel": "", + "notestext": "", "partslocation": "", "responsibilitycenter": "", "responsibilitycenter_accountdesc": "", diff --git a/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/down.yaml b/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/down.yaml new file mode 100644 index 000000000..6df4170c7 --- /dev/null +++ b/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/down.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "md_notes_presets"; + type: run_sql diff --git a/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/up.yaml b/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/up.yaml new file mode 100644 index 000000000..da28d8713 --- /dev/null +++ b/hasura/migrations/1596561493315_alter_table_public_bodyshops_add_column_md_notes_presets/up.yaml @@ -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 diff --git a/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..06a490337 --- /dev/null +++ b/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/down.yaml @@ -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 diff --git a/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..00761bb0f --- /dev/null +++ b/hasura/migrations/1596561513554_update_permission_user_public_table_bodyshops/up.yaml @@ -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 diff --git a/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/down.yaml b/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/down.yaml new file mode 100644 index 000000000..e458aac22 --- /dev/null +++ b/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/down.yaml @@ -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 diff --git a/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/up.yaml b/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/up.yaml new file mode 100644 index 000000000..172d0cfce --- /dev/null +++ b/hasura/migrations/1596561522463_update_permission_user_public_table_bodyshops/up.yaml @@ -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 diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml index 7aa332be6..72dcdede0 100644 --- a/hasura/migrations/metadata.yaml +++ b/hasura/migrations/metadata.yaml @@ -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