Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ispyb/EXI
Browse files Browse the repository at this point in the history
  • Loading branch information
antolinos committed Mar 23, 2018
2 parents e24b70c + 0e49f2e commit c4f6574
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 144 deletions.
70 changes: 29 additions & 41 deletions js/core/view/shipping/caseform.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function CaseForm(args) {
this.showTitle = args.showTitle;
}
}

this.onSaved = new Event(this);
}

Expand All @@ -40,9 +39,9 @@ CaseForm.prototype.getDewar = function() {
this.dewar.code = Ext.getCmp(this.id + "dewar_code").getValue();
this.dewar.comments = Ext.getCmp(this.id + "dewar_comments").getValue();
this.dewar.transportValue = Ext.getCmp(this.id + "dewar_transportValue").getValue();
// this.dewar.storageLocation = Ext.getCmp("dewar_storageLocation").getValue();
this.dewar.storageLocation = this.storageLocationComboBox.getValue();
//this.dewar.firstExperimentId = this.sessionsCombo.getValue();

return this.dewar;
};

Expand All @@ -60,29 +59,17 @@ CaseForm.prototype.setDewar = function(dewar) {
Ext.getCmp(this.id + "dewar_code").setValue(this.dewar.code);
Ext.getCmp(this.id + "dewar_comments").setValue(this.dewar.comments);
Ext.getCmp(this.id + "dewar_transportValue").setValue(this.dewar.transportValue);
// Ext.getCmp("dewar_storageLocation").setValue(this.dewar.storageLocation);
this.storageLocationComboBox.setValue(this.dewar.storageLocation);
/*if (this.dewar.sessionVO != null) {
this.sessionsCombo.setValue(this.dewar.sessionVO.sessionId);
}*/

};

/*
CaseForm.prototype.getSessionCombo = function() {
this.sessionsCombo = BIOSAXS_COMBOMANAGER.getComboSessions(EXI.proposalManager.getFutureSessions(), {
labelWidth : 200,
margin : '5 0 00 0',
width : 500
});
return this.sessionsCombo;
};*/

CaseForm.prototype.getStorageLocationCombo = function() {
this.storageLocationComboBox = BIOSAXS_COMBOMANAGER.getComboStorageTemperature();
return this.storageLocationComboBox;
};

CaseForm.prototype.getPanel = function(dewar) {
CaseForm.prototype.getPanel = function(dewar, hideReimb) {

this.panel = Ext.create('Ext.form.Panel', {
width : this.width - 10,
// cls : 'border-grid',
Expand All @@ -106,30 +93,31 @@ CaseForm.prototype.getPanel = function(dewar) {
id : this.id + 'dewar_code',
labelWidth : 200,
width : 500
}
},
]
},
this.getStorageLocationCombo(),
{
xtype : 'numberfield',
width : 500,
labelWidth : 200,
margin : '10 0 0 0',
fieldLabel : 'Transport Value',
id : this.id + 'dewar_transportValue'
},
{
xtype : 'textareafield',
name : 'comments',
fieldLabel : 'Comments',
labelWidth : 200,
width : 500,
margin : '10 0 0 0',
height : 100,
id : this.id + 'dewar_comments'
} ]
} ]
});
},
this.getStorageLocationCombo(),
{
xtype : 'numberfield',
width : 500,
labelWidth : 200,
margin : '10 0 0 0',
fieldLabel : 'Transport Value',
id : this.id + 'dewar_transportValue'
},
{
xtype : 'textareafield',
name : 'comments',
fieldLabel : 'Comments',
labelWidth : 200,
width : 500,
margin : '10 0 0 0',
height : 100,
id : this.id + 'dewar_comments'
},
]}]
});

this.refresh(dewar);
return this.panel;
};
};
14 changes: 9 additions & 5 deletions js/core/view/shipping/containerspreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ ContainerSpreadSheet.prototype.getHeader = function() {
{ text : '#', id: 'position', column : {width : 20}},
{ text :'Protein <br />Acronym', id :'Protein Acronym', column : {
width : 80,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: this.getAcronyms()
}
},
{ text :'Sample<br /> Name', id :'Sample Name', column : {width : 120}},
{ text :'Crystal Form', id : 'Crystal Form',column : {
width : 230,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: function(query, process) {
var colIndex = _this.getColumnIndex("Protein Acronym");
var protein = EXI.proposalManager.getProteinByAcronym(this.instance.getDataAtCell(this.row,colIndex));
Expand All @@ -243,7 +245,8 @@ ContainerSpreadSheet.prototype.getHeader = function() {
},
{ text :'Exp.<br /> Type', id : 'Experiment Type', column : {
width : 100,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: [ "Default", "MXPressE", "MXPressO", "MXPressI", "MXPressE_SAD", "MXScore", "MXPressM", "MXPressP", "MXPressP_SAD" ]
}
},
Expand All @@ -257,9 +260,10 @@ ContainerSpreadSheet.prototype.getHeader = function() {
{ text :'Required<br /> multiplicity', id :'Required multiplicity', column : {width : 60}},
{ text :'Required<br /> Completeness', id :'Required Completeness', column : {width : 80}},

{ text :'Forced <br /> Space G.', id : 'Space Group', column : {
{ text :'Forced <br /> Space G.', id : 'Space Group', column : {
width : 55,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: _.concat([""], ExtISPyB.spaceGroups)
}
},
Expand Down
12 changes: 8 additions & 4 deletions js/core/view/shipping/csvcontainerspreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ CSVContainerSpreadSheet.prototype.getHeader = function() {
{ text : '#', id: 'position', column : {width : 20, renderer: samplePositionParameterRenderer}},
{ text :'Protein <br />Acronym', id :'Protein Acronym', column : {
width : 80,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
renderer: proteinParameterRenderer,
source: this.getAcronyms()
}
Expand All @@ -599,15 +600,17 @@ CSVContainerSpreadSheet.prototype.getHeader = function() {

{ text :'Exp.<br /> Type', id : 'experimentKind', column : {
width : 100,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
renderer: mandatoryParameterRenderer,
source: [ "Default", "MXPressE", "MXPressO", "MXPressI", "MXPressE_SAD", "MXScore", "MXPressM", "MXPressP", "MXPressP_SAD" ]
}
},

{ text :'Space <br />group', id : 'Space Group', column : {
width : 70,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
renderer: mandatoryParameterRenderer,
source: _.concat([""], ExtISPyB.spaceGroups)
}},
Expand All @@ -625,7 +628,8 @@ CSVContainerSpreadSheet.prototype.getHeader = function() {
{ text :'Required<br /> Completeness', id :'Required Completeness', column : {width : 80}},
{ text :'Forced <br /> SPG', id :'forced', column : {
width : 70,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: _.concat([""], ExtISPyB.spaceGroups)
}},

Expand Down
3 changes: 2 additions & 1 deletion js/core/view/shipping/genericcontainerspreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ GenericContainerSpreadSheet.prototype.getHeader = function() {
header = [{ text : '#', id: 'position', column : {width : 20}},
{ text :'Samplesheet <br />Acronym', id :'Protein Acronym', column : {
width : 100,
type: 'dropdown',
type: 'autocomplete',
filter: 'true',
source: this.getAcronyms()
}
},
Expand Down
67 changes: 57 additions & 10 deletions js/core/view/shipping/parcelgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function ParcelGrid(args) {
this.btnEditVisible = true;
this.btnRemoveVisible = true;

this.reimbursementId = this.id + "_reimbursement_panel";

if (args != null) {
if (args.height != null) {
this.height = args.height;
Expand Down Expand Up @@ -43,29 +45,71 @@ function ParcelGrid(args) {
this.onRemove = new Event(this);
}

ParcelGrid.prototype.getReimbursementContentHTML = function(currentReimbursedDewars, maxReimbursedDewars ) {
return "("+ currentReimbursedDewars +" reimbursed out of " + maxReimbursedDewars +" allowed)";
};
ParcelGrid.prototype.getReimbursementHTML = function(currentReimbursedDewars, maxReimbursedDewars ) {
if (maxReimbursedDewars){
if (maxReimbursedDewars > 0){
return "<span id='" + this.reimbursementId +"' style='color:orange'>" + this.getReimbursementContentHTML(currentReimbursedDewars, maxReimbursedDewars)+ "</span>"
}
}
return "";
};

ParcelGrid.prototype.refreshReimbursementContentHTML = function(currentReimbursedDewars, maxReimbursedDewars ) {
$("#" + this.reimbursementId).html(this.getReimbursementContentHTML(currentReimbursedDewars, maxReimbursedDewars));
};

ParcelGrid.prototype.displayContentLabel = function(dewars,nSamples,nMeasured, currentReimbursedDewars, maxReimbursedDewars ) {

$("#" + this.id + "-label").html("Content (" + dewars.length + " Parcels " + this.getReimbursementHTML(currentReimbursedDewars, maxReimbursedDewars) + " - " + nSamples + " Samples - " + nMeasured + " Measured )");
};

ParcelGrid.prototype.getAuthorizedReimbursedDewars = function(sessions) {
if (sessions){
if (sessions.length > 0){
return sessions[0].nbReimbDewars;
}
};
return 0;
};

ParcelGrid.prototype.getCurrentReimbursedDewars = function(dewars) {
return _.filter(dewars, function(o){ return o.isReimbursed == true}).length;
};

ParcelGrid.prototype.load = function(shipment,hasExportedData,samples,withoutCollection) {
var _this = this;
this.shipment = shipment;
this.dewars = shipment.dewarVOs;
this.hasExportedData = hasExportedData;
nSamples = 0;
nMeasured = 0;
this.maxReimbursedDewars = 0;
this.currentReimbursedDewars = 0;
if (samples) {
nSamples = samples.length;
nMeasured = nSamples - withoutCollection.length;
this.samples = _.groupBy(samples,"Dewar_dewarId");
this.withoutCollection = _.groupBy(withoutCollection,"Dewar_dewarId");
};

if (shipment){
this.maxReimbursedDewars = this.getAuthorizedReimbursedDewars(this.shipment.sessions);
this.currentReimbursedDewars = this.getCurrentReimbursedDewars(this.dewars);
}

this.dewars.sort(function(a, b) {
return a.dewarId - b.dewarId;
});

$("#" + this.id + "-label").html("Content (" + this.dewars.length + " Parcels - " + nSamples + " Samples - " + nMeasured + " Measured)");
this.displayContentLabel(this.dewars, nSamples, nMeasured, this.currentReimbursedDewars, this.maxReimbursedDewars);
$("#" + this.id + "-add-button").removeClass("disabled");
$("#" + this.id + "-add-button").unbind('click').click(function(sender){
_this.edit();
});

if (nSamples > 0) {
$("#" + this.id + "-export").removeClass("disabled");
$("#" + this.id + "-export").unbind('click').click(function(sender){
Expand All @@ -74,14 +118,15 @@ ParcelGrid.prototype.load = function(shipment,hasExportedData,samples,withoutCol
exportForm.show();
});
}

this.fillTab("content", this.dewars);

this.attachCallBackAfterRender();
};

ParcelGrid.prototype.fillTab = function (tabName, dewars) {
var _this = this;
var _this = this;

$("#" + tabName + "-" + this.id).html("");
this.parcelPanels[tabName] = Ext.create('Ext.panel.Panel', {
// cls : 'border-grid',
Expand All @@ -98,20 +143,22 @@ ParcelGrid.prototype.fillTab = function (tabName, dewars) {
dewar["shippingId"] = _this.shipment.shippingId;

var onSuccess = function(sender, shipment) {
_this.panel.setLoading(false);
_this.panel.doLayout();
_this.panel.setLoading(false);
_this.refreshReimbursementContentHTML( _this.getCurrentReimbursedDewars(shipment.dewarVOs), _this.getAuthorizedReimbursedDewars(shipment.sessions));
_this.currentReimbursedDewars = _this.getCurrentReimbursedDewars(shipment.dewarVOs);
_this.panel.doLayout();
};
EXI.getDataAdapter({onSuccess : onSuccess}).proposal.dewar.saveDewar(_this.shipment.shippingId, dewar);
}

for ( var i in dewars) {
var parcelPanel = new ParcelPanel({
height : 90,
width : this.panel.getWidth()*0.9,
height : 110,
width : this.panel.getWidth()*0.9,
shippingId : this.shipment.shippingId,
shippingStatus : this.shipment.shippingStatus,
index : Number(i)+1,
currentTab : tabName
currentTab : tabName,
});
this.parcelPanels[tabName].insert(parcelPanel.getPanel());
parcelPanel.load(this.dewars[i],this.shipment,this.samples[this.dewars[i].dewarId],this.withoutCollection[this.dewars[i].dewarId]);
Expand All @@ -130,7 +177,7 @@ ParcelGrid.prototype.edit = function(dewar) {
width : 600,
modal : true,
layout : 'fit',
items : [ caseForm.getPanel(dewar) ],
items : [ caseForm.getPanel(dewar, true) ],
listeners : {
afterrender : function(component, eOpts) {
if (_this.puck != null) {
Expand Down
Loading

0 comments on commit c4f6574

Please sign in to comment.