OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Make columns configurable in admin settings
Oliver Günthere8dde985aaea
diff --git a/app/cells/projects/table_cell.rb b/app/cells/projects/table_cell.rbindex 5d27029e81c..4240505ff7a 100644--- a/app/cells/projects/table_cell.rb+++ b/app/cells/projects/table_cell.rb@@ -64,6 +64,9 @@ module Projectsdef headersall_columns+ .select do |name, options|+ options[:builtin] || Setting.enabled_projects_columns.include?(name.to_s)+ endenddef sortable_column?(_column)diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erbindex ad9e156cd46..152988e9ed1 100644--- a/app/views/settings/_projects.html.erb+++ b/app/views/settings/_projects.html.erb@@ -47,13 +47,32 @@ See docs/COPYRIGHT.rdoc for more details.<fieldset class="form--fieldset"><legend class="form--fieldset-legend"><%= t('settings.projects.section_project_overview') %></legend><%- column_choices = Query.new.available_columns.map { |column|- { caption: column.caption, value: column.name.to_s }- }+ column_choices = ::Projects::TableCell+ .new(nil, current_user: current_user)+ .all_columns+ .reject { |_, options| options[:builtin] }+ .map { |name, options| { caption: options[:caption], value: name.to_s } }%>- <%= settings_matrix([:work_package_list_default_columns],- column_choices, label_choices: :setting_work_package_properties) %>+ <%= settings_matrix([:enabled_projects_columns],+ column_choices, label_choices: :description_selected_columns) %>++ <div class="form--field">+ <%= setting_block("project_gantt_query") do %>+ <span class="form--check-box-field-container -slim">+ <%= content_tag 'editable-query-props',+ '',+ data: {+ name: 'settings[project_gantt_query]',+ id: 'settings_project_gantt_query',+ query: Setting.project_gantt_query+ }+ %>+ </span>+ <% end %>+ <div class="form--field-instructions">+ <%= I18n.t(:setting_project_gantt_query_text) %>+ </div>+ </div></fieldset></section>- <%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %><% end %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 59e4a6ace4b..0bb01892208 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2219,6 +2219,7 @@ en:setting_emails_header: "Emails header"setting_email_login: "Use email as login"setting_enabled_scm: "Enabled SCM"+ setting_enabled_projects_columns: "Visible in project list"setting_feeds_enabled: "Enable Feeds"setting_feeds_limit: "Feed content limit"setting_file_max_size_displayed: "Max size of text files displayed inline"@@ -2249,6 +2250,8 @@ en:setting_per_page_options: "Objects per page options"setting_plain_text_mail: "Plain text mail (no HTML)"setting_protocol: "Protocol"+ setting_project_gantt_query: "Project portfolio Gantt view"+ setting_project_gantt_query_text: "You can modify the query that is used to display Gantt chart from the project overview page."setting_security_badge_displayed: "Display security badge"setting_registration_footer: "Registration footer"setting_repositories_automatic_managed_vendor: "Automatic repository vendor type"diff --git a/config/settings.yml b/config/settings.ymlindex 59cadaa7faa..fb2b41b11f4 100644--- a/config/settings.yml+++ b/config/settings.yml@@ -285,6 +285,17 @@ default_projects_modules:- news- costs- wiki+enabled_projects_columns:+ serialized: true+ default:+ - name+ - project_status+ - public+ - created_at+ - latest_activity_at+ - required_disk_space+project_gantt_query:+ default: ''# Role given to a non-admin user who creates a projectnew_project_user_role_id:format: intdiff --git a/frontend/src/app/global-dynamic-components.const.ts b/frontend/src/app/global-dynamic-components.const.tsindex d2ac8e89fdd..7b35f46cf54 100644--- a/frontend/src/app/global-dynamic-components.const.ts+++ b/frontend/src/app/global-dynamic-components.const.ts@@ -150,6 +150,10 @@ import {quickInfoMacroSelector,WorkPackageQuickinfoMacroComponent} from "core-app/modules/fields/macros/work-package-quickinfo-macro.component";+import {+ EditableQueryPropsComponent,+ editableQueryPropsSelector+} from "core-app/modules/admin/editable-query-props/editable-query-props.component";export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: appBaseSelector, cls: ApplicationBaseComponent },@@ -195,6 +199,7 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: attributeValueMacro, cls: AttributeValueMacroComponent, embeddable: true },{ selector: attributeLabelMacro, cls: AttributeLabelMacroComponent, embeddable: true },{ selector: quickInfoMacroSelector, cls: WorkPackageQuickinfoMacroComponent, embeddable: true },+ { selector: editableQueryPropsSelector, cls: EditableQueryPropsComponent }];diff --git a/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.html b/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.htmlnew file mode 100644index 00000000000..3ee58733880--- /dev/null+++ b/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.html@@ -0,0 +1,9 @@+<input type="hidden"+ [attr.name]="name || undefined"+ [attr.id]="id || undefined"+ [value]="queryProps"/>+<a+ class="button--link"+ (accessibleClick)="editQuery()"+ [accessibleClickStopEvent]="true"+ [textContent]="text.edit_query"></a>diff --git a/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.ts b/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.tsnew file mode 100644index 00000000000..e64c205d555--- /dev/null+++ b/frontend/src/app/modules/admin/editable-query-props/editable-query-props.component.ts@@ -0,0 +1,54 @@+import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit} from "@angular/core";+import {I18nService} from "core-app/modules/common/i18n/i18n.service";+import {ExternalQueryConfigurationService} from "core-components/wp-table/external-configuration/external-query-configuration.service";++export const editableQueryPropsSelector = 'editable-query-props';++@Component({+ selector: editableQueryPropsSelector,+ templateUrl: './editable-query-props.component.html',+ changeDetection: ChangeDetectionStrategy.OnPush,+})+export class EditableQueryPropsComponent implements OnInit {+ id:string|null;+ name:string|null;++ queryProps:string;++ text = {+ edit_query: this.I18n.t('js.admin.type_form.edit_query')+ };++ constructor(private elementRef:ElementRef,+ private I18n:I18nService,+ private cdRef:ChangeDetectorRef,+ private externalQuery:ExternalQueryConfigurationService) {+ }++ ngOnInit() {+ const element = this.elementRef.nativeElement;+ this.id = element.dataset.id;+ this.name = element.dataset.name;++ this.queryProps = element.dataset.query;+ }++ public editQuery() {+ let json;++ try {+ json = JSON.parse(this.queryProps);+ } catch (e) {+ console.error(`Failed to parse query props from ${this.queryProps}: ${e}`);+ json = {};+ }++ this.externalQuery.show(+ json,+ (queryProps:any) => {+ this.queryProps = JSON.stringify(queryProps);+ this.cdRef.detectChanges();+ }+ );+ }+}\ No newline at end of filediff --git a/frontend/src/app/modules/admin/openproject-admin.module.ts b/frontend/src/app/modules/admin/openproject-admin.module.tsindex e1abfd3fda9..87802f87d1d 100644--- a/frontend/src/app/modules/admin/openproject-admin.module.ts+++ b/frontend/src/app/modules/admin/openproject-admin.module.ts@@ -33,11 +33,14 @@ import {GroupEditInPlaceComponent} from 'core-app/modules/admin/types/group-editimport {TypeFormAttributeGroupComponent} from 'core-app/modules/admin/types/attribute-group.component';import {DragulaModule} from 'ng2-dragula';import {TypeFormQueryGroupComponent} from "core-app/modules/admin/types/query-group.component";+import {OpenprojectAccessibilityModule} from "core-app/modules/a11y/openproject-a11y.module";+import {EditableQueryPropsComponent} from "core-app/modules/admin/editable-query-props/editable-query-props.component";@NgModule({imports: [DragulaModule.forRoot(),- OpenprojectCommonModule+ OpenprojectCommonModule,+ OpenprojectAccessibilityModule],providers: [],@@ -45,7 +48,8 @@ import {TypeFormQueryGroupComponent} from "core-app/modules/admin/types/query-grTypeFormAttributeGroupComponent,TypeFormQueryGroupComponent,TypeFormConfigurationComponent,- GroupEditInPlaceComponent+ GroupEditInPlaceComponent,+ EditableQueryPropsComponent,]})export class OpenprojectAdminModule { }diff --git a/frontend/src/global_styles/content/_forms.sass b/frontend/src/global_styles/content/_forms.sassindex 0b3581ed323..e231620259a 100644--- a/frontend/src/global_styles/content/_forms.sass+++ b/frontend/src/global_styles/content/_forms.sass@@ -699,7 +699,7 @@ input[readonly].-clickableborder: var(--content-form-input-border)border-radius: 2pxbackground: none- margin: 0+ margin: 0 0 2rem 0font-size: 0.9remline-height: 1.5