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

show notice when accessing unprocessed defaults

ulfertse3a32cb35c18
diff --git a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
index 75c034b7a7e..f04ac41ba34 100644
--- a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
+++ b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
@@ -52,7 +52,7 @@ module ::IFCModels
def edit; end
def show
- provision_gon([@ifc_model])
+ provision_gon_for_ifc_model(@ifc_models, [@ifc_model])
end
def show_defaults
@@ -61,7 +61,7 @@ module ::IFCModels
end
@default_ifc_models = @project.ifc_models.defaults
- provision_gon(@default_ifc_models)
+ provision_gon_for_ifc_model(@ifc_models, @default_ifc_models)
end
def create
@@ -118,31 +118,6 @@ module ::IFCModels
.order('created_at ASC')
end
- def provision_gon(models_to_load = [])
- all_converted_models = converted_ifc_models(@ifc_models)
- converted_models_to_load = converted_ifc_models(models_to_load)
-
- models_to_load = Hash[converted_models_to_load.map { |ifc_model| [ifc_model.id, true] }]
- gon.ifc_models = {
- models: all_converted_models.map do |ifc_model|
- model = {}
- model[:id] = ifc_model.id
- model[:name] = ifc_model.title
- model[:default] = (!!models_to_load[ifc_model.id])
-
- model
- end,
- projects: [{ id: @project.identifier, name: @project.name }],
- xkt_attachment_ids: Hash[all_converted_models.map { |ifc_model| [ifc_model.id, ifc_model.xkt_attachment.id] }],
- metadata_attachment_ids: Hash[
- all_converted_models.map do |ifc_model|
- [ifc_model.id,
- ifc_model.metadata_attachment.id]
- end
- ]
- }
- end
-
def permitted_model_params
params
.require(:ifc_models_ifc_model)
@@ -152,9 +127,5 @@ module ::IFCModels
def find_ifc_model_object
@ifc_model = IFCModels::IFCModel.find_by(id: params[:id])
end
-
- def converted_ifc_models(ifc_models)
- ifc_models.select { |ifc_model| ifc_model.xkt_attachment.present? && ifc_model.metadata_attachment.present? }
- end
end
end
diff --git a/modules/ifc_models/app/helpers/ifc_models_helper.rb b/modules/ifc_models/app/helpers/ifc_models_helper.rb
index 33d80722eb9..5026edbac6b 100644
--- a/modules/ifc_models/app/helpers/ifc_models_helper.rb
+++ b/modules/ifc_models/app/helpers/ifc_models_helper.rb
@@ -1,9 +1,41 @@
module IFCModelsHelper
- def attachment_content_url(attachment)
- if attachment.external_storage?
- attachment.external_url
- else
- API::V3::Utilities::PathHelper::ApiV3Path.attachment_content(attachment.id)
+ def provision_gon_for_ifc_model(all_models, models_to_load = [])
+ all_converted_models = converted_ifc_models(all_models)
+
+ gon.ifc_models = {
+ models: gon_ifc_model_models(all_converted_models, models_to_load),
+ projects: [{ id: @project.identifier, name: @project.name }],
+ xkt_attachment_ids: gon_ifc_model_xkt_attachment_ids(all_converted_models),
+ metadata_attachment_ids: gon_ifc_model_metadata_attachment_ids(all_converted_models)
+ }
+ end
+
+ def converted_ifc_models(ifc_models)
+ ifc_models.select(&:converted?)
+ end
+
+ def gon_ifc_model_models(all_models, models_to_load)
+ all_converted_models = converted_ifc_models(all_models)
+
+ all_converted_models.map do |ifc_model|
+ {
+ id: ifc_model.id,
+ name: ifc_model.title,
+ default: models_to_load.include?(ifc_model)
+ }
end
end
+
+ def gon_ifc_model_xkt_attachment_ids(models)
+ Hash[models.map { |model| [model.id, model.xkt_attachment.id] }]
+ end
+
+ def gon_ifc_model_metadata_attachment_ids(models)
+ Hash[
+ models.map do |model|
+ [model.id,
+ model.metadata_attachment.id]
+ end
+ ]
+ end
end
\ No newline at end of file
diff --git a/modules/ifc_models/app/views/ifc_models/ifc_models/show_defaults.html.erb b/modules/ifc_models/app/views/ifc_models/ifc_models/show_defaults.html.erb
index 7eb221a5069..d1ff3ba6db4 100644
--- a/modules/ifc_models/app/views/ifc_models/ifc_models/show_defaults.html.erb
+++ b/modules/ifc_models/app/views/ifc_models/ifc_models/show_defaults.html.erb
@@ -58,10 +58,24 @@ See doc/COPYRIGHT.rdoc for more details.
<% end %>
</div>
</div>
-<% end %>
+<% else %>
+ <% unconverted = @default_ifc_models.reject(&:converted?) %>
+
+ <% if unconverted.any? %>
+ <div class="notification-box -info">
+ <a href="#" title="close" class="notification-box--close icon-context icon-close"></a>
+ <div class="notification-box--content">
+ <p><%= t('ifc_models.processing_notice.processing_default') %></p>
+ <ul>
+ <% unconverted.each do |model| %>
+ <li><%= model.title %></li>
+ <% end %>
+ </ul>
+ </div>
+ </div>
+ <% end %>
-<% if @default_ifc_models.map(&:converted?).uniq == [true] %>
-<div class="ifc-viewer--container">
- <ifc-viewer></ifc-viewer>
-</div>
+ <div class="ifc-viewer--container">
+ <ifc-viewer></ifc-viewer>
+ </div>
<% end %>
diff --git a/modules/ifc_models/config/locales/en.yml b/modules/ifc_models/config/locales/en.yml
index 4b00fd40d5e..76c1271f5b5 100644
--- a/modules/ifc_models/config/locales/en.yml
+++ b/modules/ifc_models/config/locales/en.yml
@@ -16,6 +16,8 @@ en:
label: 'Processing?'
in_progress: 'In progress'
completed: 'Completed'
+ processing_notice:
+ processing_default: 'The following default IFC models are still being processed and are thus not available, yet:'
flash_messages:
upload_successful: 'Upload succeeded. It will now get processed and will be ready to use in a couple of minutes.'
conversion: