From b7477a0f22fc217807c623eb48580fc834d4954e Mon Sep 17 00:00:00 2001 From: Mark W <24956497+ndg63276@users.noreply.github.com> Date: Thu, 31 Aug 2023 12:20:39 +0100 Subject: [PATCH] LIMS-222: Apply experimental parameters to all samples (#595) * 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 Co-authored-by: John Holt --- .../modules/imaging/views/queuecontainer.js | 30 +++++++++++++------ .../js/templates/imaging/queuecontainer.html | 4 ++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/client/src/js/modules/imaging/views/queuecontainer.js b/client/src/js/modules/imaging/views/queuecontainer.js index 8c53dc5eb..e4c6d396d 100644 --- a/client/src/js/modules/imaging/views/queuecontainer.js +++ b/client/src/js/modules/imaging/views/queuecontainer.js @@ -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', @@ -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) { diff --git a/client/src/js/templates/imaging/queuecontainer.html b/client/src/js/templates/imaging/queuecontainer.html index b3d665d83..26ecbe899 100644 --- a/client/src/js/templates/imaging/queuecontainer.html +++ b/client/src/js/templates/imaging/queuecontainer.html @@ -50,7 +50,9 @@

Available Samples

Queued Samples

-Presets: Apply +Presets: + Apply to Selected + Apply to All