Skip to content

Commit

Permalink
Changes for #712 Item 6: Added pop-up error for wrong SIF style,layou…
Browse files Browse the repository at this point in the history
…t imports. Item 2: Using Minerva when converting SBML to .sbgnml
  • Loading branch information
okg21 committed Jul 4, 2024
1 parent 5fe2cd0 commit 9ec0cb4
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 11 deletions.
15 changes: 14 additions & 1 deletion app/js/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function() {
var dynamicResize = appUtilities.dynamicResize.bind(appUtilities);

var layoutPropertiesView, generalPropertiesView,neighborhoodQueryView, pathsBetweenQueryView, pathsFromToQueryView, commonStreamQueryView, pathsByURIQueryView, promptSaveView, promptConfirmationView,
promptMapTypeView, promptInvalidTypeWarning, promtErrorPD2AF, promptInvalidFileView, promptFileConversionErrorView, promptInvalidURIWarning, reactionTemplateView, gridPropertiesView, fontPropertiesView, fileSaveView,saveUserPreferencesView, loadUserPreferencesView;
promptMapTypeView, promptInvalidTypeWarning, promtErrorPD2AF, promptInvalidFileView, promptFileConversionErrorView, promptInvalidURIWarning, reactionTemplateView, gridPropertiesView, fontPropertiesView, fileSaveView,saveUserPreferencesView, loadUserPreferencesView, sifMapWarning;

function validateSBGNML(xml) {
$.ajax({
Expand Down Expand Up @@ -158,6 +158,7 @@ module.exports = function() {
promptMapTypeView = appUtilities.promptMapTypeView = new BackboneViews.PromptMapTypeView({el: '#prompt-mapType-table'});
promptInvalidFileView = appUtilities.promptInvalidFileView = new BackboneViews.PromptInvalidFileView({el: '#prompt-invalidFile-table'});
promptInvalidTypeWarning = appUtilities.promptInvalidTypeWarning = new BackboneViews.PromptInvalidTypeWarning({el: '#prompt-errorInvalidType-table'});
sifMapWarning = appUtilities.sifMapWarning = new BackboneViews.SifMapWarning({el: '#errorSifMap-table'});
promtErrorPD2AF = appUtilities.promtErrorPD2AF = new BackboneViews.PromtErrorPD2AF({el: '#prompt-errorPD2AF-table'});
promptFileConversionErrorView = appUtilities.promptFileConversionErrorView = new BackboneViews.PromptFileConversionErrorView({el: '#prompt-fileConversionError-table'});
reactionTemplateView = appUtilities.reactionTemplateView = new BackboneViews.ReactionTemplateView({el: '#sbgn-bricks-table'});
Expand Down Expand Up @@ -450,10 +451,22 @@ module.exports = function() {
});

$("#import-sif-style").click(function () {
//Check if current map type is SIF
var mapType = appUtilities.getActiveChiseInstance().elementUtilities.mapType;
if (mapType != "SIF") {
sifMapWarning.render();
return;
}
$("#sif-style-input").trigger('click');
});

$("#import-sif-layout").click(function () {
//Check if current map type is SIF
var mapType = appUtilities.getActiveChiseInstance().elementUtilities.mapType;
if (mapType != "SIF") {
sifMapWarning.render();
return;
}
$("#sif-layout-input").trigger('click');
});

Expand Down
72 changes: 62 additions & 10 deletions app/js/backbone-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ var FileSaveView = Backbone.View.extend({
self.template = _.template($("#file-save-template").html());

// Check for unsupported conversions
map_type = appUtilities.getActiveChiseInstance().elementUtilities.mapType;
mapType = appUtilities.getActiveChiseInstance().elementUtilities.mapType;
var unsupportedConversions = {
"PD": ["sif", "sifLayout"],
"AF": ["sif", "sifLayout", "sbml", "celldesigner", "gpml"],
Expand All @@ -3235,7 +3235,7 @@ var FileSaveView = Backbone.View.extend({
"HybridAny": ["sbgn", "sif", "sifLayout", "sbml", "celldesigner", "gpml"]
};

if (unsupportedConversions[map_type] && unsupportedConversions[map_type].includes(fileformat)) {
if (unsupportedConversions[mapType] && unsupportedConversions[mapType].includes(fileformat)) {
var exportErrorView = new ExportErrorView({el: "#exportError-table",});
exportErrorView.render();
document.getElementById("export-error-message").innerText = "Not applicable for the current map type!";
Expand Down Expand Up @@ -3331,6 +3331,20 @@ var FileSaveView = Backbone.View.extend({

var saveAsFcn = chiseInstance.saveAsNwt;
if (fileformat === "sbgn") {
if (chiseInstance.elementUtilities.mapType === "SBML") {
console.log("fileformat is sbgn and maptype is SBML");
chiseInstance.saveAsSbgnmlForSBML(filename, function () {
var promptSbmlConversionErrorView =
new PromptSbmlConversionErrorView({
el: "#prompt-sbmlConversionError-table",
});
promptSbmlConversionErrorView.render();
document.getElementById("file-conversion-error-message").innerText =
"Conversion service is not available!";
}
);
return;
}
saveAsFcn = chiseInstance.saveAsSbgnml;
}

Expand Down Expand Up @@ -3394,14 +3408,27 @@ var FileSaveView = Backbone.View.extend({
"Conversion service is not available!";
});
} else if (fileformat === "sbml") {
chiseInstance.saveAsSbml(filename, function (data, errorMessage) {
var promptSbmlConversionErrorView =
new PromptSbmlConversionErrorView({
el: "#prompt-sbmlConversionError-table",
});
promptSbmlConversionErrorView.render(data, errorMessage);
//document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
});

if (mapType === "PD") {
chiseInstance.saveAsSbml(filename, function (data, errorMessage) {
var promptSbmlConversionErrorView =
new PromptSbmlConversionErrorView({
el: "#prompt-sbmlConversionError-table",
});
promptSbmlConversionErrorView.render(data, errorMessage);
//document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
});
} else if (mapType === "SBML") {
chiseInstance.saveSbmlForSBML(filename, function (data, errorMessage) {
var promptSbmlConversionErrorView =
new PromptSbmlConversionErrorView({
el: "#prompt-sbmlConversionError-table",
});
promptSbmlConversionErrorView.render(data, errorMessage);
//document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
});
}

} else if (fileformat === "gpml") {
chiseInstance.saveAsGpml(filename, function (data, errorMessage) {
var promptSbmlConversionErrorView =
Expand Down Expand Up @@ -4335,6 +4362,30 @@ var PromptInvalidTypeWarning = Backbone.View.extend({
return this;
},
});

var SifMapWarning = Backbone.View.extend({
initialize: function () {
var self = this;
self.template = _.template($("#sifMapWarning-template").html());
},
render: function () {
var self = this;
self.template = _.template($("#sifMapWarning-template").html());

$(self.el).html(self.template);
$(self.el).modal("show");

$(document)
.off("click", "#sifMapWarning-confirm")
.on("click", "#sifMapWarning-confirm", function (evt) {
$(self.el).modal("toggle");
});

return this;
},
});


var PromtErrorPD2AF = Backbone.View.extend({
initialize: function () {
var self = this;
Expand Down Expand Up @@ -6940,6 +6991,7 @@ module.exports = {
PromptMapTypeView: PromptMapTypeView,
PromptInvalidFileView: PromptInvalidFileView,
PromptInvalidTypeWarning: PromptInvalidTypeWarning,
SifMapWarning: SifMapWarning,
PromtErrorPD2AF: PromtErrorPD2AF,
PromptFileConversionErrorView: PromptFileConversionErrorView,
ExportErrorView: ExportErrorView,
Expand Down
36 changes: 36 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,13 @@
>
<!-- map type change confirmation dialog will be shown here-->
</div>
<div
id="errorSifMap-table"
tabindex="-1"
class="modal fade"
role="dialog"
>
</div>
<div
id="prompt-errorPD2AF-table"
tabindex="-1"
Expand Down Expand Up @@ -4470,7 +4477,36 @@ <h4 class="modal-title">Error</h4>
</div>
</div>
</script>
<!-- SIF Map Warning-->
<script type="text/template" id="sifMapWarning-template">
<div class="modal-dialog sbgn-modal-dialog" style="width: 335px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Error</h4>
</div>
<div class="modal-body">
<table class="table-condensed layout-table dialog-table" style="margin: auto;">
<tbody>
<tr>
<th style="padding-left: 0px;" align="left">
<span class="add-on layout-text centered">Can only be used on SIF maps!</span>
</th>
</tr>

<tr id="sifMapWarning-buttons" style="padding-bottom: 0px; margin-bottom: 0px;">
<td>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer" style="text-align: center">
<button id="sifMapWarning-confirm" class="btn btn-default">OK</button>
</div>
</div>
</div>
</script>
<!-- Invalid Map Type Warning-->
<script type="text/template" id="prompt-errorInvalidType-template">
<div class="modal-dialog sbgn-modal-dialog" style="width: 335px;">
Expand Down

0 comments on commit 9ec0cb4

Please sign in to comment.