From 90a3d98f81fb1a5410b179a14cb8cd4c31c25edf Mon Sep 17 00:00:00 2001 From: roxy-dao Date: Thu, 14 Nov 2024 16:39:11 +1300 Subject: [PATCH 1/5] Migrations for extra fields store pref --- .../src/db_diesel/store_preference_row.rs | 2 ++ .../add_store_pref_use_extra_fields.rs | 20 +++++++++++++++++++ .../repository/src/migrations/v2_04_00/mod.rs | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 server/repository/src/migrations/v2_04_00/add_store_pref_use_extra_fields.rs diff --git a/server/repository/src/db_diesel/store_preference_row.rs b/server/repository/src/db_diesel/store_preference_row.rs index e9d284abe6..a25261b158 100644 --- a/server/repository/src/db_diesel/store_preference_row.rs +++ b/server/repository/src/db_diesel/store_preference_row.rs @@ -26,6 +26,7 @@ table! { months_understock -> Double, months_items_expire -> Double, stocktake_frequency -> Double, + extra_fields_in_requisition -> Bool, } } @@ -60,6 +61,7 @@ pub struct StorePreferenceRow { pub months_understock: f64, pub months_items_expire: f64, pub stocktake_frequency: f64, + pub extra_fields_in_requisition: bool, } pub struct StorePreferenceRowRepository<'a> { diff --git a/server/repository/src/migrations/v2_04_00/add_store_pref_use_extra_fields.rs b/server/repository/src/migrations/v2_04_00/add_store_pref_use_extra_fields.rs new file mode 100644 index 0000000000..9d015a8b2f --- /dev/null +++ b/server/repository/src/migrations/v2_04_00/add_store_pref_use_extra_fields.rs @@ -0,0 +1,20 @@ +use crate::migrations::*; + +pub(crate) struct Migrate; + +impl MigrationFragment for Migrate { + fn identifier(&self) -> &'static str { + "add_store_pref_use_extra_fields" + } + + fn migrate(&self, connection: &StorageConnection) -> anyhow::Result<()> { + sql!( + connection, + r#" + ALTER TABLE store_preference ADD extra_fields_in_requisition BOOLEAN NOT NULL DEFAULT FALSE; + "# + )?; + + Ok(()) + } +} diff --git a/server/repository/src/migrations/v2_04_00/mod.rs b/server/repository/src/migrations/v2_04_00/mod.rs index 329ddb8add..f41a356546 100644 --- a/server/repository/src/migrations/v2_04_00/mod.rs +++ b/server/repository/src/migrations/v2_04_00/mod.rs @@ -7,6 +7,7 @@ mod add_expected_lifespan_to_assets; mod add_item_variant_id_to_stock_line_and_invoice_line; mod add_manual_requisition_line_fields; mod add_reason_option_table; +mod add_store_pref_use_extra_fields; mod add_unserviceable_status_to_asset_status_enum; mod delete_pack_variant; mod indicator_line_column_create_tables; @@ -42,6 +43,7 @@ impl Migration for V2_04_00 { Box::new(indicator_value_create_table::Migrate), Box::new(add_bundled_item_table::Migrate), Box::new(add_demographic_indicator_types_to_activity_log::Migrate), + Box::new(add_store_pref_use_extra_fields::Migrate), ] } } From fc5a17f82266a5ac542105d5632fca45eb7a51a3 Mon Sep 17 00:00:00 2001 From: roxy-dao Date: Thu, 14 Nov 2024 16:40:34 +1300 Subject: [PATCH 2/5] Sync extra fields --- server/service/src/sync/test/test_data/store_preference.rs | 4 +++- server/service/src/sync/translations/store_preference.rs | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/service/src/sync/test/test_data/store_preference.rs b/server/service/src/sync/test/test_data/store_preference.rs index 117d46e1cf..9448159532 100644 --- a/server/service/src/sync/test/test_data/store_preference.rs +++ b/server/service/src/sync/test/test_data/store_preference.rs @@ -104,7 +104,7 @@ const STORE_PREFERENCE_2: (&str, &str) = ( "includeRequisitionsInSuppliersRemoteAuthorisationProcesses": true, "canLinkRequisitionToSupplierInvoice": false, "responseRequisitionAutoFillSupplyQuantity": false, - "useExtraFieldsForRequisitions": false, + "useExtraFieldsForRequisitions": true, "CommentFieldToBeShownOnSupplierInvoiceLines": false, "UseEDDPlaceholderLinesOnSupplierInvoice": false, "consolidateBatches": false, @@ -156,6 +156,7 @@ pub(crate) fn test_pull_upsert_records() -> Vec { months_understock: 4.42, months_items_expire: 2.12, stocktake_frequency: 1.34, + extra_fields_in_requisition: false, }, ), TestSyncIncomingRecord::new_pull_upsert( @@ -177,6 +178,7 @@ pub(crate) fn test_pull_upsert_records() -> Vec { months_understock: 3.0, months_items_expire: 3.0, stocktake_frequency: 1.0, + extra_fields_in_requisition: true, }, ), ] diff --git a/server/service/src/sync/translations/store_preference.rs b/server/service/src/sync/translations/store_preference.rs index eb6fcb53c6..c80af36d36 100644 --- a/server/service/src/sync/translations/store_preference.rs +++ b/server/service/src/sync/translations/store_preference.rs @@ -61,6 +61,9 @@ pub struct LegacyPrefData { #[serde(default)] #[serde(rename = "stocktakeFrequency")] pub stocktake_frequency: f64, + #[serde(default)] + #[serde(rename = "useExtraFieldsForRequisitions")] + pub extra_fields_in_requisition: bool, } // Needs to be added to all_translators() @@ -110,6 +113,7 @@ impl SyncTranslation for StorePreferenceTranslation { months_understock, months_items_expire, stocktake_frequency, + extra_fields_in_requisition, } = data; let result = StorePreferenceRow { @@ -127,6 +131,7 @@ impl SyncTranslation for StorePreferenceTranslation { months_understock, months_items_expire, stocktake_frequency, + extra_fields_in_requisition, }; Ok(PullTranslateResult::upsert(result)) From a364d011f2522d6d69a93fe0f7cfca923ca8ce35 Mon Sep 17 00:00:00 2001 From: roxy-dao Date: Thu, 14 Nov 2024 16:41:27 +1300 Subject: [PATCH 3/5] Expose extra fields in GraphQL --- server/graphql/types/src/types/store_preference.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/graphql/types/src/types/store_preference.rs b/server/graphql/types/src/types/store_preference.rs index e2199bec4d..28797c3dec 100644 --- a/server/graphql/types/src/types/store_preference.rs +++ b/server/graphql/types/src/types/store_preference.rs @@ -62,6 +62,10 @@ impl StorePreferenceNode { pub async fn stocktake_frequency(&self) -> &f64 { &self.store_preference.stocktake_frequency } + + pub async fn extra_fields_in_requisition(&self) -> &bool { + &self.store_preference.extra_fields_in_requisition + } } impl StorePreferenceNode { From 5896854eb10c55402e78bb880eb25ed851a9fe59 Mon Sep 17 00:00:00 2001 From: roxy-dao Date: Thu, 14 Nov 2024 16:49:19 +1300 Subject: [PATCH 4/5] Expose extra field pref in frontend --- .../api/operations.generated.ts | 5 +- .../src/authentication/api/operations.graphql | 1 + client/packages/common/src/types/schema.ts | 104 +++++++++++++++++- 3 files changed, 107 insertions(+), 3 deletions(-) diff --git a/client/packages/common/src/authentication/api/operations.generated.ts b/client/packages/common/src/authentication/api/operations.generated.ts index 27c261d2e3..e3931e0c0f 100644 --- a/client/packages/common/src/authentication/api/operations.generated.ts +++ b/client/packages/common/src/authentication/api/operations.generated.ts @@ -3,7 +3,7 @@ import * as Types from '@openmsupply-client/common'; import { GraphQLClient, RequestOptions } from 'graphql-request'; import gql from 'graphql-tag'; type GraphQLClientRequestHeaders = RequestOptions['requestHeaders']; -export type UserStoreNodeFragment = { __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number } }; +export type UserStoreNodeFragment = { __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number, extraFieldsInRequisition: boolean } }; export type AuthTokenQueryVariables = Types.Exact<{ username: Types.Scalars['String']['input']; @@ -16,7 +16,7 @@ export type AuthTokenQuery = { __typename: 'Queries', authToken: { __typename: ' export type MeQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type MeQuery = { __typename: 'Queries', me: { __typename: 'UserNode', email?: string | null, language: Types.LanguageType, username: string, userId: string, firstName?: string | null, lastName?: string | null, phoneNumber?: string | null, jobTitle?: string | null, defaultStore?: { __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number } } | null, stores: { __typename: 'UserStoreConnector', totalCount: number, nodes: Array<{ __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number } }> } } }; +export type MeQuery = { __typename: 'Queries', me: { __typename: 'UserNode', email?: string | null, language: Types.LanguageType, username: string, userId: string, firstName?: string | null, lastName?: string | null, phoneNumber?: string | null, jobTitle?: string | null, defaultStore?: { __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number, extraFieldsInRequisition: boolean } } | null, stores: { __typename: 'UserStoreConnector', totalCount: number, nodes: Array<{ __typename: 'UserStoreNode', code: string, id: string, nameId: string, name: string, storeMode: Types.StoreModeNodeType, createdDate?: string | null, homeCurrencyCode?: string | null, isDisabled: boolean, preferences: { __typename: 'StorePreferenceNode', id: string, responseRequisitionRequiresAuthorisation: boolean, requestRequisitionRequiresAuthorisation: boolean, packToOne: boolean, omProgramModule: boolean, vaccineModule: boolean, issueInForeignCurrency: boolean, monthlyConsumptionLookBackPeriod: number, monthsLeadTime: number, monthsOverstock: number, monthsUnderstock: number, monthsItemsExpire: number, stocktakeFrequency: number, extraFieldsInRequisition: boolean } }> } } }; export type IsCentralServerQueryVariables = Types.Exact<{ [key: string]: never; }>; @@ -75,6 +75,7 @@ export const UserStoreNodeFragmentDoc = gql` monthsUnderstock monthsItemsExpire stocktakeFrequency + extraFieldsInRequisition } createdDate homeCurrencyCode diff --git a/client/packages/common/src/authentication/api/operations.graphql b/client/packages/common/src/authentication/api/operations.graphql index 0407136c61..549526ea96 100644 --- a/client/packages/common/src/authentication/api/operations.graphql +++ b/client/packages/common/src/authentication/api/operations.graphql @@ -18,6 +18,7 @@ fragment UserStoreNode on UserStoreNode { monthsUnderstock monthsItemsExpire stocktakeFrequency + extraFieldsInRequisition } createdDate homeCurrencyCode diff --git a/client/packages/common/src/types/schema.ts b/client/packages/common/src/types/schema.ts index 9cab1ca79b..255447a41b 100644 --- a/client/packages/common/src/types/schema.ts +++ b/client/packages/common/src/types/schema.ts @@ -2350,6 +2350,45 @@ export type InboundInvoiceCounts = { notDelivered: Scalars['Int']['output']; }; +export type IndicatorColumnNode = { + __typename: 'IndicatorColumnNode'; + columnNumber: Scalars['Int']['output']; + name: Scalars['String']['output']; + value?: Maybe; + valueType: IndicatorValueTypeNode; +}; + + +export type IndicatorColumnNodeValueArgs = { + customerNameLinkId: Scalars['String']['input']; + periodId: Scalars['String']['input']; + storeId: Scalars['String']['input']; +}; + +export type IndicatorLineNode = { + __typename: 'IndicatorLineNode'; + columns: Array; + line: IndicatorLineRowNode; +}; + +export type IndicatorLineRowNode = { + __typename: 'IndicatorLineRowNode'; + code: Scalars['String']['output']; + lineNumber: Scalars['Int']['output']; + name: Scalars['String']['output']; +}; + +export type IndicatorValueNode = { + __typename: 'IndicatorValueNode'; + id: Scalars['String']['output']; + value: Scalars['String']['output']; +}; + +export enum IndicatorValueTypeNode { + Number = 'NUMBER', + String = 'STRING' +} + export type InitialisationStatusNode = { __typename: 'InitialisationStatusNode'; siteName?: Maybe; @@ -4048,6 +4087,7 @@ export type Mutations = { updateInboundShipment: UpdateInboundShipmentResponse; updateInboundShipmentLine: UpdateInboundShipmentLineResponse; updateInboundShipmentServiceLine: UpdateInboundShipmentServiceLineResponse; + updateIndicatorValue: UpdateIndicatorValueResponse; updateLabelPrinterSettings: UpdateLabelPrinterSettingsResponse; updateLocation: UpdateLocationResponse; updateLogLevel: UpsertLogLevelResponse; @@ -4566,6 +4606,12 @@ export type MutationsUpdateInboundShipmentServiceLineArgs = { }; +export type MutationsUpdateIndicatorValueArgs = { + input: UpdateIndicatorValueInput; + storeId: Scalars['String']['input']; +}; + + export type MutationsUpdateLabelPrinterSettingsArgs = { input: LabelPrinterSettingsInput; }; @@ -5400,6 +5446,37 @@ export type ProgramFilterInput = { name?: InputMaybe; }; +export type ProgramIndicatorConnector = { + __typename: 'ProgramIndicatorConnector'; + nodes: Array; + totalCount: Scalars['Int']['output']; +}; + +export type ProgramIndicatorFilterInput = { + id?: InputMaybe; + programId?: InputMaybe; +}; + +export type ProgramIndicatorNode = { + __typename: 'ProgramIndicatorNode'; + code?: Maybe; + id: Scalars['String']['output']; + lineAndColumns: Array; + program: ProgramNode; +}; + +export type ProgramIndicatorResponse = ProgramIndicatorConnector; + +export enum ProgramIndicatorSortFieldInput { + Code = 'code', + ProgramId = 'programId' +} + +export type ProgramIndicatorSortInput = { + desc?: InputMaybe; + key: ProgramIndicatorSortFieldInput; +}; + export type ProgramNode = { __typename: 'ProgramNode'; id: Scalars['String']['output']; @@ -5564,6 +5641,7 @@ export type Queries = { plugins: Array; programEnrolments: ProgramEnrolmentResponse; programEvents: ProgramEventResponse; + programIndicators: ProgramIndicatorResponse; programs: ProgramsResponse; rAndRForm: RnRFormResponse; rAndRForms: RnRFormsResponse; @@ -6054,6 +6132,13 @@ export type QueriesProgramEventsArgs = { }; +export type QueriesProgramIndicatorsArgs = { + filter?: InputMaybe; + sort?: InputMaybe; + storeId: Scalars['String']['input']; +}; + + export type QueriesProgramsArgs = { filter?: InputMaybe; page?: InputMaybe; @@ -6341,7 +6426,7 @@ export type RecordBelongsToAnotherStore = DeleteAssetErrorInterface & DeleteAsse description: Scalars['String']['output']; }; -export type RecordNotFound = AddFromMasterListErrorInterface & AddToInboundShipmentFromMasterListErrorInterface & AddToOutboundShipmentFromMasterListErrorInterface & AllocateOutboundShipmentUnallocatedLineErrorInterface & CreateRequisitionShipmentErrorInterface & DeleteAssetCatalogueItemErrorInterface & DeleteAssetErrorInterface & DeleteAssetLogReasonErrorInterface & DeleteCustomerReturnErrorInterface & DeleteErrorInterface & DeleteInboundShipmentErrorInterface & DeleteInboundShipmentLineErrorInterface & DeleteInboundShipmentServiceLineErrorInterface & DeleteLocationErrorInterface & DeleteOutboundShipmentLineErrorInterface & DeleteOutboundShipmentServiceLineErrorInterface & DeleteOutboundShipmentUnallocatedLineErrorInterface & DeletePrescriptionErrorInterface & DeletePrescriptionLineErrorInterface & DeleteRequestRequisitionErrorInterface & DeleteRequestRequisitionLineErrorInterface & DeleteResponseRequisitionErrorInterface & DeleteResponseRequisitionLineErrorInterface & DeleteSupplierReturnErrorInterface & DeleteVaccineCourseErrorInterface & NodeErrorInterface & RequisitionLineChartErrorInterface & RequisitionLineStatsErrorInterface & ScannedDataParseErrorInterface & SupplyRequestedQuantityErrorInterface & UpdateAssetErrorInterface & UpdateErrorInterface & UpdateInboundShipmentErrorInterface & UpdateInboundShipmentLineErrorInterface & UpdateInboundShipmentServiceLineErrorInterface & UpdateLocationErrorInterface & UpdateNameErrorInterface & UpdateNamePropertiesErrorInterface & UpdateOutboundShipmentLineErrorInterface & UpdateOutboundShipmentServiceLineErrorInterface & UpdateOutboundShipmentUnallocatedLineErrorInterface & UpdatePrescriptionErrorInterface & UpdatePrescriptionLineErrorInterface & UpdateRequestRequisitionErrorInterface & UpdateRequestRequisitionLineErrorInterface & UpdateResponseRequisitionErrorInterface & UpdateResponseRequisitionLineErrorInterface & UpdateReturnOtherPartyErrorInterface & UpdateSensorErrorInterface & UpdateStockLineErrorInterface & UseSuggestedQuantityErrorInterface & { +export type RecordNotFound = AddFromMasterListErrorInterface & AddToInboundShipmentFromMasterListErrorInterface & AddToOutboundShipmentFromMasterListErrorInterface & AllocateOutboundShipmentUnallocatedLineErrorInterface & CreateRequisitionShipmentErrorInterface & DeleteAssetCatalogueItemErrorInterface & DeleteAssetErrorInterface & DeleteAssetLogReasonErrorInterface & DeleteCustomerReturnErrorInterface & DeleteErrorInterface & DeleteInboundShipmentErrorInterface & DeleteInboundShipmentLineErrorInterface & DeleteInboundShipmentServiceLineErrorInterface & DeleteLocationErrorInterface & DeleteOutboundShipmentLineErrorInterface & DeleteOutboundShipmentServiceLineErrorInterface & DeleteOutboundShipmentUnallocatedLineErrorInterface & DeletePrescriptionErrorInterface & DeletePrescriptionLineErrorInterface & DeleteRequestRequisitionErrorInterface & DeleteRequestRequisitionLineErrorInterface & DeleteResponseRequisitionErrorInterface & DeleteResponseRequisitionLineErrorInterface & DeleteSupplierReturnErrorInterface & DeleteVaccineCourseErrorInterface & NodeErrorInterface & RequisitionLineChartErrorInterface & RequisitionLineStatsErrorInterface & ScannedDataParseErrorInterface & SupplyRequestedQuantityErrorInterface & UpdateAssetErrorInterface & UpdateErrorInterface & UpdateInboundShipmentErrorInterface & UpdateInboundShipmentLineErrorInterface & UpdateInboundShipmentServiceLineErrorInterface & UpdateIndicatorValueErrorInterface & UpdateLocationErrorInterface & UpdateNameErrorInterface & UpdateNamePropertiesErrorInterface & UpdateOutboundShipmentLineErrorInterface & UpdateOutboundShipmentServiceLineErrorInterface & UpdateOutboundShipmentUnallocatedLineErrorInterface & UpdatePrescriptionErrorInterface & UpdatePrescriptionLineErrorInterface & UpdateRequestRequisitionErrorInterface & UpdateRequestRequisitionLineErrorInterface & UpdateResponseRequisitionErrorInterface & UpdateResponseRequisitionLineErrorInterface & UpdateReturnOtherPartyErrorInterface & UpdateSensorErrorInterface & UpdateStockLineErrorInterface & UseSuggestedQuantityErrorInterface & { __typename: 'RecordNotFound'; description: Scalars['String']['output']; }; @@ -7240,6 +7325,7 @@ export type StoreNodeNameArgs = { export type StorePreferenceNode = { __typename: 'StorePreferenceNode'; + extraFieldsInRequisition: Scalars['Boolean']['output']; id: Scalars['String']['output']; issueInForeignCurrency: Scalars['Boolean']['output']; monthlyConsumptionLookBackPeriod: Scalars['Float']['output']; @@ -7843,6 +7929,22 @@ export enum UpdateInboundShipmentStatusInput { Verified = 'VERIFIED' } +export type UpdateIndicatorValueError = { + __typename: 'UpdateIndicatorValueError'; + error: UpdateIndicatorValueErrorInterface; +}; + +export type UpdateIndicatorValueErrorInterface = { + description: Scalars['String']['output']; +}; + +export type UpdateIndicatorValueInput = { + id: Scalars['String']['input']; + value: Scalars['String']['input']; +}; + +export type UpdateIndicatorValueResponse = IndicatorValueNode | UpdateIndicatorValueError; + export type UpdateLabelPrinterSettingsError = { __typename: 'UpdateLabelPrinterSettingsError'; error: Scalars['String']['output']; From d674f72facf5c2610795106a73246b59d7289bfe Mon Sep 17 00:00:00 2001 From: roxy-dao Date: Thu, 14 Nov 2024 16:53:45 +1300 Subject: [PATCH 5/5] Add check to hide extra columns for normal programs --- .../DetailView/ResponseLineEdit/ResponseLineEdit.tsx | 10 ++++++---- .../src/ResponseRequisition/DetailView/columns.ts | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/packages/requisitions/src/ResponseRequisition/DetailView/ResponseLineEdit/ResponseLineEdit.tsx b/client/packages/requisitions/src/ResponseRequisition/DetailView/ResponseLineEdit/ResponseLineEdit.tsx index 28d9b8ca19..0333f3d01c 100644 --- a/client/packages/requisitions/src/ResponseRequisition/DetailView/ResponseLineEdit/ResponseLineEdit.tsx +++ b/client/packages/requisitions/src/ResponseRequisition/DetailView/ResponseLineEdit/ResponseLineEdit.tsx @@ -14,6 +14,7 @@ import { Popover, ReasonOptionNodeType, TextArea, + useAuthContext, useToggle, } from '@openmsupply-client/common'; import { useResponse } from '../../api'; @@ -49,6 +50,7 @@ export const ResponseLineEdit = ({ isProgram, }: ResponseLineEditProps) => { const t = useTranslation(); + const { store } = useAuthContext(); const { isOn: ourStats, toggle: toggleOurStats } = useToggle(); const { isOn: theirStats, toggle: toggleTheirStats } = useToggle(); const { data } = useResponse.line.stats(draft?.id); @@ -107,7 +109,7 @@ export const ResponseLineEdit = ({ sx={{ marginBottom: 1 }} /> )} - {isProgram && ( + {isProgram && store?.preferences.extraFieldsInRequisition && ( <> - {isProgram && ( + {isProgram && store?.preferences.extraFieldsInRequisition && ( - {isProgram && ( + {isProgram && store?.preferences.extraFieldsInRequisition && ( - {isProgram && ( + {isProgram && store?.preferences.extraFieldsInRequisition && ( { updateSortQuery, queryParams: { sortBy }, } = useUrlQueryParams({ initialSort: { key: 'itemName', dir: 'asc' } }); + const { store } = useAuthContext(); const { isRemoteAuthorisation } = useResponse.utils.isRemoteAuthorisation(); const { programName } = useResponse.document.fields(['programName']); @@ -71,7 +73,7 @@ export const useResponseColumns = () => { accessor: ({ rowData }) => rowData.availableStockOnHand, }); } - if (programName) { + if (programName && store?.preferences?.extraFieldsInRequisition) { columnDefinitions.push( // TODO: Global pref to show/hide the next columns { @@ -234,7 +236,7 @@ export const useResponseColumns = () => { ]); // TODO: Global pref to show/hide column - if (programName) { + if (programName && store?.preferences?.extraFieldsInRequisition) { columnDefinitions.push({ key: 'reason', label: 'label.reason',