access token display and delete works

pull/576/head
Justin Richer 2014-03-01 00:34:59 +00:00
parent 0137f182ff
commit c9bea0f180
1 changed files with 23 additions and 5 deletions

View File

@ -60,7 +60,9 @@ var AccessTokenView = Backbone.View.extend({
}, },
render:function (eventName) { render:function (eventName) {
this.$el.html(this.template(this.model.toJSON())); var json = {token: this.model.toJSON(), client: this.options.client.toJSON()};
this.$el.html(this.template(json));
return this; return this;
}, },
@ -77,7 +79,7 @@ var AccessTokenView = Backbone.View.extend({
self.$el.fadeTo("fast", 0.00, function () { //fade self.$el.fadeTo("fast", 0.00, function () { //fade
$(this).slideUp("fast", function () { //slide up $(this).slideUp("fast", function () { //slide up
$(this).remove(); //then remove from the DOM $(this).remove(); //then remove from the DOM
app.tokenListView.togglePlaceholder(); app.tokensListView.togglePlaceholder();
}); });
}); });
}, },
@ -97,7 +99,7 @@ var AccessTokenView = Backbone.View.extend({
} }
}); });
app.tokenListView.delegateEvents(); app.tokensListView.delegateEvents();
} }
return false; return false;
@ -210,10 +212,14 @@ var TokenListView = Backbone.View.extend({
refreshTable:function() { refreshTable:function() {
var _self = this; var _self = this;
this.model.fetch({ _self.model.access.fetch({
success: function() {
_self.model.refresh.fetch({
success:function() { success:function() {
_self.render(); _self.render();
} }
})
}
}); });
}, },
@ -239,6 +245,18 @@ var TokenListView = Backbone.View.extend({
// append and render the table structure // append and render the table structure
$(this.el).html($('#tmpl-token-table').html()); $(this.el).html($('#tmpl-token-table').html());
var _self = this;
_.each(this.model.access.models, function (token) {
// look up client
var client = app.clientList.getByClientId(token.get('clientId'));
$('#access-token-table', _self.el).append(new AccessTokenView({model: token, client: client}).render().el);
});
// refresh token goes here
/* /*
_.each(this.model.models, function (scope) { _.each(this.model.models, function (scope) {
$("#scope-table", this.el).append(new SystemScopeView({model: scope}).render().el); $("#scope-table", this.el).append(new SystemScopeView({model: scope}).render().el);