From 68ea8f636afe8c7bb6acba8eea7b055c826e116d Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 24 Jan 2024 13:17:42 +0530 Subject: [PATCH] avniproject/avni-client#1256 | Override nested card name, textColor and cardBackgroundColor based on queryResponse --- packages/openchs-android/package-lock.json | 14 +++++++------- .../src/service/RuleEvaluationService.js | 11 +++++------ .../src/views/customDashboard/CardListView.js | 18 +++++++++++------- .../src/views/customDashboard/CardTileView.js | 8 +++++--- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index 8776fdbe2..4da5f1e74 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -33,7 +33,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.31.23", + "openchs-models": "1.31.24", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.3", @@ -16433,9 +16433,9 @@ } }, "node_modules/openchs-models": { - "version": "1.31.23", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.23.tgz", - "integrity": "sha512-LLMRT313pTlCIplIcg76hNUyvVqlaPR8qGnRLyOG/3x3f1bijVkzBuOBe2eHPDuJH0hLMtGh4RZ2Tr+OuQ4MfA==", + "version": "1.31.24", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.24.tgz", + "integrity": "sha512-A2FhW4ZzwDDQsm+MEIo+04S5J/kcDTXn9CfPjRzy/SAuHQZn1vx6Q4TT8iiktZeQvE3Jx37KBpzhBSy10iJ2sA==", "dependencies": { "uuid": "^9.0.1" }, @@ -35159,9 +35159,9 @@ } }, "openchs-models": { - "version": "1.31.23", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.23.tgz", - "integrity": "sha512-LLMRT313pTlCIplIcg76hNUyvVqlaPR8qGnRLyOG/3x3f1bijVkzBuOBe2eHPDuJH0hLMtGh4RZ2Tr+OuQ4MfA==", + "version": "1.31.24", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.24.tgz", + "integrity": "sha512-A2FhW4ZzwDDQsm+MEIo+04S5J/kcDTXn9CfPjRzy/SAuHQZn1vx6Q4TT8iiktZeQvE3Jx37KBpzhBSy10iJ2sA==", "requires": { "uuid": "^9.0.1" } diff --git a/packages/openchs-android/src/service/RuleEvaluationService.js b/packages/openchs-android/src/service/RuleEvaluationService.js index cafcd4dc3..3cc55c2f8 100644 --- a/packages/openchs-android/src/service/RuleEvaluationService.js +++ b/packages/openchs-android/src/service/RuleEvaluationService.js @@ -710,12 +710,11 @@ class RuleEvaluationService extends BaseService { } else if (reportCard.nested) { return _.map(queryResult.reportCards, (reportCardResultsItr, index) => { return { - textColor: reportCard.textColor, - cardColor: reportCard.cardColor, - ...reportCardResultsItr, - clickable: _.isFunction(reportCardResultsItr.lineListFunction), - itemKey: reportCard.getCardId(index), - reportCardUUID: reportCard.uuid + cardColor: reportCard.colour, + ...reportCardResultsItr, + clickable: _.isFunction(reportCardResultsItr.lineListFunction), + itemKey: reportCard.getCardId(index), + reportCardUUID: reportCard.uuid }; }); } else { diff --git a/packages/openchs-android/src/views/customDashboard/CardListView.js b/packages/openchs-android/src/views/customDashboard/CardListView.js index c1a399a67..947571825 100644 --- a/packages/openchs-android/src/views/customDashboard/CardListView.js +++ b/packages/openchs-android/src/views/customDashboard/CardListView.js @@ -7,15 +7,19 @@ import {get} from 'lodash'; export const CardListView = ({reportCard, I18n, onCardPress, countResult}) => { const {name, colour, itemKey} = reportCard; - const renderNumber = () => { + const cardName = (countResult && countResult.cardName) || name; + const textColor = (countResult && countResult.textColor) || '#ffffff'; + const cardColor = (countResult && countResult.cardColor) || colour || '#0000ff'; + + const renderNumber = (textColor) => { return (_.isNil(get(countResult, 'primaryValue')) ? - : + : ) }; @@ -25,11 +29,11 @@ export const CardListView = ({reportCard, I18n, onCardPress, countResult}) => { - {I18n.t(name)} + {I18n.t(cardName)} - + - {renderNumber()} + {renderNumber(textColor)} diff --git a/packages/openchs-android/src/views/customDashboard/CardTileView.js b/packages/openchs-android/src/views/customDashboard/CardTileView.js index 4a96e3f6a..0d8ea487f 100644 --- a/packages/openchs-android/src/views/customDashboard/CardTileView.js +++ b/packages/openchs-android/src/views/customDashboard/CardTileView.js @@ -28,9 +28,11 @@ const renderNumber = function (countResult, textColor) { const cardGap = 16; export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult}) => { - const {name, itemKey, textColor, iconName} = reportCard; + const {name, colour, itemKey, iconName} = reportCard; const cardWidth = (Dimensions.get('window').width - cardGap * 3) / 2; - const cardColor = reportCard.cardColor || '#ffffff'; + const cardName = (countResult && countResult.cardName) || name; + const textColor = (countResult && countResult.textColor) || '#ffffff'; + const cardColor = (countResult && countResult.cardColor) || colour || '#ffffff'; return ( onCardPress(itemKey)} disabled={!get(countResult, 'clickable')}> @@ -46,7 +48,7 @@ export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult} {renderNumber(countResult, textColor)} - {I18n.t(name)} + {I18n.t(cardName)} {iconName && renderIcon(iconName, textColor)}