decidim-friendly_signup 0.2 → 0.3
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.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/app/forms/concerns/decidim/friendly_signup/auto_nickname.rb +35 -0
- data/app/packs/src/decidim/friendly_signup/lib/instant_validator.js +1 -0
- data/app/views/decidim/devise/registrations/new.html.erb +7 -5
- data/lib/decidim/friendly_signup/engine.rb +1 -0
- data/lib/decidim/friendly_signup/version.rb +1 -1
- data/lib/decidim/friendly_signup.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88bd76deb088270153f2b8d9dc3376d1f6333c0429e2433c2f896870027cbd30
|
|
4
|
+
data.tar.gz: d2e2efec13ef916c6835e8f09b4d50e8e20ddef3c05a1f41bf24b51a1054c074
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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". 
|
|
20
20
|
|
|
21
|
-
- [
|
|
21
|
+
- [x] Remove the nickname field from the registration process and automatically create one on registering. 
|
|
22
22
|
- [x] Instant validate parameters when registering without having to send it for backend validation. 
|
|
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
|
-
|
|
42
|
-
<div class="
|
|
43
|
-
|
|
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
|
-
|
|
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
|
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.
|
|
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-
|
|
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
|