diff --git a/jupyter-openbis-extension/static/state.js b/jupyter-openbis-extension/static/state.js index b63805681c87effe51d45f46042b0c2b02023416..e5008e9d8fc526181418951394435ce514c632a6 100644 --- a/jupyter-openbis-extension/static/state.js +++ b/jupyter-openbis-extension/static/state.js @@ -8,8 +8,10 @@ define([], uploadDataSetType: null, uploadDataSetTypes: {}, uploadEntityIdentifier: '', - getSelectedDataSets: () => [], - getSelectedFiles: () => [] + datasetCheckboxes: [], + fileCheckboxes: [], + selectedFiles: [], + unselectedDatasets: [] } } ) \ No newline at end of file diff --git a/jupyter-openbis-extension/static/uploadDialog.js b/jupyter-openbis-extension/static/uploadDialog.js index 55e73c064a0f1660ff9579fa5565724538ed9611..c32a1636876bdfd93ce6cbcc7ad7be897d1f10b1 100644 --- a/jupyter-openbis-extension/static/uploadDialog.js +++ b/jupyter-openbis-extension/static/uploadDialog.js @@ -40,7 +40,7 @@ define([ .then(function(data){ var values = Object.keys(data.files) values.sort() - state.getSelectedFiles = createSelectTable(values, container, false) + state.fileCheckboxes = createSelectTable(values, container, false, state.selectedFiles) }) } else { @@ -55,7 +55,7 @@ define([ if (datasets != null) { var values = Object.keys(datasets) values.sort() - state.getSelectedDataSets = createSelectTable(values, container, true) + state.datasetCheckboxes = createSelectTable(values, container, true, state.unselectedDatasets) } } @@ -156,7 +156,7 @@ define([ }) } - function createSelectTable(values, container, checked) { + function createSelectTable(values, container, checked, overrides) { var table = document.createElement("TABLE") table.className = 'table-bordered table-striped table-condensed' @@ -170,7 +170,7 @@ define([ var checkbox = document.createElement("INPUT") checkbox.type = "checkbox" checkbox.value = value - checkbox.checked = checked + checkbox.checked = overrides.includes(value) ? !checked : checked checkboxes.push(checkbox) row.insertCell().appendChild(checkbox) var valueCell = row.insertCell() @@ -179,7 +179,7 @@ define([ }) container.appendChild(table) - return () => checkboxes.filter(cb => cb.checked).map(cb => cb.value) + return checkboxes } return { @@ -255,6 +255,8 @@ define([ } } state.uploadEntityIdentifier = sampleIdentifier.value + state.unselectedDatasets = state.datasetCheckboxes.filter(cb => !cb.checked).map(cb => cb.value) + state.selectedFiles = state.fileCheckboxes.filter(cb => cb.checked).map(cb => cb.value) } function onOk() { @@ -268,7 +270,7 @@ define([ var uploadUrl = env.notebook.base_url + 'openbis/dataset/' + connection_name var notebook = IPython.notebook - var files = state.getSelectedFiles() + var files = state.fileCheckboxes.filter(cb => cb.checked).map(cb => cb.value) var re = /\/notebooks\/(.*?)$/ var filepath = window.location.pathname.match(re)[1] files.push(filepath) @@ -281,6 +283,7 @@ define([ var dataSetInfo = { "type": dataset_types.value, "files": files, + "parents": state.datasetCheckboxes.filter(cb => cb.checked).map(cb => cb.value), "sampleIdentifier": sampleIdentifier.value, "props": props }