From c7e57a0254de41a6896c7ee64a56d54855f783ae Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 6 Jan 2018 18:21:21 -0300 Subject: [PATCH] See Allinq epots changelog v1.3.0 --- .../action-list/organization-filter.coffee | 8 +++++ .../action-list/organization-filter.js | 20 ++++++++++++ .../instance-action-value-display.coffee | 1 + .../project/instance-action-value-display.js | 1 + .../show/project-instance/index.coffee | 1 - .../show/project-instance-group/index.coffee | 32 ++++++++++++++++--- .../show/project-instance/index.coffee | 1 + app/templates/action-list.emblem | 2 +- .../action-list/organization-filter.emblem | 2 +- .../show/project-instance-action/index.emblem | 2 +- .../show/project-instance-group/index.emblem | 11 +++++-- .../show/project-instance/index.emblem | 2 +- .../show/project-instance/show/index.emblem | 3 ++ .../app/i18n/translations/attributes.coffee | 4 ++- tests/dummy/app/initializers/globals.coffee | 9 +++++- 15 files changed, 85 insertions(+), 14 deletions(-) diff --git a/addon/components/action-list/organization-filter.coffee b/addon/components/action-list/organization-filter.coffee index a042aaf..2ced11f 100644 --- a/addon/components/action-list/organization-filter.coffee +++ b/addon/components/action-list/organization-filter.coffee @@ -1,8 +1,16 @@ import Ember from 'ember' +{get} = Ember export default Ember.Component.extend tagName: 'span' organizations: [] + relevant_organizations: Ember.computed 'organizations.[]', 'globals.current_user.admin', -> + return [] unless user = @get('globals.current_user') + organizations = @get('organizations') + return organizations if get(user, 'admin') + organizations.filter (o) -> + user_ids = get(o, 'users').mapBy('id') + get(user, 'id') in user_ids actions: apply_filters: -> @get('apply_filters')?() diff --git a/addon/components/action-list/organization-filter.js b/addon/components/action-list/organization-filter.js index 0785ec7..2b6259a 100644 --- a/addon/components/action-list/organization-filter.js +++ b/addon/components/action-list/organization-filter.js @@ -1,9 +1,29 @@ // Generated by CoffeeScript 1.12.5 +var get, + indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + import Ember from 'ember'; +get = Ember.get; + export default Ember.Component.extend({ tagName: 'span', organizations: [], + relevant_organizations: Ember.computed('organizations.[]', 'globals.current_user.admin', function() { + var organizations, user; + if (!(user = this.get('globals.current_user'))) { + return []; + } + organizations = this.get('organizations'); + if (get(user, 'admin')) { + return organizations; + } + return organizations.filter(function(o) { + var ref, user_ids; + user_ids = get(o, 'users').mapBy('id'); + return ref = get(user, 'id'), indexOf.call(user_ids, ref) >= 0; + }); + }), actions: { apply_filters: function() { var base; diff --git a/addon/components/project/instance-action-value-display.coffee b/addon/components/project/instance-action-value-display.coffee index 3cef8a9..56b81eb 100644 --- a/addon/components/project/instance-action-value-display.coffee +++ b/addon/components/project/instance-action-value-display.coffee @@ -1,6 +1,7 @@ import Ember from 'ember' export default Ember.Component.extend + tagName: 'span' classNames: ['project-instance-action-value-display'] eventIO: null project_instance_action: null diff --git a/addon/components/project/instance-action-value-display.js b/addon/components/project/instance-action-value-display.js index cde28ed..ea2f1e5 100644 --- a/addon/components/project/instance-action-value-display.js +++ b/addon/components/project/instance-action-value-display.js @@ -2,6 +2,7 @@ import Ember from 'ember'; export default Ember.Component.extend({ + tagName: 'span', classNames: ['project-instance-action-value-display'], eventIO: null, project_instance_action: null, diff --git a/app/controllers/project/show/project-instance/index.coffee b/app/controllers/project/show/project-instance/index.coffee index 69eddfc..f2f1eec 100644 --- a/app/controllers/project/show/project-instance/index.coffee +++ b/app/controllers/project/show/project-instance/index.coffee @@ -3,7 +3,6 @@ import {create_date_sort} from 'ember-cli-dunlop/utils/date-sort' {get} = Ember date_sort = create_date_sort('reference_date') export default Ember.Controller.extend - possible_states: ['uncategorized', 'unplanned', 'planned', 'active', 'overdue', 'any_rejected', 'all_completed'] #filter: Ember.Object.create # project_scenario_id_in: [] # state_in: [] diff --git a/app/routes/project/show/project-instance-group/index.coffee b/app/routes/project/show/project-instance-group/index.coffee index 3fc6547..98de963 100644 --- a/app/routes/project/show/project-instance-group/index.coffee +++ b/app/routes/project/show/project-instance-group/index.coffee @@ -1,8 +1,30 @@ import Ember from 'ember' +import PagedRemoteArray from 'ember-cli-pagination/remote/paged-remote-array' +export default_filter = Ember.Object.create + workflow_group_id_in: [] + state_in: [] + s: 'project_instance_reference_date asc' export default Ember.Route.extend + queryParams: + q: + refreshModel: true + + setupController: (controller, model) -> + controller.set 'filters', default_filter + controller.set 'project', @modelFor('project.show') + @_super arguments... + model: (params) -> - #project = @modelFor('project.show') - #Ember.RSVP.hash - # project: project - # project_instance_groups: @store.peekAll('panda/project-instance-group').filterBy('project_instance.project.id', project.get('id')) - @modelFor 'project.show' + project = @modelFor 'project.show' + #@store.findAll('epots/migration-window-planning') + default_filter.project_id = project.id + otherParams = {q: default_filter.toProperties()} + PagedRemoteArray.create + modelName: 'panda/project-instance-group' + store: @store + page: params.page || 1 + perPage: params.perPage || 30 + otherParams: otherParams + paramMapping: + total_pages: 'total-pages' + total_count: 'total-count' diff --git a/app/routes/project/show/project-instance/index.coffee b/app/routes/project/show/project-instance/index.coffee index 0da9f33..458239a 100644 --- a/app/routes/project/show/project-instance/index.coffee +++ b/app/routes/project/show/project-instance/index.coffee @@ -1,6 +1,7 @@ import Ember from 'ember' import PagedRemoteArray from 'ember-cli-pagination/remote/paged-remote-array' export default_filter = Ember.Object.create + state_in: [] s: 'reference_date asc' export default Ember.Route.extend diff --git a/app/templates/action-list.emblem b/app/templates/action-list.emblem index 1fa09ab..c9e8583 100644 --- a/app/templates/action-list.emblem +++ b/app/templates/action-list.emblem @@ -45,7 +45,7 @@ table.ui.attached.stiped.table th = filter.input key='workflow_action_definition_title_cont' = filter.input key='project_instance_client_identifier_cont' - = filter.dropdown-select key='state' options=globals.project_instance_action.states translationPath='attributes.state' + = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_action.states translationPath='attributes.state' = filter.input key='notes_cont' = filter.date-range key='target_date' expandingTime=true weekSelector=true th diff --git a/app/templates/components/action-list/organization-filter.emblem b/app/templates/components/action-list/organization-filter.emblem index f3ee00e..cf48dcc 100644 --- a/app/templates/components/action-list/organization-filter.emblem +++ b/app/templates/components/action-list/organization-filter.emblem @@ -3,7 +3,7 @@ .default.text= t 'action.select_model' modelPath='models.organization' i.dropdown.icon .menu - each organizations as |organization| + each relevant_organizations as |organization| .item data-value='{{map-value mapper organization}}' = organization.name if scope_organization diff --git a/app/templates/project/show/project-instance-action/index.emblem b/app/templates/project/show/project-instance-action/index.emblem index e1c0d47..500a7fc 100644 --- a/app/templates/project/show/project-instance-action/index.emblem +++ b/app/templates/project/show/project-instance-action/index.emblem @@ -56,7 +56,7 @@ table.ui.stiped.table if filters.workflow_action_definition_id_in.length i.remove.icon{action 'clear_filter' 'workflow_action_definition_id_in'} = filter.input key='project_instance_client_identifier_cont' - = filter.dropdown-select key='state' options=globals.project_instance_action.states translationPath='attributes.state' + = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_action.states translationPath='attributes.state' filter.date-range key='target_date' /th class=date_filter_active:active-filter ui-dropdown class='right basic labeled top right pointing icon' action='nothing' diff --git a/app/templates/project/show/project-instance-group/index.emblem b/app/templates/project/show/project-instance-group/index.emblem index cc98ef5..c59b374 100644 --- a/app/templates/project/show/project-instance-group/index.emblem +++ b/app/templates/project/show/project-instance-group/index.emblem @@ -4,9 +4,12 @@ d-breadcrumbs as |breadcrumb| breadcrumb.item span= t 'models.project' span : - = link-to 'project.show' model: span= model.name + = link-to 'project.show' project: span= project.name breadcrumb.item active=true span= t 'models.plural.project_instance_group' +.ui.right.floated.pagination.menu= page-numbers content=model showFL=true += page-title 'models.plural.project_instance_group' + = pagination-progress content=model class='between-brackets' table.ui.stiped.table thead tr @@ -25,8 +28,12 @@ table.ui.stiped.table th= t 'models.project_instance' th= t 'attributes.project_instance_group.state' + table-filters content=model filters=filters as |filter| + = filter.dropdown-select key='workflow_group_id' options=project.sorted_workflow_groups labelPath='name' + = filter.input key='project_instance_client_identifier_cont' + = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_group.states translationPath='attributes.state' tbody - each model.project_instance_groups as |project_instance_group| + each model as |project_instance_group| tr td= link-to 'project.show.project-instance-group.show' project_instance_group.project_instance.project project_instance_group span= project_instance_group.workflow_group.name diff --git a/app/templates/project/show/project-instance/index.emblem b/app/templates/project/show/project-instance/index.emblem index 35cf019..baea5d9 100644 --- a/app/templates/project/show/project-instance/index.emblem +++ b/app/templates/project/show/project-instance/index.emblem @@ -25,7 +25,7 @@ table.ui.table i.upload.icon table-filters content=model filters=filters as |filter| = filter.input key='client_identifier_cont' - = filter.dropdown-select key='state' options=possible_states + = filter.dropdown-select-multiple key='state_in' options=globals.project_instance.states translationPath='attributes.state' = filter.dropdown-select key='project_scenario_id' options=project.sorted_project_scenarios labelPath='name' = filter.date-range key='reference_date' if project.instance_scope_batch diff --git a/app/templates/project/show/project-instance/show/index.emblem b/app/templates/project/show/project-instance/show/index.emblem index 7a61432..d2b3d73 100644 --- a/app/templates/project/show/project-instance/show/index.emblem +++ b/app/templates/project/show/project-instance/show/index.emblem @@ -9,6 +9,9 @@ .ten.wide.column= project_instance_action.workflow_action_definition.title .six.wide.column = project/instance-action-value-display project_instance_action=project_instance_action + if project_instance_action.target_date + ' + small= format-date project_instance_action.target_date format='ll' /if (or (eq project_instance_action.workflow_action_definition.value_type 'boolean') (eq project_instance_action.workflow_action_definition.value_type 'number')) / = project_instance_action.value_display /else diff --git a/tests/dummy/app/i18n/translations/attributes.coffee b/tests/dummy/app/i18n/translations/attributes.coffee index 78ed739..01f7eed 100644 --- a/tests/dummy/app/i18n/translations/attributes.coffee +++ b/tests/dummy/app/i18n/translations/attributes.coffee @@ -5,10 +5,12 @@ translations = attributes: uncategorized: 'uncategorized' unplanned: 'unplanned' planned: 'planned' - active: 'active' overdue: 'overdue' + active: 'active' rejected: 'rejected' completed: 'completed' + all_completed: 'All completed' + any_rejected: 'Has rejected' user: email: 'E-mail' nickname: 'Nickname' diff --git a/tests/dummy/app/initializers/globals.coffee b/tests/dummy/app/initializers/globals.coffee index 60916d0..a65b69c 100644 --- a/tests/dummy/app/initializers/globals.coffee +++ b/tests/dummy/app/initializers/globals.coffee @@ -24,8 +24,15 @@ default_globals = instance_scope_options: ['instance', 'batch'] workflow_group: batch_element_threshold_unit_options: ['businessday', 'day', 'week'] + + project_instance: + states: ['uncategorized', 'unplanned', 'planned', 'active', 'overdue', 'any_rejected', 'all_completed'] + + project_instance_group: + states: ['pending', 'overdue', 'active', 'inquiry', 'rejected', 'completed'] + project_instance_action: - states: ['pending', 'planned', 'overdue', 'inquiry', 'rejected', 'completed'] + states: ['pending', 'planned', 'overdue', 'active', 'inquiry', 'rejected', 'completed'] final_states: ['inquiry', 'rejected', 'completed'] time_formatting: 'LLL'