From f9176983080a0adbc57a26c7d4824dd6acefc173 Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:40:23 +0200 Subject: [PATCH 1/5] fixed layout of forms with attributes becoming relevant (#3014) * fixed layout of forms with attributes becoming relevant * restored old code * fixed tests --------- Co-authored-by: Stefano Ricci --- core/survey/nodeDefLayout.js | 4 +++- core/survey/survey.js | 1 + .../nodeDefs/components/types/nodeDefEntitySwitch.js | 9 ++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/survey/nodeDefLayout.js b/core/survey/nodeDefLayout.js index c3fdaa6f58..7607fd8556 100644 --- a/core/survey/nodeDefLayout.js +++ b/core/survey/nodeDefLayout.js @@ -92,9 +92,11 @@ export const getLayoutChildrenCompressed = : // item in another row, can have the same x of the previous one Math.min(itemPrev.x, xOriginal) + const prevYDiff = itemPrev.yOriginal - itemPrev.y + const y = sameRowOfPreviousItem ? // item can have the same y of the previous one - Math.min(itemPrev.y, yOriginal) + yOriginal - prevYDiff : // item in another row, move it yPrev + hPrev Math.min(itemPrev.y + itemPrev.h, yOriginal) diff --git a/core/survey/survey.js b/core/survey/survey.js index 526e4c9283..495884225d 100644 --- a/core/survey/survey.js +++ b/core/survey/survey.js @@ -149,6 +149,7 @@ export const { getNodeDefChildren, getNodeDefChildrenInOwnPage, hasNodeDefChildrenEntities, + getNodeDefChildrenSorted, getNodeDefChildByName, getNodeDefSiblingByName, getNodeDefByName, diff --git a/webapp/components/survey/SurveyForm/nodeDefs/components/types/nodeDefEntitySwitch.js b/webapp/components/survey/SurveyForm/nodeDefs/components/types/nodeDefEntitySwitch.js index 914a1eefb5..517360796a 100644 --- a/webapp/components/survey/SurveyForm/nodeDefs/components/types/nodeDefEntitySwitch.js +++ b/webapp/components/survey/SurveyForm/nodeDefs/components/types/nodeDefEntitySwitch.js @@ -2,7 +2,6 @@ import './nodeDefEntitySwitch.scss' import React from 'react' -import * as A from '@core/arena' import * as Survey from '@core/survey/survey' import * as NodeDef from '@core/survey/nodeDef' import * as NodeDefLayout from '@core/survey/nodeDefLayout' @@ -20,20 +19,20 @@ const componentsByRenderType = { const NodeDefEntitySwitch = (props) => { const { surveyCycleKey, nodeDef } = props + const survey = useSurvey() + const renderType = NodeDefLayout.getRenderType(surveyCycleKey)(nodeDef) if (!renderType) { // node def not in current cycle return null } - const survey = useSurvey() - const includeAnalysis = false - const childDefs = Survey.getNodeDefChildren(props.nodeDef, includeAnalysis)(survey) + const childDefs = Survey.getNodeDefChildrenSorted({ nodeDef, includeAnalysis, cycle: surveyCycleKey })(survey) const nodeDefName = NodeDef.getName(nodeDef) const childUuids = NodeDefLayout.getLayoutChildrenUuids(surveyCycleKey)(nodeDef) - const childNames = childUuids.map((childUuid) => A.pipe(Survey.getNodeDefByUuid(childUuid), NodeDef.getName)(survey)) + const childNames = Survey.getNodeDefsByUuids(childUuids)(survey).map(NodeDef.getName) return (
Date: Mon, 18 Sep 2023 18:56:14 +0200 Subject: [PATCH 2/5] fixed node defs import batch insert (#3015) Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../nodeDef/repository/nodeDefRepository.js | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/server/modules/nodeDef/repository/nodeDefRepository.js b/server/modules/nodeDef/repository/nodeDefRepository.js index c571aea7a8..78791da969 100644 --- a/server/modules/nodeDef/repository/nodeDefRepository.js +++ b/server/modules/nodeDef/repository/nodeDefRepository.js @@ -71,13 +71,12 @@ export const insertNodeDef = async (surveyId, nodeDef, client = DB) => (row) => dbTransformCallback({ row, draft: true, advanced: true }) // Always loading draft when creating or updating a nodeDef ) -export const insertNodeDefsBatch = async ({ surveyId, nodeDefs, backup = false }, client = DB) => - client.tx(async (tx) => { - const schema = getSurveyDBSchema(surveyId) - await tx.batch([ - nodeDefs.map((nodeDef) => - tx.none( - ` +export const insertNodeDefsBatch = async ({ surveyId, nodeDefs, backup = false }, client = DB) => { + const schema = getSurveyDBSchema(surveyId) + return client.batch([ + nodeDefs.map((nodeDef) => + client.none( + ` INSERT INTO ${schema}.node_def ( parent_uuid, uuid, @@ -93,22 +92,22 @@ export const insertNodeDefsBatch = async ({ surveyId, nodeDefs, backup = false } $4::jsonb, $5::jsonb, $6::jsonb, $7::jsonb, $8,$9,$10)`, - [ - NodeDef.getParentUuid(nodeDef), - nodeDef.uuid, - NodeDef.getType(nodeDef), - backup ? NodeDef.getProps(nodeDef) : {}, - backup ? NodeDef.getPropsDraft(nodeDef) : NodeDef.getProps(nodeDef), - backup ? NodeDef.getPropsAdvanced(nodeDef) : {}, - backup ? NodeDef.getPropsAdvancedDraft(nodeDef) : NodeDef.getPropsAdvanced(nodeDef), - NodeDef.getMeta(nodeDef), - NodeDef.isAnalysis(nodeDef), - NodeDef.isVirtual(nodeDef), - ] - ) - ), - ]) - }) + [ + NodeDef.getParentUuid(nodeDef), + nodeDef.uuid, + NodeDef.getType(nodeDef), + backup ? NodeDef.getProps(nodeDef) : {}, + backup ? NodeDef.getPropsDraft(nodeDef) : NodeDef.getProps(nodeDef), + backup ? NodeDef.getPropsAdvanced(nodeDef) : {}, + backup ? NodeDef.getPropsAdvancedDraft(nodeDef) : NodeDef.getPropsAdvanced(nodeDef), + NodeDef.getMeta(nodeDef), + NodeDef.isAnalysis(nodeDef), + NodeDef.isVirtual(nodeDef), + ] + ) + ), + ]) +} // ============== READ From 270fa49109680f54b54fedd86e708db0ac0ca9af Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Mon, 18 Sep 2023 19:10:16 +0200 Subject: [PATCH 3/5] records list layout adjustments (#3016) * records list layout adjustments * layout adjustments --------- Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- .../VisibleColumnsMenu/VisibleColumnsMenu.js | 1 + webapp/style/table.scss | 4 +--- .../Data/Records/HeaderLeft/HeaderLeft.js | 1 - .../Data/Records/HeaderLeft/HeaderLeft.scss | 20 ++++++++++++------- .../views/App/views/Data/Records/Records.js | 5 +++++ .../App/views/Data/Records/useColumns.js | 17 +++++++++++----- .../useNodeDefKeysCategoryItemsInLevel.js | 14 +++++++++---- 7 files changed, 42 insertions(+), 20 deletions(-) diff --git a/webapp/components/Table/Header/VisibleColumnsMenu/VisibleColumnsMenu.js b/webapp/components/Table/Header/VisibleColumnsMenu/VisibleColumnsMenu.js index f4d98ee4f3..e613571b40 100644 --- a/webapp/components/Table/Header/VisibleColumnsMenu/VisibleColumnsMenu.js +++ b/webapp/components/Table/Header/VisibleColumnsMenu/VisibleColumnsMenu.js @@ -28,6 +28,7 @@ export const VisibleColumnsMenu = (props) => { return ( { diff --git a/webapp/style/table.scss b/webapp/style/table.scss index d1c4aef7e8..b45325dbcf 100644 --- a/webapp/style/table.scss +++ b/webapp/style/table.scss @@ -1,6 +1,6 @@ @import 'webapp/style/vars'; -$tableHeaderHeight: 30px; +$tableHeaderHeight: 40px; $tableFooterHeight: 30px; .table { @@ -10,7 +10,6 @@ $tableFooterHeight: 30px; } .table__header { - height: $tableHeaderHeight; display: flex; align-items: center; justify-content: space-between; @@ -25,7 +24,6 @@ $tableFooterHeight: 30px; } .table__footer { - height: $tableFooterHeight; display: flex; justify-content: flex-end; } diff --git a/webapp/views/App/views/Data/Records/HeaderLeft/HeaderLeft.js b/webapp/views/App/views/Data/Records/HeaderLeft/HeaderLeft.js index 98ba5b190f..5c404adbf0 100644 --- a/webapp/views/App/views/Data/Records/HeaderLeft/HeaderLeft.js +++ b/webapp/views/App/views/Data/Records/HeaderLeft/HeaderLeft.js @@ -77,7 +77,6 @@ const HeaderLeft = ({ handleSearch, navigateToRecord, onRecordsUpdate, search, s