Skip to content

Commit

Permalink
starting to create the new sample_name_cell_component
Browse files Browse the repository at this point in the history
  • Loading branch information
ksierks committed Jul 30, 2024
1 parent 2cf91f7 commit 84a0589
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/components/nextflow/samplesheet/column_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Nextflow
module Samplesheet
# Renders a column in the sample sheet table
class ColumnComponent < Component
class ColumnComponent < Component # ,
attr_reader :namespace_id, :header, :property, :samples

# rubocop:disable Metrics/ParameterLists
Expand All @@ -18,10 +18,12 @@ def initialize(namespace_id:, header:, property:, samples:, metadata_fields:, re

# rubocop:enable Metrics/ParameterLists

def render_cell_type(property, entry, sample, fields, index)
def render_cell_type(property, entry, sample, fields, index) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
case entry['cell_type']
when 'sample_cell'
render_sample_cell(sample, fields)
when 'sample_name_cell'
render_sample_name_cell(sample, fields)
when 'fastq_cell'
render_fastq_cell(sample, property, entry, fields, index)
when 'file_cell'
Expand Down Expand Up @@ -71,6 +73,10 @@ def render_sample_cell(sample, fields)
render(Samplesheet::SampleCellComponent.new(sample:, fields:))
end

def render_sample_name_cell(sample, fields)
render(Samplesheet::SampleNameCellComponent.new(sample:, fields:))
end

def render_metadata_cell(sample, name, fields)
render(Samplesheet::MetadataCellComponent.new(sample:, name:, form: fields))
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="p-2.5 sticky left-0">
<%= sample.name %>
<%= fields.hidden_field :sample_name, value: sample.name %>
</div>
15 changes: 15 additions & 0 deletions app/components/nextflow/samplesheet/sample_name_cell_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Nextflow
module Samplesheet
# Component to render a cell with the sample name into the sample sheet
class SampleNameCellComponent < Component
attr_reader :sample, :fields

def initialize(sample:, fields:)
@sample = sample
@fields = fields
end
end
end
end
2 changes: 2 additions & 0 deletions app/components/nextflow/samplesheet_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def extract_properties(schema)
def identify_cell_type(property, entry)
return 'sample_cell' if property == 'sample'

return 'sample_name_cell' if property == 'sample_name'

return 'fastq_cell' if property.match(/fastq_\d+/)

return 'file_cell' if check_for_file(entry)
Expand Down
2 changes: 1 addition & 1 deletion test/components/nextflow_samplesheet_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NextflowSamplesheetComponentTest < ApplicationSystemTestCase
visit("/rails/view_components/nextflow_samplesheet_component/default?sample_ids[]=#{sample1.id}&sample_ids[]=#{sample2.id}") # rubocop:disable Layout/LineLength

assert_selector '.samplesheet-table' do |table|
table.assert_selector '.table-header', count: 4
table.assert_selector '.table-header', count: 5
table.assert_selector '.table-column:last-of-type .table-header', text: 'STRANDEDNESS (REQUIRED)'
table.assert_selector '.table-column:first-of-type .table-td', count: 2
table.assert_selector '.table-column:first-of-type .table-td:first-of-type', text: sample1.puid
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/files/nextflow/samplesheet_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"pattern": "^\\S+$",
"errorMessage": "Sample name must be provided and cannot contain spaces"
},
"sample_name": {
"type": "string",
"pattern": "^\\S+$",
"meta": ["name"],
"errorMessage": "Sample name must be provided and cannot contain spaces"
},
"fastq_1": {
"type": "string",
"pattern": "^\\S+\\.f(ast)?q\\.gz$",
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/files/nextflow/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"pattern": "^\\S+$",
"meta": ["id"],
"unique": true,
"errorMessage": "Sample id must be provided and cannot contain spaces"
},
"sample_name": {
"type": "string",
"pattern": "^\\S+$",
"meta": ["name"],
"errorMessage": "Sample name must be provided and cannot contain spaces"
},
"fastq_1": {
Expand Down

0 comments on commit 84a0589

Please sign in to comment.