decidim-friendly_signup 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c631ec440674f278ea3a0f3369435831014443e36f2f4247d1a87d914e7e66c8
4
- data.tar.gz: cf5ca968cfe4459a63471e02ff36dd38f28cfb042c3146e175c3766dab4a6571
3
+ metadata.gz: 88bd76deb088270153f2b8d9dc3376d1f6333c0429e2433c2f896870027cbd30
4
+ data.tar.gz: d2e2efec13ef916c6835e8f09b4d50e8e20ddef3c05a1f41bf24b51a1054c074
5
5
  SHA512:
6
- metadata.gz: cdd1a58fad3b2b40cb5f73497c3ca408a621afce743073b40c9fee720a4e9050e0d5a8f3b495e5024b6e807ce7fe8c61859e264259fd3ccec30424d025114bb3
7
- data.tar.gz: b0437d886f9018aaed1a3f405f52032d77c8c01ec7f1f40bb8a61b708138f1eeedbacb424ab394d26048c7bb643d14b3579ddce4954cd5c2af521fea6ffc8f38
6
+ metadata.gz: 4a23dbcb2623314b4fcfbe30b8025b97309049beb28a2ab66ab0bb070498624509805054e2fc476f04f078fd56ed3161f49c66accae5b5d06b9537547d1fcbdd
7
+ data.tar.gz: f5312068c52ccb019f87e1af5beabc72e7f85396aee34ab4b1799001dcb905e17962c042186c55b749af4a4a69bdb19b7b915cfad4581e17bccb8e96529e31fe
data/README.md CHANGED
@@ -18,7 +18,7 @@ This module simply substitutes some pages to ease up the registration process in
18
18
 
19
19
  - [x] Simplify the password field and add a button with a "show password". ![Show/hide password](examples/passwords.png)
20
20
 
21
- - [ ] Remove the nickname field from the registration process and automatically create one on registering
21
+ - [x] Remove the nickname field from the registration process and automatically create one on registering. ![Hide nickname](examples/nickname.png)
22
22
  - [x] Instant validate parameters when registering without having to send it for backend validation. ![Instant validation](examples/instant_validation.png)
23
23
  - [ ] Use checkout codes to validate the email instead of a link
24
24
 
@@ -51,6 +51,7 @@ Depending on your Decidim version, choose the corresponding FriendlySignup versi
51
51
 
52
52
  | FriendlySignup version | Compatible Decidim versions |
53
53
  |---|---|
54
+ | 0.3.x | 0.26.x |
54
55
  | 0.2.x | 0.26.x |
55
56
  | 0.1.x | 0.26.x |
56
57
 
@@ -67,6 +68,9 @@ Decidim::FriendlySignup.configure do |config|
67
68
 
68
69
  # Automatically validate user inputs in the register form (default is true):
69
70
  config.use_instant_validation = false
71
+
72
+ # Hide nickname field and create one automatically from user's name or email (default is true)
73
+ config.hide_nickname = false
70
74
  end
71
75
  ```
72
76
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+
5
+ module Decidim
6
+ module FriendlySignup
7
+ module AutoNickname
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ def nickname
12
+ return super unless FriendlySignup.hide_nickname
13
+
14
+ UserBaseEntity.nicknamize(name || email, organization: current_organization)
15
+ end
16
+
17
+ private
18
+
19
+ # nickname is removed from the view, so put any (that shouldn't ever happen) error on the base
20
+ def nickname_unique_in_organization
21
+ return false unless nickname
22
+
23
+ if valid_users.find_by("LOWER(nickname)= ? AND decidim_organization_id = ?", nickname.downcase, current_organization.id).present?
24
+ errors.add :base, :taken
25
+ errors.add :nickname, :taken
26
+ end
27
+ end
28
+
29
+ def valid_users
30
+ UserBaseEntity.where(invitation_token: nil)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -15,6 +15,7 @@ export default class InstantValidator {
15
15
  }
16
16
 
17
17
  init() {
18
+ this.$form.foundation("disableValidation");
18
19
  // this final validation prevents abide from resetting the field when user loses focus
19
20
  this.$inputs.on("blur", (evt) => {
20
21
  this.validate($(evt.currentTarget));
@@ -34,15 +34,17 @@
34
34
 
35
35
  <div class="user-person">
36
36
  <div class="field">
37
- <%= f.text_field :name, help_text: t(".username_help"), autocomplete: "off" %>
37
+ <%= f.text_field :name, help_text: t(".username_help"), autocomplete: "off", data: { "instant-attribute": "nickname" } %>
38
38
  </div>
39
39
  </div>
40
40
 
41
- <div class="user-nickname">
42
- <div class="field">
43
- <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name), prefix: { value: "@", small: 1, large: 1 }, autocomplete: "off" %>
41
+ <% unless friendly_override_activated?(:hide_nickname) %>
42
+ <div class="user-nickname">
43
+ <div class="field">
44
+ <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name), prefix: { value: "@", small: 1, large: 1 }, autocomplete: "off", data: { "instant-attribute": "nickname" } %>
45
+ </div>
44
46
  </div>
45
- </div>
47
+ <% end %>
46
48
 
47
49
  <div class="field">
48
50
  <%= f.email_field :email, autocomplete: "email", data: { "instant-attribute": "email" } %>
@@ -21,6 +21,7 @@ module Decidim
21
21
  Decidim::Devise::InvitationsController.include(Decidim::FriendlySignup::NeedsHeaderSnippets)
22
22
  Decidim::Devise::PasswordsController.include(Decidim::FriendlySignup::NeedsHeaderSnippets)
23
23
  Decidim::AccountController.include(Decidim::FriendlySignup::NeedsHeaderSnippets)
24
+ Decidim::RegistrationForm.include(Decidim::FriendlySignup::AutoNickname)
24
25
  end
25
26
 
26
27
  initializer "FriendlySignup.webpacker.assets_path" do
@@ -5,6 +5,6 @@ module Decidim
5
5
  module FriendlySignup
6
6
  DECIDIM_VERSION = "0.26.2"
7
7
  COMPAT_DECIDIM_VERSION = "~> 0.26.0"
8
- VERSION = "0.2"
8
+ VERSION = "0.3"
9
9
  end
10
10
  end
@@ -18,6 +18,11 @@ module Decidim
18
18
  config_accessor :use_instant_validation do
19
19
  true
20
20
  end
21
+
22
+ # Whether to hide nickname and generate it automatically
23
+ config_accessor :hide_nickname do
24
+ true
25
+ end
21
26
  end
22
27
  end
23
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-friendly_signup
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Vergés
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-13 00:00:00.000000000 Z
11
+ date: 2022-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -51,6 +51,7 @@ files:
51
51
  - app/controllers/concerns/decidim/friendly_signup/needs_header_snippets.rb
52
52
  - app/controllers/decidim/friendly_signup/application_controller.rb
53
53
  - app/controllers/decidim/friendly_signup/validator_controller.rb
54
+ - app/forms/concerns/decidim/friendly_signup/auto_nickname.rb
54
55
  - app/packs/entrypoints/decidim_friendly_signup.js
55
56
  - app/packs/entrypoints/decidim_friendly_signup.scss
56
57
  - app/packs/images/decidim/friendly_signup/icon.svg