-
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.
Unify the form (add-general-agenda-app)
- Loading branch information
Showing
6 changed files
with
64 additions
and
95 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 |
---|---|---|
|
@@ -6,35 +6,30 @@ class ApplicationForm | |
include ActiveModel::Validations | ||
|
||
validate :recipient_present? | ||
validates :subject, presence: true, if: -> { current_step == 'fill_message' } | ||
validates :text, presence: true, if: -> { current_step == 'fill_message' } | ||
validates :subject, presence: true | ||
validates :text, presence: true | ||
|
||
attr_accessor( | ||
:subject, | ||
:text, | ||
# Static/template attributes | ||
:title, | ||
:description, | ||
:attachments_template, | ||
|
||
# Submitted through form | ||
:recipient_name, | ||
:recipient_uri, | ||
:current_step, | ||
:subject, | ||
:text, | ||
:text_hint, | ||
:signed_required, | ||
:attachments, | ||
:is_submitted | ||
) | ||
|
||
def should_redirect_to_upvs_submission? | ||
current_step == 'fill_message' && valid? | ||
end | ||
|
||
private | ||
|
||
def recipient_present? | ||
errors.add(:recipient, 'Zvoľte prijímateľa') if recipient_uri.blank? | ||
end | ||
|
||
def subject_present? | ||
return unless (@current_step == 'email') | ||
|
||
if @email.present? | ||
errors.add(:email, 'Zadajte emailovú adresu v platnom tvare, napríklad [email protected]') unless @email.match?(URI::MailTo::EMAIL_REGEXP) | ||
else | ||
errors.add(:email, 'Zadajte emailovú adresu') | ||
end | ||
errors.add(:recipient_name, 'Zvoľte prijímateľa') if recipient_name.blank? || recipient_uri.blank? | ||
end | ||
end | ||
end | ||
|
3 changes: 0 additions & 3 deletions
3
app/views/apps/general_agenda_app/general_agenda/_hidden_fields.html.erb
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
app/views/apps/general_agenda_app/general_agenda/fill_message.erb
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
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