-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
180 additions
and
156 deletions.
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 |
---|---|---|
@@ -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
19 changes: 7 additions & 12 deletions
19
app/views/steps/_step_subscription.html.erb → ...line_notifications/_subscription_info.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 |
---|---|---|
@@ -1,29 +1,24 @@ | ||
<div id="step_subscription"> | ||
<% if current_user_step.submitted_at %> | ||
<p> | ||
Teraz treba počkať na rozhodnutie. Ostáva <%= current_user_step.remaining_time %> z | ||
pôvodných <%= t('components.deadline.remaining_days', count: @current_step.waiting_time) %>. | ||
</p> | ||
<% end %> | ||
<div id="subsciption_info"> | ||
<% if current_user_step.to_be_notified_at %> | ||
<p> | ||
Budeme vás o tom notifikovať e-mailom <%= current_user_step.to_be_notified_at.strftime('%d.%m.%Y') %>. | ||
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ť naplánovanú notifikáciu.', class: 'govuk-button' %> | ||
<%= submit_tag 'Zrušiť notifikáciu', class: 'govuk-button govuk-button--warning' %> | ||
<% end %> | ||
<% else | ||
current_user_step.submitted_at %> | ||
<p> | ||
Pošleme Vám na e-mail notifikáciu keď sa bude lehota blížiť? | ||
Vychádza to na <%= current_user_step.expected_resolution_date.strftime('%d.%m.%Y') %> | ||
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 'Áno, toto chcem.', class: 'govuk-button' %> | ||
<%= 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> |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ws/steps/step_subscription_updated.js.erb → ...ons/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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
$('#step_subscription').replaceWith('<%= j render "step_subscription", current_user_step: @user_step %>'); | ||
$('#next-steps-info').removeClass('sdn-appear-link-hide') | ||
$('#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 was deleted.
Oops, something went wrong.
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.