Skip to content

Commit

Permalink
UI: implemented can_edit #200
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Jan 21, 2015
1 parent 7ec7764 commit d7082cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
10 changes: 5 additions & 5 deletions nodeshot/ui/default/static/ui/nodeshot/js/app.js
Expand Up @@ -30,16 +30,16 @@
body: '#body'
});

// init layout
// main initializers
Ns.addInitializer(function () {
Ns.notifications.show(new Ns.views.Notification());
Ns.account.show(new Ns.views.Account());
Ns.menu.show(new Ns.views.Menu());
Ns.search.show(new Ns.views.Search());
});

// init pages
Ns.addInitializer(function () {
// empty node cache when user logs in / logs out
// needed for node can_edit
Ns.db.user.on('loggedin loggedout', function(){ Ns.db.nodes.reset() });
// init backbone app
Backbone.history.start();
});

Expand Down
11 changes: 9 additions & 2 deletions nodeshot/ui/default/static/ui/nodeshot/js/views/map.js
Expand Up @@ -73,8 +73,15 @@
},

showEditNode: function(node) {
this.details.show(new Ns.views.node.Detail({ model: node, parent: this }));
this.details.currentView.edit();
// ensure is allowed to edit
if (node.get('can_edit')) {
this.details.show(new Ns.views.node.Detail({ model: node, parent: this }));
this.details.currentView.edit();
}
// otherwise go back to details
else {
Ns.router.navigate('nodes/' + node.id, { trigger: true });
}
},

/*
Expand Down
2 changes: 1 addition & 1 deletion nodeshot/ui/default/templates/includes/node-details.html
Expand Up @@ -16,7 +16,7 @@ <h2>
<a href="javascript:$.createModal({message:'not implemented yet'})" class="icon-mail">{% trans 'contact' %}</a>
<% } %>
<a href="#permalink" class="icon-link" data-text="{% trans 'Press CTRL+C to copy' %}">{% trans 'permalink' %}</a>
<% if(Ns.db.user.isAuthenticated()){ %>
<% if(Ns.db.user.isAuthenticated() && can_edit){ %>
<a href="#nodes/<%= slug %>/edit" class="icon-edit">{% trans 'edit' %}</a>
<% } %>
</p>
Expand Down

0 comments on commit d7082cc

Please sign in to comment.