diff --git a/app/assets/javascripts/protocols/handson.js b/app/assets/javascripts/protocols/handson.js index 3682a1edf..9ce984acb 100644 --- a/app/assets/javascripts/protocols/handson.js +++ b/app/assets/javascripts/protocols/handson.js @@ -11,13 +11,12 @@ var contents = $(this).find('.hot-contents'); var metadataJson = $(this).find('.hot-metadata'); var metadata = JSON.parse(metadataJson.val() || '{}'); - var isPlateTemplate = metadata.plateTemplate === 'true'; $container.handsontable({ startRows: HANDSONTABLE_INIT_ROWS_CNT, startCols: HANDSONTABLE_INIT_COLS_CNT, - rowHeaders: tableColRowName.tableRowHeaders(isPlateTemplate), - colHeaders: tableColRowName.tableColHeaders(isPlateTemplate), + rowHeaders: tableColRowName.tableRowHeaders(metadata.plateTemplate), + colHeaders: tableColRowName.tableColHeaders(metadata.plateTemplate), fillHandle: false, formulas: true, data: JSON.parse(contents.attr('value')).data, diff --git a/app/assets/javascripts/reports/content.js b/app/assets/javascripts/reports/content.js index 178788c30..ee0aff54a 100644 --- a/app/assets/javascripts/reports/content.js +++ b/app/assets/javascripts/reports/content.js @@ -44,7 +44,6 @@ var parentEl; var order; var metadata; - var isPlateTemplate; // Special handling if this is a repository table if (input.hasClass('hot-repository-items')) { @@ -66,11 +65,10 @@ el.handsontable('getInstance').getPlugin('columnSorting').sort(3, order); } else { metadata = JSON.parse(metadataJson.val() || '{}'); - isPlateTemplate = metadata.plateTemplate === 'true'; el.handsontable({ disableVisualSelection: true, - rowHeaders: tableRowHeaders(isPlateTemplate), - colHeaders: tableColHeaders(isPlateTemplate), + rowHeaders: tableRowHeaders(metadata.plateTemplate), + colHeaders: tableColHeaders(metadata.plateTemplate), editor: false, copyPaste: false, formulas: true, diff --git a/app/controllers/step_elements/tables_controller.rb b/app/controllers/step_elements/tables_controller.rb index 18142d929..4326503a7 100644 --- a/app/controllers/step_elements/tables_controller.rb +++ b/app/controllers/step_elements/tables_controller.rb @@ -18,7 +18,7 @@ module StepElements name: name, contents: { data: Array.new(predefined_table_dimensions[0], Array.new(predefined_table_dimensions[1], '')) }.to_json, - metadata: { plateTemplate: create_table_params[:plateTemplate] }, + metadata: { plateTemplate: create_table_params[:plateTemplate] == 'true' }, created_by: current_user, team: @step.protocol.team )) diff --git a/app/javascript/vue/protocol/step_elements/table.vue b/app/javascript/vue/protocol/step_elements/table.vue index 494692311..9cc6d7564 100644 --- a/app/javascript/vue/protocol/step_elements/table.vue +++ b/app/javascript/vue/protocol/step_elements/table.vue @@ -181,15 +181,14 @@ let container = this.$refs.hotTable; let data = JSON.parse(this.element.attributes.orderable.contents); let metadata = this.element.attributes.orderable.metadata || {}; - let isPlateTemplate = metadata.plateTemplate === 'true'; this.tableObject = new Handsontable(container, { data: data.data, width: '100%', startRows: 5, startCols: 5, - rowHeaders: tableColRowName.tableRowHeaders(isPlateTemplate), - colHeaders: tableColRowName.tableColHeaders(isPlateTemplate), + rowHeaders: tableColRowName.tableRowHeaders(metadata.plateTemplate), + colHeaders: tableColRowName.tableColHeaders(metadata.plateTemplate), cell: metadata.cells || [], contextMenu: this.editingTable, formulas: true,