From 620bce4c267245b217d73205d53c00e289c3df85 Mon Sep 17 00:00:00 2001 From: Jens Kuebler Date: Mon, 20 Feb 2017 22:06:15 +0100 Subject: [PATCH] F: #187 add gauges --- src/js/oseam-views-gaugedialog.js | 56 ++++++++++++++++++++++ src/js/templates/gaugedialog-en.handlebars | 43 +++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/js/oseam-views-gaugedialog.js create mode 100644 src/js/templates/gaugedialog-en.handlebars diff --git a/src/js/oseam-views-gaugedialog.js b/src/js/oseam-views-gaugedialog.js new file mode 100644 index 0000000..9c52d7c --- /dev/null +++ b/src/js/oseam-views-gaugedialog.js @@ -0,0 +1,56 @@ +OSeaM.views.GaugeDialog = OSeaM.View.extend({ + + events : { + 'click #oseam-cancel' : 'onCancel', + 'click #close' : 'onCancel', + 'click #oseam-save' : 'onSave', + }, + initialize : function() { + OSeaM.frontend.on("change:language", this.render, this); + }, + render : function() { + new OSeaM.views.Wizard(); + var language = OSeaM.frontend.getLanguage(); + var template = OSeaM.loadTemplate('gaugedialog-' + language); + //var template = OSeaM.loadTemplate('vessel'); + this.renderParams = { + name : this.model.get('name') + }; + var content = $(template(this.renderParams)); + OSeaM.frontend.translate(content); + this.$el.append(content); + this.el = content; + return content; + }, + onCancel : function(evt) { + // removes the inserted dialog div and stops listening for events + // this.wizard.remove(); + this.el.remove(); + this.undelegateEvents(); + }, + onSave : function(evt) { + /* + * If this is new project it won't have the ID attribute defined + */ + if (null == this.model.id) { + /* + * We are creating our model through its collection (this way we'll automatically update its views and persist it to DB) + */ + this.model.save(); + this.collection.add(this.model); + } else { + /* + * Simple save will persist the model to the DB and update its view + */ + this.model.save(); + } + /* + * Hiding modal dialog window + * removes the inserted dialog div and stops listening for events + */ + // + // this.wizard.remove(); + this.el.remove(); + this.undelegateEvents(); + } +}); \ No newline at end of file diff --git a/src/js/templates/gaugedialog-en.handlebars b/src/js/templates/gaugedialog-en.handlebars new file mode 100644 index 0000000..873670e --- /dev/null +++ b/src/js/templates/gaugedialog-en.handlebars @@ -0,0 +1,43 @@ +