Skip to content

Commit d0cb9ef

Browse files
authored
chain: layout adjustments (#4178)
* chain: layout adjustments (buttons bar); * keep chain "quantitiative" and "categorical" translations * code cleanup * code cleanup * code cleanup; merging chain statistical analysis form into sampling design form * moved to sampling design form only necessary fields * code cleanup * code cleanup * code cleanup * code cleanup --------- Co-authored-by: Stefano Ricci <SteRiccio@users.noreply.github.com>
1 parent 3430716 commit d0cb9ef

18 files changed

Lines changed: 267 additions & 154 deletions

File tree

core/i18n/resources/en/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ It can be simple text or Markdown language (https://www.markdownguide.org).`,
720720
surveyNotPublished: '$t(chainView.cannotStartRStudio.common): publish the survey first',
721721
},
722722
nonResponseBiasCorrection: 'Non-response bias correction',
723-
nonResponseBiasCorrectionTip: `To implement this method, add 'design_psu' and 'design_ssu' into the stratum category as extra properties.`,
723+
nonResponseBiasCorrectionInfo: `To implement this method, add 'design_psu' and 'design_ssu' into the stratum category as extra properties.`,
724724
pValue: 'P-value',
725725
resultsBackFromRStudio: 'Results read back from RStudio',
726726
samplingDesign: 'Sampling Design',
@@ -744,6 +744,7 @@ It can be simple text or Markdown language (https://www.markdownguide.org).`,
744744
dimensionsSeparate: 'Dimensions separately',
745745
},
746746
reportingArea: 'Total reporting area (ha) (Optional)',
747+
reportingAreaInfo: `With stratified sampling, give areas of strata within the stratum attribute's category table (column name 'area')`,
747748
},
748749
stratumAttribute: 'Stratum attribute',
749750
postStratificationAttribute: 'Post stratification attribute',
@@ -795,6 +796,8 @@ $t(common.cantUndoWarning)`,
795796
chain: {
796797
quantitative: 'Quantitative',
797798
categorical: 'Categorical',
799+
addQuantitative: 'Add quantitative attribute',
800+
addCategorical: 'Add categorical attribute',
798801
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
799802
entityExcludedInRStudioScripts:
800803
'the entity and all the related result variables will be excluded in the RStudio scripts',

core/i18n/resources/es/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ export default {
590590
surveyNotPublished: '$t(chainView.cannotStartRStudio.common): primero publique la encuesta',
591591
},
592592
nonResponseBiasCorrection: 'Corrección de sesgo por no respuesta',
593-
nonResponseBiasCorrectionTip:
593+
nonResponseBiasCorrectionInfo:
594594
"Para implementar este método, agregue 'design_psu' y 'design_ssu' a la categoría de estrato como propiedades adicionales.",
595595
pValue: 'Valor P',
596596
resultsBackFromRStudio: 'Resultados leídos de RStudio',
@@ -615,6 +615,7 @@ export default {
615615
dimensionsSeparate: 'Dimensiones por separado',
616616
},
617617
reportingArea: 'Área total de informe (ha) (Opcional)',
618+
reportingAreaInfo: `Con muestreo estratificado, proporcione las áreas de los estratos en la tabla de categorías del atributo de estrato (nombre de la columna 'area')`,
618619
},
619620
stratumAttribute: 'Atributo de estrato',
620621
postStratificationAttribute: 'Atributo de postestratificación',
@@ -649,6 +650,8 @@ export default {
649650
chain: {
650651
quantitative: 'Cuantitativo',
651652
categorical: 'Categórico',
653+
addQuantitative: 'Agregar atributo cuantitativo',
654+
addCategorical: 'Agregar atributo categórico',
652655
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
653656
entityExcludedInRStudioScripts:
654657
'la entidad y todas las variables de resultado relacionadas se excluirán en los scripts de RStudio',

core/i18n/resources/fr/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ Il peut être du texte simple ou du langage Markdown (https://www.markdownguide.
724724
surveyNotPublished: "$t(chainView.cannotStartRStudio.common) : publiez d'abord le formulaire",
725725
},
726726
nonResponseBiasCorrection: 'Correction du biais de non-réponse',
727-
nonResponseBiasCorrectionTip: `Pour implémenter cette méthode, ajoutez 'design_psu' et 'design_ssu' dans la catégorie de strate comme propriétés supplémentaires.`,
727+
nonResponseBiasCorrectionInfo: `Pour implémenter cette méthode, ajoutez 'design_psu' et 'design_ssu' dans la catégorie de strate comme propriétés supplémentaires.`,
728728
pValue: 'Valeur P',
729729
resultsBackFromRStudio: 'Résultats relus depuis RStudio',
730730
samplingDesign: "Plan d'échantillonnage",
@@ -748,6 +748,7 @@ Il peut être du texte simple ou du langage Markdown (https://www.markdownguide.
748748
dimensionsSeparate: 'Dimensions séparément',
749749
},
750750
reportingArea: 'Surface totale de rapport (ha) (Optionnel)',
751+
reportingAreaInfo: `Avec un échantillonnage stratifié, indiquez les superficies des strates dans la table de catégories de l'attribut de strate (nom de la colonne 'area')`,
751752
},
752753
stratumAttribute: 'Attribut de strate',
753754
postStratificationAttribute: 'Attribut de post-stratification',
@@ -800,6 +801,8 @@ $t(common.cantUndoWarning)`,
800801
chain: {
801802
quantitative: 'Quantitatif',
802803
categorical: 'Catégoriel',
804+
addQuantitative: 'Ajouter un attribut quantitatif',
805+
addCategorical: 'Ajouter un attribut catégoriel',
803806
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
804807
entityExcludedInRStudioScripts:
805808
"l'entité et toutes les variables de résultats associées seront exclues des scripts RStudio",

core/i18n/resources/mn/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ $t(common.raiseTicketInSupportForum)
702702
surveyNotPublished: '$t(chainView.cannotStartRStudio.common): эхлээд судалгааг нийтлэх',
703703
},
704704
nonResponseBiasCorrection: 'Хариу өгөхгүй байх хазайлт засварлах',
705-
nonResponseBiasCorrectionTip: `Энэ аргыг хэрэгжүүлэхийн тулд "design_psu" болон "design_ssu"-г давхаргын ангилалд нэмэлт шинж чанар болгон нэмнэ үү.`,
705+
nonResponseBiasCorrectionInfo: `Энэ аргыг хэрэгжүүлэхийн тулд "design_psu" болон "design_ssu"-г давхаргын ангилалд нэмэлт шинж чанар болгон нэмнэ үү.`,
706706
pValue: 'P-утга',
707707
resultsBackFromRStudio: 'RStudio-оос үр дүнг буцааж уншсан',
708708
samplingDesign: 'Түүвэрлэлтийн загвар',
@@ -726,6 +726,7 @@ $t(common.raiseTicketInSupportForum)
726726
dimensionsSeparate: 'Хэмжээсүүдийг тусад нь',
727727
},
728728
reportingArea: 'Нийт тайлагнах талбай (га) (Заавал биш)',
729+
reportingAreaInfo: `Үечилсэн түүвэрлэлтийн хувьд үечилсэн шинж чанарын ангиллын хүснэгтэд давхаргуудын талбайг оруулна уу (баганын нэр 'area')`,
729730
},
730731
stratumAttribute: 'Үеийн шинж чанар',
731732
postStratificationAttribute: 'Дараах үечилсэн шинж чанар',
@@ -769,6 +770,8 @@ $t(common.cantUndoWarning)`,
769770
chain: {
770771
quantitative: 'Тоон',
771772
categorical: 'Ангиллын',
773+
addQuantitative: 'Тоон шинж чанар нэмэх',
774+
addCategorical: 'Ангиллын шинж чанар нэмэх',
772775
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
773776
entityExcludedInRStudioScripts:
774777
'объект болон түүнтэй холбоотой бүх үр дүнгийн хувьсагчид RStudio скриптүүдэд хасагдана',

core/i18n/resources/pt/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ Obrigado e aproveite **$t(common.appNameFull)**!`,
721721
surveyNotPublished: '$t(chainView.cannotStartRStudio.common): publique o inventário primeiro',
722722
},
723723
nonResponseBiasCorrection: 'Correção de viés de não resposta',
724-
nonResponseBiasCorrectionTip: `Para implementar este método, adicione 'design_psu' e 'design_ssu' na categoria de estrato como propriedades extras.`,
724+
nonResponseBiasCorrectionInfo: `Para implementar este método, adicione 'design_psu' e 'design_ssu' na categoria de estrato como propriedades extras.`,
725725
pValue: 'Valor-p',
726726
resultsBackFromRStudio: 'Resultados lidos de volta do RStudio',
727727
samplingDesign: 'Desenho amostral',
@@ -745,6 +745,7 @@ Obrigado e aproveite **$t(common.appNameFull)**!`,
745745
dimensionsSeparate: 'Dimensões separadamente',
746746
},
747747
reportingArea: 'Área total de reporte (ha) (Opcional)',
748+
reportingAreaInfo: `Com amostragem estratificada, forneça as áreas dos estratos na tabela de categorias do atributo de estrato (nome da coluna 'area')`,
748749
},
749750
stratumAttribute: 'Atributo de estrato',
750751
postStratificationAttribute: 'Atributo de pós-estratificação',
@@ -796,6 +797,8 @@ $t(common.cantUndoWarning)`,
796797
chain: {
797798
quantitative: 'Quantitativo',
798799
categorical: 'Categórico',
800+
addQuantitative: 'Adicionar atributo quantitativo',
801+
addCategorical: 'Adicionar atributo categórico',
799802
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
800803
entityExcludedInRStudioScripts:
801804
'a entidade e todas as variáveis de resultado relacionadas serão excluídas dos scripts do RStudio',

core/i18n/resources/ru/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ $t(common.raiseTicketInSupportForum)
701701
surveyNotPublished: '$t(chainView.cannotStartRStudio.common): сначала опубликуйте опрос',
702702
},
703703
nonResponseBiasCorrection: 'Коррекция смещения из-за неответной реакции',
704-
nonResponseBiasCorrectionTip: `Для реализации этого метода добавьте 'design_psu' и 'design_ssu' в категорию страты как дополнительные свойства.`,
704+
nonResponseBiasCorrectionInfo: `Для реализации этого метода добавьте 'design_psu' и 'design_ssu' в категорию страты как дополнительные свойства.`,
705705
pValue: 'P-значение',
706706
resultsBackFromRStudio: 'Результаты получены из RStudio',
707707
samplingDesign: 'Дизайн выборки',
@@ -725,6 +725,7 @@ $t(common.raiseTicketInSupportForum)
725725
dimensionsSeparate: 'Измерения отдельно',
726726
},
727727
reportingArea: 'Общая площадь отчетности (га) (Необязательно)',
728+
reportingAreaInfo: `При стратифицированной выборке укажите площади страт в таблице категорий атрибута страты (название столбца 'area')`,
728729
},
729730
stratumAttribute: 'Атрибут страты',
730731
postStratificationAttribute: 'Атрибут послестратификации',
@@ -776,6 +777,8 @@ $t(common.cantUndoWarning)`,
776777
chain: {
777778
quantitative: 'Количественный',
778779
categorical: 'Категориальный',
780+
addQuantitative: 'Добавить количественный атрибут',
781+
addCategorical: 'Добавить категориальный атрибут',
779782
emptyNodeDefs: '$t(validationErrors:analysis.analysisNodeDefsRequired)',
780783
entityExcludedInRStudioScripts:
781784
'сущность и все связанные результирующие переменные будут исключены из скриптов RStudio',

webapp/components/buttons/Button.js

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ const getLabel = (props, t) => {
3030
return label
3131
}
3232

33+
const Icon = (props) => {
34+
const { icon, iconAlt, iconClassName, iconHeight, iconSrc, iconWidth, alignLeft, alignRight } = props
35+
return (
36+
<>
37+
{iconClassName && (
38+
<span className={classNames('icon', iconClassName, { 'icon-left': alignLeft, 'icon-right': alignRight })} />
39+
)}
40+
{iconSrc && <img alt={iconAlt} height={iconHeight} src={iconSrc} width={iconWidth} />}
41+
{icon}
42+
</>
43+
)
44+
}
45+
46+
Icon.propTypes = {
47+
alignLeft: PropTypes.bool,
48+
alignRight: PropTypes.bool,
49+
icon: PropTypes.node,
50+
iconAlt: PropTypes.string,
51+
iconClassName: PropTypes.string,
52+
iconHeight: PropTypes.number,
53+
iconSrc: PropTypes.string,
54+
iconWidth: PropTypes.number,
55+
}
56+
3357
export const Button = forwardRef((props, ref) => {
3458
const {
3559
active,
@@ -42,6 +66,9 @@ export const Button = forwardRef((props, ref) => {
4266
iconClassName,
4367
iconHeight,
4468
iconSrc,
69+
iconEnd = null,
70+
iconEndClassName = null,
71+
iconEndSrc = null,
4572
iconWidth,
4673
id,
4774
isTitleMarkdown = false,
@@ -78,17 +105,38 @@ export const Button = forwardRef((props, ref) => {
78105
color={color}
79106
data-testid={testId}
80107
disabled={disabled ? disabled : undefined}
108+
endIcon={
109+
showIcon &&
110+
(iconEnd || iconEndClassName || iconEndSrc) && (
111+
<Icon
112+
icon={iconEnd}
113+
iconAlt={iconAlt}
114+
iconClassName={iconEndClassName}
115+
iconHeight={iconHeight}
116+
iconSrc={iconEndSrc}
117+
iconWidth={iconWidth}
118+
alignRight={Boolean(label)}
119+
/>
120+
)
121+
}
81122
onClick={onClick}
123+
startIcon={
124+
showIcon &&
125+
(icon || iconClassName || iconSrc) && (
126+
<Icon
127+
alignLeft={Boolean(label)}
128+
icon={icon}
129+
iconAlt={iconAlt}
130+
iconClassName={iconClassName}
131+
iconHeight={iconHeight}
132+
iconSrc={iconSrc}
133+
iconWidth={iconWidth}
134+
/>
135+
)
136+
}
82137
variant={variant}
83138
{...otherProps}
84139
>
85-
{showIcon && (
86-
<>
87-
{iconClassName && <span className={classNames('icon', iconClassName, { 'icon-left': Boolean(label) })} />}
88-
{iconSrc && <img alt={iconAlt} height={iconHeight} src={iconSrc} width={iconWidth} />}
89-
{icon}
90-
</>
91-
)}
92140
{label}
93141
{children}
94142
</MuiButton>
@@ -122,6 +170,9 @@ Button.propTypes = {
122170
iconHeight: PropTypes.number,
123171
iconSrc: PropTypes.string,
124172
iconWidth: PropTypes.number,
173+
iconEnd: PropTypes.node,
174+
iconEndClassName: PropTypes.string,
175+
iconEndSrc: PropTypes.string,
125176
isTitleMarkdown: PropTypes.bool,
126177
label: PropTypes.string,
127178
labelIsI18nKey: PropTypes.bool,

webapp/components/survey/SurveyForm/nodeDefs/nodeDefUIProps.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ const keyIcon = <span className="icon icon-key icon-left" />
3838

3939
const propsUI = {
4040
[integer]: {
41-
icon: <span className="icon-left node_def__icon">123</span>,
41+
icon: <span className="icon icon-left node_def__icon">123</span>,
4242
numberFormat: NumberFormats.integer(),
4343
defaultValue: '',
4444
},
4545

4646
[decimal]: {
47-
icon: <span className="icon-left node_def__icon">1.23</span>,
47+
icon: <span className="icon icon-left node_def__icon">1.23</span>,
4848
numberFormat: NumberFormats.decimal(),
4949
defaultValue: '',
5050
},
5151

5252
[text]: {
53-
icon: <span className="icon-left node_def__icon">ABC</span>,
53+
icon: <span className="icon icon-left node_def__icon">ABC</span>,
5454
defaultValue: '',
5555
},
5656

webapp/views/App/views/Analysis/Chain/AnalysisNodeDefs/AnalysisNodeDefsHeader/AnalysisNodeDefsHeader.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import * as Chain from '@common/analysis/chain'
77
import * as NodeDef from '@core/survey/nodeDef'
88

99
import { ChainActions, useChain } from '@webapp/store/ui/chain'
10-
import { useI18n } from '@webapp/store/system'
1110

1211
import * as NodeDefUIProps from '@webapp/components/survey/SurveyForm/nodeDefs/nodeDefUIProps'
12+
import { Button } from '@webapp/components'
1313
import { Checkbox } from '@webapp/components/form'
1414

1515
const AnalysisNodeDefsHeader = ({ toggleShowSamplingNodeDefs, showSamplingNodeDefs }) => {
1616
const dispatch = useDispatch()
1717
const navigate = useNavigate()
18-
const i18n = useI18n()
1918
const chain = useChain()
2019

2120
const createNodeDef = (type) => dispatch(ChainActions.createNodeDef({ navigate, type }))
@@ -31,15 +30,18 @@ const AnalysisNodeDefsHeader = ({ toggleShowSamplingNodeDefs, showSamplingNodeDe
3130
/>
3231
)}
3332
<div className="analysis-node-defs-header__buttons">
34-
<div>
35-
{i18n.t('common.add')} <span className="icon icon-plus icon-12px" />
36-
</div>
37-
<button className="btn btn-s" onClick={() => createNodeDef(NodeDef.nodeDefType.decimal)} type="button">
38-
{i18n.t('chain.quantitative')} {NodeDefUIProps.getIconByType(NodeDef.nodeDefType.decimal)}
39-
</button>
40-
<button className="btn btn-s" onClick={() => createNodeDef(NodeDef.nodeDefType.code)} type="button">
41-
{i18n.t('chain.categorical')} {NodeDefUIProps.getIconByType(NodeDef.nodeDefType.code)}
42-
</button>
33+
<Button
34+
iconClassName="icon-plus"
35+
iconEnd={NodeDefUIProps.getIconByType(NodeDef.nodeDefType.decimal)}
36+
label="common:chain.addQuantitative"
37+
onClick={() => createNodeDef(NodeDef.nodeDefType.decimal)}
38+
/>
39+
<Button
40+
iconClassName="icon-plus"
41+
iconEnd={NodeDefUIProps.getIconByType(NodeDef.nodeDefType.code)}
42+
label="common:chain.addCategorical"
43+
onClick={() => createNodeDef(NodeDef.nodeDefType.code)}
44+
/>
4345
</div>
4446
</div>
4547
</div>

webapp/views/App/views/Analysis/Chain/AnalysisNodeDefs/AnalysisNodeDefsHeader/AnalysisNodeDefsHeader.scss

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,11 @@
77
}
88

99
.analysis-node-defs-header__buttons {
10-
background-color: rgba($greyBorder, 0.6);
1110
display: flex;
1211
align-items: center;
1312
padding: 4px 8px;
1413
height: 3rem;
15-
16-
div {
17-
margin-right: 8px;
18-
}
19-
20-
button {
21-
margin-left: 8px;
22-
display: flex;
23-
justify-content: space-between;
24-
font-weight: 600;
25-
min-width: 144px;
26-
27-
.icon {
28-
font-size: 0.8rem !important;
29-
}
30-
31-
.icon-left {
32-
margin-right: unset;
33-
}
34-
}
14+
gap: 1rem;
3515
}
3616

3717
.analysis-node-defs-header__buttons_container {
@@ -41,4 +21,4 @@
4121

4222
.analysis-node-defs-header__filter {
4323
margin-right: 8px;
44-
}
24+
}

0 commit comments

Comments
 (0)