diff --git a/app/controllers/admin/steps_controller.rb b/app/controllers/admin/steps_controller.rb
index d7e80c2c..d63c7cad 100644
--- a/app/controllers/admin/steps_controller.rb
+++ b/app/controllers/admin/steps_controller.rb
@@ -83,7 +83,8 @@ def step_params
:position,
:app_url,
:app_link_text,
- :type
+ :type,
+ :waiting_time
)
end
end
diff --git a/app/models/step.rb b/app/models/step.rb
index e7a14cb6..e141049a 100644
--- a/app/models/step.rb
+++ b/app/models/step.rb
@@ -18,6 +18,7 @@ class Step < ApplicationRecord
validates :slug, presence: true, uniqueness: true
validates :description, presence: true
validates :is_waiting_step, inclusion: { in: [true, false] }
+ validates :waiting_time, :numericality => { :greater_than_or_equal_to => 0 }
# FIXME: fill in position from id!
diff --git a/app/views/admin/steps/_form.html.erb b/app/views/admin/steps/_form.html.erb
index fe23e500..c5673752 100644
--- a/app/views/admin/steps/_form.html.erb
+++ b/app/views/admin/steps/_form.html.erb
@@ -10,6 +10,7 @@
<%= form.text_field :custom_title %>
<%= form.text_field :keywords %>
<%= form.check_box :is_waiting_step %>
+ <%= form.number_field :waiting_time %>
<%= form.text_field :slug %>
<%= form.text_field :app_url %>
<%= form.text_field :app_link_text %>
diff --git a/app/views/components/_timeline.html.erb b/app/views/components/_timeline.html.erb
index 0ae44188..63810b71 100644
--- a/app/views/components/_timeline.html.erb
+++ b/app/views/components/_timeline.html.erb
@@ -23,6 +23,18 @@
<%= link_to step.title, [@journey, step], class: 'sdn-timeline__link' %>
+ <% if step.waiting_time > 0 && user_step.status == "waiting" %>
+ <% time_waited = step.waiting_time - (Date.today - Date.parse(user_step.updated_at.to_s)).to_i %>
+ <% if time_waited < 0 %>
+
+ <% elsif time_waited < 5 %>
+
+ <% else %>
+
+ <% end %>
+ <%= time_waited %>
+
+ <% end %>
<% else %>
<%= link_to step.title, [@journey, step], class: 'sdn-timeline__link' %>
<% end %>
diff --git a/db/migrate/20230627134435_add_waiting_time_to_steps.rb b/db/migrate/20230627134435_add_waiting_time_to_steps.rb
new file mode 100644
index 00000000..b339a6cc
--- /dev/null
+++ b/db/migrate/20230627134435_add_waiting_time_to_steps.rb
@@ -0,0 +1,5 @@
+class AddWaitingTimeToSteps < ActiveRecord::Migration[6.1]
+ def change
+ add_column :steps, :waiting_time, :integer, default: 0
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 0010d3d2..df1066d6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -1025,7 +1025,8 @@ CREATE TABLE public.steps (
app_url character varying,
type character varying DEFAULT 'BasicStep'::character varying NOT NULL,
app_link_text character varying,
- custom_title character varying
+ custom_title character varying,
+ waiting_time integer DEFAULT 0
);
@@ -2440,6 +2441,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230325092744'),
('20230325095737'),
('20230325151049'),
-('20240427124856');
+('20240427124856'),
+('20230627134435');