diff options
Diffstat (limited to 'module/web/static/js/views/accounts/accountListView.js')
-rw-r--r-- | module/web/static/js/views/accounts/accountListView.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/module/web/static/js/views/accounts/accountListView.js b/module/web/static/js/views/accounts/accountListView.js new file mode 100644 index 000000000..ea01f679e --- /dev/null +++ b/module/web/static/js/views/accounts/accountListView.js @@ -0,0 +1,44 @@ +define(['jquery', 'underscore', 'backbone', 'app', 'collections/AccountList', './accountView'], + function($, _, Backbone, App, AccountList, accountView) { + + // Renders settings over view page + return Backbone.View.extend({ + + el: "body", + + events: { + 'click .btn-add': 'addAccount' + }, + + content: null, + accounts: null, + modal: null, + + initialize: function() { + this.content = this.$('#account-content'); + this.accounts = new AccountList(); + this.refresh(); + }, + + refresh: function() { + this.accounts.fetch({success: _.bind(this.render, this)}); + }, + + render: function() { + var self = this; + this.accounts.each(function(account) { + self.content.append(new accountView({model: account}).render().el); + }); + }, + + addAccount: function() { + var self = this; + _.requireOnce(['views/accounts/accountModal'], function(Modal) { + if (self.modal === null) + self.modal = new Modal(); + + self.modal.show(); + }); + } + }); + });
\ No newline at end of file |