forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve registration and verification flow (decidim#13295)
Co-authored-by: Alexandru Emil Lupu <[email protected]> Co-authored-by: Maxim Colls <[email protected]>
- Loading branch information
1 parent
ea44d41
commit 74701b1
Showing
87 changed files
with
1,564 additions
and
413 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
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
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
2 changes: 2 additions & 0 deletions
2
decidim-core/app/cells/decidim/amendable/promote_button_card/show.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
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
15 changes: 15 additions & 0 deletions
15
decidim-core/app/cells/decidim/onboarding_action_message/show.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,15 @@ | ||
<div id="onboarding-messages-container" class="container"> | ||
<div class="flash info" data-closable> | ||
<div class="flash__icon"> | ||
<%= info_icon %> | ||
</div> | ||
|
||
<div class="flash__message"> | ||
<%= message_text %> | ||
</div> | ||
|
||
<%= button_to decidim_verifications.clear_onboarding_data_authorizations_path, form_class: "close-button", role: :button, method: :delete, remote: true, data: { close: "" } do %> | ||
<%= close_icon %> | ||
<% end %> | ||
</div> | ||
</div> |
76 changes: 76 additions & 0 deletions
76
decidim-core/app/cells/decidim/onboarding_action_message_cell.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,76 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
# This cell renders an announcement of pending onboarding action | ||
# if exists for a user | ||
# | ||
# The `model` is expected to be a user | ||
# | ||
class OnboardingActionMessageCell < Decidim::ViewModel | ||
include ActiveLinkTo | ||
|
||
alias user model | ||
|
||
def show | ||
return if is_active_link?(onboarding_path) | ||
return unless onboarding_manager.valid? | ||
return unless onboarding_manager.pending_action? | ||
return if authorization_status == :unauthorized | ||
return if pending_authorization_link_active? | ||
|
||
render :show | ||
end | ||
|
||
private | ||
|
||
def onboarding_path | ||
decidim_verifications.onboarding_pending_authorizations_path | ||
end | ||
|
||
def onboarding_manager | ||
@onboarding_manager ||= OnboardingManager.new(user) | ||
end | ||
|
||
def authorizations | ||
@authorizations ||= action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources) | ||
end | ||
|
||
def authorization_status | ||
@authorization_status ||= authorizations.global_code | ||
end | ||
|
||
def pending_authorization_link_active? | ||
return unless authorizations.single_authorization_required? | ||
|
||
is_active_link? authorizations.statuses.first.current_path | ||
end | ||
|
||
def message_text | ||
t( | ||
"cta_html", | ||
scope: "decidim.onboarding_action_message", | ||
link_text:, | ||
path: onboarding_path, | ||
action: onboarding_manager.action_text.downcase, | ||
resource_name: onboarding_manager.model_name.human.downcase, | ||
resource_title: decidim_sanitize_translated(onboarding_manager.model_title) | ||
) | ||
end | ||
|
||
def link_text | ||
if onboarding_manager.finished_verifications? | ||
t("click_link", scope: "decidim.onboarding_action_message") | ||
else | ||
t("finish_authorization_process", scope: "decidim.onboarding_action_message") | ||
end | ||
end | ||
|
||
def info_icon | ||
icon("information-line") | ||
end | ||
|
||
def close_icon | ||
icon("close-line") | ||
end | ||
end | ||
end |
Oops, something went wrong.