Create a BCF module for the frontend and create first tiny component to show viewpoints

pull/7190/head
Wieland Lindenthal 6 years ago
parent f7c0d37bdb
commit 1ec96c006c
  1. 4
      frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html
  2. 2
      frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html
  3. 0
      frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.sass
  4. 31
      frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts
  5. 51
      frontend/src/app/modules/bcf/openproject-bcf.module.ts
  6. 4
      frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
  7. 17
      modules/bcf/lib/open_project/bcf/engine.rb
  8. 60
      modules/bcf/spec/api/v3/work_packages/work_package_representer_spec.rb
  9. 42
      modules/bcf/spec/factories/bcf_issue_factory.rb
  10. 48
      modules/bcf/spec/factories/bcf_viewpoint_attachment_factory.rb
  11. 42
      modules/bcf/spec/factories/bcf_viewpoint_factory.rb
  12. 2
      modules/costs/spec/factories/cost_object_factory.rb

@ -74,6 +74,10 @@
</div>
</div>
<div *ngIf="workPackage.bcf">
<bcf-wp-single-view [workPackage]="workPackage"></bcf-wp-single-view>
</div>
<div class="attributes-group description-group">
<div class="attributes-group--header">
<div class="attributes-group--header-container">

@ -0,0 +1,2 @@
<h3 class="attributes-groupe header-text">BCF</h3>
<img src="{{workPackage.bcf.viewpoints[0]}}" *ngIf="workPackage.bcf.viewpoints.length > 0">

@ -0,0 +1,31 @@
import {Component, Injector, Input, OnDestroy, OnInit} from "@angular/core";
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {StateService} from "@uirouter/core";
import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
@Component({
selector: 'bcf-wp-single-view',
templateUrl: './bcf-wp-single-view.component.html',
styleUrls: ['./bcf-wp-single-view.component.sass']
})
export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
@Input() workPackage:WorkPackageResource;
public text = {
};
constructor(public readonly state:StateService,
private readonly I18n:I18nService,
private readonly injector:Injector) {
}
ngOnInit():void {
// TODO
}
ngOnDestroy():void {
// Nothing to do.
}
}

@ -0,0 +1,51 @@
// -- 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-2013 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 doc/COPYRIGHT.rdoc for more details.
// ++
import {NgModule} from '@angular/core';
import {OpenprojectCommonModule} from "core-app/modules/common/openproject-common.module";
import {OpenprojectWorkPackagesModule} from "core-app/modules/work_packages/openproject-work-packages.module";
import {BcfWpSingleViewComponent} from "core-app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component";
@NgModule({
imports: [
OpenprojectCommonModule,
],
providers: [
],
declarations: [
BcfWpSingleViewComponent,
],
exports: [
BcfWpSingleViewComponent,
],
entryComponents: [
]
})
export class OpenprojectBcfModule {
}

@ -156,6 +156,8 @@ import {WorkPackageCardViewComponent} from "core-components/wp-card-view/wp-card
import {WorkPackageIsolatedQuerySpaceDirective} from "core-app/modules/work_packages/query-space/wp-isolated-query-space.directive";
import {WorkPackageDmService} from "core-app/modules/hal/dm-services/work-package-dm.service";
import {WorkPackageRelationsService} from "core-components/wp-relations/wp-relations.service";
import {BcfWpSingleViewComponent} from "core-app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component";
import {OpenprojectBcfModule} from "core-app/modules/bcf/openproject-bcf.module";
@NgModule({
imports: [
@ -170,6 +172,8 @@ import {WorkPackageRelationsService} from "core-components/wp-relations/wp-relat
OpenprojectAttachmentsModule,
OpenprojectBcfModule,
// Work package custom actions
//WpCustomActionsModule,
DynamicModule.withComponents([WorkPackageFormAttributeGroupComponent, WorkPackageChildrenQueryComponent])

@ -36,6 +36,23 @@ module OpenProject::Bcf
patch_with_namespace :BasicData, :SettingSeeder
extend_api_response(:v3, :work_packages, :work_package) do
property :bcf,
exec_context: :decorator,
getter: ->(*) {
issue = represented.bcf_issue
bcf = {}
bcf[:viewpoints] = issue.viewpoints.map do |viewpoint|
attachment_path(viewpoint.snapshot.id)
end
bcf
},
if: ->(*) {
represented.bcf_issue.present?
}
end
extend_api_response(:v3, :work_packages, :work_package_collection) do
require_relative 'patches/api/v3/export_formats'

@ -0,0 +1,60 @@
#-- copyright
# OpenProject Costs Plugin
#
# Copyright (C) 2009 - 2014 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.
#
# 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.
#++
require 'spec_helper'
describe ::API::V3::WorkPackages::WorkPackageRepresenter do
include API::V3::Utilities::PathHelper
let(:project) { FactoryBot.create(:project) }
let(:role) do
FactoryBot.create(:role, permissions: [:view_linked_issues,
:view_work_packages])
end
let(:user) do
FactoryBot.create(:user,
member_in_project: project,
member_through_role: role)
end
let(:bcf_issue) do
FactoryBot.create(:bcf_issue)
end
let(:work_package) do
FactoryBot.create(:work_package,
project_id: project.id,
bcf_issue: bcf_issue)
end
let(:representer) do
described_class.new(work_package,
current_user: user,
embed_links: true)
end
before(:each) do
allow(User).to receive(:current).and_return user
end
subject(:generated) { representer.to_json }
describe 'with BCF issues' do
it { is_expected.to have_json_path('bcf') }
it { is_expected.to have_json_path('bcf/viewpoints') }
it { is_expected.to be_json_eql(["/attachments/#{bcf_issue.viewpoints.first.id}"].to_json).at_path('bcf/viewpoints') }
end
end

@ -0,0 +1,42 @@
#-- copyright
# OpenProject Backlogs Plugin
#
# Copyright (C)2013-2014 the OpenProject Foundation (OPF)
# Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
# Copyright (C)2010-2011 friflaj
# Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
# Copyright (C)2009-2010 Mark Maglana
# Copyright (C)2009 Joe Heck, Nate Lowrie
#
# 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 Backlogs is a derivative work based on ChiliProject Backlogs.
# The copyright follows:
# Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
# Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
#
# 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 doc/COPYRIGHT.rdoc for more details.
#++
FactoryBot.define do
factory :bcf_issue, class: ::Bcf::Issue do
after(:create) do |issue|
create(:bcf_viewpoint, issue: issue)
end
end
end

@ -0,0 +1,48 @@
#-- copyright
# OpenProject Backlogs Plugin
#
# Copyright (C)2013-2014 the OpenProject Foundation (OPF)
# Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
# Copyright (C)2010-2011 friflaj
# Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
# Copyright (C)2009-2010 Mark Maglana
# Copyright (C)2009 Joe Heck, Nate Lowrie
#
# 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 Backlogs is a derivative work based on ChiliProject Backlogs.
# The copyright follows:
# Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
# Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
#
# 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 doc/COPYRIGHT.rdoc for more details.
#++
FactoryBot.define do
factory :bcf_viewpoint_attachment, class: Attachment do
description "snapshot"
filename "snapshot.jpg"
content_type "image/jpeg"
author User.current
file do
OpenProject::Files.create_uploaded_file name: filename,
content_type: content_type,
binary: true
end
end
end

@ -0,0 +1,42 @@
#-- copyright
# OpenProject Backlogs Plugin
#
# Copyright (C)2013-2014 the OpenProject Foundation (OPF)
# Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
# Copyright (C)2010-2011 friflaj
# Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
# Copyright (C)2009-2010 Mark Maglana
# Copyright (C)2009 Joe Heck, Nate Lowrie
#
# 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 Backlogs is a derivative work based on ChiliProject Backlogs.
# The copyright follows:
# Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
# Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
#
# 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 doc/COPYRIGHT.rdoc for more details.
#++
FactoryBot.define do
factory :bcf_viewpoint, class: ::Bcf::Viewpoint do
after(:create) do |viewpoint|
create(:bcf_viewpoint_attachment, container: viewpoint)
end
end
end

@ -18,7 +18,7 @@
#++
FactoryBot.define do
factory :cost_object do
factory :cost_object do
subject { 'Some Cost Object' }
description { 'Some costs' }
kind { 'VariableCostObject' }

Loading…
Cancel
Save