Skip to content

Commit

Permalink
4033: Use Objects.isNil to check props to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
minotogna committed Oct 18, 2024
1 parent 8fee7d3 commit 2ec91b6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
15 changes: 8 additions & 7 deletions src/meta/assessment/cols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ const cloneProps = (props: { cycleSource: Cycle; cycleTarget: Cycle; col: Col })
const _props: Col['props'] = Objects.cloneDeep(col.props)
_props.cycles.push(cycleTargetUuid)

if (_props.calculateFn?.[cycleSourceUuid])
if (!Objects.isNil(_props.calculateFn?.[cycleSourceUuid]))
_props.calculateFn[cycleTargetUuid] = Objects.cloneDeep(_props.calculateFn[cycleSourceUuid])
if (_props.classNames?.[cycleSourceUuid])
if (!Objects.isNil(_props.classNames?.[cycleSourceUuid]))
_props.classNames[cycleTargetUuid] = Objects.cloneDeep(_props.classNames[cycleSourceUuid])
if (_props.labels?.[cycleSourceUuid])
if (!Objects.isNil(_props.labels?.[cycleSourceUuid]))
_props.labels[cycleTargetUuid] = Objects.cloneDeep(_props.labels[cycleSourceUuid])
if (_props.linkedNodes?.[cycleSourceUuid])
if (!Objects.isNil(_props.linkedNodes?.[cycleSourceUuid]))
_props.linkedNodes[cycleTargetUuid] = Objects.cloneDeep(_props.linkedNodes[cycleSourceUuid])
if (_props.style?.[cycleSourceUuid]) _props.style[cycleTargetUuid] = Objects.cloneDeep(_props.style[cycleSourceUuid])
if (_props.validateFns?.[cycleSourceUuid])
if (!Objects.isNil(_props.style?.[cycleSourceUuid]))
_props.style[cycleTargetUuid] = Objects.cloneDeep(_props.style[cycleSourceUuid])
if (!Objects.isNil(_props.validateFns?.[cycleSourceUuid]))
_props.validateFns[cycleTargetUuid] = Objects.cloneDeep(_props.validateFns[cycleSourceUuid])
if (_props.variableNo?.[cycleSourceUuid])
if (!Objects.isNil(_props.variableNo?.[cycleSourceUuid]))
_props.variableNo[cycleTargetUuid] = Objects.cloneDeep(_props.variableNo[cycleSourceUuid])

return _props
Expand Down
15 changes: 8 additions & 7 deletions src/meta/assessment/rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ const cloneProps = (props: { cycleSource: Cycle; cycleTarget: Cycle; row: Row })
const _props: Row['props'] = Objects.cloneDeep(row.props)
_props.cycles.push(cycleTargetUuid)

if (_props.calculateFn?.[cycleSourceUuid])
if (!Objects.isNil(_props.calculateFn?.[cycleSourceUuid]))
_props.calculateFn[cycleTargetUuid] = Objects.cloneDeep(_props.calculateFn[cycleSourceUuid])
if (_props.calculateIf?.[cycleSourceUuid])
if (!Objects.isNil(_props.calculateIf?.[cycleSourceUuid]))
_props.calculateIf[cycleTargetUuid] = Objects.cloneDeep(_props.calculateIf[cycleSourceUuid])
if (_props.chart?.[cycleSourceUuid]) _props.chart[cycleTargetUuid] = Objects.cloneDeep(_props.chart[cycleSourceUuid])
if (_props.excludeFromDataExport?.[cycleSourceUuid])
if (!Objects.isNil(_props.chart?.[cycleSourceUuid]))
_props.chart[cycleTargetUuid] = Objects.cloneDeep(_props.chart[cycleSourceUuid])
if (!Objects.isNil(_props.excludeFromDataExport?.[cycleSourceUuid]))
_props.excludeFromDataExport[cycleTargetUuid] = Objects.cloneDeep(_props.excludeFromDataExport[cycleSourceUuid])
if (_props.linkToSection?.[cycleSourceUuid])
if (!Objects.isNil(_props.linkToSection?.[cycleSourceUuid]))
_props.linkToSection[cycleTargetUuid] = Objects.cloneDeep(_props.linkToSection[cycleSourceUuid])
if (_props.validateFns?.[cycleSourceUuid])
if (!Objects.isNil(_props.validateFns?.[cycleSourceUuid]))
_props.validateFns[cycleTargetUuid] = Objects.cloneDeep(_props.validateFns[cycleSourceUuid])
if (_props.withReview?.[cycleSourceUuid])
if (!Objects.isNil(_props.withReview?.[cycleSourceUuid]))
_props.withReview[cycleTargetUuid] = Objects.cloneDeep(_props.withReview[cycleSourceUuid])

return _props
Expand Down
4 changes: 2 additions & 2 deletions src/meta/assessment/sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const cloneProps = (props: { cycleSource: Cycle; cycleTarget: Cycle; section: Se
const _props: Section['props'] = Objects.cloneDeep(section.props)
_props.cycles.push(cycleTargetUuid)

if (_props.anchors?.[cycleSourceUuid])
if (!Objects.isNil(_props.anchors?.[cycleSourceUuid]))
_props.anchors[cycleTargetUuid] = Objects.cloneDeep(_props.anchors[cycleSourceUuid])
if (_props.labels?.[cycleSourceUuid])
if (!Objects.isNil(_props.labels?.[cycleSourceUuid]))
_props.labels[cycleTargetUuid] = Objects.cloneDeep(_props.labels[cycleSourceUuid])

return _props
Expand Down
5 changes: 3 additions & 2 deletions src/meta/assessment/subSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const cloneProps = (props: { cycleSource: Cycle; cycleTarget: Cycle; subSection:
Objects.unset(descriptionsSource, ['nationalData', 'dataSources', 'text'])
_props.descriptions[cycleTargetUuid] = descriptionsSource
}
if (_props.hidden?.[cycleSourceUuid])
if (!Objects.isNil(_props.hidden?.[cycleSourceUuid]))
_props.hidden[cycleTargetUuid] = Objects.cloneDeep(_props.hidden[cycleSourceUuid])
if (_props.hints?.[cycleSourceUuid]) _props.hints[cycleTargetUuid] = Objects.cloneDeep(_props.hints[cycleSourceUuid])
if (!Objects.isNil(_props.hints?.[cycleSourceUuid]))
_props.hints[cycleTargetUuid] = Objects.cloneDeep(_props.hints[cycleSourceUuid])

return _props
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/assessment/tableSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const cloneProps = (props: {
const _props: TableSection['props'] = Objects.cloneDeep(tableSection.props)
_props.cycles.push(cycleTargetUuid)

if (_props.descriptions?.[cycleSourceUuid])
if (!Objects.isNil(_props.descriptions?.[cycleSourceUuid]))
_props.descriptions[cycleTargetUuid] = Objects.cloneDeep(_props.descriptions[cycleSourceUuid])
if (_props.labels?.[cycleSourceUuid])
if (!Objects.isNil(_props.labels?.[cycleSourceUuid]))
Objects.cloneDeep((_props.labels[cycleTargetUuid] = _props.labels[cycleSourceUuid]))

return _props
Expand Down
10 changes: 5 additions & 5 deletions src/meta/assessment/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const cloneProps = (props: { cycleSource: Cycle; cycleTarget: Cycle; table: Tabl
const _props: Table['props'] = Objects.cloneDeep(table.props)
_props.cycles.push(cycleTargetUuid)

if (_props.cellsExportAlways?.[cycleSourceUuid])
if (!Objects.isNil(_props.cellsExportAlways?.[cycleSourceUuid]))
_props.cellsExportAlways[cycleTargetUuid] = Objects.cloneDeep(_props.cellsExportAlways[cycleSourceUuid])
if (_props.columnNames?.[cycleSourceUuid])
if (!Objects.isNil(_props.columnNames?.[cycleSourceUuid]))
_props.columnNames[cycleTargetUuid] = Objects.cloneDeep(_props.columnNames[cycleSourceUuid])
if (_props.columnsExport?.[cycleSourceUuid])
if (!Objects.isNil(_props.columnsExport?.[cycleSourceUuid]))
_props.columnsExport[cycleTargetUuid] = Objects.cloneDeep(_props.columnsExport[cycleSourceUuid])
if (_props.columnsExportAlways?.[cycleSourceUuid])
if (!Objects.isNil(_props.columnsExportAlways?.[cycleSourceUuid]))
_props.columnsExportAlways[cycleTargetUuid] = Objects.cloneDeep(_props.columnsExportAlways[cycleSourceUuid])
if (_props.disableErrorMessage?.[cycleSourceUuid])
if (!Objects.isNil(_props.disableErrorMessage?.[cycleSourceUuid]))
_props.disableErrorMessage[cycleTargetUuid] = Objects.cloneDeep(_props.disableErrorMessage[cycleSourceUuid])

return _props
Expand Down

0 comments on commit 2ec91b6

Please sign in to comment.