Merge pull request #8153 from opf/bim/fix-bcf-snapshot-column-second-try

Bim/fix bcf snapshot column second try
pull/8167/head
Henriette Dinger 5 years ago committed by GitHub
commit cd5013f923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/assets/stylesheets/content/work_packages/_table_content.sass
  2. 11
      frontend/src/app/modules/bim/bcf/fields/display/bcf-thumbnail-field.module.ts
  3. 5
      frontend/src/app/modules/bim/bcf/helper/bcf-path-helper.service.ts
  4. 2
      modules/bim/lib/open_project/bim/engine.rb
  5. 37
      modules/bim/spec/features/bcf/bcf_snapshot_column_spec.rb

@ -135,6 +135,9 @@ html:not(.-browser-mobile)
.inline-edit--display-field
display: initial
&.bcfThumbnail
outline: none
// Some padding for the inner cells of the display fields
.inline-edit--display-field
padding: 2px
@ -159,4 +162,5 @@ body.-browser-edge
.wp-table--cell-td img.thumbnail
height: 40px
outline: none

@ -27,17 +27,18 @@
// ++
import {DisplayField} from "core-app/modules/fields/display/display-field.module";
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
import {BcfPathHelperService} from "core-app/modules/bim/bcf/helper/bcf-path-helper.service";
export class BcfThumbnailDisplayField extends DisplayField {
@InjectField() pathHelper:PathHelperService;
@InjectField() bcfPathHelper:BcfPathHelperService;
public render(element:HTMLElement, displayText:string):void {
if (_.get(this, 'resource.bcf.viewpoints[0]')) {
let vp = this.resource.bcf.viewpoints[0];
const viewpoints = this.resource.bcfViewpoints;
if (viewpoints && viewpoints.length > 0) {
const viewpoint = viewpoints[0];
element.innerHTML = `
<img src="${this.pathHelper.attachmentDownloadPath(vp.id, vp.file_name)}" class="thumbnail">
<img src="${this.bcfPathHelper.snapshotPath(viewpoint)}" class="thumbnail">
`;
} else {
element.innerHTML = '';

@ -28,6 +28,7 @@
import {Injectable} from '@angular/core';
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {HalLink} from "core-app/modules/hal/hal-link/hal-link";
@Injectable()
export class BcfPathHelperService {
@ -45,4 +46,8 @@ export class BcfPathHelperService {
return this.pathHelper.projectPath(projectIdentifier) + '/work_packages.bcf';
}
}
public snapshotPath(viewpoint:HalLink) {
return viewpoint.href + '/snapshot';
}
}

@ -152,7 +152,7 @@ module OpenProject::Bim
type: 'BCF Thumbnail',
required: false,
writable: false,
show_if: ->(*) { represented&.project&.module_enabled?(:bcf) }
show_if: ->(*) { represented&.project&.module_enabled?(:bim) }
end
extend_api_response(:v3, :activities, :activity) do

@ -0,0 +1,37 @@
require 'spec_helper'
describe 'BCF snapshot column', type: :feature, js: true, with_mail: false do
let(:project) { FactoryBot.create(:project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:permissions) { %i[add_work_packages view_work_packages view_linked_issues] }
let!(:work_package) { FactoryBot.create(:work_package, project: project) }
let!(:bcf_issue) { FactoryBot.create(:bcf_issue_with_viewpoint, work_package: work_package) }
let(:user) do
FactoryBot.create :user,
member_in_project: project,
member_with_permissions: permissions
end
let!(:query) do
query = FactoryBot.build(:query, user: user, project: project)
query.column_names = ['subject', 'bcf_thumbnail']
query.filters.clear
query.show_hierarchies = false
query.save!
query
end
before do
login_as(user)
end
it 'shows BCF snapshot column correctly (Regression)' do
wp_table.visit_query query
wp_table.expect_work_package_listed(work_package)
page.within(".wp-row-#{work_package.id} td.bcfThumbnail") do
image_path = "/api/bcf/2.1/projects/#{project.identifier}/topics/#{bcf_issue.uuid}/viewpoints/#{bcf_issue.viewpoints.first.uuid}/snapshot"
expect(page).to have_selector("img[src=\"#{image_path}\"]")
end
end
end
Loading…
Cancel
Save