Skip to content

Instantly share code, notes, and snippets.

@Mariusio
Created March 9, 2016 18:51
Show Gist options
  • Save Mariusio/b4e37b223c854b31f33b to your computer and use it in GitHub Desktop.
Save Mariusio/b4e37b223c854b31f33b to your computer and use it in GitHub Desktop.
showDashboardLink: Ember.computed(
function() {
if (this.get('session.isAuthenticated')) {
return this.get('store').findAll('datasource').then((datasources) => {
this.get('store').filter('datasource', {}, function(datasource) {
return datasource.get('id') != null;
}).then((datasources) => {
if (datasources.get('length') != 0) {
return true
} else {
return false
}
});
});
} else {
return false
}
}
),
@stephencattaneo
Copy link


showDashboardLink: false,
watchIsAuthenticated: Ember.observer('session.isAuthenticated', function() {
 if (this.get('session.isAuthenticated')) {
        return this.get('store').findAll('datasource').then((datasources) => {
          this.get('store').filter('datasource', {}, function(datasource) {
            return datasource.get('id') != null;
          }).then(function(datasources) {
            this.set('showDashboardLink', datasources.get('length') !== 0); 
          }.bind(this));
        });
      } else {
         this.set('showDashboardLink', false);
      }
}),

@Mariusio
Copy link
Author

Mariusio commented Mar 9, 2016


  watchIsAuthenticated: Ember.observer('session.isAuthenticated', () => {
   if (this.get('session.isAuthenticated')) {
          return this.get('store').findAll('datasource').then((datasources) => {
            this.get('store').filter('datasource', {}, (datasource) => {
              return true;
            }).then((datasources) => {
              this.set('showDashboardLink', true);
            }.bind(this));
          });
        } else {
           this.set('showDashboardLink', true);
        }
  }),

@locks
Copy link

locks commented Mar 9, 2016

(datasources) => {
              this.set('showDashboardLink', true);
            }.bind(this)

unnecesary bind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment