-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added waiting time to waiting step (#460) #590
Open
xpavle00
wants to merge
7
commits into
master
Choose a base branch
from
feature/460
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7b82819
Added waiting time to waiting step (#460)
xpavle00 81d3e3f
Add happy path of subscribing to user step deadline expiration
crutch 1c29a6c
Add rather ugly invalid date error handling
crutch 98f36fa
This somehow slipped my initial commit...
crutch 0f38ac7
Solve hiding/showing of date picker like a Cro-magnon
crutch 8eacb90
Changed waiting time in stepper design to be more clear.
xpavle00 1d32da8
Changes based on PR.
xpavle00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,8 @@ def step_params | |
:position, | ||
:app_url, | ||
:app_link_text, | ||
:type | ||
:type, | ||
:waiting_time | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class DeadlineNotificationsController < ApplicationController | ||
before_action :set_journey_and_step | ||
def subscribe_to_deadline_notification | ||
notification_date = params[:notification_date] ? Date.parse(params[:notification_date]) : nil | ||
notification_date ||= Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i) | ||
|
||
@user_journey = UserJourney.order(id: :desc).find_by(user: current_user, journey: @journey) | ||
@user_step = @user_journey.user_steps.find_by(step: @current_step) | ||
|
||
@user_step.update(to_be_notified_at: notification_date) | ||
respond_to do |format| | ||
format.html do | ||
redirect_to [@journey, @current_step] | ||
end | ||
format.js do | ||
render 'deadline_notifications_updated' | ||
end | ||
end | ||
|
||
rescue Date::Error => e | ||
respond_to do |format| | ||
format.html do | ||
redirect_to [@journey, @current_step] | ||
end | ||
format.js do | ||
render 'deadline_notifications_update_error' | ||
end | ||
end | ||
end | ||
|
||
def unsubscribe_deadline_notification | ||
@user_journey = UserJourney.order(id: :desc).find_by(user: current_user, journey: @journey) | ||
@user_step = @user_journey.user_steps.find_by(step: @current_step) | ||
|
||
@user_step.update(to_be_notified_at: nil) | ||
|
||
respond_to do |format| | ||
format.html do | ||
redirect_to [@journey, @current_step] | ||
end | ||
format.js do | ||
render 'deadline_notifications_updated' | ||
end | ||
end | ||
|
||
end | ||
|
||
private | ||
|
||
def set_journey_and_step | ||
@journey = Journey.published.find_by!(slug: params[:journey_id]) | ||
@current_step = @journey.steps.find_by!(slug: params[:id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div id="subsciption_info"> | ||
<% if current_user_step.to_be_notified_at %> | ||
<p> | ||
O vypršaní lehoty vám zašleme notifikáciu e-mailom dňa <%= current_user_step.to_be_notified_at.strftime('%d.%m.%Y') %>. | ||
<a id="change-notification-date-link" href="#">Zmeniť dátum</a> | ||
</p> | ||
<%= form_tag unsubscribe_deadline_notification_journey_step_path(@current_step.journey, @current_step), remote: true, authenticity_token: true, method: :delete do %> | ||
<%= hidden_field_tag :current_user_step_id, current_user_step.id %> | ||
<%= submit_tag 'Zrušiť notifikáciu', class: 'govuk-button govuk-button--warning' %> | ||
<% end %> | ||
<% else | ||
current_user_step.submitted_at %> | ||
<p> | ||
Ak si želáte môžeme vám poslať notifikáciu dňa <%= current_user_step.expected_resolution_date.strftime('%d.%m.%Y') %>. | ||
<a id="change-notification-date-link" href="#">Zmeniť dátum</a> | ||
</p> | ||
|
||
<%= form_tag subscribe_to_deadline_notification_journey_step_path(@current_step.journey, @current_step), remote: true, authenticity_token: true do %> | ||
<%= hidden_field_tag :current_user_step_id, current_user_step.id %> | ||
<%= hidden_field_tag :notification_date, current_user_step.expected_resolution_date %> | ||
<%= submit_tag 'Zapnúť notifikáciu', class: 'govuk-button' %> | ||
<% end %> | ||
<% end %> | ||
</div> |
36 changes: 36 additions & 0 deletions
36
app/views/deadline_notifications/_subscription_settings.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div id="deadline-notifications-info"> | ||
<%= render 'deadline_notifications/subscription_info', current_user_step: current_user_step %> | ||
</div> | ||
<div id="change-notification-date" class="sdn-appear-link-hide"> | ||
<%= form_tag subscribe_to_deadline_notification_journey_step_path(@current_step.journey, @current_step) , remote: true, authenticity_token: true do %> | ||
<div class="govuk-form-group"> | ||
<div class="govuk-grid-column-two-thirds" style="padding: 0"> | ||
Zmeniť dátum notifikácie | ||
</div> | ||
<div class="govuk-grid-column-one-third" style="text-align:right"> | ||
<a href="#" id="change-notification-date-close">Zatvoriť</a> | ||
</div> | ||
<span id="dob-error" class="govuk-error-message sdn-appear-link-hide"> | ||
<span class="govuk-visually-hidden">Chyba:</span> Zadali ste neplatný dátum | ||
</span> | ||
<div class="govuk-date-input" id="dob"> | ||
<div class="govuk-date-input__item"> | ||
<div class="govuk-form-group"> | ||
<%= label_tag 'dob-day', 'Deň', class: "govuk-label govuk-date-input__label" %> | ||
<%= number_field_tag 'day', current_user_step.expected_resolution_date.day, required: true, min: 1, max: 31, class: 'govuk-input govuk-date-input__input govuk-input--width-2', id: 'dob-day' %></div> | ||
</div> | ||
<div class="govuk-date-input__item"> | ||
<div class="govuk-form-group"> | ||
<%= label_tag 'dob-month', 'Mesiac', class: "govuk-label govuk-date-input__label" %> | ||
<%= number_field_tag 'month', current_user_step.expected_resolution_date.month, required: true, min: 1, max: 12, class: 'govuk-input govuk-date-input__input govuk-input--width-2', id: 'dob-month' %></div> | ||
</div> | ||
<div class="govuk-date-input__item"> | ||
<div class="govuk-form-group"> | ||
<%= label_tag 'dob-year', 'Rok', class: "govuk-label govuk-date-input__label" %> | ||
<%= number_field_tag 'year', current_user_step.expected_resolution_date.year, required: true, min: 2023, class: 'govuk-input govuk-date-input__input govuk-input--width-2', id: 'dob-year' %></div> | ||
</div> | ||
</div> | ||
</div> | ||
<%= submit_tag 'Zmeniť dátum a zapnúť notifikáciu', class: 'govuk-button' %> | ||
<% end %> | ||
</div> |
2 changes: 2 additions & 0 deletions
2
app/views/deadline_notifications/deadline_notifications_update_error.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$('#change-notification-date').find('.govuk-form-group').addClass('govuk-form-group--error') | ||
$('#change-notification-date').find('#dob-error').removeClass('sdn-appear-link-hide') |
5 changes: 5 additions & 0 deletions
5
app/views/deadline_notifications/deadline_notifications_updated.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$('#subsciption_info').replaceWith('<%= j render "deadline_notifications/subscription_info", current_user_step: @user_step %>'); | ||
$('#deadline-notifications-info').removeClass('sdn-appear-link-hide') | ||
$('#change-notification-date').addClass('sdn-appear-link-hide') | ||
$('#change-notification-date').find('.govuk-form-group').removeClass('govuk-form-group--error') | ||
$('#change-notification-date').find('#dob-error').addClass('sdn-appear-link-hide') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddWaitingTimeToSteps < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :steps, :waiting_time, :integer, default: 0 | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20231007072828_add_submitted_at_and_to_be_notified_at_to_user_step.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSubmittedAtAndToBeNotifiedAtToUserStep < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :user_steps, :submitted_at, :date, default: nil | ||
add_column :user_steps, :to_be_notified_at, :date, default: nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toto by mal vidiet este nejaky dizajner.