start on work_packages_table widget

pull/7185/head
Jens Ulferts 6 years ago
parent f7c0d37bdb
commit 323487bee0
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 2
      config/locales/js-en.yml
  2. 7
      frontend/src/app/modules/grids/openproject-grids.module.ts
  3. 24
      frontend/src/app/modules/grids/widgets/wp-table/wp-table.component.ts
  4. 1
      modules/grids/lib/grids/my_page_grid_registration.rb
  5. 96
      modules/grids/spec/features/my/my_page_work_package_table_spec.rb

@ -208,6 +208,8 @@ en:
title: 'Work packages created by me'
work_packages_watched:
title: 'Work packages watched by me'
work_packages_table:
title: 'Work package table'
work_packages_calendar:
title: 'Calendar'

@ -50,6 +50,7 @@ import {Ng2StateDeclaration, UIRouterModule} from '@uirouter/angular';
import {WidgetDocumentsComponent} from "core-app/modules/grids/widgets/documents/documents.component";
import {WidgetNewsComponent} from "core-app/modules/grids/widgets/news/news.component";
import {WidgetWpAccountableComponent} from './widgets/wp-accountable/wp-accountable.component';
import {WidgetWpTableComponent} from "core-app/modules/grids/widgets/wp-table/wp-table.component";
export const GRID_ROUTES:Ng2StateDeclaration[] = [
{
@ -76,6 +77,7 @@ export const GRID_ROUTES:Ng2StateDeclaration[] = [
WidgetWpAccountableComponent,
WidgetWpCreatedComponent,
WidgetWpWatchedComponent,
WidgetWpTableComponent,
WidgetWpCalendarComponent,
WidgetTimeEntriesCurrentUserComponent]),
@ -100,6 +102,7 @@ export const GRID_ROUTES:Ng2StateDeclaration[] = [
WidgetWpCreatedComponent,
WidgetWpWatchedComponent,
WidgetWpCalendarComponent,
WidgetWpTableComponent,
WidgetTimeEntriesCurrentUserComponent,
AddGridWidgetModal,
@ -142,6 +145,10 @@ export function registerWidgets(injector:Injector) {
identifier: 'work_packages_watched',
component: WidgetWpWatchedComponent
},
{
identifier: 'work_packages_table',
component: WidgetWpTableComponent
},
{
identifier: 'work_packages_calendar',
component: WidgetWpCalendarComponent

@ -0,0 +1,24 @@
import {Component, OnInit} from "@angular/core";
import {ApiV3FilterBuilder} from "core-components/api/api-v3/api-v3-filter-builder";
import {WidgetWpListComponent} from "core-app/modules/grids/widgets/wp-widget/wp-widget.component";
@Component({
templateUrl: '../wp-widget/wp-widget.component.html',
styleUrls: ['../wp-widget/wp-widget.component.css']
})
export class WidgetWpTableComponent extends WidgetWpListComponent implements OnInit {
public text = { title: this.i18n.t('js.grid.widgets.work_packages_table.title') };
public queryProps:any;
ngOnInit() {
super.ngOnInit();
// TODO: adapt to arbitrary query
let filters = new ApiV3FilterBuilder();
filters.add('watcher', '=', ["me"]);
filters.add('status', 'o', []);
this.queryProps = {"columns[]":["id", "project", "type", "subject"],
"filters":filters.toJson()};
}
}

@ -8,6 +8,7 @@ module Grids
'work_packages_watched',
'work_packages_created',
'work_packages_calendar',
'work_packages_table',
'time_entries_current_user',
'documents',
'news'

@ -0,0 +1,96 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
describe 'Arbitrary WorkPackage query table widget widget on my page', type: :feature, js: true do
let!(:type) { FactoryBot.create :type }
let!(:other_type) { FactoryBot.create :type }
let!(:priority) { FactoryBot.create :default_priority }
let!(:project) { FactoryBot.create :project, types: [type] }
let!(:other_project) { FactoryBot.create :project, types: [type] }
let!(:open_status) { FactoryBot.create :default_status }
let!(:type_work_package) do
FactoryBot.create :work_package,
project: project,
type: type,
author: user,
responsible: user
end
let!(:other_type_work_package) do
FactoryBot.create :work_package,
project: project,
type: other_type,
author: user,
responsible: user
end
let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages add_work_packages]) }
let(:user) do
FactoryBot.create(:user,
member_in_project: project,
member_through_role: role)
end
let(:my_page) do
Pages::My::Page.new
end
before do
login_as user
my_page.visit!
end
it 'can add the widget and see the work packages of the filtered for types' do
my_page.add_column(3, before_or_after: :before)
my_page.add_widget(2, 3, "Work package table")
sleep(0.2)
filter_area = Components::Grids::GridArea.new('.grid--area', text: "Work package table")
created_area = Components::Grids::GridArea.new('.grid--area', text: "Work packages created by me")
filter_area.expect_to_span(2, 3, 5, 4)
filter_area.resize_to(6, 4)
filter_area.expect_to_span(2, 3, 7, 5)
## enlarging the accountable area will have moved the created area down
created_area.expect_to_span(7, 4, 13, 6)
#expect(accountable_area.area)
# .to have_selector('.subject', text: accountable_work_package.subject)
#expect(accountable_area.area)
# .to have_no_selector('.subject', text: accountable_by_other_work_package.subject)
#expect(accountable_area.area)
# .to have_no_selector('.subject', text: accountable_but_invisible_work_package.subject)
end
end
Loading…
Cancel
Save