commit
0323eb3015
@ -0,0 +1,53 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module AttributeHelpTexts |
||||
class BaseContract < ::ModelContract |
||||
include Attachments::ValidateReplacements |
||||
|
||||
def validate |
||||
validate_user_allowed_to_manage |
||||
|
||||
super |
||||
end |
||||
|
||||
def self.model |
||||
AttributeHelpText |
||||
end |
||||
|
||||
attribute :type |
||||
attribute :attribute_name |
||||
attribute :help_text |
||||
|
||||
def validate_user_allowed_to_manage |
||||
errors.add :base, :error_unauthorized unless user.admin? |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,34 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module AttributeHelpTexts |
||||
class CreateContract < BaseContract |
||||
end |
||||
end |
@ -0,0 +1,34 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module AttributeHelpTexts |
||||
class UpdateContract < BaseContract |
||||
end |
||||
end |
@ -0,0 +1,54 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
class AttributeHelpText::Project < AttributeHelpText |
||||
def self.available_attributes |
||||
skip = %w[_type links _dependencies id] |
||||
|
||||
attributes = API::V3::Projects::Schemas::ProjectSchemaRepresenter |
||||
.representable_definitions |
||||
.reject { |key, _| skip.include?(key.to_s) } |
||||
.transform_values { |definition| definition[:name_source].call } |
||||
|
||||
ProjectCustomField.all.each do |field| |
||||
attributes["custom_field_#{field.id}"] = field.name |
||||
end |
||||
|
||||
attributes |
||||
end |
||||
|
||||
validates_inclusion_of :attribute_name, in: ->(*) { available_attributes.keys } |
||||
|
||||
def type_caption |
||||
Project.model_name.human |
||||
end |
||||
|
||||
def self.visible_condition(_user) |
||||
::AttributeHelpText.where(attribute_name: available_attributes.keys) |
||||
end |
||||
end |
@ -0,0 +1,35 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module AttributeHelpTexts |
||||
class SetAttributesService < ::BaseServices::SetAttributes |
||||
include Attachments::SetReplacements |
||||
end |
||||
end |
@ -0,0 +1,35 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module AttributeHelpTexts |
||||
class UpdateService < ::BaseServices::Update |
||||
include Attachments::ReplaceAttachments |
||||
end |
||||
end |
@ -0,0 +1,78 @@ |
||||
<% entries = @texts_by_type[tab[:name]] || [] %> |
||||
<% if entries.any? %> |
||||
<div class="generic-table--container"> |
||||
<div class="generic-table--results-container"> |
||||
<table class="generic-table"> |
||||
<colgroup> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col> |
||||
</colgroup> |
||||
<thead> |
||||
<tr> |
||||
<th> |
||||
<div class="generic-table--sort-header-outer"> |
||||
<div class="generic-table--sort-header"> |
||||
<span> |
||||
<%= AttributeHelpText.human_attribute_name(:attribute_name) %> |
||||
</span> |
||||
</div> |
||||
</div> |
||||
</th> |
||||
<th> |
||||
<div class="generic-table--sort-header-outer"> |
||||
<div class="generic-table--sort-header"> |
||||
<span> |
||||
<%= AttributeHelpText.human_attribute_name(:help_text) %> |
||||
</span> |
||||
</div> |
||||
</div> |
||||
</th> |
||||
<th> |
||||
<div class="generic-table--empty-header"></div> |
||||
</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<% entries.each do |attribute_help_text| -%> |
||||
<tr class="attribute-help-text--entry"> |
||||
<td> |
||||
<%= link_to h(attribute_help_text.attribute_caption), |
||||
edit_attribute_help_text_path(attribute_help_text) %> |
||||
</td> |
||||
<td> |
||||
<attribute-help-text |
||||
data-help-text-id="<%= attribute_help_text.id %>" |
||||
data-attribute="<%= attribute_help_text.attribute_name %>" |
||||
data-attribute-scope="'<%= attribute_help_text.attribute_scope %>'" |
||||
data-additional-label="<%= t(:'attribute_help_texts.show_preview') %>"> |
||||
</attribute-help-text> |
||||
</td> |
||||
<td class="buttons"> |
||||
<%= link_to( |
||||
op_icon('icon icon-delete'), |
||||
(attribute_help_text_path(attribute_help_text)), |
||||
method: :delete, |
||||
data: { confirm: I18n.t(:text_are_you_sure) }, |
||||
title: t(:button_delete)) %> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
<% else %> |
||||
<%= no_results_box %> |
||||
<% end %> |
||||
|
||||
<div class="generic-table--action-buttons"> |
||||
<%= link_to new_attribute_help_text_path(name: tab[:name]), |
||||
{ class: 'attribute-help-texts--create-button button -alt-highlight', |
||||
aria: {label: t(:'attribute_help_texts.add_new')}, |
||||
title: t(:'attribute_help_texts.add_new')} do %> |
||||
<%= op_icon('button--icon icon-add') %> |
||||
<span class="button--text"><%= t('activerecord.models.attribute_help_text') %></span> |
||||
<% end %> |
||||
</div> |
@ -1,22 +0,0 @@ |
||||
import {WorkPackageCardViewComponent} from "core-components/wp-card-view/wp-card-view.component"; |
||||
import { |
||||
CardEventHandler, |
||||
CardViewHandlerRegistry |
||||
} from "core-components/wp-card-view/event-handler/card-view-handler-registry"; |
||||
import {BcfDoubleClickHandler} from "core-app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler"; |
||||
import {BcfClickHandler} from "core-app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-click-handler"; |
||||
import {CardRightClickHandler} from "core-components/wp-card-view/event-handler/right-click-handler"; |
||||
|
||||
|
||||
export class BcfCardViewHandlerRegistry extends CardViewHandlerRegistry { |
||||
|
||||
protected eventHandlers:((c:WorkPackageCardViewComponent) => CardEventHandler)[] = [ |
||||
// Clicking on the card (not within a cell)
|
||||
c => new BcfClickHandler(this.injector, c), |
||||
// Double clicking on the card
|
||||
c => new BcfDoubleClickHandler(this.injector, c), |
||||
// Right clicking on cards
|
||||
t => new CardRightClickHandler(this.injector, t), |
||||
]; |
||||
} |
||||
|
@ -1,22 +0,0 @@ |
||||
import {CardClickHandler} from "core-components/wp-card-view/event-handler/click-handler"; |
||||
import {InjectField} from "core-app/helpers/angular/inject-field.decorator"; |
||||
import {States} from "core-components/states.service"; |
||||
import {IFCViewerService} from "core-app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.service"; |
||||
import {BcfApiService} from "core-app/modules/bim/bcf/api/bcf-api.service"; |
||||
import {BcfViewpointPaths} from "core-app/modules/bim/bcf/api/viewpoints/bcf-viewpoint.paths"; |
||||
|
||||
export class BcfClickHandler extends CardClickHandler { |
||||
@InjectField() viewer:IFCViewerService; |
||||
@InjectField() states:States; |
||||
@InjectField() bcfApi:BcfApiService; |
||||
|
||||
protected handleWorkPackage(wpId:string, element:JQuery<HTMLElement>, evt:JQuery.TriggeredEvent) { |
||||
this.setSelection(wpId, element, evt); |
||||
const wp = this.states.workPackages.get(wpId).value!; |
||||
|
||||
// Open the viewpoint if any
|
||||
if (this.viewer.viewerVisible() && wp.bcfViewpoints) { |
||||
this.viewer.showViewpoint(wp, 0); |
||||
} |
||||
} |
||||
} |
@ -1,17 +0,0 @@ |
||||
import {StateService} from "@uirouter/core"; |
||||
import {CardDblClickHandler} from "core-components/wp-card-view/event-handler/double-click-handler"; |
||||
import {InjectField} from "core-app/helpers/angular/inject-field.decorator"; |
||||
import {bimListViewIdentifier, BimViewService} from "core-app/modules/bim/ifc_models/pages/viewer/bim-view.service"; |
||||
|
||||
export class BcfDoubleClickHandler extends CardDblClickHandler { |
||||
@InjectField() state:StateService; |
||||
@InjectField() bimView:BimViewService; |
||||
|
||||
protected handleWorkPackage(wpId:string) { |
||||
if (this.bimView.current === bimListViewIdentifier) { |
||||
this.state.go('work-packages.show', { workPackageId: wpId }); |
||||
} else { |
||||
this.state.go('.details', { workPackageId: wpId }); |
||||
} |
||||
} |
||||
} |
@ -1,11 +1,13 @@ |
||||
<h3 class="widget-box--header" |
||||
[ngClass]="{ '-editable': isRenameable }"> |
||||
|
||||
<ng-content select="[slot=prepend]"></ng-content> |
||||
|
||||
<editable-toolbar-title [title]="name" |
||||
(onSave)="renamed($event)" |
||||
[editable]="isRenameable" |
||||
class="widget-box--header-title"> |
||||
</editable-toolbar-title> |
||||
|
||||
<ng-content></ng-content> |
||||
<ng-content select="[slot=menu]"></ng-content> |
||||
</h3> |
||||
|
@ -0,0 +1,52 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Attachments |
||||
class AttachmentsByHelpTextAPI < ::API::OpenProjectAPI |
||||
resources :attachments do |
||||
helpers API::V3::Attachments::AttachmentsByContainerAPI::Helpers |
||||
|
||||
helpers do |
||||
def container |
||||
@help_text |
||||
end |
||||
|
||||
def get_attachment_self_path |
||||
api_v3_paths.attachments_by_help_text(container.id) |
||||
end |
||||
end |
||||
|
||||
get &API::V3::Attachments::AttachmentsByContainerAPI.read |
||||
post &API::V3::Attachments::AttachmentsByContainerAPI.create |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,53 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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 AttributeHelpTexts::BaseContract do |
||||
let(:model) { FactoryBot.build_stubbed :work_package_help_text } |
||||
let(:contract) { described_class.new(model, current_user) } |
||||
subject { contract.validate } |
||||
|
||||
context 'as admin' do |
||||
let(:current_user) { FactoryBot.build_stubbed :admin } |
||||
|
||||
it 'validates the contract' do |
||||
expect(subject).to eq true |
||||
end |
||||
end |
||||
|
||||
context 'as regular user' do |
||||
let(:current_user) { FactoryBot.build_stubbed :user } |
||||
|
||||
it 'returns an error on validation' do |
||||
expect(subject).to eq false |
||||
expect(contract.errors.symbols_for(:base)) |
||||
.to match_array [:error_unauthorized] |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,96 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2020 the OpenProject GmbH |
||||
# |
||||
# 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 'Project attribute help texts', type: :feature, js: true do |
||||
let(:project) { FactoryBot.create :project } |
||||
|
||||
let(:instance) do |
||||
FactoryBot.create :project_help_text, |
||||
attribute_name: :status, |
||||
help_text: 'Some **help text** for status.' |
||||
end |
||||
|
||||
let(:grid) do |
||||
grid = FactoryBot.create :grid |
||||
grid.widgets << FactoryBot.create(:grid_widget, |
||||
identifier: 'project_status', |
||||
options: { 'name' => 'Project status' }, |
||||
start_row: 1, |
||||
end_row: 2, |
||||
start_column: 1, |
||||
end_column: 1) |
||||
end |
||||
|
||||
let(:modal) { Components::AttributeHelpTextModal.new(instance) } |
||||
let(:wp_page) { Pages::FullWorkPackage.new work_package } |
||||
|
||||
before do |
||||
login_as user |
||||
project |
||||
instance |
||||
end |
||||
|
||||
shared_examples 'allows to view help texts' do |
||||
it 'shows an indicator for whatever help text exists' do |
||||
visit project_path(project) |
||||
|
||||
within '#menu-sidebar' do |
||||
click_link "Overview" |
||||
end |
||||
|
||||
expect(page).to have_selector('.widget-box--header .help-text--entry', wait: 10) |
||||
|
||||
# Open help text modal |
||||
modal.open! |
||||
expect(modal.modal_container).to have_selector('strong', text: 'help text') |
||||
modal.expect_edit(admin: user.admin?) |
||||
|
||||
modal.close! |
||||
end |
||||
end |
||||
|
||||
describe 'as admin' do |
||||
let(:user) { FactoryBot.create :admin } |
||||
it_behaves_like 'allows to view help texts' |
||||
end |
||||
|
||||
describe 'as regular user' do |
||||
let(:view_role) do |
||||
FactoryBot.create :role, permissions: [:view_project] |
||||
end |
||||
let(:user) do |
||||
FactoryBot.create :user, |
||||
member_in_project: project, |
||||
member_through_role: view_role |
||||
end |
||||
|
||||
it_behaves_like 'allows to view help texts' |
||||
end |
||||
end |
Loading…
Reference in new issue