I'm trying to figure out how to trigger my login modal before allowing user to create something.
Did some research, found that I could use beforeModel, but I'm concerned that would prevent user from seeing the entire route? I want the route to remain visible, just want the user to be triggered a login modal if not authenticated yet.
My template:
<div class="input-group input-group-lg center-block">
{{input class="form-control" type="text" value=newListTitle action="createList" placeholder="Create a Stack"}}
</div>
My route with the action:
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.find('list');
},
actions: {
createList: function() {
var newListTitle = this.controllerFor('lists').get('newListTitle');
//var user = this.get('session.user.displayName');
var userId = this.get('session.user.uid');
//var user = this.get('session.user');
if (Ember.isBlank(newListTitle)) { return false; }
//1
var list = this.store.createRecord('list', {
title: newListTitle,
user: userId,
});
...
Modal:
{{#modal-dialog title="modal" id="modal" action="close"}}
...
Thanks, I'd appreciate if you could point me in the right direction.
Aucun commentaire:
Enregistrer un commentaire