From 080643e89af62013d70bb574cd54cf4876628515 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 11 Aug 2013 20:36:10 +0200 Subject: improved account list --- .../web/app/scripts/views/accounts/accountView.js | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'pyload/web/app/scripts/views/accounts/accountView.js') diff --git a/pyload/web/app/scripts/views/accounts/accountView.js b/pyload/web/app/scripts/views/accounts/accountView.js index 7d1f04315..123327a27 100644 --- a/pyload/web/app/scripts/views/accounts/accountView.js +++ b/pyload/web/app/scripts/views/accounts/accountView.js @@ -9,10 +9,39 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/accounts/account'], template: template, events: { - 'click .btn-danger': 'deleteAccount' + 'click .btn-success': 'toggle', + 'click .btn-blue': 'edit', + 'click .btn-yellow': 'refresh', + 'click .btn-danger': 'remove' }, - deleteAccount: function() { + modelEvents: { + 'change': 'render' + }, + + modal: null, + + toggle: function() { + this.model.set('activated', !this.model.get('activated')); + this.model.save(); + }, + + edit: function() { + // TODO: clean the modal on view close + var self = this; + _.requireOnce(['views/accounts/accountEdit'], function(Modal) { + if (self.modal === null) + self.modal = new Modal({model: self.model}); + + self.modal.show(); + }); + }, + + refresh: function() { + this.model.fetch({refresh: true}); + }, + + remove: function() { this.model.destroy(); } }); -- cgit v1.2.3