From f04a6fc2afc090299a159834fb0733d7e28ac458 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 27 Apr 2020 15:08:37 -0700 Subject: [PATCH] BOD-20 added onclick to production schedule + parts totals. --- bodyshop_translations.babel | 21 ++ .../job-detail-lines/job-lines.component.jsx | 26 +- .../jobs-detail-header-actions.component.jsx | 4 +- .../jobs-detail-header.component.jsx | 2 +- .../parts-status-pie.component.jsx | 43 ++++ .../production-list-detail.component.jsx | 58 +++++ .../production-list-table.component.jsx | 226 +++++++++--------- client/src/graphql/jobs.queries.js | 3 +- client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + .../1588021481109_run_sql_migration/down.yaml | 1 + .../1588021481109_run_sql_migration/up.yaml | 18 ++ .../down.yaml | 48 ++++ .../up.yaml | 50 ++++ .../down.yaml | 50 ++++ .../up.yaml | 49 ++++ .../down.yaml | 1 + .../up.yaml | 5 + .../1588023324274_run_sql_migration/down.yaml | 1 + .../1588023324274_run_sql_migration/up.yaml | 22 ++ .../down.yaml | 6 + .../up.yaml | 13 + .../down.yaml | 6 + .../up.yaml | 44 ++++ 25 files changed, 580 insertions(+), 120 deletions(-) create mode 100644 client/src/components/parts-status-pie/parts-status-pie.component.jsx create mode 100644 client/src/components/production-list-detail/production-list-detail.component.jsx create mode 100644 hasura/migrations/1588021481109_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1588021481109_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1588021714218_update_permission_user_public_table_productionview/down.yaml create mode 100644 hasura/migrations/1588021714218_update_permission_user_public_table_productionview/up.yaml create mode 100644 hasura/migrations/1588023147082_update_permission_user_public_table_productionview/down.yaml create mode 100644 hasura/migrations/1588023147082_update_permission_user_public_table_productionview/up.yaml create mode 100644 hasura/migrations/1588023310053_drop_view_public_productionview/down.yaml create mode 100644 hasura/migrations/1588023310053_drop_view_public_productionview/up.yaml create mode 100644 hasura/migrations/1588023324274_run_sql_migration/down.yaml create mode 100644 hasura/migrations/1588023324274_run_sql_migration/up.yaml create mode 100644 hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/down.yaml create mode 100644 hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/up.yaml create mode 100644 hasura/migrations/1588023375186_update_permission_user_public_table_productionview/down.yaml create mode 100644 hasura/migrations/1588023375186_update_permission_user_public_table_productionview/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index d514e7a91..e0e128297 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -11394,6 +11394,27 @@ + + jobdetail + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + note false diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index e62b0d97d..56f13572c 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -33,6 +33,19 @@ export function JobLinesComponent({ const { t } = useTranslation(); const columns = [ + { + title: t("joblines.fields.line_no"), + dataIndex: "line_no", + key: "line_no", + // onFilter: (value, record) => record.ro_number.includes(value), + // filteredValue: state.filteredInfo.text || null, + sorter: (a, b) => a.line_no - b.line_no, + sortOrder: + state.sortedInfo.columnKey === "line_no" && state.sortedInfo.order, + //ellipsis: true, + editable: true, + width: 75, + }, { title: t("joblines.fields.unq_seq"), dataIndex: "unq_seq", @@ -192,8 +205,7 @@ export function JobLinesComponent({ actions: { refetch: refetch }, context: record, }); - }} - > + }}> {t("general.actions.edit")} @@ -229,8 +241,7 @@ export function JobLinesComponent({ linesToOrder: selectedLines, }, }); - }} - > + }}> {t("parts.actions.order")} + }}> {t("joblines.actions.new")} ); }} loading={loading} - size="small" + size='small' expandedRowRender={(record) => (
{t("parts_orders.labels.orderhistory")} @@ -276,7 +286,7 @@ export function JobLinesComponent({ setSelectedLines(selectedRows), }} columns={columns.map((item) => ({ ...item }))} - rowKey="id" + rowKey='id' dataSource={jobLines} onChange={handleTableChange} /> diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index d37113716..63775e055 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -18,7 +18,7 @@ const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); -export function JobsDetailHeaderActions({ job, bodyshop }) { +export function JobsDetailHeaderActions({ job, bodyshop, refetch }) { const { t } = useTranslation(); const client = useApolloClient(); const history = useHistory(); @@ -36,7 +36,7 @@ export function JobsDetailHeaderActions({ job, bodyshop }) { AddToProduction(client, job.id)}> + onClick={() => AddToProduction(client, job.id, refetch)}> {t("jobs.actions.addtoproduction")} diff --git a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx index 7f5bc979f..fb6f814c7 100644 --- a/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx +++ b/client/src/components/jobs-detail-header/jobs-detail-header.component.jsx @@ -101,7 +101,7 @@ export function JobsDetailHeader({ }}> {t("jobs.actions.convert")} , - , + , , diff --git a/client/src/components/parts-status-pie/parts-status-pie.component.jsx b/client/src/components/parts-status-pie/parts-status-pie.component.jsx new file mode 100644 index 000000000..866a02eb2 --- /dev/null +++ b/client/src/components/parts-status-pie/parts-status-pie.component.jsx @@ -0,0 +1,43 @@ +import React, { useState } from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import { Pie } from "@nivo/pie"; +import { useTranslation } from "react-i18next"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export function PartsStatusPie({ partsList }) { + const { t } = useTranslation(); + //const [pieData, setPieData] = useState([]); + + const result = partsList + ? partsList.reduce((names, name) => { + const val = name || "?"; + const count = names[val] || 0; + names[val] = count + 1; + return names; + }, {}) + : {}; + + const pieData = Object.keys(result).map((i) => { + console.log("i", i); + return { + id: i, + label: i, + value: result[i], + }; + }); + + const commonProperties = { + width: 250, + height: 250, + margin: { top: 40, right: 60, bottom: 40, left: 60 }, + animate: true, + }; + + return ; +} +export default connect(mapStateToProps, null)(PartsStatusPie); diff --git a/client/src/components/production-list-detail/production-list-detail.component.jsx b/client/src/components/production-list-detail/production-list-detail.component.jsx new file mode 100644 index 000000000..3c4cce7eb --- /dev/null +++ b/client/src/components/production-list-detail/production-list-detail.component.jsx @@ -0,0 +1,58 @@ +import React from "react"; +import { Descriptions, Drawer } from "antd"; +import { useTranslation } from "react-i18next"; +import CurrencyFormatter from "../../utils/CurrencyFormatter"; +import { DateFormatter } from "../../utils/DateFormatter"; +import PartsPieGraph from "../parts-status-pie/parts-status-pie.component"; +import Barcode from "react-barcode"; + +export default function ProductionListDetail({ selected, setSelected, jobs }) { + const { t } = useTranslation(); + const theJob = jobs.find((j) => j.id === selected) || {}; + + return ( + setSelected(null)} + visible={!!selected}> +
+ + + + {theJob.ro_number || ""} + + + {`${theJob.ownr_fn || ""} ${theJob.ownr_ln || ""} ${ + theJob.ownr_co_nm || "" + }`} + + + {`${theJob.v_model_yr || ""} ${theJob.v_color || ""} ${ + theJob.v_make_desc || "" + } ${theJob.v_model_desc || ""}`} + + + {theJob.clm_total} + + + {theJob.actual_in} + + + {theJob.scheduled_completion} + + + + + +
+
+ ); +} diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index d5bbec173..a83f18c1d 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -1,23 +1,20 @@ -import { Table, Button, Menu, Dropdown, Input } from "antd"; -import React, { useState } from "react"; import { SyncOutlined } from "@ant-design/icons"; -import ProductionListSaveConfigButton from "../production-list-save-config-button/production-list-save-config-button.component"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import { Button, Dropdown, Input, Menu, Table } from "antd"; +import React, { useState } from "react"; +import ReactDragListView from "react-drag-listview"; //TODO Is there a better way? This library is too big. +import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import ReactDragListView from "react-drag-listview"; //TODO Is there a better way? This library is too big. -import "./production-list-table.styles.scss"; -import { useTranslation } from "react-i18next"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import ProductionListColumnsAdd from "../production-list-columns/production-list-columns.add.component"; +import ProductionListSaveConfigButton from "../production-list-save-config-button/production-list-save-config-button.component"; import ResizeableTitle from "./production-list-table.resizeable.component"; +import "./production-list-table.styles.scss"; +import ProductionListDetail from "../production-list-detail/production-list-detail.component"; const mapStateToProps = createStructuredSelector({ - //currentUser: selectCurrentUser bodyshop: selectBodyshop, }); -const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) -}); const OneCalendarDay = 60 * 60 * 24 * 1000; @@ -36,10 +33,10 @@ export function ProductionListTable({ filteredInfo: { text: "" }, } ); + const [selected, setSelected] = useState(null); const { t } = useTranslation(); - + const Now = new Date(); const handleTableChange = (pagination, filters, sorter) => { - console.log("sorter", sorter); setState({ ...state, filteredInfo: filters, @@ -68,8 +65,6 @@ export function ProductionListTable({ setColumns(nextColumns); }; - const Now = new Date(); - const headerItem = (col) => ( {col.title} ); + + const dataSource = + searchText === "" + ? data + : data.filter( + (j) => + (j.ro_number || "") + .toString() + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.ownr_fn || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.ownr_ln || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.status || "").toLowerCase().includes(searchText.toLowerCase()) || + (j.ins_co_nm || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.clm_no || "").toLowerCase().includes(searchText.toLowerCase()) || + (j.v_model_desc || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.v_make_desc || "") + .toLowerCase() + .includes(searchText.toLowerCase()) + ); + + const tableTitle = () => ( +
+ + + + setSearchText(e.target.value)} + placeholder={t("general.labels.search")} + value={searchText} + /> +
+ ); + + const handleSelectRecord = (record) => { + if (selected !== record.id) { + setSelected(record.id); + } else { + setSelected(null); + } + }; + if (!!!columns) return
No columns found.
; return ( - - ( -
- - - - setSearchText(e.target.value)} - placeholder={t("general.labels.search")} - value={searchText} - /> -
- )} - columns={columns.map((c, index) => { - return { - ...c, - sortOrder: - state.sortedInfo.columnKey === c.key && state.sortedInfo.order, - title: headerItem(c), - onHeaderCell: (column) => ({ - width: column.width, - onResize: handleResize(index), - }), - }; - })} - rowKey='id' - loading={loading} - dataSource={ - searchText === "" - ? data - : data.filter( - (j) => - (j.ro_number || "") - .toString() - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ownr_fn || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ownr_ln || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.status || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ins_co_nm || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.clm_no || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.v_model_desc || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.v_make_desc || "") - .toLowerCase() - .includes(searchText.toLowerCase()) - ) - } - onChange={handleTableChange} - rowClassName={(record, index) => { - const classes = []; - if (!!record.scheduled_completion) { - if (new Date(record.scheduled_completion) - Now < OneCalendarDay) - classes.push("production-completion-1"); - } - return classes.join(" "); - }} //TODO What could be good usage here? - onRow={(record, index) => (record.refetch = refetch)} +
+ - + +
{ + return { + ...c, + sortOrder: + state.sortedInfo.columnKey === c.key && state.sortedInfo.order, + title: headerItem(c), + onHeaderCell: (column) => ({ + width: column.width, + onResize: handleResize(index), + }), + }; + })} + rowKey='id' + loading={loading} + onRow={(record, rowIndex) => { + return { + onClick: (event) => { + handleSelectRecord(record); + }, + }; + }} + dataSource={dataSource} + onChange={handleTableChange} + rowClassName={(record, index) => { + const classes = []; //TODO What could be good usage here? + if (!!record.scheduled_completion) { + if (new Date(record.scheduled_completion) - Now < OneCalendarDay) + classes.push("production-completion-1"); + } + return classes.join(" "); + }} + /> + + ); } -export default connect( - mapStateToProps, - mapDispatchToProps -)(ProductionListTable); +export default connect(mapStateToProps, null)(ProductionListTable); diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index 8fb11526b..0e4e83490 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -104,6 +104,7 @@ export const SUBSCRIPTION_JOBS_IN_PRODUCTION = gql` production_vars labhrs larhrs + partcount } } `; @@ -248,7 +249,7 @@ export const GET_JOB_BY_PK = gql` date_exported status owner_owing - + joblines { id unq_seq diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index d37849a89..23cfff0d8 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -739,6 +739,7 @@ "bodyhours": "B", "bodypriority": "B/P", "cycletime": "C/T", + "jobdetail": "Job Details", "note": "Production Note", "paintpriority": "P/P", "refinishhours": "R" diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index cdb468941..7e345dc89 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -739,6 +739,7 @@ "bodyhours": "", "bodypriority": "", "cycletime": "", + "jobdetail": "", "note": "", "paintpriority": "", "refinishhours": "" diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 04c8c61dd..60a5e7e83 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -739,6 +739,7 @@ "bodyhours": "", "bodypriority": "", "cycletime": "", + "jobdetail": "", "note": "", "paintpriority": "", "refinishhours": "" diff --git a/hasura/migrations/1588021481109_run_sql_migration/down.yaml b/hasura/migrations/1588021481109_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1588021481109_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1588021481109_run_sql_migration/up.yaml b/hasura/migrations/1588021481109_run_sql_migration/up.yaml new file mode 100644 index 000000000..b34cb0c10 --- /dev/null +++ b/hasura/migrations/1588021481109_run_sql_migration/up.yaml @@ -0,0 +1,18 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE VIEW \"public\".\"productionview\" AS \n SELECT j.id,\n + \ j.status,\n j.ro_number,\n j.est_number,\n j.ownr_fn,\n j.ownr_ln,\n + \ j.v_model_yr,\n j.v_model_desc,\n j.clm_no,\n j.v_make_desc,\n + \ j.v_color,\n j.plate_no,\n j.actual_in,\n j.scheduled_completion,\n + \ j.scheduled_delivery,\n j.ins_co_nm,\n j.clm_total,\n j.ownr_ph1,\n + \ j.special_coverage_policy,\n j.production_vars,\n lab.labhrs,\n lar.larhrs,\n + \ j.shopid,\n parts.*\n FROM ((jobs j\n LEFT JOIN ( SELECT l.jobid,\n + \ sum(l.mod_lb_hrs) AS labhrs\n FROM joblines l\n WHERE + (l.mod_lbr_ty = 'LAB'::text)\n GROUP BY l.jobid) lab ON ((lab.jobid + = j.id)))\n LEFT JOIN ( SELECT l2.jobid,\n sum(l2.mod_lb_hrs) + AS larhrs\n FROM joblines l2\n WHERE (l2.mod_lbr_ty = 'LAR'::text)\n + \ GROUP BY l2.jobid) lar ON ((lar.jobid = j.id)))\n left join ( select + \ l3.jobid, json_agg(l3.status) partcount from joblines l3 group by l3.jobid, + l3.status ) parts on parts.jobid = j.id\n WHERE (j.inproduction = true);" + type: run_sql diff --git a/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/down.yaml b/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/down.yaml new file mode 100644 index 000000000..b828c15b8 --- /dev/null +++ b/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/down.yaml @@ -0,0 +1,48 @@ +- args: + role: user + table: + name: productionview + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - id + - status + - ro_number + - est_number + - ownr_fn + - ownr_ln + - v_model_yr + - v_model_desc + - clm_no + - v_make_desc + - v_color + - plate_no + - actual_in + - scheduled_completion + - scheduled_delivery + - ins_co_nm + - clm_total + - ownr_ph1 + - special_coverage_policy + - production_vars + - labhrs + - larhrs + - shopid + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: productionview + schema: public + type: create_select_permission diff --git a/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/up.yaml b/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/up.yaml new file mode 100644 index 000000000..2e6370f32 --- /dev/null +++ b/hasura/migrations/1588021714218_update_permission_user_public_table_productionview/up.yaml @@ -0,0 +1,50 @@ +- args: + role: user + table: + name: productionview + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - actual_in + - clm_no + - clm_total + - est_number + - id + - ins_co_nm + - jobid + - labhrs + - larhrs + - ownr_fn + - ownr_ln + - ownr_ph1 + - partcount + - plate_no + - production_vars + - ro_number + - scheduled_completion + - scheduled_delivery + - shopid + - special_coverage_policy + - status + - v_color + - v_make_desc + - v_model_desc + - v_model_yr + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: productionview + schema: public + type: create_select_permission diff --git a/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/down.yaml b/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/down.yaml new file mode 100644 index 000000000..2e6370f32 --- /dev/null +++ b/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/down.yaml @@ -0,0 +1,50 @@ +- args: + role: user + table: + name: productionview + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - actual_in + - clm_no + - clm_total + - est_number + - id + - ins_co_nm + - jobid + - labhrs + - larhrs + - ownr_fn + - ownr_ln + - ownr_ph1 + - partcount + - plate_no + - production_vars + - ro_number + - scheduled_completion + - scheduled_delivery + - shopid + - special_coverage_policy + - status + - v_color + - v_make_desc + - v_model_desc + - v_model_yr + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: productionview + schema: public + type: create_select_permission diff --git a/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/up.yaml b/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/up.yaml new file mode 100644 index 000000000..dbf40fea5 --- /dev/null +++ b/hasura/migrations/1588023147082_update_permission_user_public_table_productionview/up.yaml @@ -0,0 +1,49 @@ +- args: + role: user + table: + name: productionview + schema: public + type: drop_select_permission +- args: + permission: + allow_aggregations: false + columns: + - actual_in + - clm_no + - clm_total + - est_number + - id + - ins_co_nm + - jobid + - labhrs + - larhrs + - ownr_fn + - ownr_ln + - ownr_ph1 + - plate_no + - production_vars + - ro_number + - scheduled_completion + - scheduled_delivery + - shopid + - special_coverage_policy + - status + - v_color + - v_make_desc + - v_model_desc + - v_model_yr + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + role: user + table: + name: productionview + schema: public + type: create_select_permission diff --git a/hasura/migrations/1588023310053_drop_view_public_productionview/down.yaml b/hasura/migrations/1588023310053_drop_view_public_productionview/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1588023310053_drop_view_public_productionview/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1588023310053_drop_view_public_productionview/up.yaml b/hasura/migrations/1588023310053_drop_view_public_productionview/up.yaml new file mode 100644 index 000000000..6e88a06bd --- /dev/null +++ b/hasura/migrations/1588023310053_drop_view_public_productionview/up.yaml @@ -0,0 +1,5 @@ +- args: + cascade: false + read_only: false + sql: DROP VIEW "public"."productionview"; + type: run_sql diff --git a/hasura/migrations/1588023324274_run_sql_migration/down.yaml b/hasura/migrations/1588023324274_run_sql_migration/down.yaml new file mode 100644 index 000000000..fe51488c7 --- /dev/null +++ b/hasura/migrations/1588023324274_run_sql_migration/down.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/migrations/1588023324274_run_sql_migration/up.yaml b/hasura/migrations/1588023324274_run_sql_migration/up.yaml new file mode 100644 index 000000000..087db6700 --- /dev/null +++ b/hasura/migrations/1588023324274_run_sql_migration/up.yaml @@ -0,0 +1,22 @@ +- args: + cascade: true + read_only: false + sql: "CREATE OR REPLACE VIEW \"public\".\"productionview\" AS \n SELECT j.id,\n + \ j.status,\n j.ro_number,\n j.est_number,\n j.ownr_fn,\n j.ownr_ln,\n + \ j.v_model_yr,\n j.v_model_desc,\n j.clm_no,\n j.v_make_desc,\n + \ j.v_color,\n j.plate_no,\n j.actual_in,\n j.scheduled_completion,\n + \ j.scheduled_delivery,\n j.ins_co_nm,\n j.clm_total,\n j.ownr_ph1,\n + \ j.special_coverage_policy,\n j.production_vars,\n lab.labhrs,\n lar.larhrs,\n + \ j.shopid,\n parts.partcount\n FROM ((jobs j\n LEFT JOIN ( SELECT + l.jobid,\n sum(l.mod_lb_hrs) AS labhrs\n FROM joblines + l\n WHERE (l.mod_lbr_ty = 'LAB'::text)\n GROUP BY l.jobid) + lab ON ((lab.jobid = j.id)))\n LEFT JOIN ( SELECT l2.jobid,\n sum(l2.mod_lb_hrs) + AS larhrs\n FROM joblines l2\n WHERE (l2.mod_lbr_ty = 'LAR'::text)\n + \ GROUP BY l2.jobid) lar ON ((lar.jobid = j.id)))\n left join ( select + \ l3.jobid, json_agg(l3.status) partcount from joblines l3 group by l3.jobid + ) parts on parts.jobid = j.id\n WHERE (j.inproduction = true);" + type: run_sql +- args: + name: productionview + schema: public + type: add_existing_table_or_view diff --git a/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/down.yaml b/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/down.yaml new file mode 100644 index 000000000..c8bccabac --- /dev/null +++ b/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/down.yaml @@ -0,0 +1,6 @@ +- args: + relationship: bodyshop + table: + name: productionview + schema: public + type: drop_relationship diff --git a/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/up.yaml b/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/up.yaml new file mode 100644 index 000000000..b91854674 --- /dev/null +++ b/hasura/migrations/1588023349497_create_relationship_bodyshop_public_table_productionview/up.yaml @@ -0,0 +1,13 @@ +- args: + name: bodyshop + table: + name: productionview + schema: public + using: + manual_configuration: + column_mapping: + shopid: id + remote_table: + name: bodyshops + schema: public + type: create_object_relationship diff --git a/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/down.yaml b/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/down.yaml new file mode 100644 index 000000000..d2ca2e22f --- /dev/null +++ b/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/down.yaml @@ -0,0 +1,6 @@ +- args: + role: user + table: + name: productionview + schema: public + type: drop_select_permission diff --git a/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/up.yaml b/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/up.yaml new file mode 100644 index 000000000..4b1ca46d8 --- /dev/null +++ b/hasura/migrations/1588023375186_update_permission_user_public_table_productionview/up.yaml @@ -0,0 +1,44 @@ +- args: + permission: + allow_aggregations: false + columns: + - id + - status + - ro_number + - est_number + - ownr_fn + - ownr_ln + - v_model_yr + - v_model_desc + - clm_no + - v_make_desc + - v_color + - plate_no + - actual_in + - scheduled_completion + - scheduled_delivery + - ins_co_nm + - clm_total + - ownr_ph1 + - special_coverage_policy + - production_vars + - labhrs + - larhrs + - shopid + - partcount + computed_fields: [] + filter: + bodyshop: + associations: + _and: + - user: + authid: + _eq: X-Hasura-User-Id + - active: + _eq: true + limit: null + role: user + table: + name: productionview + schema: public + type: create_select_permission