Skip to content

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

Update admin tabs layout

Inga Mai0f4ce76ab596
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb
index 0c1acf62f05..b3cdbaa3430 100644
--- a/app/controllers/custom_fields_controller.rb
+++ b/app/controllers/custom_fields_controller.rb
@@ -31,6 +31,8 @@
class CustomFieldsController < ApplicationController
layout 'admin'
+ helper_method :gon
+
before_action :require_admin
before_action :find_custom_field, only: %i(edit update destroy move delete_option)
before_action :prepare_custom_option_position, only: %i(update create)
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index 25b7f2d0e8f..5d8d3d7eb5a 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -30,6 +30,8 @@
class SettingsController < ApplicationController
layout 'admin'
+ helper_method :gon
+
before_action :require_admin
current_menu_item [:index, :edit] do
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index a78236f6062..3d9e1faae05 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -31,14 +31,14 @@
module CustomFieldsHelper
def custom_fields_tabs
[
- { name: 'WorkPackageCustomField', partial: 'custom_fields/tab', label: :label_work_package_plural },
- { name: 'TimeEntryCustomField', partial: 'custom_fields/tab', label: :label_spent_time },
- { name: 'ProjectCustomField', partial: 'custom_fields/tab', label: :label_project_plural },
- { name: 'VersionCustomField', partial: 'custom_fields/tab', label: :label_version_plural },
- { name: 'UserCustomField', partial: 'custom_fields/tab', label: :label_user_plural },
- { name: 'GroupCustomField', partial: 'custom_fields/tab', label: :label_group_plural },
- { name: 'TimeEntryActivityCustomField', partial: 'custom_fields/tab', label: TimeEntryActivity::OptionName },
- { name: 'IssuePriorityCustomField', partial: 'custom_fields/tab', label: IssuePriority::OptionName }
+ { name: 'WorkPackageCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_work_package_plural) },
+ { name: 'TimeEntryCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_spent_time) },
+ { name: 'ProjectCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_project_plural) },
+ { name: 'VersionCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_version_plural) },
+ { name: 'UserCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_user_plural) },
+ { name: 'GroupCustomField', partial: 'custom_fields/tab', label: I18n.t(:label_group_plural) },
+ { name: 'TimeEntryActivityCustomField', partial: 'custom_fields/tab', label: I18n.t(TimeEntryActivity::OptionName) },
+ { name: 'IssuePriorityCustomField', partial: 'custom_fields/tab', label: I18n.t(IssuePriority::OptionName) }
]
end
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index b6c2fbc71a6..3e91d2d069d 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -34,12 +34,12 @@ module SettingsHelper
def administration_settings_tabs
[
- { name: 'general', partial: 'settings/general', label: :label_general },
- { name: 'display', partial: 'settings/display', label: :label_display },
- { name: 'projects', partial: 'settings/projects', label: :label_project_plural },
- { name: 'notifications', partial: 'settings/notifications', label: Proc.new { User.human_attribute_name(:mail_notification) } },
- { name: 'mail_handler', partial: 'settings/mail_handler', label: :label_incoming_emails },
- { name: 'repositories', partial: 'settings/repositories', label: :label_repository_plural }
+ { name: 'general', partial: 'settings/general', label: I18n.t(:label_general) },
+ { name: 'display', partial: 'settings/display', label: I18n.t(:label_display) },
+ { name: 'projects', partial: 'settings/projects', label: I18n.t(:label_project_plural) },
+ { name: 'notifications', partial: 'settings/notifications', label: I18n.t('activerecord.attributes.user.mail_notification') },
+ { name: 'mail_handler', partial: 'settings/mail_handler', label: I18n.t(:label_incoming_emails) },
+ { name: 'repositories', partial: 'settings/repositories', label: I18n.t(:label_repository_plural) }
]
end
diff --git a/app/views/common/_tabs.html.erb b/app/views/common/_tabs.html.erb
index c8c14bf4f02..e1774a3a10d 100644
--- a/app/views/common/_tabs.html.erb
+++ b/app/views/common/_tabs.html.erb
@@ -26,28 +26,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See docs/COPYRIGHT.rdoc for more details.
++#%>
-<div class="tabs">
- <ul>
- <% tabs.each do |tab| %>
- <li><%=
- position_span = you_are_here_info(tab[:name], tab != selected_tab)
- caption = case tab[:label]
- when Proc
- tab[:label].call
- else
- t(tab[:label])
- end
- link_to(position_span + caption, { tab: tab[:name] },
- id: "tab-#{tab[:name]}",
- class: "tab-show #{(tab == selected_tab ? 'selected' : '')}",
- data: { name: tab[:name] }) %></li>
- <% end %>
- </ul>
- <div class="tabs-buttons" style="display:none;">
- <button class="tab-left icon-context icon-arrow-left4"></button>
- <button class="tab-right icon-context icon-arrow-right5"></button>
- </div>
-</div>
+<% gon.admin_tabs = { tabs: tabs.to_json.html_safe, selected: selected_tab.to_json.html_safe } %>
+<%= nonced_javascript_tag do %>
+ <%= include_gon(need_tag: false) -%>
+<% end %>
+
+<admin-tabs></admin-tabs>
<%= content_tag 'div',
render(partial: selected_tab[:partial], locals: { tab: selected_tab } ),
diff --git a/frontend/src/app/modules/admin/openproject-admin.module.ts b/frontend/src/app/modules/admin/openproject-admin.module.ts
index 752d28bd00b..b5643804622 100644
--- a/frontend/src/app/modules/admin/openproject-admin.module.ts
+++ b/frontend/src/app/modules/admin/openproject-admin.module.ts
@@ -33,6 +33,7 @@ import {GroupEditInPlaceComponent} from 'core-app/modules/admin/types/group-edit
import {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 {AdminTabsComponent} from "core-app/modules/admin/tabs/admin-tabs.component";
@NgModule({
imports: [
@@ -46,10 +47,11 @@ import {TypeFormQueryGroupComponent} from "core-app/modules/admin/types/query-gr
TypeFormQueryGroupComponent,
TypeFormConfigurationComponent,
GroupEditInPlaceComponent,
+ AdminTabsComponent
],
entryComponents: [
- TypeFormConfigurationComponent
+ TypeFormConfigurationComponent,
+ AdminTabsComponent
]
})
export class OpenprojectAdminModule { }
-
diff --git a/frontend/src/app/modules/admin/tabs/admin-tabs.component.ts b/frontend/src/app/modules/admin/tabs/admin-tabs.component.ts
new file mode 100644
index 00000000000..36413d89b59
--- /dev/null
+++ b/frontend/src/app/modules/admin/tabs/admin-tabs.component.ts
@@ -0,0 +1,92 @@
+// -- copyright
+// OpenProject is a project management system.
+// Copyright (C) 2012-2015 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 {
+ Component,
+ OnDestroy,
+ Input,
+ ElementRef
+} from '@angular/core';
+import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
+import {GonService} from "core-app/modules/common/gon/gon.service";
+import {StateService} from '@uirouter/core';
+import {ScrollableTabsComponent} from "core-app/modules/common/tabs/scrollable-tabs.component";
+
+
+export const adminTabsSelector = 'admin-tabs';
+
+interface Tab {
+ name:string;
+ partial:string;
+ label:string;
+}
+
+@Component({
+ selector: adminTabsSelector,
+ templateUrl: '/app/modules/common/tabs/scrollable-tabs.component.html'
+})
+
+export class AdminTabsComponent extends ScrollableTabsComponent {
+ public myTabs: Tab[] = [];
+ public currentTab: Tab;
+
+ public classes:string[] = ['settings--tabs', 'scrollable-tabs'];
+
+ private gonData:any = this.gon.get('admin_tabs');
+
+ constructor(readonly elementRef:ElementRef,
+ readonly $state:StateService,
+ readonly gon:GonService) {
+ super();
+ // parse tabs from backend and map them to scrollable tabs structure
+ this.myTabs = jQuery.parseJSON(this.gonData.tabs);
+ this.tabs = jQuery.map(this.myTabs, (tab:any) => {
+ return {
+ id: tab.name,
+ name: tab.label
+ } });
+
+ // highlight current tab
+ this.currentTab = jQuery.parseJSON(this.gonData.selected);
+ this.currentTabId = this.currentTab.name;
+ }
+
+ public clickTab(tab:string) {
+ // set selected tab as current
+ this.currentTab = jQuery.grep(this.myTabs, thisTab => thisTab.name === tab)[0];
+
+ // set correct partial for selected tab
+ this.partial = this.currentTab.partial.split('/')[0] + '?tab=' + this.currentTab.name;
+
+ super.clickTab(tab);
+ }
+}
+
+DynamicBootstrapper.register({
+ selector: adminTabsSelector, cls: AdminTabsComponent
+});
diff --git a/frontend/src/app/modules/common/tabs/scrollable-tabs.component.html b/frontend/src/app/modules/common/tabs/scrollable-tabs.component.html
index df325f293b6..34f95636091 100644
--- a/frontend/src/app/modules/common/tabs/scrollable-tabs.component.html
+++ b/frontend/src/app/modules/common/tabs/scrollable-tabs.component.html
@@ -3,7 +3,7 @@
<li *ngFor="let tab of tabs"
[class.selected]="tab.id === currentTabId"
[attr.tab-id]="tab.id">
- <a href="#" (click)="clickTab(tab.id)" [textContent]="tab.name"></a>
+ <a [href]="partial" (click)="clickTab(tab.id)" [textContent]="tab.name"></a>
</li>
</ul>
<div #scrollLeftBtn [hidden]="hideLeftButton"
diff --git a/frontend/src/app/modules/common/tabs/scrollable-tabs.component.ts b/frontend/src/app/modules/common/tabs/scrollable-tabs.component.ts
index e147776bcab..230cca7e243 100644
--- a/frontend/src/app/modules/common/tabs/scrollable-tabs.component.ts
+++ b/frontend/src/app/modules/common/tabs/scrollable-tabs.component.ts
@@ -13,6 +13,7 @@ export class ScrollableTabsComponent implements AfterViewInit {
public currentTabId:string = '';
public tabs:{id:string, name:string}[] = [];
public classes:string[] = ['scrollable-tabs'];
+ public partial:string = '#';
public hideLeftButton:boolean = true;
public hideRightButton:boolean = true;
diff --git a/modules/documents/app/models/document_category.rb b/modules/documents/app/models/document_category.rb
index 0fbe65b9a9e..4681ebd8219 100644
--- a/modules/documents/app/models/document_category.rb
+++ b/modules/documents/app/models/document_category.rb
@@ -30,7 +30,7 @@
class DocumentCategory < Enumeration
has_many :documents, foreign_key: 'category_id'
- OptionName = :enumeration_doc_categories
+ OptionName = I18n.t(:enumeration_doc_categories)
def option_name
OptionName