Skip to content

Commit

Permalink
LIMS-222: Apply experimental parameters to all samples (#595)
Browse files Browse the repository at this point in the history
* LIMS-222: Apply experimental parameters to all samples

* LIMS-222: Fix bug from renaming method

* Use toArray instead of filter and make names better

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: John Holt <[email protected]>
  • Loading branch information
3 people authored Aug 31, 2023
1 parent ee38e05 commit b7477a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
30 changes: 21 additions & 9 deletions client/src/js/modules/imaging/views/queuecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ define(['marionette',
events: {
'click button.submit': 'queueContainer',
'click a.apply': 'applyPreset',
'click a.applyall': 'applyPresetAll',
'click a.unqueue': 'unqueueContainer',
'click a.addpage': 'queuePageSamples',
'click a.addall': 'queueAllSamples',
Expand Down Expand Up @@ -615,25 +616,36 @@ define(['marionette',
e.preventDefault()

var p = this.plans.findWhere({ DIFFRACTIONPLANID: this.ui.preset.val() })
if (p) this.applyModel(p)
if (p) this.applyModel(p, true)
},

applyModel: function(p) {
var models = this.qsubsamples.where({ isGridSelected: true })
_.each(models, function(m) {
if (p.get('EXPERIMENTKIND') !== m.get('EXPERIMENTKIND')) return
applyPresetAll:function(e) {
e.preventDefault()

var p = this.plans.findWhere({ DIFFRACTIONPLANID: this.ui.preset.val() })
if (p) this.applyModel(p, false)
},

applyModel: function(modelParameter, isLimitedToSelected) {
if (isLimitedToSelected) {
var models = this.qsubsamples.where({ isGridSelected: true })
} else {
var models = this.qsubsamples.fullCollection.toArray()
}
_.each(models, function(model) {
if (modelParameter.get('EXPERIMENTKIND') !== model.get('EXPERIMENTKIND')) return

_.each(['REQUIREDRESOLUTION', 'PREFERREDBEAMSIZEX', 'PREFERREDBEAMSIZEY', 'EXPOSURETIME', 'BOXSIZEX', 'BOXSIZEY', 'AXISSTART', 'AXISRANGE', 'NUMBEROFIMAGES', 'TRANSMISSION', 'ENERGY', 'MONOCHROMATOR'], function(k) {
if (p.get(k) !== null) m.set(k, p.get(k))
if (modelParameter.get(k) !== null) model.set(k, modelParameter.get(k))
}, this)
m.save()
m.trigger('refresh')
model.save()
model.trigger('refresh')
}, this)
},

cloneModel: function(m) {
console.log('cloning', m)
this.applyModel(m)
this.applyModel(m, true)
},

queueContainer: function(e) {
Expand Down
4 changes: 3 additions & 1 deletion client/src/js/templates/imaging/queuecontainer.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ <h2>Available Samples</h2>

<h2>Queued Samples</h2>
<div class="r rpreset">
Presets: <select name="preset"></select> <a href="#" class="button apply" title="Apply this preset to the selected samples"><i class="fa fa-file-o"></i> Apply</a>
Presets: <select name="preset"></select>
<a href="#" class="button apply" title="Apply this preset to the selected samples"><i class="fa fa-check-square-o"></i> Apply to Selected</a>
<a href="#" class="button applyall" title="Apply this preset to all samples"><i class="fa fa-file-text-o"></i> Apply to All</a>
</div>
<div class="filter filter-nohide qfilt"></div>
<div class="qsamples"></div>
Expand Down

0 comments on commit b7477a0

Please sign in to comment.