Skip to content

Commit

Permalink
Fix for #712 item 1. Added ExportErrorView as popup message for non a…
Browse files Browse the repository at this point in the history
…pplicable exports.
  • Loading branch information
okg21 committed Jul 1, 2024
1 parent 34da6cb commit db7c4d2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/js/backbone-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,24 @@ var FileSaveView = Backbone.View.extend({
var self = this;
self.template = _.template($("#file-save-template").html());

// Check for unsupported conversions
map_type = appUtilities.getActiveChiseInstance().elementUtilities.mapType;
var unsupportedConversions = {
"PD": ["sif", "sifLayout"],
"AF": ["sif", "sifLayout", "sbml", "celldesigner", "gpml"],
"PD+AF": ["sif", "sifLayout", "sbml", "celldesigner", "gpml"],
"SIF": ["sbgn", "sbml", "celldesigner", "gpml"],
"SBML": ["sif", "sifLayout", "gpml"],
"All": ["sbgn", "sif", "sifLayout", "sbml", "celldesigner", "gpml"]
};

if (unsupportedConversions[map_type] && unsupportedConversions[map_type].includes(fileformat)) {
var exportErrorView = new ExportErrorView({el: "#exportError-table",});
exportErrorView.render();
document.getElementById("export-error-message").innerText = "Not applicable for the current map type!";
return;
}

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

Expand Down Expand Up @@ -4339,6 +4357,28 @@ var PromptFileConversionErrorView = Backbone.View.extend({
},
});

var ExportErrorView = Backbone.View.extend({
initialize: function () {
var self = this;
self.template = _.template(
$("#export-Error-template").html()
);
},
render: function () {
var self = this;
$(self.el).html(self.template);
$(self.el).modal("show");

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

return this;
},
});

var PromptSbmlConversionErrorView = Backbone.View.extend({
initialize: function () {
var self = this;
Expand Down Expand Up @@ -6874,6 +6914,7 @@ module.exports = {
PromptInvalidTypeWarning: PromptInvalidTypeWarning,
PromtErrorPD2AF: PromtErrorPD2AF,
PromptFileConversionErrorView: PromptFileConversionErrorView,
ExportErrorView: ExportErrorView,
ReactionTemplateView: ReactionTemplateView,
GridPropertiesView: GridPropertiesView,
FontPropertiesView: FontPropertiesView,
Expand Down
35 changes: 35 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,15 @@
>
<!-- map type change confirmation dialog will be shown here-->
</div>

<div
id="exportError-table"
tabindex="-1"
class="modal fade"
role="dialog"
>
</div>

<div
id="prompt-sbmlConversionError-table"
tabindex="-1"
Expand Down Expand Up @@ -4392,6 +4401,32 @@ <h4 class="modal-title">Error</h4>
</div>
</script>

<!-- Export error warning -->
<script type="text/template" id="export-Error-template">
<div class="modal-dialog sbgn-modal-dialog" style="width: 300px;">
<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" id="export-error-message">Conversion failed!</span>
</th>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer" style="text-align: center">
<button id="export-Error-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 db7c4d2

Please sign in to comment.