Skip to content

Commit

Permalink
Allow to specify reserved cells
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Feb 3, 2025
1 parent 28fc232 commit 4e32e4a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
window.vue_sanger_sequencing_well_plate_editor_app = {
props: ["submissions", "builder_config"],
props: ["submissions"],

data() {
return {
builder: new SangerSequencing.WellPlateBuilder,
columnOrder: null
columnOrder: null,
reservedCells: "",
};
},

beforeCompile() {
this.colorBuilder = new SangerSequencing.WellPlateColors(this.builder);
return this.builder.setReservedCells(this.builder_config.reserved_cells);
},

compiled() {
this.updateReservedCells();
},

ready() {
Expand All @@ -27,6 +31,10 @@ window.vue_sanger_sequencing_well_plate_editor_app = {
this.builder.changeOrderStrategy(this.columnOrder);
},

updateReservedCells() {
this.builder.setReservedCells(this.reservedCells.split(", "));
},

addSubmission(submissionId) {
return this.builder.addSubmission(this.findSubmission(submissionId));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def new
.includes(:samples, order_detail: :product)
.for_facility(current_facility)
.for_product_group(product_group)
@builder_config = WellPlateConfiguration.find(product_group)
end

def create
Expand Down Expand Up @@ -86,6 +85,16 @@ def order_options

helper_method :order_options

def reserved_cells_options
[
[text(".reserved_cells.none"), ""],
["A01", "A01"],
["A01, A02", "A01, A02"],
]
end

helper_method :reserved_cells_options

private

def product_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class BatchForm
attribute :batch
attribute :column_order, default: "odd_first"

attr_writer :reserved_cells

delegate :submission_ids, :group, to: :batch

validates :submission_ids, presence: true
Expand Down Expand Up @@ -49,6 +51,12 @@ def save
batch.save if valid?
end

def reserved_cells
return @reserved_cells if @reserved_cells.present?

WellPlateConfiguration.find(group).reserved_cells.join(", ")
end

private

def submissions_in_correct_facility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module SangerSequencing

class WellPlateConfiguration

attr_reader :reserved_cells

def initialize(reserved_cells: [])
@reserved_cells = reserved_cells
end
Expand All @@ -16,13 +18,6 @@ def initialize(reserved_cells: [])
def self.find(key)
CONFIGS[key] || CONFIGS[:default]
end

def to_json
{
reserved_cells: Array(@reserved_cells),
}.to_json
end

end

end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= javascript_include_tag "sanger_sequencing/well_plate"
= stylesheet_link_tag "sanger_sequencing/application"

%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples), ":builder_config" => @builder_config.to_json }
%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples) }

= simple_form_for :batch, url: facility_sanger_sequencing_admin_batches_path do |f|
= f.input :group, as: :hidden
Expand All @@ -18,7 +18,13 @@
collection: order_options,
include_blank: false,
label: SangerSequencing::BatchForm.human_attribute_name(:column_order),
input_html: { "v-on:change": "changeOrder()", "v-model" => "columnOrder" }
input_html: { "v-on:change": "changeOrder()", "v-model": "columnOrder" }
= f.input :reserved_cells,
collection: reserved_cells_options,
label: SangerSequencing::BatchForm.human_attribute_name(:reserved_cells),
include_blank: false,
input_html: { "v-model": "reservedCells", "v-on:change": "updateReservedCells()" }
= f.submit text("submit"), class: "btn btn-primary"
Expand Down
3 changes: 3 additions & 0 deletions vendor/engines/sanger_sequencing/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ en:
orders:
sequential: "Full Plate"
odd_first: "Half Plate"
reserved_cells:
none: None
sanger_sequencing/admin/primers:
update:
success: Core Primers updated successfully
Expand Down Expand Up @@ -111,6 +113,7 @@ en:
attributes:
sanger_sequencing/batch_form:
column_order: Column Order
reserved_cells: Reserved Cells
errors:
models:
sanger_sequencing/batch_form:
Expand Down

0 comments on commit 4e32e4a

Please sign in to comment.