forked from discourse/discourse-authentication-validations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.rb
28 lines (22 loc) · 1.07 KB
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
# name: discourse-authentication-validations
# about: Add custom validations to a User Field to toggle the display of User Fields based on the Signup Modal. This allows you to "chain" User Fields together, so that a User Field is only displayed if a previous User Field has a specific value.
# meta_topic_id: 292547
# version: 0.0.1
# authors: Discourse
# url: TODO
# required_version: 2.7.0
enabled_site_setting :discourse_authentication_validations_enabled
module ::DiscourseAuthenticationValidations
PLUGIN_NAME = "discourse-authentication-validations"
end
require_relative "lib/discourse_authentication_validations/engine"
after_initialize do
add_to_serializer(:user_field, :has_custom_validation) { object.has_custom_validation }
add_to_serializer(:user_field, :show_values) { object.show_values }
add_to_serializer(:user_field, :target_user_field_ids) { object.target_user_field_ids }
register_modifier(:admin_user_fields_columns) do |columns|
columns.push(:has_custom_validation, :show_values, :target_user_field_ids)
columns
end
end