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
Seed BCF board
Wieland Lindenthalb3f1a2251a8b
diff --git a/modules/bim_seeder/config/locales/en.seeders.bim.yml b/modules/bim_seeder/config/locales/en.seeders.bim.ymlindex 4671ed39edc..4226d8194b7 100644--- a/modules/bim_seeder/config/locales/en.seeders.bim.yml+++ b/modules/bim_seeder/config/locales/en.seeders.bim.yml@@ -1063,6 +1063,9 @@ en:- type- status- assigned_to+ boards:+ bcf:+ name: "BCF issues"bcf_xml_file: "seed.bcfzip"work_packages:- :start: 73diff --git a/modules/bim_seeder/lib/open_project/bim_seeder/engine.rb b/modules/bim_seeder/lib/open_project/bim_seeder/engine.rbindex a5e7cb00576..1b213796d68 100644--- a/modules/bim_seeder/lib/open_project/bim_seeder/engine.rb+++ b/modules/bim_seeder/lib/open_project/bim_seeder/engine.rb@@ -16,5 +16,6 @@ module OpenProject::BimSeederpatch_with_namespace :DemoData, :QueryBuilderpatch_with_namespace :DemoData, :ProjectSeederpatch_with_namespace :DemoData, :WorkPackageSeeder+ patch_with_namespace :DemoData, :WorkPackageBoardSeederendenddiff --git a/modules/bim_seeder/lib/open_project/bim_seeder/patches/work_package_board_seeder_patch.rb b/modules/bim_seeder/lib/open_project/bim_seeder/patches/work_package_board_seeder_patch.rbnew file mode 100644index 00000000000..f4ebce3a39c--- /dev/null+++ b/modules/bim_seeder/lib/open_project/bim_seeder/patches/work_package_board_seeder_patch.rb@@ -0,0 +1,68 @@+module OpenProject::BimSeeder::Patches::WorkPackageBoardSeederPatch+ def self.included(base) # :nodoc:+ base.prepend InstanceMethods+ end++ module InstanceMethods+ def seed_data!+ super++ if project_has_data_for?(key, 'boards.bcf')+ print ' ↳ Creating demo BCF board'+ seed_bcf_board+ puts+ end+ end++ def seed_bcf_board+ board = ::Boards::Grid.new project: project++ board.name = project_data_for(key, 'boards.bcf.name')+ board.options = { 'type' => 'action', 'attribute' => 'status', 'highlightingMode' => 'type' }++ board.widgets = seed_bcf_board_queries.each_with_index.map do |query, i|+ Grids::Widget.new start_row: 1, end_row: 2,+ start_column: i + 1, end_column: i + 2,+ options: { query_id: query.id,+ filters: [{ status: { operator: '=', values: query.filters[0].values } }] },+ identifier: 'work_package_query'+ end++ board.column_count = board.widgets.count+ board.row_count = 1++ board.save!++ Setting.boards_demo_data_available = 'true'+ end++ def seed_bcf_board_queries+ admin = User.admin.first+ status_names = ['New', 'In progress', 'Resolved', 'Closed']+ statuses = Status.where(name: status_names).to_a++ if statuses.size < status_names.size+ raise StandardError.new "Not all statuses needed for seeding a BCF board are present. Check that they get seeded."+ end++ statuses.to_a.map do |status|+ Query.new_default(project: project, user: admin).tap do |query|+ # Hide the query in the main menu+ query.hidden = true++ # Make it public so that new members can see it too+ query.is_public = true++ query.name = status.name+ # Set filter by this status+ query.add_filter('status_id', '=', [status.id])++ # Set manual sort filter+ query.sort_criteria = [[:manual_sorting, 'asc']]++ query.save!+ end+ end+ end+ end+end