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

Use a seeder for the BIM theme

Oliver Günther250466db5adc
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index fce4dbe484c..2fe6de5bbaf 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/app/controllers/custom_styles_controller.rb
@@ -98,7 +98,7 @@ class CustomStylesController < ApplicationController
end
def update_themes
- theme = OpenProject::CustomStyles::ColorThemes::THEMES.find { |t| t[:theme] == params[:theme] }
+ theme = OpenProject::CustomStyles::ColorThemes.themes.find { |t| t[:theme] == params[:theme] }
call = ::Design::UpdateDesignService
.new(theme)
@@ -122,7 +122,7 @@ class CustomStylesController < ApplicationController
private
def options_for_theme_select
- options = OpenProject::CustomStyles::ColorThemes::THEMES.map { |val| val[:theme] }
+ options = OpenProject::CustomStyles::ColorThemes.themes.map { |val| val[:theme] }
options << [t('admin.custom_styles.color_theme_custom'), '', disabled: true] if @current_theme.empty?
options
diff --git a/lib/open_project/custom_styles/color_themes.rb b/lib/open_project/custom_styles/color_themes.rb
index 7ac6e8dfa73..2454647013e 100644
--- a/lib/open_project/custom_styles/color_themes.rb
+++ b/lib/open_project/custom_styles/color_themes.rb
@@ -96,7 +96,7 @@ module OpenProject::CustomStyles
}
].freeze
- def themes
+ def self.themes
THEMES
end
end
diff --git a/modules/bim/app/seeders/bim/basic_data/theme_seeder.rb b/modules/bim/app/seeders/bim/basic_data/theme_seeder.rb
new file mode 100644
index 00000000000..5e6cee40a0a
--- /dev/null
+++ b/modules/bim/app/seeders/bim/basic_data/theme_seeder.rb
@@ -0,0 +1,41 @@
+#-- 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 Bim
+ module BasicData
+ class ThemeSeeder < Seeder
+ def seed_data!
+ theme = OpenProject::CustomStyles::ColorThemes.themes.find { |t| t[:theme] == 'OpenProject BIM' }
+
+ ::Design::UpdateDesignService
+ .new(theme)
+ .call
+ end
+ end
+ end
+end
diff --git a/modules/bim/app/seeders/bim/basic_data_seeder.rb b/modules/bim/app/seeders/bim/basic_data_seeder.rb
index 7cafc22f938..174e275348e 100644
--- a/modules/bim/app/seeders/bim/basic_data_seeder.rb
+++ b/modules/bim/app/seeders/bim/basic_data_seeder.rb
@@ -39,7 +39,8 @@ module Bim
::Bim::BasicData::CustomStyleSeeder,
::Bim::BasicData::WorkflowSeeder,
::Bim::BasicData::PrioritySeeder,
- ::Bim::BasicData::SettingSeeder
+ ::Bim::BasicData::SettingSeeder,
+ ::Bim::BasicData::ThemeSeeder
]
end
end
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index b7ada871b48..33b4cbd104a 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -93,11 +93,11 @@ module OpenProject::Bim
class_inflection_override('v2_1' => 'V2_1')
- assets %w(bim/bcf.css bim/ifc_viewer/generic.css)
+ assets %w(bim/bcf.css bim/logo_openproject_bim_big.png bim/ifc_viewer/generic.css)
patches %i[WorkPackage Type Journal RootSeeder Project]
- patch_with_namespace :OpenProject, :CustomStyles, :Design
+ patch_with_namespace :OpenProject, :CustomStyles, :ColorThemes
patch_with_namespace :API, :V3, :Activities, :ActivityRepresenter
patch_with_namespace :Journal, :AggregatedJournal
patch_with_namespace :API, :V3, :Activities, :ActivitiesSharedHelpers
diff --git a/modules/bim/lib/open_project/bim/patches/color_themes_patch.rb b/modules/bim/lib/open_project/bim/patches/color_themes_patch.rb
new file mode 100644
index 00000000000..5fd5f194e76
--- /dev/null
+++ b/modules/bim/lib/open_project/bim/patches/color_themes_patch.rb
@@ -0,0 +1,42 @@
+require 'open_project/custom_styles/design'
+
+module OpenProject::Bim
+ module Patches
+ module ColorThemesPatch
+ def self.included(base)
+ class << base
+ prepend ClassMethods
+ end
+ end
+
+ module ClassMethods
+ def themes
+ if OpenProject::Configuration.bim?
+ super + [bim_theme]
+ else
+ super
+ end
+ end
+
+ def bim_theme
+ {
+ theme: 'OpenProject BIM',
+ colors: {
+ 'primary-color' => "#3270DB",
+ 'primary-color-dark' => "#163473",
+ 'alternative-color' => "#349939",
+ 'header-bg-color' => "#05002C",
+ 'header-item-bg-hover-color' => "#163473",
+ 'content-link-color' => "#275BB5",
+ 'main-menu-bg-color' => "#0E2045",
+ 'main-menu-bg-selected-background' => "#3270DB",
+ 'main-menu-bg-hover-background' => "#163473",
+ # TODO 'new-feature-teaser-image' => '#{image-url("bim/new_feature_teaser.jpg")}'
+ },
+ logo: 'bim/logo_openproject_bim_big.png'
+ }
+ end
+ end
+ end
+ end
+end
diff --git a/modules/bim/lib/open_project/bim/patches/design_patch.rb b/modules/bim/lib/open_project/bim/patches/design_patch.rb
deleted file mode 100644
index dd14e86b45d..00000000000
--- a/modules/bim/lib/open_project/bim/patches/design_patch.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'open_project/custom_styles/design'
-
-module OpenProject::Bim
- module Patches
- module DesignPatch
- def self.included(base)
- class << base
- prepend ClassMethods
- end
- end
-
- module ClassMethods
- def variables
- if OpenProject::Configuration.bim?
- super.merge 'primary-color' => "#3270DB",
- 'primary-color-dark' => "#163473",
- 'alternative-color' => "#349939",
- 'header-bg-color' => "#05002C",
- 'header-item-bg-hover-color' => "#163473",
- 'content-link-color' => "#275BB5",
- 'main-menu-bg-color' => "#0E2045",
- 'main-menu-bg-selected-background' => "#3270DB",
- 'main-menu-bg-hover-background' => "#163473",
- 'header-home-link-bg' => '#{image-url("bim/logo_openproject_bim_big.png") no-repeat 20px 0}',
- 'new-feature-teaser-image' => '#{image-url("bim/new_feature_teaser.jpg")}'
- else
- super
- end
- end
- end
- end
- end
-end