diff --git a/addon/components/organization-statistics1.coffee b/addon/components/organization-statistics1.coffee index 09b824e..4f796cf 100644 --- a/addon/components/organization-statistics1.coffee +++ b/addon/components/organization-statistics1.coffee @@ -13,16 +13,14 @@ export default Ember.Component.extend states = ['pending', 'planned', 'active', 'overdue', 'inquiry', 'rejected', 'completed'] project_specific = @get('project_specific') unless project_specific - global_name = t('organization.statistics1.global.title') states.forEach (state) -> target[state] = 0 for project_id, stats of d.content.data if project_specific project = d.content.projects.findBy('id', project_id) - project_name = project.get('name') - target[project_name] = [] + target[project_id] = {project: project, states: []} states.forEach (state) -> - target[project_name].push(state: state, count: stats[state] || 0, project_id: project_id) + target[project_id].states.push(state: state, count: stats[state] || 0) else for state, count of stats target[state] += count diff --git a/addon/components/organization-statistics1.js b/addon/components/organization-statistics1.js index f3beb1e..2202bdf 100644 --- a/addon/components/organization-statistics1.js +++ b/addon/components/organization-statistics1.js @@ -9,7 +9,7 @@ export default Ember.Component.extend({ session: Ember.inject.service('session'), classNames: ['project-aggregate-statistics', 'project-aggregate-organization-statistics'], statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() { - var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target; + var count, d, project, project_id, project_specific, ref, state, states, stats, target; d = this.get('statistics_data'); if (!d.isFulfilled) { return {}; @@ -18,7 +18,6 @@ export default Ember.Component.extend({ states = ['pending', 'planned', 'active', 'overdue', 'inquiry', 'rejected', 'completed']; project_specific = this.get('project_specific'); if (!project_specific) { - global_name = t('organization.statistics1.global.title'); states.forEach(function(state) { return target[state] = 0; }); @@ -28,13 +27,14 @@ export default Ember.Component.extend({ stats = ref[project_id]; if (project_specific) { project = d.content.projects.findBy('id', project_id); - project_name = project.get('name'); - target[project_name] = []; + target[project_id] = { + project: project, + states: [] + }; states.forEach(function(state) { - return target[project_name].push({ + return target[project_id].states.push({ state: state, - count: stats[state] || 0, - project_id: project_id + count: stats[state] || 0 }); }); } else { diff --git a/addon/components/user-main-statistics1.coffee b/addon/components/user-main-statistics1.coffee index b65f9d3..d25b36f 100644 --- a/addon/components/user-main-statistics1.coffee +++ b/addon/components/user-main-statistics1.coffee @@ -14,16 +14,14 @@ export default Ember.Component.extend states = @get('globals.project_instance_action.states') project_specific = @get('project_specific') unless project_specific - global_name = t('user.statistics1.global.title') states.forEach (state) -> target[state] = 0 for project_id, stats of d.content.data if project_specific project = d.content.projects.findBy('id', project_id) - project_name = project.get('name') - target[project_name] = [] + target[project_id] = {project: project, states: []} states.forEach (state) -> - target[project_name].push(state: state, count: stats[state] || 0, project_id: project_id) + target[project_id].states.push(state: state, count: stats[state] || 0) else for state, count of stats target[state] += count diff --git a/addon/components/user-main-statistics1.js b/addon/components/user-main-statistics1.js index 84124ee..f27b519 100644 --- a/addon/components/user-main-statistics1.js +++ b/addon/components/user-main-statistics1.js @@ -9,7 +9,7 @@ export default Ember.Component.extend({ session: Ember.inject.service('session'), classNames: ['project-aggregate-statistics', 'project-aggregate-user-statistics'], statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() { - var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target; + var count, d, project, project_id, project_specific, ref, state, states, stats, target; d = this.get('statistics_data'); if (!d.isFulfilled) { return {}; @@ -18,7 +18,6 @@ export default Ember.Component.extend({ states = this.get('globals.project_instance_action.states'); project_specific = this.get('project_specific'); if (!project_specific) { - global_name = t('user.statistics1.global.title'); states.forEach(function(state) { return target[state] = 0; }); @@ -28,13 +27,14 @@ export default Ember.Component.extend({ stats = ref[project_id]; if (project_specific) { project = d.content.projects.findBy('id', project_id); - project_name = project.get('name'); - target[project_name] = []; + target[project_id] = { + project: project, + states: [] + }; states.forEach(function(state) { - return target[project_name].push({ + return target[project_id].states.push({ state: state, - count: stats[state] || 0, - project_id: project_id + count: stats[state] || 0 }); }); } else { diff --git a/app/templates/components/organization-statistics1.emblem b/app/templates/components/organization-statistics1.emblem index 5452dba..3838f19 100644 --- a/app/templates/components/organization-statistics1.emblem +++ b/app/templates/components/organization-statistics1.emblem @@ -2,11 +2,16 @@ if statistics ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific)) ' if project_specific - each-in statistics as |project_name stats| - .ui.header= project_name - = each stats as |stat| + each-in statistics as |project_id stats| + if (can 'read' 'model' 'panda/project-instance') + .ui.header + = link-to 'project.show' project_id + = stats.project.name + else + .ui.header= stats.project.name + each stats.states as |stat| if (can 'read' 'model' 'panda/project-instance') - = link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state organization_id=record.id) + = link-to 'project.show.project-instance-action' project_id (query-params state=stat.state organization_id=record.id) = state-badge stat.state ' span.between-brackets= stat.count diff --git a/app/templates/components/user-main-statistics1.emblem b/app/templates/components/user-main-statistics1.emblem index 8cc8e8e..5c46b76 100644 --- a/app/templates/components/user-main-statistics1.emblem +++ b/app/templates/components/user-main-statistics1.emblem @@ -5,11 +5,16 @@ if user.email ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific)) ' if project_specific - each-in statistics as |project_name stats| - .ui.header= project_name - = each stats as |stat| + each-in statistics as |project_id stats| + if (can 'read' 'model' 'panda/project-instance') + .ui.header + = link-to 'project.show' project_id + = stats.project.name + else + .ui.header= stats.project.name + = each stats.states as |stat| if (can 'read' 'model' 'panda/project-instance') - = link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state) + = link-to 'project.show.project-instance-action' project_id (query-params state=stat.state) = state-badge stat.state ' span.between-brackets= stat.count