Skip to content

Commit

Permalink
Merge pull request #72 from sanger/devel
Browse files Browse the repository at this point in the history
Merge devel into master
  • Loading branch information
jbeast committed May 27, 2016
2 parents 8ea879d + de1067d commit 421052a
Show file tree
Hide file tree
Showing 23 changed files with 185 additions and 214 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
Expand Down Expand Up @@ -41,7 +40,7 @@ gem 'kaminari'

gem 'backbone-on-rails'

gem 'rest-client'
gem 'pmb-client', '0.1.0', :github => 'sanger/pmb-client'

gem 'exception_notification'

Expand Down
34 changes: 20 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: git://github.com/sanger/pmb-client.git
revision: 016f151a3bde84448ed64e528259c3511282dcdb
specs:
pmb-client (0.1.0)
json_api_client (~> 1.1)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -78,8 +85,6 @@ GEM
database_cleaner (1.4.1)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
eco (1.0.0)
coffee-script
eco-source
Expand All @@ -96,13 +101,15 @@ GEM
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.8)
font-awesome-rails (4.5.0.0)
railties (>= 3.2, < 5.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
i18n (0.7.0)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
Expand All @@ -119,6 +126,12 @@ GEM
json (1.8.3)
json-schema (2.6.0)
addressable (~> 2.3.8)
json_api_client (1.1.1)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
addressable (~> 2.2)
faraday (~> 0.9)
faraday_middleware (~> 0.9)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
Expand All @@ -132,9 +145,9 @@ GEM
mini_portile (0.6.2)
minitest (5.8.3)
multi_json (1.11.2)
multipart-post (2.0.0)
mysql2 (0.3.20)
net-ldap (0.12.0)
netrc (0.11.0)
nokogiri (1.6.6.3)
mini_portile (~> 0.6.0)
phantomjs (1.9.8.0)
Expand Down Expand Up @@ -183,10 +196,6 @@ GEM
uri_template (~> 0.7)
rdoc (4.2.0)
ref (2.0.0)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rouge (1.10.1)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
Expand Down Expand Up @@ -250,9 +259,6 @@ GEM
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
uri_template (0.7.0)
web-console (2.2.1)
activemodel (>= 4.0)
Expand Down Expand Up @@ -290,12 +296,12 @@ DEPENDENCIES
mysql2 (= 0.3.20)
net-ldap
phantomjs
pmb-client (= 0.1.0)!
poltergeist
puma
rails (= 4.2.3)
rake
raml_ruby (~> 0.1.1)
rest-client
rspec-rails (~> 3.1)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
Expand All @@ -310,4 +316,4 @@ DEPENDENCIES
with_model

BUNDLED WITH
1.11.2
1.12.1
6 changes: 4 additions & 2 deletions app/assets/javascripts/batches.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $ ->
userFavouritesCollection = new Mixtio.Collections.UserFavourites(Mixtio.Bootstrap.UserFavourites)
consumableTypesCollection = new Mixtio.Collections.ConsumableTypes(Mixtio.Bootstrap.ConsumableTypes)
kitchensCollection = new Mixtio.Collections.Kitchens(Mixtio.Bootstrap.Kitchens)
ingredientsCollection = new Mixtio.Collections.Ingredients()
ingredientsCollection = new Mixtio.Collections.Ingredients(Mixtio.Bootstrap.Ingredients)

# Create the Views
consumableTypeView = new Mixtio.Views.ConsumableTypes(
Expand Down Expand Up @@ -48,7 +48,7 @@ $ ->
favouritesStarView.update(model, options)
expiryDateView.update(model)
consumablesView.update(model)

ingredients = model?.get('latest_batch')?.ingredients?.map (ingredient) ->
type = Mixtio.Bootstrap.ConsumableTypes.filter((type) -> type.id == ingredient.consumable_type_id)[0]
{
Expand All @@ -66,5 +66,7 @@ $ ->

# And finally render
consumableTypeView.render()
consumableTypeView.setSelected(Mixtio.Bootstrap.SelectedConsumableType)
ingredientsView.render()

$('[data-toggle="tooltip"]').tooltip()
7 changes: 5 additions & 2 deletions app/assets/javascripts/views/consumable_types.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Mixtio.Views.ConsumableTypes extends Backbone.View

events:
change: 'setSelected'
change: 'onChange'

initialize: (options) ->
@favourites_collection = options.favourites
Expand Down Expand Up @@ -30,7 +30,10 @@ class Mixtio.Views.ConsumableTypes extends Backbone.View
@$el.append(view)
)

setSelected: () ->
setSelected: (val) ->
@$el.val(val)

onChange: () ->
id = @$el.val()

if id is ""
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/expiry_date.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class Mixtio.Views.ExpiryDate extends Backbone.View
@render()

render: () ->
@$el.datepicker('setDate', @model?.get('days_to_keep'))
@$el.datepicker('setDate', @model?.get('days_to_keep') or 'today')
this
6 changes: 1 addition & 5 deletions app/models/concerns/has_volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module HasVolume

included do
enum unit: {
"μL": -6,
"µL": -6,
"mL": -3,
'L': 0,
}
Expand All @@ -19,8 +19,4 @@ def display_volume
end
end

def simple_volume
display_volume ? display_volume.gsub('μ', 'u') : nil
end

end
4 changes: 0 additions & 4 deletions app/models/consumable_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class ConsumableType < ActiveRecord::Base
"LN2": 5
}

def simple_storage_condition
(storage_condition or "").gsub('°', '')
end

def latest_batch
batches.last
end
Expand Down
17 changes: 0 additions & 17 deletions app/serializers/consumable_label_serializer.rb

This file was deleted.

25 changes: 0 additions & 25 deletions app/serializers/print_job_serializer.rb

This file was deleted.

6 changes: 3 additions & 3 deletions app/views/api/v2/docs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ sort=-updated_at
"created_at":"2016-04-08T11:19:44.440Z",
"barcode":"RGNT_171",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand All @@ -486,7 +486,7 @@ sort=-updated_at
"created_at":"2016-04-08T11:19:44.446Z",
"barcode":"RGNT_172",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand Down Expand Up @@ -530,7 +530,7 @@ sort=-updated_at
"created_at":"2016-04-08T11:19:44.440Z",
"barcode":"RGNT_171",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand Down
2 changes: 2 additions & 0 deletions app/views/batches/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<script type="text/javascript">
Mixtio.Bootstrap.UserFavourites = <%= json_escape(ConsumableType.find_user_favourites(current_user).to_json.html_safe); %>
Mixtio.Bootstrap.ConsumableTypes = <%= json_escape(ConsumableType.order_by_name.to_json(include: {latest_batch: {include: {ingredients: {}, consumables: {}}}, latest_lot: {}}).html_safe); %>
Mixtio.Bootstrap.SelectedConsumableType = <%= json_escape(@batch_form.consumable_type_id.to_json.html_safe) %>;
Mixtio.Bootstrap.Kitchens = <%= json_escape(Kitchen.order_by_name.to_json.html_safe) %>;
Mixtio.Bootstrap.Ingredients = <%= json_escape(@batch_form.ingredients.to_json.html_safe) %>;
</script>

<div class="form-group">
Expand Down
6 changes: 3 additions & 3 deletions config/api.raml
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ resourceTypes:
"created_at":"2016-04-08T11:19:44.440Z",
"barcode":"RGNT_171",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand All @@ -427,7 +427,7 @@ resourceTypes:
"created_at":"2016-04-08T11:19:44.446Z",
"barcode":"RGNT_172",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand Down Expand Up @@ -480,7 +480,7 @@ resourceTypes:
"created_at":"2016-04-08T11:19:44.440Z",
"barcode":"RGNT_171",
"volume":"51.8",
"unit":"μL",
"unit":"µL",
"depleted":false
},
"relationships":{
Expand Down
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@

# config.stub_ldap = true

# Print My Barcode api base
config.x.pmb_api_base = 'http://pmb.dev/api/v1'
end
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Print My Barcode api base
config.x.pmb_api_base = 'http://pmb.prod/api/v1'
end
3 changes: 3 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@
exception_recipients: %w(#{Rails.configuration.mailer['smtp']['recipient']})
}

# Print My Barcode api base
config.x.pmb_api_base = 'http://pmb.test/api/v1'

end
1 change: 1 addition & 0 deletions config/initializers/print_my_barcode.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PMB::Base.site = Rails.configuration.x.pmb_api_base
33 changes: 33 additions & 0 deletions lib/labels.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Labels

attr_accessor :consumables

def initialize(batch)
@consumables = batch.single_barcode? ? [batch.consumables.first] : batch.consumables
end

def to_h
{
body: body
}
end

private

def body
consumables.map do |consumable|
{
label_1: {
barcode_text: consumable.barcode,
reagent_name: consumable.batch.consumable_type.name,
batch_no: consumable.batch.number,
date: "Use by:#{consumable.batch.expiry_date}",
barcode: consumable.barcode,
volume: consumable.display_volume,
storage_condition: consumable.batch.consumable_type.storage_condition,
}
}
end
end

end
Loading

0 comments on commit 421052a

Please sign in to comment.