Skip to content

Commit

Permalink
#1256 | Override nested card name, textColor and cardBackgroundColor …
Browse files Browse the repository at this point in the history
…based on queryResponse
  • Loading branch information
himeshr committed Jan 24, 2024
1 parent 1135a09 commit 68ea8f6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
14 changes: 7 additions & 7 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions packages/openchs-android/src/service/RuleEvaluationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 11 additions & 7 deletions packages/openchs-android/src/views/customDashboard/CardListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) ?
<ActivityIndicator size="large" color="#0000ff" style={{paddingVertical: 25}}/> :
<ActivityIndicator size="large" color={textColor} style={{paddingVertical: 25}}/> :
<CountResult
direction={'column'}
primary={countResult.primaryValue}
secondary={countResult.secondaryValue}
primaryStyle={styles.primaryTextStyle}
secondaryStyle={styles.secondaryTextStyle}
primaryStyle={[styles.primaryTextStyle, {color: textColor}]}
secondaryStyle={[styles.secondaryTextStyle, {color: textColor}]}
/>
)
};
Expand All @@ -25,11 +29,11 @@ export const CardListView = ({reportCard, I18n, onCardPress, countResult}) => {
<View key={itemKey} style={styles.container}>
<View style={styles.rowContainer}>
<View style={styles.nameContainer}>
<Text style={styles.nameTextStyle}>{I18n.t(name)}</Text>
<Text style={styles.nameTextStyle}>{I18n.t(cardName)}</Text>
</View>
<View style={[styles.numberContainer, {backgroundColor: colour}]}>
<View style={[styles.numberContainer, {backgroundColor: cardColor}]}>
<View style={{alignSelf: 'center'}}>
{renderNumber()}
{renderNumber(textColor)}
</View>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TouchableNativeFeedback onPress={() => onCardPress(itemKey)} disabled={!get(countResult, 'clickable')}>
Expand All @@ -46,7 +48,7 @@ export const CardTileView = ({index, reportCard, I18n, onCardPress, countResult}
<View style={{height: 30, marginBottom: 10}}>
{renderNumber(countResult, textColor)}
</View>
<Text style={[styles.cardNameTextStyle, {color: textColor}]}>{I18n.t(name)}</Text>
<Text style={[styles.cardNameTextStyle, {color: textColor}]}>{I18n.t(cardName)}</Text>
</View>
{iconName && renderIcon(iconName, textColor)}
</View>
Expand Down

0 comments on commit 68ea8f6

Please sign in to comment.