Skip to content

Commit

Permalink
Fix listing not updated after instrument assignment in Worksheet's vi…
Browse files Browse the repository at this point in the history
…ew (senaite#2062)

* Refresh worksheet after instrumnent assignment

* Changelog

* Fix listing not updated after instrument assignment in Worksheet's view

* Use a reload event for the refresh of the analyses listing
  • Loading branch information
xispa committed Jul 19, 2022
1 parent 5adaf31 commit 353ef78
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
2.3.0 (unreleased)
------------------

- #2062 Fix listing not updated after instrument assignment in Worksheet's view
- #2061 Fire notifications when UID references are created/destroyed
- #2058 Filter 'Interpretation templates' in sample view by template and type
- #2048 Fix catalog logging counter duplicates
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/core/browser/static/bundles/legacy.js

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions src/senaite/core/browser/static/js/bika.lims.worksheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
this.on_instrument_change = bind(this.on_instrument_change, this);
this.on_layout_change = bind(this.on_layout_change, this);
this.on_analyst_change = bind(this.on_analyst_change, this);
this.reload_analyses_listing = bind(this.reload_analyses_listing, this);
this.get_analyses_listing = bind(this.get_analyses_listing, this);
this.get_authenticator = bind(this.get_authenticator, this);
this.get_base_url = bind(this.get_base_url, this);
this.get_portal_url = bind(this.get_portal_url, this);
Expand Down Expand Up @@ -219,6 +221,28 @@
return $("input[name='_authenticator']").val();
};

WorksheetManageResultsView.prototype.get_analyses_listing = function() {

/*
* Returns the root element of the analysis listing for results entry
*/
var listing, selector;
selector = "#analyses_form div.ajax-contents-table";
listing = document.querySelector(selector);
return listing;
};

WorksheetManageResultsView.prototype.reload_analyses_listing = function() {

/*
* Reloads the analyses listing for results entry
*/
var event, listing;
listing = this.get_analyses_listing();
event = new Event("reload");
return listing.dispatchEvent(event);
};


/* EVENT HANDLER */

Expand Down Expand Up @@ -282,9 +306,7 @@
},
dataType: "json"
}).done(function(data) {
bika.lims.SiteView.notify_in_panel(_t("Changes saved."), "succeed");
$("select[column_key='Instrument'] option[value='" + instrument_uid + "']").parent().find("option[value='" + instrument_uid + "']").prop("selected", false);
return $("select[column_key='Instrument'] option[value='" + instrument_uid + "']").prop("selected", true);
return this.reload_analyses_listing();
}).fail(function() {
return bika.lims.SiteView.notify_in_panel(_t("Unable to apply the selected instrument"), "error");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ class window.WorksheetManageResultsView
return $("input[name='_authenticator']").val()


get_analyses_listing: =>
###
* Returns the root element of the analysis listing for results entry
###
selector = "#analyses_form div.ajax-contents-table";
listing = document.querySelector selector
return listing


reload_analyses_listing: () =>
###
* Reloads the analyses listing for results entry
###
listing = @get_analyses_listing()
event = new Event "reload"
listing.dispatchEvent event


### EVENT HANDLER ###

on_analyst_change: (event) =>
Expand Down Expand Up @@ -243,12 +261,7 @@ class window.WorksheetManageResultsView
_authenticator: @get_authenticator()
dataType: "json"
.done (data) ->
bika.lims.SiteView.notify_in_panel _t("Changes saved."), "succeed"
# Set the selected instrument to all the analyses which that can be done
# using that instrument. The rest of of the instrument picklist will not
# be changed
$("select[column_key='Instrument'] option[value='#{instrument_uid}']").parent().find("option[value='#{instrument_uid}']").prop "selected", no
$("select[column_key='Instrument'] option[value='#{instrument_uid}']").prop "selected", yes
@reload_analyses_listing()
.fail () ->
bika.lims.SiteView.notify_in_panel _t("Unable to apply the selected instrument"), "error"

Expand Down

0 comments on commit 353ef78

Please sign in to comment.