diff --git a/samplesheets/tests/test_views_ajax.py b/samplesheets/tests/test_views_ajax.py index 156c6c49..fbb4a6f9 100644 --- a/samplesheets/tests/test_views_ajax.py +++ b/samplesheets/tests/test_views_ajax.py @@ -1504,6 +1504,9 @@ def test_insert_study_cache(self): self.assertEqual(cache_item.data, {}) self.assertEqual(JSONCacheItem.objects.count(), 1) + # TODO: Test inserting with pooling using named processes + # TODO: Test to ensure duplicate rows are not created + class TestSheetRowDeleteAjaxView( RowEditMixin, SheetConfigMixin, SamplesheetsViewTestBase diff --git a/samplesheets/views_ajax.py b/samplesheets/views_ajax.py index a2c79e40..17ce0ad3 100644 --- a/samplesheets/views_ajax.py +++ b/samplesheets/views_ajax.py @@ -999,10 +999,11 @@ def _get_name(cls, node): """ if node['cells'][0]['obj_cls'] == 'Process': for cell in node['cells']: - if cell['header_type'] == 'process_name': + if cell.get('header_type') == 'process_name': return cell['value'] else: # Material return node['cells'][0]['value'] + return None @classmethod def _add_node_attr(cls, node_obj, cell): @@ -1191,8 +1192,15 @@ def _insert_row(self, row): ) ) + # TODO: We create duplicate rows with named processes, fix! + # Check if we'll need to consider collapsing of unnamed nodes - if len([n for n in row['nodes'] if not self._get_name(n)]) > 0: + # (References to existing nodes with UUID will not have to be collapsed) + if [ + n + for n in row['nodes'] + if not n['cells'][0].get('uuid') and not self._get_name(n) + ]: logger.debug('Unnamed node(s) in row, will attempt collapsing') collapse = True try: @@ -1390,6 +1398,8 @@ def post(self, request, *args, **kwargs): except Exception as ex: return Response({'detail': str(ex)}, status=500) except Exception as ex: + if settings.DEBUG: + raise (ex) return Response({'detail': str(ex)}, status=500) return Response(self.ok_data, status=200) diff --git a/samplesheets/vueapp/src/components/renderers/RowEditRenderer.vue b/samplesheets/vueapp/src/components/renderers/RowEditRenderer.vue index ee4d972d..2afe0908 100644 --- a/samplesheets/vueapp/src/components/renderers/RowEditRenderer.vue +++ b/samplesheets/vueapp/src/components/renderers/RowEditRenderer.vue @@ -313,25 +313,17 @@ export default Vue.extend({ let groupId = cols[startIdx].originalParent.groupId let fieldIdx = 0 // Field index within node let nodeCells = [] - let nodeClass + // let nodeClass let nodeStartIdx = startIdx for (let i = startIdx; i < cols.length - 1; i++) { - if (fieldIdx === 0) { - nodeStartIdx = i - nodeClass = cols[i].colDef.cellEditorParams.headerInfo.obj_cls - } - + if (fieldIdx === 0) nodeStartIdx = i // Add cells for new nodes, only the first node for existing ones - // TODO: This fails for process nodes (at least named ones), fix! - // TODO: We end up with all of the columns instead of just the 1st - if (nodeClass === 'Process' || - fieldIdx === 0 || + if (fieldIdx === 0 || (!this.rowNode.data[cols[i].colId].uuid && !(this.assayMode && inSampleNode))) { nodeCells.push(this.getCellData(cols[i])) } - if (i === cols.length - 1 || groupId !== cols[i + 1].originalParent.groupId) { groupId = cols[i + 1].originalParent.groupId