(
column,
columns,
headerRowIndex,
mergeDuplicateHeaders,
newColumnName
)
| 148 | }; |
| 149 | |
| 150 | export function changeColumnHeader( |
| 151 | column, |
| 152 | columns, |
| 153 | headerRowIndex, |
| 154 | mergeDuplicateHeaders, |
| 155 | newColumnName |
| 156 | ) { |
| 157 | let newColumns = columns; |
| 158 | const maxLength = getHeaderRows(newColumns); |
| 159 | const columnIndex = newColumns.findIndex(col => col.id === column.id); |
| 160 | |
| 161 | if (typeof column.name === 'string' && maxLength > 1) { |
| 162 | const newColumnNames = Array(maxLength).fill(column.name); |
| 163 | const cloneColumn = R.mergeRight(column, {name: newColumnNames}); |
| 164 | newColumns = newColumns.slice(0); |
| 165 | newColumns[columnIndex] = cloneColumn; |
| 166 | } |
| 167 | |
| 168 | const {groupIndexFirst, groupIndexLast} = getGroupedColumnIndices( |
| 169 | column, |
| 170 | newColumns, |
| 171 | headerRowIndex, |
| 172 | mergeDuplicateHeaders, |
| 173 | columnIndex, |
| 174 | true |
| 175 | ); |
| 176 | |
| 177 | R.range(groupIndexFirst, groupIndexLast + 1).map(i => { |
| 178 | const namePath = [i, 'name']; |
| 179 | if (R.type(newColumns[i].name) === 'Array') { |
| 180 | namePath.push(headerRowIndex); |
| 181 | } |
| 182 | newColumns = R.set(R.lensPath(namePath), newColumnName, newColumns); |
| 183 | }); |
| 184 | |
| 185 | return {columns: newColumns}; |
| 186 | } |
| 187 | |
| 188 | export function editColumnName( |
| 189 | column, |
no test coverage detected
searching dependent graphs…