Make project specific statistics project available and use for click link to project if has permissions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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')
|
||||
= link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state organization_id=record.id)
|
||||
.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' project_id (query-params state=stat.state organization_id=record.id)
|
||||
= state-badge stat.state
|
||||
'
|
||||
span.between-brackets= stat.count
|
||||
|
||||
@@ -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')
|
||||
= link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state)
|
||||
.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' project_id (query-params state=stat.state)
|
||||
= state-badge stat.state
|
||||
'
|
||||
span.between-brackets= stat.count
|
||||
|
||||
Reference in New Issue
Block a user