diff options
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r-- | module/web/static/js/views/accounts/accountListView.js | 44 | ||||
-rw-r--r-- | module/web/static/js/views/accounts/accountModal.js | 60 | ||||
-rw-r--r-- | module/web/static/js/views/accounts/accountView.js | 19 |
3 files changed, 123 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 diff --git a/module/web/static/js/views/accounts/accountModal.js b/module/web/static/js/views/accounts/accountModal.js new file mode 100644 index 000000000..898b10a89 --- /dev/null +++ b/module/web/static/js/views/accounts/accountModal.js @@ -0,0 +1,60 @@ +define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/accountDialog.html', 'select2'], + function($, _, App, modalView, template) { + return modalView.extend({ + + events: { + 'click .btn-add': 'add' + }, + template: _.compile(template), + plugins: null, + select: null, + + initialize: function() { + // Inherit parent events + this.events = _.extend({}, modalView.prototype.events, this.events); + var self = this; + $.ajax(App.apiRequest('getAccountTypes', null, {success: function(data) { + self.plugins = _.sortBy(data, function(item) { + return item; + }); + self.render(); + }})); + }, + + onRender: function() { + // TODO: could be a seperate input type if needed on multiple pages + if (this.plugins) + this.select = this.$('#pluginSelect').select2({ + escapeMarkup: function(m) { + return m; + }, + formatResult: this.format, + formatSelection: this.format, + data: {results: this.plugins, text: function(item) { + return item; + }}, + id: function(item) { + return item; + } + }); + }, + + onShow: function() { + }, + + onHide: function() { + }, + + format: function(data) { + return '<img class="logo-select" src="icons/' + data + '"> ' + data; + }, + + add: function(e) { + e.stopPropagation(); + if (this.select) { + var plugin = this.select.val(); + // TODO + } + } + }); + });
\ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountView.js b/module/web/static/js/views/accounts/accountView.js new file mode 100644 index 000000000..f310e4cc2 --- /dev/null +++ b/module/web/static/js/views/accounts/accountView.js @@ -0,0 +1,19 @@ +define(['jquery', 'underscore', 'backbone', 'app'], + function($, _, Backbone, App) { + + // Renders settings over view page + return Backbone.View.extend({ + + el: "li", + + events: { + }, + + initialize: function() { + }, + + render: function() { + return this; + } + }); + });
\ No newline at end of file |