Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Last active August 1, 2017 07:32
Show Gist options
  • Save kumkanillam/77853a0da29f25eca9633a1a019949d2 to your computer and use it in GitHub Desktop.
Save kumkanillam/77853a0da29f25eca9633a1a019949d2 to your computer and use it in GitHub Desktop.
test
import Ember from 'ember';
export default Ember.Component.extend({
userConfig: Ember.inject.service(),
didReceiveAttrs(){
console.log(' didReceiveAttrs in report-prereq');
let prerequisiteCategory = this.get('userConfig').isReportPrerequisiteNeeded(this.get('reportId'));
if(prerequisiteCategory){
if(prerequisiteCategory === 'sharepoint-report-permission'){
//request the server ajax request
Ember.RSVP.resolve('getJSON').then((result)=>{
//logic check autoAddPermission false && siteCollection is there without permission
this.set('showSharePointReportPermission',true);
});
}
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
userConfig:Ember.inject.service(),
currentRouteNameChanged: Ember.observer('currentRouteName', function() {
this.set('userConfig.currentRouteName', this.get('currentRouteName'));
}),
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('reports',{path:'reports/:reportId'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model({reportId}){
return {reportId};
}
});
import Ember from 'ember';
export default Ember.Service.extend({
currentRouteName:'',
isSharePointReports:Ember.computed('currentRouteName',function(){
return this.get('currentRouteName') === 'reports' ? true: false;
}),
isExchangeAuditReports:Ember.computed('currentRouteName',function(){
return true;
}),
isReportPrerequisiteNeeded(reportId){
if(this.get('isSharePointReports') && this.get('reportId') == 1){
return 'sharepoint-report-permission'
}
/*
if(this.get('isExchangeAuditReports')){
return 'exchange-audit-reports-permission';
}
*/
return false;
}
});
<h1>Welcome to {{appName}}</h1>
<br>
{{userConfig.isReports}}
<br>
{{outlet}}
<br>
<br>
{{#if userConfig.isReportPrerequisite}}
Permission Needed
{{/if}}
{{yield}}
ReportId{{model.reportId}}{{report-prerequisite reportId=model.reportId }}
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment