Action list filtering revamp
This commit is contained in:
@@ -3,10 +3,12 @@ import Ember from 'ember'
|
|||||||
|
|
||||||
export default Ember.Controller.extend
|
export default Ember.Controller.extend
|
||||||
session: Ember.inject.service('session')
|
session: Ember.inject.service('session')
|
||||||
filters: {}
|
filters: {filter_calls: 0} # will be overwritten in route
|
||||||
scope_project: null
|
scope_project: null
|
||||||
scope_scenario: null
|
scope_scenario: null
|
||||||
scope_organization: null
|
scope_organization: null
|
||||||
|
projects: ( -> @store.findAll('panda/project')).property()
|
||||||
|
sorted_projects: Ember.computed 'projects.@each.name', -> @get('projects').sortBy('name')
|
||||||
show_completed_at: Ember.computed 'filters.state_in.[]', 'filters.completed_at_gteq', 'filters.completed_at_lteq', 'filters.s', ->
|
show_completed_at: Ember.computed 'filters.state_in.[]', 'filters.completed_at_gteq', 'filters.completed_at_lteq', 'filters.s', ->
|
||||||
return true if @get('filters.completed_at_lteq') or @get('filters.completed_at_gteq')
|
return true if @get('filters.completed_at_lteq') or @get('filters.completed_at_gteq')
|
||||||
return true if /^completed_at/.test @get('filters.s')
|
return true if /^completed_at/.test @get('filters.s')
|
||||||
@@ -27,12 +29,29 @@ export default Ember.Controller.extend
|
|||||||
base_url = @store.adapterFor(model_name).buildURL(model_name)
|
base_url = @store.adapterFor(model_name).buildURL(model_name)
|
||||||
filter_addition = Ember.$.param q: @get('filter_query'), include_pointing: true
|
filter_addition = Ember.$.param q: @get('filter_query'), include_pointing: true
|
||||||
"#{base_url}/export_technical.csv?#{filter_addition}"
|
"#{base_url}/export_technical.csv?#{filter_addition}"
|
||||||
apply_filters: ->
|
|
||||||
@incrementProperty 'filters.filter_calls'
|
|
||||||
@get('model.project_instance_actions')?.reload()
|
|
||||||
false
|
|
||||||
actions:
|
actions:
|
||||||
refresh_list: -> @apply_filters()
|
apply_filters: ->
|
||||||
|
@incrementProperty 'filters.filter_calls'
|
||||||
|
current_scope_project_id = @get('scope_project.id')
|
||||||
|
if project_ids = @get('filters.project_id_in')
|
||||||
|
if project_ids.length is 1
|
||||||
|
if current_scope_project_id isnt project_ids[0] # only reload if changed
|
||||||
|
project = @store.peekRecord('panda/project', project_ids[0]) # projects all pre-loaded
|
||||||
|
@set 'filters.workflow_action_definition_title_cont', '' if @get('filters.workflow_action_definition_title_cont') # this field disappears since actual action matching is assumed
|
||||||
|
project.reload().then =>
|
||||||
|
@set 'scope_project', project
|
||||||
|
else if @get('scope_project')
|
||||||
|
@set 'scope_project', null
|
||||||
|
@set 'filters.project_instance_project_scenario_id_in', []
|
||||||
|
@set 'filters.project_instance_group_workflow_group_id_in', []
|
||||||
|
@set 'filters.workflow_action_definition_identifier_in', []
|
||||||
|
else if @get('scope_project')
|
||||||
|
@set 'scope_project', null
|
||||||
|
@set 'filters.project_instance_project_scenario_id_in', []
|
||||||
|
@set 'filters.project_instance_group_workflow_group_id_in', []
|
||||||
|
@set 'filters.workflow_action_definition_identifier_in', []
|
||||||
|
@get('model.project_instance_actions')?.reload()
|
||||||
|
false
|
||||||
edit_project_instance_action: (project_instance_action) ->
|
edit_project_instance_action: (project_instance_action) ->
|
||||||
@modal 'project/edit-instance-action', model: project_instance_action
|
@modal 'project/edit-instance-action', model: project_instance_action
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,18 @@ import Ember from 'ember';
|
|||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
session: Ember.inject.service('session'),
|
session: Ember.inject.service('session'),
|
||||||
filters: {},
|
filters: {
|
||||||
|
filter_calls: 0
|
||||||
|
},
|
||||||
scope_project: null,
|
scope_project: null,
|
||||||
scope_scenario: null,
|
scope_scenario: null,
|
||||||
scope_organization: null,
|
scope_organization: null,
|
||||||
|
projects: (function() {
|
||||||
|
return this.store.findAll('panda/project');
|
||||||
|
}).property(),
|
||||||
|
sorted_projects: Ember.computed('projects.@each.name', function() {
|
||||||
|
return this.get('projects').sortBy('name');
|
||||||
|
}),
|
||||||
show_completed_at: Ember.computed('filters.state_in.[]', 'filters.completed_at_gteq', 'filters.completed_at_lteq', 'filters.s', function() {
|
show_completed_at: Ember.computed('filters.state_in.[]', 'filters.completed_at_gteq', 'filters.completed_at_lteq', 'filters.s', function() {
|
||||||
if (this.get('filters.completed_at_lteq') || this.get('filters.completed_at_gteq')) {
|
if (this.get('filters.completed_at_lteq') || this.get('filters.completed_at_gteq')) {
|
||||||
return true;
|
return true;
|
||||||
@@ -51,17 +59,40 @@ export default Ember.Controller.extend({
|
|||||||
});
|
});
|
||||||
return base_url + "/export_technical.csv?" + filter_addition;
|
return base_url + "/export_technical.csv?" + filter_addition;
|
||||||
}),
|
}),
|
||||||
apply_filters: function() {
|
|
||||||
var ref;
|
|
||||||
this.incrementProperty('filters.filter_calls');
|
|
||||||
if ((ref = this.get('model.project_instance_actions')) != null) {
|
|
||||||
ref.reload();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh_list: function() {
|
apply_filters: function() {
|
||||||
return this.apply_filters();
|
var current_scope_project_id, project, project_ids, ref;
|
||||||
|
this.incrementProperty('filters.filter_calls');
|
||||||
|
current_scope_project_id = this.get('scope_project.id');
|
||||||
|
if (project_ids = this.get('filters.project_id_in')) {
|
||||||
|
if (project_ids.length === 1) {
|
||||||
|
if (current_scope_project_id !== project_ids[0]) {
|
||||||
|
project = this.store.peekRecord('panda/project', project_ids[0]);
|
||||||
|
if (this.get('filters.workflow_action_definition_title_cont')) {
|
||||||
|
this.set('filters.workflow_action_definition_title_cont', '');
|
||||||
|
}
|
||||||
|
project.reload().then((function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.set('scope_project', project);
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
|
}
|
||||||
|
} else if (this.get('scope_project')) {
|
||||||
|
this.set('scope_project', null);
|
||||||
|
this.set('filters.project_instance_project_scenario_id_in', []);
|
||||||
|
this.set('filters.project_instance_group_workflow_group_id_in', []);
|
||||||
|
this.set('filters.workflow_action_definition_identifier_in', []);
|
||||||
|
}
|
||||||
|
} else if (this.get('scope_project')) {
|
||||||
|
this.set('scope_project', null);
|
||||||
|
this.set('filters.project_instance_project_scenario_id_in', []);
|
||||||
|
this.set('filters.project_instance_group_workflow_group_id_in', []);
|
||||||
|
this.set('filters.workflow_action_definition_identifier_in', []);
|
||||||
|
}
|
||||||
|
if ((ref = this.get('model.project_instance_actions')) != null) {
|
||||||
|
ref.reload();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
edit_project_instance_action: function(project_instance_action) {
|
edit_project_instance_action: function(project_instance_action) {
|
||||||
return this.modal('project/edit-instance-action', {
|
return this.modal('project/edit-instance-action', {
|
||||||
|
|||||||
@@ -11,17 +11,15 @@
|
|||||||
a href=export_human_url: span Human
|
a href=export_human_url: span Human
|
||||||
.item
|
.item
|
||||||
a href=export_technical_url: span Technical
|
a href=export_technical_url: span Technical
|
||||||
= action-list/project-filter apply_filters=(action 'refresh_list') filters=filters scope_project=scope_project scope_scenario=scope_scenario projects=model.projects
|
/= action-list/project-filter apply_filters=(action 'apply_filters') filters=filters scope_project=scope_project scope_scenario=scope_scenario projects=model.projects
|
||||||
= action-list/organization-filter apply_filters=(action 'refresh_list') filters=filters scope_organization=scope_organization organizations=model.organizations
|
/= action-list/organization-filter apply_filters=(action 'apply_filters') filters=filters scope_organization=scope_organization organizations=model.organizations
|
||||||
|
.clearfix
|
||||||
table.ui.attached.stiped.sortable.table
|
table.ui.attached.stiped.sortable.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
unless scope_project
|
th= t 'models.organization'
|
||||||
th= t 'models.project'
|
th= t 'models.project'
|
||||||
unless scope_scenario
|
th= t 'models.project_scenario'
|
||||||
th= t 'models.project_scenario'
|
|
||||||
unless scope_organization
|
|
||||||
th= t 'models.organization'
|
|
||||||
th= t 'models.project_instance_group'
|
th= t 'models.project_instance_group'
|
||||||
th= t 'models.workflow_action_definition'
|
th= t 'models.workflow_action_definition'
|
||||||
= sortable-table-header filters=filters key='project_instance_client_identifier' model=model.project_instance_actions defaultDirection='asc'
|
= sortable-table-header filters=filters key='project_instance_client_identifier' model=model.project_instance_actions defaultDirection='asc'
|
||||||
@@ -37,17 +35,15 @@ table.ui.attached.stiped.sortable.table
|
|||||||
= sortable-table-header filters=filters key='inquiry_at' model=model.project_instance_actions defaultDirection='desc'
|
= sortable-table-header filters=filters key='inquiry_at' model=model.project_instance_actions defaultDirection='desc'
|
||||||
= t 'attributes.project_instance_action.inquiry_at'
|
= t 'attributes.project_instance_action.inquiry_at'
|
||||||
th= t 'attributes.project_instance_action.value'
|
th= t 'attributes.project_instance_action.value'
|
||||||
table-filters content=model.project_instance_actions filters=filters as |filter|
|
table-filters content=model.project_instance_actions filters=filters apply_filters=(action 'apply_filters') as |filter|
|
||||||
unless scope_project
|
= filter.dropdown-select-multiple key='workflow_action_definition_organization_id_in' options=model.organizations labelPath='name'
|
||||||
th
|
= filter.dropdown-select-multiple key='project_id_in' options=sorted_projects labelPath='name'
|
||||||
unless scope_scenario
|
|
||||||
th
|
|
||||||
unless scope_organization
|
|
||||||
th
|
|
||||||
if (and scope_project scope_project.isLoaded)
|
if (and scope_project scope_project.isLoaded)
|
||||||
= filter.dropdown-select key='project_instance_group_workflow_group_id' options=scope_project.sorted_workflow_groups labelPath='name'
|
= filter.dropdown-select-multiple key='project_instance_project_scenario_id_in' options=scope_project.sorted_project_scenarios labelPath='name'
|
||||||
= filter.dropdown-select-multiple key='workflow_action_definition_identifier_in' options=scope_project.sorted_workflow_action_definitions labelPath='title' valuePath='identifier'
|
= filter.dropdown-select-multiple key='project_instance_group_workflow_group_id_in' options=scope_project.sorted_workflow_groups labelPath='name'
|
||||||
|
= filter.dropdown-select-multiple key='workflow_action_definition_identifier_in' options=scope_project.sorted_workflow_action_definitions labelPath='title' valuePath='identifier'
|
||||||
else
|
else
|
||||||
|
th
|
||||||
th
|
th
|
||||||
= filter.input key='workflow_action_definition_title_cont'
|
= filter.input key='workflow_action_definition_title_cont'
|
||||||
= filter.input key='project_instance_client_identifier_cont'
|
= filter.input key='project_instance_client_identifier_cont'
|
||||||
@@ -67,12 +63,9 @@ table.ui.attached.stiped.sortable.table
|
|||||||
else
|
else
|
||||||
each model.project_instance_actions as |project_instance_action|
|
each model.project_instance_actions as |project_instance_action|
|
||||||
tr.record-with-pointing-records
|
tr.record-with-pointing-records
|
||||||
unless scope_project
|
td= project_instance_action.workflow_action_definition.organization.name
|
||||||
td= project_instance_action.project.name
|
td= project_instance_action.project.name
|
||||||
unless scope_scenario
|
td= project_instance_action.project_instance.project_scenario.name
|
||||||
td= project_instance_action.project_instance.project_scenario.name
|
|
||||||
unless scope_organization
|
|
||||||
td= project_instance_action.workflow_action_definition.organization.name
|
|
||||||
td
|
td
|
||||||
if project_instance_action.project_instance_group.id
|
if project_instance_action.project_instance_group.id
|
||||||
if (can 'read' 'model' 'panda/project-instance')
|
if (can 'read' 'model' 'panda/project-instance')
|
||||||
|
|||||||
Reference in New Issue
Block a user