diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index d270c0d9f..075b0ebd4 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -23609,6 +23609,27 @@ + + phonebook + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + vehicles false @@ -27004,6 +27025,27 @@ fields + + category + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + city false diff --git a/client/src/components/global-search/global-search.component.jsx b/client/src/components/global-search/global-search.component.jsx index feb2ef1f1..b1c460e53 100644 --- a/client/src/components/global-search/global-search.component.jsx +++ b/client/src/components/global-search/global-search.component.jsx @@ -137,6 +137,28 @@ export default function GlobalSearch() { }; }), }, + { + label: renderTitle(t("menus.header.search.phonebook")), + options: data.search_phonebook.map((pb) => { + return { + key: pb.id, + value: `${pb.firstname || ""} ${pb.lastname || ""} ${ + pb.company || "" + }`, + label: ( + + }> + {`${pb.firstname || ""} ${pb.lastname || ""} ${ + pb.company || "" + }`} + {pb.phone1} + {pb.email} + + + ), + }; + }), + }, ] : []; diff --git a/client/src/components/phonebook-form/phonebook-form.component.jsx b/client/src/components/phonebook-form/phonebook-form.component.jsx index ac992a285..bcb0bb653 100644 --- a/client/src/components/phonebook-form/phonebook-form.component.jsx +++ b/client/src/components/phonebook-form/phonebook-form.component.jsx @@ -55,6 +55,9 @@ export default function PhonebookFormComponent({ + + + diff --git a/client/src/graphql/search.queries.js b/client/src/graphql/search.queries.js index 86b93b78e..472b5df03 100644 --- a/client/src/graphql/search.queries.js +++ b/client/src/graphql/search.queries.js @@ -52,5 +52,12 @@ export const GLOBAL_SEARCH_QUERY = gql` name } } + search_phonebook(args: { search: $search }) { + id + firstname + lastname + company + phone1 + } } `; diff --git a/client/src/pages/phonebook/phonebook.page.component.jsx b/client/src/pages/phonebook/phonebook.page.component.jsx index cb2c07b7d..2d99e8b3c 100644 --- a/client/src/pages/phonebook/phonebook.page.component.jsx +++ b/client/src/pages/phonebook/phonebook.page.component.jsx @@ -76,6 +76,11 @@ export function PhonebookPageComponent({ bodyshop }) { dataIndex: "company", key: "company", }, + { + title: t("phonebook.fields.category"), + dataIndex: "category", + key: "category", + }, { title: t("phonebook.fields.email"), dataIndex: "email", diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 12e589571..fe3f687a4 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1392,6 +1392,7 @@ "jobs": "Jobs", "owners": "Owners", "payments": "Payments", + "phonebook": "Phonebook", "vehicles": "Vehicles" }, "shiftclock": "Shift Clock", @@ -1618,6 +1619,7 @@ "new": "New Phonebook Entry" }, "fields": { + "category": "Category", "city": "City", "company": "Company", "country": "Country", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index decc6c3ed..ad781f52e 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1392,6 +1392,7 @@ "jobs": "", "owners": "", "payments": "", + "phonebook": "", "vehicles": "" }, "shiftclock": "", @@ -1618,6 +1619,7 @@ "new": "" }, "fields": { + "category": "", "city": "", "company": "", "country": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 86e851f9c..848ac9966 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1392,6 +1392,7 @@ "jobs": "", "owners": "", "payments": "", + "phonebook": "", "vehicles": "" }, "shiftclock": "", @@ -1618,6 +1619,7 @@ "new": "" }, "fields": { + "category": "", "city": "", "company": "", "country": "", diff --git a/hasura/migrations/1619540860369_run_sql_migration/down.yaml b/hasura/migrations/1619540860369_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1619540860369_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1619540860369_run_sql_migration/up.yaml b/hasura/migrations/1619540860369_run_sql_migration/up.yaml new file mode 100644 index 000000000..d343558ea --- /dev/null +++ b/hasura/migrations/1619540860369_run_sql_migration/up.yaml @@ -0,0 +1,26 @@ +- args: + cascade: false + read_only: false + sql: "drop function search_phonebook;\nCREATE OR REPLACE FUNCTION public.search_phonebook(search + text)\n RETURNS SETOF phonebook\n LANGUAGE plpgsql\n STABLE\nAS $function$\nBEGIN\n\tIF + search = '' THEN\n\t\tRETURN query\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\tphonebook;\n\tELSE\n\t\tRETURN + query\n\t\tSELECT\n\t\t\tphonebook.*\n\t\tFROM\n\t\t\tphonebook\n\t\tWHERE firstname + ILIKE '%' || search || '%'\n\t\t\tOR lastname ILIKE '%' || search || '%'\n\t\t\tOR + company ILIKE '%' || search || '%'\n\t\t\tOR address1 ILIKE '%' || search || + '%'\n\t\t\tOR phone1 ILIKE '%' || search || '%'\n\t\t\tOR phone2 ILIKE '%' || + search || '%'\n\t\t\tOR email ILIKE '%' || search || '%'\n\t\t\tOR category + ILIKE '%' || search || '%'\n\t\tORDER BY\n\t\t\n\t\t\tfirstname ILIKE '%' || + search || '%'\n\t\t\tOR NULL,\n\t\t\tlastname ILIKE '%' || search || '%'\n\t\t\tOR + NULL,\n\t\t\tcompany ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\taddress1 + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tphone1 ILIKE '%' || search + || '%'\n\t\t\tOR NULL,\n\t\t\tphone2 ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\temail + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tcategory ILIKE '%' || search + || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 ILIKE '%' || search || '%'\n\t\t\tOR + NULL,\n\t\t\townr_addr1 ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\townr_addr1 ILIKE '%' || search + || '%'\n\t\t\tOR NULL;\n\tEND IF;\nEND\n$function$;" + type: run_sql +- args: + name: search_phonebook + schema: public + type: track_function diff --git a/hasura/migrations/1619540900896_run_sql_migration/down.yaml b/hasura/migrations/1619540900896_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1619540900896_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1619540900896_run_sql_migration/up.yaml b/hasura/migrations/1619540900896_run_sql_migration/up.yaml new file mode 100644 index 000000000..91bfa0f12 --- /dev/null +++ b/hasura/migrations/1619540900896_run_sql_migration/up.yaml @@ -0,0 +1,23 @@ +- args: + cascade: false + read_only: false + sql: "drop function search_phonebook;\nCREATE OR REPLACE FUNCTION public.search_phonebook(search + text)\n RETURNS SETOF phonebook\n LANGUAGE plpgsql\n STABLE\nAS $function$\nBEGIN\n\tIF + search = '' THEN\n\t\tRETURN query\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\tphonebook;\n\tELSE\n\t\tRETURN + query\n\t\tSELECT\n\t\t\tphonebook.*\n\t\tFROM\n\t\t\tphonebook\n\t\tWHERE firstname + ILIKE '%' || search || '%'\n\t\t\tOR lastname ILIKE '%' || search || '%'\n\t\t\tOR + company ILIKE '%' || search || '%'\n\t\t\tOR address1 ILIKE '%' || search || + '%'\n\t\t\tOR phone1 ILIKE '%' || search || '%'\n\t\t\tOR phone2 ILIKE '%' || + search || '%'\n\t\t\tOR email ILIKE '%' || search || '%'\n\t\t\tOR category + ILIKE '%' || search || '%'\n\t\tORDER BY\n\t\t\n\t\t\tfirstname ILIKE '%' || + search || '%'\n\t\t\tOR NULL,\n\t\t\tlastname ILIKE '%' || search || '%'\n\t\t\tOR + NULL,\n\t\t\tcompany ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\taddress1 + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tphone1 ILIKE '%' || search + || '%'\n\t\t\tOR NULL,\n\t\t\tphone2 ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\temail + ILIKE '%' || search || '%'\n\t\t\tOR NULL,\n\t\t\tcategory ILIKE '%' || search + || '%'\n\t\t\tOR NULL;\n\tEND IF;\nEND\n$function$;" + type: run_sql +- args: + name: search_phonebook + schema: public + type: track_function