Skip to content

Commit

Permalink
fix data sent to ajax view (wip) (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Feb 27, 2024
1 parent 9f9e66f commit 2e3342c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions samplesheets/tests/test_views_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions samplesheets/views_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
14 changes: 3 additions & 11 deletions samplesheets/vueapp/src/components/renderers/RowEditRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e3342c

Please sign in to comment.