decidim-direct_verifications 1.0.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -0
  3. data/app/commands/decidim/direct_verifications/verification/create_import.rb +19 -10
  4. data/app/controllers/concerns/decidim/direct_verifications/admin/needs_verification_snippets.rb +61 -0
  5. data/app/controllers/decidim/direct_verifications/verification/admin/application_controller.rb +15 -0
  6. data/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb +3 -1
  7. data/app/controllers/decidim/direct_verifications/verification/admin/direct_verifications_controller.rb +1 -1
  8. data/app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb +1 -1
  9. data/app/controllers/decidim/direct_verifications/verification/admin/stats_controller.rb +2 -2
  10. data/app/controllers/decidim/direct_verifications/verification/admin/user_authorizations_controller.rb +64 -0
  11. data/app/jobs/decidim/direct_verifications/authorize_users_job.rb +2 -0
  12. data/app/jobs/decidim/direct_verifications/base_import_job.rb +22 -6
  13. data/app/jobs/decidim/direct_verifications/register_users_job.rb +1 -0
  14. data/app/jobs/decidim/direct_verifications/revoke_users_job.rb +1 -0
  15. data/app/packs/entrypoints/decidim_direct_verifications.js +4 -0
  16. data/app/packs/entrypoints/decidim_direct_verifications.scss +1 -0
  17. data/app/packs/entrypoints/decidim_direct_verifications_participants.js +1 -0
  18. data/app/packs/src/decidim/direct_verifications/admin/checkboxes.js +5 -0
  19. data/app/packs/src/decidim/direct_verifications/admin/participants.js +88 -0
  20. data/app/{assets/stylesheets/decidim/direct_verifications → packs/stylesheets/decidim/direct_verifications/admin}/authorizations.scss +1 -1
  21. data/app/permissions/decidim/direct_verifications/admin/permissions.rb +19 -0
  22. data/app/views/decidim/direct_verifications/verification/admin/authorizations/index.html.erb +2 -1
  23. data/app/views/decidim/direct_verifications/verification/admin/direct_verifications/index.html.erb +1 -1
  24. data/app/views/decidim/direct_verifications/verification/admin/imports/new.html.erb +1 -1
  25. data/app/views/decidim/direct_verifications/verification/admin/stats/index.html.erb +3 -1
  26. data/app/views/decidim/direct_verifications/verification/admin/user_authorizations/show.html.erb +27 -0
  27. data/config/assets.rb +25 -0
  28. data/config/locales/ca.yml +14 -29
  29. data/config/locales/cs.yml +25 -18
  30. data/config/locales/en.yml +35 -17
  31. data/config/locales/es.yml +14 -28
  32. data/config/locales/fr.yml +26 -22
  33. data/lib/decidim/direct_verifications/parsers/metadata_parser.rb +5 -11
  34. data/lib/decidim/direct_verifications/verification/admin.rb +2 -0
  35. data/lib/decidim/direct_verifications/verification/admin_engine.rb +9 -5
  36. data/lib/decidim/direct_verifications/version.rb +3 -3
  37. data/lib/decidim/direct_verifications.rb +6 -0
  38. data/package.json +192 -0
  39. metadata +19 -10
  40. data/app/assets/config/direct_verifications_admin_manifest.css +0 -3
  41. data/app/assets/config/direct_verifications_admin_manifest.js +0 -1
  42. data/app/assets/javascripts/decidim/direct_verifications/verification/admin/direct_verifications_admin.js.es6 +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d0c77bd7a23a324cffa17539eedb6d2fd8bfbcfafe08f0b77cbc75035d59262
4
- data.tar.gz: 8d0f5a889569f909f2b8d6dafaf59959c7b7523ba2e9d5659dbe319b201de993
3
+ metadata.gz: d7a348b9504d3371592edd997c1af5847b05b3fa060a155de266c13ad3385b1c
4
+ data.tar.gz: 6d21de70c4ae4b1d40b2ab27514f90cdeccbaaf309eae82f0eb9671f1b597355
5
5
  SHA512:
6
- metadata.gz: d15873f3e2da17204d2de7e5b880288c5c4643414ae0eb847a646588855c4e2def9b641235ffb0231afabddba618524ede04baec25366af6efda6c4f88d87b9d
7
- data.tar.gz: 1ccce49b7915f7d6fc67ec7ed057dfcbf5d2a061ffc5bc624832462afe1d9bc0382f39f2efe3e4b309c7533e0846161711a443155fe5fae7c0bc57d3ecf31ed4
6
+ metadata.gz: efa9e4d88b715b7a1255bdf2890e0f9f0f34b52b2cf3f02cc211954eec9b53b43c75a3373a456c7d71a23ba9920f6b3c9ec47f5fe3476cfc23564b7c4897159e
7
+ data.tar.gz: 2825c1c7d5bb1230c242a019288d76fd4d42ae69770fa5cbe5f91a9492c4de0c96a7e36dc012195cd65f0301243792a6dd5f9ea7a8584b995b174de9a5ada695
data/README.md CHANGED
@@ -55,6 +55,28 @@ Decidim::DirectVerifications.configure do |config|
55
55
  end
56
56
  ```
57
57
 
58
+ ### Direct managements of user's authorizations
59
+
60
+ This plugin also provides a place for admins to see and manage (if configured) existing verifications for any user.
61
+ Admins can go to the "Participants" admin page and see a new management button, when clicked it shows a modal window with all the authorizations that this user has granted as well as the missing ones. If Direct Verfication is configured to manage that verification (through the `manage_workflows` config var) it can be granted or revoke just by clicking a button.
62
+
63
+ ![Participants mods](examples/participants.png)
64
+
65
+ ![Participants modal management](examples/authorization-modal.png)
66
+
67
+ This behavior can be disabled by disabling in a initializer the config var `participants_modal`.
68
+
69
+ **`config/initializers/decidim_verifications.rb`:**
70
+
71
+ ```ruby
72
+ # frozen_string_literal: true
73
+
74
+ Decidim::DirectVerifications.configure do |config|
75
+ # Disable participants direct verifications management
76
+ config.participants_modal = false
77
+ end
78
+ ```
79
+
58
80
  ## Installation
59
81
 
60
82
  Add this line to your application's Gemfile:
@@ -73,6 +95,8 @@ Depending on your Decidim version, you might want to specify the version to ensu
73
95
 
74
96
  | Direct Verifications version | Compatible Decidim versions |
75
97
  |---|---|
98
+ | 1.2 | >= 0.25.x |
99
+ | 1.1 | >= 0.25.x |
76
100
  | 1.0 | >= 0.23.x |
77
101
  | 0.22.x | 0.22.x |
78
102
 
@@ -17,13 +17,14 @@ module Decidim
17
17
 
18
18
  case action
19
19
  when :register
20
- register_users_async
20
+ register_users_async(remove_file: true)
21
+ when :authorize
22
+ authorize_users_async(remove_file: true)
21
23
  when :register_and_authorize
22
24
  register_users_async
23
- file.rewind
24
- authorize_users_async
25
+ authorize_users_async(remove_file: true)
25
26
  when :revoke
26
- revoke_users_async
27
+ revoke_users_async(remove_file: true)
27
28
  end
28
29
 
29
30
  broadcast(:ok)
@@ -33,16 +34,24 @@ module Decidim
33
34
 
34
35
  attr_reader :form, :file, :organization, :user, :action
35
36
 
36
- def register_users_async
37
- RegisterUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
37
+ def register_users_async(options = {})
38
+ RegisterUsersJob.perform_later(blob.id, organization, user, form.authorization_handler, options)
39
+ end
40
+
41
+ def revoke_users_async(options = {})
42
+ RevokeUsersJob.perform_later(blob.id, organization, user, form.authorization_handler, options)
43
+ end
44
+
45
+ def authorize_users_async(options = {})
46
+ AuthorizeUsersJob.perform_later(blob.id, organization, user, form.authorization_handler, options)
38
47
  end
39
48
 
40
- def revoke_users_async
41
- RevokeUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
49
+ def blob
50
+ @blob ||= ActiveStorage::Blob.create_and_upload!(io: file, filename: secure_name)
42
51
  end
43
52
 
44
- def authorize_users_async
45
- AuthorizeUsersJob.perform_later(file.read, organization, user, form.authorization_handler)
53
+ def secure_name
54
+ @secure_name ||= "#{SecureRandom.uuid}#{File.extname(file.tempfile)}"
46
55
  end
47
56
  end
48
57
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module DirectVerifications
7
+ module Admin
8
+ module NeedsVerificationSnippets
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ helper_method :snippets
13
+ end
14
+
15
+ def snippets
16
+ return @snippets if @snippets
17
+
18
+ @snippets = Decidim::Snippets.new
19
+ return @snippets if Decidim::DirectVerifications.participants_modal.blank?
20
+
21
+ @snippets.add(:direct_verifications, "<script>DirectVerificationsConfig = #{direct_verifications_config.to_json}</script>")
22
+ @snippets.add(:direct_verifications, ActionController::Base.helpers.javascript_pack_tag("decidim_direct_verifications_participants"))
23
+ @snippets.add(:head, @snippets.for(:direct_verifications))
24
+
25
+ @snippets
26
+ end
27
+
28
+ def direct_verifications_config
29
+ {
30
+ buttonTitle: I18n.t("decidim.direct_verifications.participants.modal.button_title", locale: detect_current_locale),
31
+ modalTitle: I18n.t("decidim.direct_verifications.participants.modal.modal_title", locale: detect_current_locale),
32
+ closeModalLabel: I18n.t("decidim.direct_verifications.participants.modal.close_modal_label", locale: detect_current_locale),
33
+ statsLabel: I18n.t("decidim.direct_verifications.verification.admin.index.stats", locale: detect_current_locale),
34
+ userVerificationsPath: Decidim::DirectVerifications::Verification::AdminEngine.routes.url_helpers.user_authorization_path("-ID-"),
35
+ statsPath: Decidim::DirectVerifications::Verification::AdminEngine.routes.url_helpers.stats_path,
36
+ verifications: direct_verifications_verifications
37
+ }
38
+ end
39
+
40
+ def direct_verifications_verifications
41
+ @direct_verifications_verifications ||= Decidim::Authorization.where(name: current_organization.available_authorizations)
42
+ .where.not(granted_at: nil)
43
+ .where(decidim_user_id: filtered_collection).map do |auth|
44
+ {
45
+ id: auth.id,
46
+ userId: auth.decidim_user_id,
47
+ name: auth.name,
48
+ title: I18n.t("decidim.authorization_handlers.#{auth.name}.name", locale: detect_current_locale, default: auth.name),
49
+ createdAt: auth.created_at,
50
+ updatedAt: auth.updated_at
51
+ }
52
+ end
53
+ end
54
+
55
+ def detect_current_locale
56
+ params[:locale] || session[:user_locale] || locale
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DirectVerifications
5
+ module Verification
6
+ module Admin
7
+ class ApplicationController < Decidim::Admin::ApplicationController
8
+ def permission_class_chain
9
+ [::Decidim::DirectVerifications::Admin::Permissions] + super
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -4,12 +4,14 @@ module Decidim
4
4
  module DirectVerifications
5
5
  module Verification
6
6
  module Admin
7
- class AuthorizationsController < Decidim::Admin::ApplicationController
7
+ class AuthorizationsController < ApplicationController
8
8
  layout "decidim/admin/users"
9
9
 
10
10
  def index
11
11
  enforce_permission_to :index, :authorization
12
12
  @authorizations = collection.includes(:user)
13
+ .page(params[:page])
14
+ .per(15)
13
15
  end
14
16
 
15
17
  def destroy
@@ -4,7 +4,7 @@ module Decidim
4
4
  module DirectVerifications
5
5
  module Verification
6
6
  module Admin
7
- class DirectVerificationsController < Decidim::Admin::ApplicationController
7
+ class DirectVerificationsController < ApplicationController
8
8
  include NeedsPermission
9
9
  helper_method :workflows, :current_authorization_handler
10
10
 
@@ -4,7 +4,7 @@ module Decidim
4
4
  module DirectVerifications
5
5
  module Verification
6
6
  module Admin
7
- class ImportsController < Decidim::Admin::ApplicationController
7
+ class ImportsController < ApplicationController
8
8
  layout "decidim/admin/users"
9
9
  helper_method :workflows, :current_authorization_handler
10
10
 
@@ -4,10 +4,10 @@ module Decidim
4
4
  module DirectVerifications
5
5
  module Verification
6
6
  module Admin
7
- class StatsController < Decidim::Admin::ApplicationController
7
+ class StatsController < ApplicationController
8
8
  include NeedsPermission
9
9
 
10
- layout "decidim/admin/users"
10
+ layout -> { request.xhr? ? false : "decidim/admin/users" }
11
11
 
12
12
  def index
13
13
  enforce_permission_to :index, :authorization
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DirectVerifications
5
+ module Verification
6
+ module Admin
7
+ class UserAuthorizationsController < ApplicationController
8
+ include NeedsPermission
9
+ layout false
10
+
11
+ helper_method :user, :authorizations, :authorization_for, :managed?
12
+
13
+ def show
14
+ enforce_permission_to :index, :authorization
15
+ end
16
+
17
+ def update
18
+ enforce_permission_to :create, :direct_authorization, name: params[:name]
19
+ handler = OpenStruct.new(handler_name: params[:name], user: user, unique_id: nil, metadata: {})
20
+ if Decidim::Authorization.create_or_update_from(handler)
21
+ flash[:notice] = t(".success", name: auth_name)
22
+ else
23
+ flash[:alert] = t(".error", name: auth_name)
24
+ end
25
+ redirect_to decidim_admin.officializations_path
26
+ end
27
+
28
+ def destroy
29
+ enforce_permission_to :destroy, :direct_authorization, name: params[:name]
30
+ begin
31
+ authorization_for(params[:name]).destroy!
32
+ flash[:notice] = t(".success", name: auth_name)
33
+ rescue StandardError => e
34
+ flash[:alert] = t(".error", name: auth_name, error: e.message)
35
+ end
36
+ redirect_to decidim_admin.officializations_path
37
+ end
38
+
39
+ private
40
+
41
+ def user
42
+ @user ||= Decidim::User.find_by(id: params[:id])
43
+ end
44
+
45
+ def authorizations
46
+ @authorizations ||= Decidim::Authorization.where(decidim_user_id: user.id)
47
+ end
48
+
49
+ def authorization_for(name)
50
+ authorizations.find_by(name: name)
51
+ end
52
+
53
+ def managed?(name)
54
+ Decidim::DirectVerifications.manage_workflows.include? name
55
+ end
56
+
57
+ def auth_name
58
+ t("decidim.authorization_handlers.#{params[:name]}.name", default: params[:name])
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -8,7 +8,9 @@ module Decidim
8
8
  class NullSession; end
9
9
 
10
10
  def process_users
11
+ Rails.logger.info "AuthorizeUsersJob: Authorizing #{emails.count} emails"
11
12
  emails.each do |email, data|
13
+ Rails.logger.debug "AuthorizeUsersJob: Authorizing #{email}"
12
14
  AuthorizeUser.new(
13
15
  email,
14
16
  data,
@@ -10,20 +10,32 @@ module Decidim
10
10
  class BaseImportJob < ApplicationJob
11
11
  queue_as :default
12
12
 
13
- def perform(userslist, organization, current_user, authorization_handler)
14
- @emails = Parsers::MetadataParser.new(userslist).to_h
13
+ def perform(blob_id, organization, current_user, authorization_handler, options = {})
14
+ @blob = ActiveStorage::Blob.find(blob_id)
15
15
  @organization = organization
16
16
  @current_user = current_user
17
- @instrumenter = Instrumenter.new(current_user)
18
17
  @authorization_handler = authorization_handler
19
18
 
20
- process_users
21
- send_email_notification
19
+ begin
20
+ @emails = Parsers::MetadataParser.new(userslist).to_h
21
+ @instrumenter = Instrumenter.new(current_user)
22
+
23
+ Rails.logger.info "BaseImportJob: Processing file #{@blob.filename}"
24
+ process_users
25
+ send_email_notification
26
+ rescue StandardError => e
27
+ Rails.logger.error "BaseImportJob Error: #{e.message} #{e.backtrace.filter { |f| f =~ /direct_verifications/ }}"
28
+ end
29
+ remove_file! if options.fetch(:remove_file, false)
22
30
  end
23
31
 
24
32
  private
25
33
 
26
- attr_reader :emails, :organization, :current_user, :instrumenter, :authorization_handler
34
+ attr_reader :blob, :emails, :organization, :current_user, :instrumenter, :authorization_handler
35
+
36
+ def userslist
37
+ @userslist ||= blob.download.force_encoding("UTF-8")
38
+ end
27
39
 
28
40
  def send_email_notification
29
41
  ImportMailer.finished_processing(
@@ -33,6 +45,10 @@ module Decidim
33
45
  authorization_handler
34
46
  ).deliver_now
35
47
  end
48
+
49
+ def remove_file!
50
+ blob.purge
51
+ end
36
52
  end
37
53
  end
38
54
  end
@@ -6,6 +6,7 @@ module Decidim
6
6
  module DirectVerifications
7
7
  class RegisterUsersJob < BaseImportJob
8
8
  def process_users
9
+ Rails.logger.info "RegisterUsersJob: Registering #{emails.count} emails"
9
10
  emails.each do |email, data|
10
11
  RegisterUser.new(email, data, organization, current_user, instrumenter).call
11
12
  end
@@ -4,6 +4,7 @@ module Decidim
4
4
  module DirectVerifications
5
5
  class RevokeUsersJob < BaseImportJob
6
6
  def process_users
7
+ Rails.logger.info "RevokeUsersJob: Revoking #{emails.count} emails"
7
8
  emails.each do |email, _name|
8
9
  RevokeUser.new(email, organization, instrumenter, authorization_handler).call
9
10
  end
@@ -0,0 +1,4 @@
1
+ import "src/decidim/direct_verifications/admin/checkboxes.js"
2
+
3
+ // CSS
4
+ import "entrypoints/decidim_direct_verifications.scss";
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/direct_verifications/admin/authorizations";
@@ -0,0 +1 @@
1
+ import "src/decidim/direct_verifications/admin/participants.js"
@@ -0,0 +1,5 @@
1
+ $(() => {
2
+ $('[type="checkbox"]#register').change(function () {
3
+ $(this).closest("label").find(".callout").toggleClass("hide", !$(this).prop("checked"))
4
+ })
5
+ })
@@ -0,0 +1,88 @@
1
+ class VerificationUI {
2
+ constructor($table, config) {
3
+ this.$table = $table;
4
+ this.svgPath = $table.find("use[href]:first").attr("href").split("#")[0];
5
+ this.icon = "icon-key";
6
+ this.config = config;
7
+ this.$table.on("click", ".show-verifications-modal", (e) => this.toggleModal(e));
8
+ this.addModal();
9
+ }
10
+
11
+ addModal() {
12
+ this.$modal = $(`<div class="reveal" id="show-verifications-modal" data-reveal>
13
+ <div class="reveal__header">
14
+ <h3 class="reveal__title">${this.config.modalTitle}</h3>
15
+ <button class="close-button" data-close aria-label="${this.config.closeModalLabel}"
16
+ type="button">
17
+ <span aria-hidden="true">&times;</span>
18
+ </button>
19
+ </div>
20
+
21
+ <div class="row">
22
+ <div class="columns medium-4 medium-centered modal-body">
23
+ </div>
24
+ </div>
25
+ </div>`);
26
+ this.$table.after(this.$modal);
27
+ this.$title = $("#user-groups .card-title:first");
28
+ this.$modalBody = this.$modal.find(".modal-body");
29
+ this.reveal = new Foundation.Reveal(this.$modal);
30
+ }
31
+
32
+ drawButtons() {
33
+ this.$table.find("tbody tr").each((idx, tr) => {
34
+ const $lastTd = $(tr).find("td:last");
35
+
36
+ $lastTd.prepend(`<a class="action-icon action-icon action-icon show-verifications-modal" title="${this.config.buttonTitle}" href="#open-show-verifications-modal"><span class="has-tip ${this.getTrStatus(tr)}"><svg aria-label="${this.config.buttonTitle}" role="img" class="icon--ban icon">
37
+ <title>${this.config.buttonTitle}</title>
38
+ <use href="${this.svgPath}#${this.icon}"></use>
39
+ </svg></span></a>`);
40
+ });
41
+ }
42
+
43
+ addStatsTitle() {
44
+ // Add upper link to verification stats
45
+ const $a = $(`<a class="button tiny button--title" href="${this.config.statsPath}">${this.config.statsLabel}</a>`);
46
+ $a.on("click", (e) => {
47
+ e.preventDefault();
48
+ this.loadUrl($a.attr("href"), true);
49
+ });
50
+ this.$title.append($a);
51
+ }
52
+
53
+ getTrStatus(tr) {
54
+ return this.getUserVerifications($(tr).data("user-id")).length
55
+ ? "alert"
56
+ : "";
57
+ }
58
+
59
+ getVerification(id) {
60
+ return this.config.verifications.find((auth) => auth.id == id);
61
+ }
62
+
63
+ getUserVerifications(userId) {
64
+ return this.config.verifications.filter((auth) => auth.userId == userId);
65
+ }
66
+
67
+ toggleModal(e) {
68
+ const userId = $(e.target).closest("tr").data("user-id");
69
+ this.loadUrl(this.config.userVerificationsPath.replace("-ID-", userId));
70
+ }
71
+
72
+ loadUrl(url, large = false) {
73
+ this.$modal.removeClass("large");
74
+ if (large) {
75
+ this.$modal.addClass("large");
76
+ }
77
+ this.$modalBody.html('<span class="loading-spinner"></span>');
78
+ this.$modalBody.load(url);
79
+ this.$modal.foundation("toggle");
80
+ }
81
+ }
82
+
83
+ $(() => {
84
+ const ui = new VerificationUI($("#user-groups table.table-list"), DirectVerificationsConfig);
85
+ // Draw the icon buttons for checking verification statuses
86
+ ui.drawButtons();
87
+ ui.addStatsTitle();
88
+ });
@@ -1,4 +1,4 @@
1
- @import "decidim/admin/utils/settings";
1
+ @import "stylesheets/decidim/admin/utils/settings";
2
2
 
3
3
  $code-color: $black;
4
4
  $code-font-family: $font-family-monospace;
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DirectVerifications
5
+ module Admin
6
+ class Permissions < Decidim::DefaultPermissions
7
+ def permissions
8
+ return permission_action if permission_action.scope != :admin
9
+ return permission_action unless user
10
+ return permission_action unless user.admin?
11
+
12
+ toggle_allow(Decidim::DirectVerifications.manage_workflows.map(&:to_s).include?(context.fetch(:name).to_s)) if permission_action.subject == :direct_authorization
13
+
14
+ permission_action
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
- <%= stylesheet_link_tag "decidim/direct_verifications/authorizations" %>
1
+ <%= stylesheet_pack_tag "decidim_direct_verifications" %>
2
2
 
3
3
  <div class="card">
4
4
  <div class="card-divider">
@@ -37,6 +37,7 @@
37
37
  <% end %>
38
38
  </tbody>
39
39
  </table>
40
+ <%= paginate @authorizations, theme: "decidim" %>
40
41
  </div>
41
42
  </div>
42
43
  </div>
@@ -42,4 +42,4 @@
42
42
  </div>
43
43
  </div>
44
44
 
45
- <%= javascript_include_tag "decidim/direct_verifications/verification/admin/direct_verifications_admin" %>
45
+ <%= javascript_pack_tag "decidim_direct_verifications" %>
@@ -47,4 +47,4 @@
47
47
  </div>
48
48
  </div>
49
49
 
50
- <%= javascript_include_tag "decidim/direct_verifications/verification/admin/direct_verifications_admin" %>
50
+ <%= javascript_pack_tag "decidim_direct_verifications" %>
@@ -2,7 +2,9 @@
2
2
  <div class="card-divider">
3
3
  <h2 class="card-title">
4
4
  <%= t("admin.index.stats", scope: "decidim.direct_verifications.verification") %>
5
- <%= link_to t("admin.index.title", scope: "decidim.direct_verifications.verification"), direct_verifications_path, class: "button tiny button--title" %>
5
+ <% unless request.xhr? %>
6
+ <%= link_to t("admin.index.title", scope: "decidim.direct_verifications.verification"), direct_verifications_path, class: "button tiny button--title" %>
7
+ <% end %>
6
8
  </h2>
7
9
  </div>
8
10
  <div class="card-section">
@@ -0,0 +1,27 @@
1
+ <strong><%= user.name %>:</strong>
2
+ <table class="table-list">
3
+ <tbody>
4
+ <% current_organization.available_authorizations.each do |name| %>
5
+ <% authorization = authorization_for(name) %>
6
+ <tr>
7
+ <td><%= I18n.t("decidim.authorization_handlers.#{name}.name", default: name) %></td>
8
+ <td>
9
+ <% if authorization&.granted? %>
10
+ <span class="label success"><%= t ".granted" %></span>
11
+ <% else %>
12
+ <span class="label alert"><%= t ".not_granted" %></span>
13
+ <% end %>
14
+ </td>
15
+ <td class="table-list__actions">
16
+ <% if managed?(name) %>
17
+ <% if authorization&.granted? %>
18
+ <%= icon_link_to "circle-x", user_authorization_path(user, name: name), t(".revoke"), method: :delete, role: "img", aria_label: t(".revoke") %>
19
+ <% else %>
20
+ <%= icon_link_to "circle-check", user_authorization_path(user, name: name), t(".grant"), method: :patch, role: "img", aria_label: t(".grant") %>
21
+ <% end %>
22
+ <% end %>
23
+ </td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
data/config/assets.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is located at `config/assets.rb` of your module.
4
+
5
+ # Define the base path of your module. Please note that `Rails.root` may not be
6
+ # used because we are not inside the Rails environment when this file is loaded.
7
+ base_path = File.expand_path("..", __dir__)
8
+
9
+ # Register an additional load path for webpack. All the assets within these
10
+ # directories will be available for inclusion within the Decidim assets. For
11
+ # example, if you have `app/packs/src/decidim/foo.js`, you can include that file
12
+ # in your JavaScript entrypoints (or other JavaScript files within Decidim)
13
+ # using `import "src/decidim/foo"` after you have registered the additional path
14
+ # as follows.
15
+ Decidim::Webpacker.register_path("#{base_path}/app/packs")
16
+
17
+ # Register the entrypoints for your module. These entrypoints can be included
18
+ # within your application using `javascript_pack_tag` and if you include any
19
+ # SCSS files within the entrypoints, they become available for inclusion using
20
+ # `stylesheet_pack_tag`.
21
+ Decidim::Webpacker.register_entrypoints(
22
+ decidim_direct_verifications: "#{base_path}/app/packs/entrypoints/decidim_direct_verifications.js",
23
+ decidim_direct_verifications_participants: "#{base_path}/app/packs/entrypoints/decidim_direct_verifications_participants.js",
24
+ decidim_direct_verifications_css: "#{base_path}/app/packs/entrypoints/decidim_direct_verifications.scss"
25
+ )