decidim-decidim_awesome 0.6.2 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -6
- data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +1 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin.js +1 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/codemirror.js.es6 +15 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/form_exit_warn.js.es6 +30 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/hashtags.js.es6 +48 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/layers.js.es6 +106 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/legacy_map.js.es6 +12 -19
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/legacy_proposals.js.es6 +3 -2
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +166 -170
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/markers.js.es6 +56 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +4 -3
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +17 -4
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6 +48 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/admin.scss +10 -3
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +16 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/leaflet.scss.erb +9 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +95 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +1 -1
- data/app/awesome_overrides/presenters/decidim/menu_presenter_override.rb +39 -0
- data/app/commands/decidim/decidim_awesome/admin/create_menu_hack.rb +51 -0
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_style.rb +34 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +47 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +40 -0
- data/app/commands/decidim/decidim_awesome/admin/update_config.rb +5 -2
- data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +47 -0
- data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +4 -3
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +40 -4
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +13 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +116 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +22 -2
- data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +0 -2
- data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +0 -2
- data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +39 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +5 -1
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +9 -3
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +19 -0
- data/app/permissions/decidim/decidim_awesome/permissions.rb +2 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +28 -0
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +2 -3
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +7 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +13 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +13 -0
- data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +9 -6
- data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +10 -0
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +5 -2
- data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +3 -0
- data/app/views/v0.22/layouts/decidim/_head.html.erb +1 -0
- data/app/views/v0.23/layouts/decidim/_head.html.erb +1 -0
- data/config/locales/ca.yml +70 -2
- data/config/locales/cs.yml +71 -3
- data/config/locales/en.yml +75 -2
- data/config/locales/es.yml +70 -2
- data/config/locales/eu.yml +225 -0
- data/config/locales/fr.yml +172 -104
- data/config/locales/nl.yml +225 -0
- data/config/locales/sv.yml +93 -25
- data/lib/decidim/decidim_awesome.rb +27 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +3 -0
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +16 -0
- data/lib/decidim/decidim_awesome/checksums.yml +6 -0
- data/lib/decidim/decidim_awesome/config.rb +13 -12
- data/lib/decidim/decidim_awesome/engine.rb +1 -1
- data/lib/decidim/decidim_awesome/map_component/component.rb +7 -1
- data/lib/decidim/decidim_awesome/menu_hacker.rb +90 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +4 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +71 -0
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/vendor/assets/javascripts/codemirror.js +9801 -0
- data/vendor/assets/javascripts/jquery.truncate.js +105 -0
- data/vendor/assets/javascripts/keymap/sublime.js +720 -0
- data/vendor/assets/javascripts/mode/css/css.js +864 -0
- data/vendor/assets/stylesheets/codemirror.css +350 -0
- data/vendor/assets/stylesheets/inscrybmde.min.scss +180 -0
- metadata +48 -3
- data/vendor/assets/stylesheets/inscrybmde.min.css +0 -8
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class CreateScopedStyle < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
def initialize(organization)
|
10
|
+
@organization = organization
|
11
|
+
@ident = rand(36**8).to_s(36)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
styles = AwesomeConfig.find_or_initialize_by(var: :scoped_styles, organization: @organization)
|
22
|
+
styles.value = {} unless styles.value.is_a? Hash
|
23
|
+
# TODO: prevent (unlikely) colisions with exisiting values
|
24
|
+
styles.value[@ident] = ""
|
25
|
+
styles.save!
|
26
|
+
|
27
|
+
broadcast(:ok, @ident)
|
28
|
+
rescue StandardError => e
|
29
|
+
broadcast(:invalid, e.message)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class DestroyMenuHack < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# item - the menu item to destroy
|
10
|
+
# organization
|
11
|
+
def initialize(item, menu_name, organization)
|
12
|
+
@item = item
|
13
|
+
@organization = organization
|
14
|
+
@menu = AwesomeConfig.find_by(var: menu_name, organization: organization)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the command. Broadcasts these events:
|
18
|
+
#
|
19
|
+
# - :ok when everything is valid.
|
20
|
+
# - :invalid if we couldn't proceed.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def call
|
24
|
+
return broadcast(:invalid) unless url_exists?
|
25
|
+
|
26
|
+
menu.value&.reject! { |i| i["url"] == item.url }
|
27
|
+
menu.save!
|
28
|
+
|
29
|
+
broadcast(:ok, @item)
|
30
|
+
rescue StandardError => e
|
31
|
+
broadcast(:invalid, e.message)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :organization, :item, :menu
|
37
|
+
|
38
|
+
def url_exists?
|
39
|
+
return false unless menu
|
40
|
+
return false unless menu.value.is_a? Array
|
41
|
+
|
42
|
+
menu.value&.detect { |i| i["url"] == item.url }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class DestroyScopedStyle < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# key - the key to destroy inise scoped_styles
|
10
|
+
# organization
|
11
|
+
def initialize(key, organization)
|
12
|
+
@key = key
|
13
|
+
@organization = organization
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
styles = AwesomeConfig.find_by(var: :scoped_styles, organization: @organization)
|
24
|
+
return broadcast(:invalid, "Not a hash") unless styles&.value.is_a? Hash
|
25
|
+
return broadcast(:invalid, "#{key} key invalid") unless styles.value.has_key?(@key)
|
26
|
+
|
27
|
+
styles.value.except!(@key)
|
28
|
+
styles.save!
|
29
|
+
# remove constrains associated (a new config var is generated automatically, by removing it, it will trigger destroy on dependents)
|
30
|
+
constraint = AwesomeConfig.find_by(var: "scoped_style_#{@key}", organization: @organization)
|
31
|
+
constraint.destroy! if constraint.present?
|
32
|
+
|
33
|
+
broadcast(:ok, @key)
|
34
|
+
rescue StandardError => e
|
35
|
+
broadcast(:invalid, e.message)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -18,12 +18,15 @@ module Decidim
|
|
18
18
|
#
|
19
19
|
# Returns nothing.
|
20
20
|
def call
|
21
|
-
|
21
|
+
if form.invalid?
|
22
|
+
message = form.errors[:scoped_styles].join("; ") if @form.errors[:scoped_styles].any?
|
23
|
+
return broadcast(:invalid, message, form.errors)
|
24
|
+
end
|
22
25
|
|
23
26
|
begin
|
24
27
|
form.attributes.each do |key, val|
|
25
28
|
# ignore nil attributes (must specifically be set to false if necessary)
|
26
|
-
next
|
29
|
+
next unless form.valid_keys.include?(key)
|
27
30
|
|
28
31
|
setting = AwesomeConfig.find_or_initialize_by(var: key, organization: form.current_organization)
|
29
32
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class UpdateMenuHack < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
def initialize(form, menu_name)
|
10
|
+
@form = form
|
11
|
+
@menu = AwesomeConfig.find_or_initialize_by(var: menu_name, organization: form.current_organization)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Executes the command. Broadcasts these events:
|
15
|
+
#
|
16
|
+
# - :ok when everything is valid.
|
17
|
+
# - :invalid if we couldn't proceed.
|
18
|
+
#
|
19
|
+
# Returns nothing.
|
20
|
+
def call
|
21
|
+
return broadcast(:invalid) if form.invalid?
|
22
|
+
|
23
|
+
menu.value = [] unless menu.value.is_a? Array
|
24
|
+
menu.value = menu.value.filter { |i| i.is_a? Hash }
|
25
|
+
found = false
|
26
|
+
menu.value.map! do |item|
|
27
|
+
if item["url"] == form.url
|
28
|
+
found = true
|
29
|
+
form.to_params
|
30
|
+
else
|
31
|
+
item
|
32
|
+
end
|
33
|
+
end
|
34
|
+
menu.value << form.to_params unless found
|
35
|
+
menu.save!
|
36
|
+
broadcast(:ok, menu)
|
37
|
+
rescue StandardError => e
|
38
|
+
broadcast(:invalid, e.message)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_reader :form, :menu
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -9,9 +9,10 @@ module Decidim
|
|
9
9
|
# Note that it inherits from `Decidim::Admin::Components::BaseController`, which
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
11
|
class ApplicationController < Decidim::Admin::ApplicationController
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def permission_class_chain
|
13
|
+
[::Decidim::DecidimAwesome::Admin::Permissions] + super
|
14
|
+
end
|
15
|
+
|
15
16
|
before_action do
|
16
17
|
enforce_permission_to :update, :organization, organization: current_organization
|
17
18
|
end
|
@@ -12,25 +12,55 @@ module Decidim
|
|
12
12
|
layout "decidim/admin/decidim_awesome"
|
13
13
|
|
14
14
|
helper_method :constraints_for
|
15
|
+
before_action do
|
16
|
+
enforce_permission_to :edit_config, configs
|
17
|
+
end
|
15
18
|
|
16
19
|
def show
|
17
20
|
@form = form(ConfigForm).from_params(organization_awesome_config)
|
18
21
|
end
|
19
22
|
|
20
23
|
def update
|
21
|
-
@form = form(ConfigForm).from_params(params)
|
22
|
-
|
24
|
+
@form = form(ConfigForm).from_params(params[:config])
|
23
25
|
UpdateConfig.call(@form) do
|
24
26
|
on(:ok) do
|
25
27
|
flash[:notice] = I18n.t("config.update.success", scope: "decidim.decidim_awesome.admin")
|
26
28
|
redirect_to decidim_admin_decidim_awesome.config_path
|
27
29
|
end
|
28
30
|
|
29
|
-
on(:invalid) do |message|
|
31
|
+
on(:invalid) do |message, err|
|
30
32
|
flash.now[:alert] = I18n.t("config.update.error", error: message, scope: "decidim.decidim_awesome.admin")
|
31
|
-
render :show
|
33
|
+
render :show, locals: { errors: err.presence }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def new_scoped_style
|
39
|
+
CreateScopedStyle.call(current_organization) do
|
40
|
+
on(:ok) do |key|
|
41
|
+
flash[:notice] = I18n.t("config.create_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
|
42
|
+
end
|
43
|
+
|
44
|
+
on(:invalid) do |message|
|
45
|
+
flash[:alert] = I18n.t("config.create_scoped_style.error", error: message, scope: "decidim.decidim_awesome.admin")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
redirect_to decidim_admin_decidim_awesome.config_path(:styles)
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy_scoped_style
|
53
|
+
DestroyScopedStyle.call(params[:key], current_organization) do
|
54
|
+
on(:ok) do |key|
|
55
|
+
flash[:notice] = I18n.t("config.destroy_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
|
56
|
+
end
|
57
|
+
|
58
|
+
on(:invalid) do |message|
|
59
|
+
flash[:alert] = I18n.t("config.destroy_scoped_style.error", error: message, scope: "decidim.decidim_awesome.admin")
|
32
60
|
end
|
33
61
|
end
|
62
|
+
|
63
|
+
redirect_to decidim_admin_decidim_awesome.config_path(:styles)
|
34
64
|
end
|
35
65
|
|
36
66
|
private
|
@@ -38,6 +68,12 @@ module Decidim
|
|
38
68
|
def constraints_for(key)
|
39
69
|
awesome_config_instance.setting_for(key)&.constraints
|
40
70
|
end
|
71
|
+
|
72
|
+
def configs
|
73
|
+
return params[:config].keys if params.has_key?(:config)
|
74
|
+
|
75
|
+
DecidimAwesome.config.keys
|
76
|
+
end
|
41
77
|
end
|
42
78
|
end
|
43
79
|
end
|
@@ -9,6 +9,9 @@ module Decidim
|
|
9
9
|
helper ConfigConstraintsHelpers
|
10
10
|
|
11
11
|
layout false
|
12
|
+
before_action do
|
13
|
+
enforce_permission_to :edit_config, constraint_key
|
14
|
+
end
|
12
15
|
|
13
16
|
def new
|
14
17
|
@form = form(ConstraintForm).from_params(filtered_params, setting: current_setting)
|
@@ -118,6 +121,16 @@ module Decidim
|
|
118
121
|
def current_setting
|
119
122
|
awesome_config_instance.setting_for params[:key]
|
120
123
|
end
|
124
|
+
|
125
|
+
def constraint_key
|
126
|
+
key = params[:key] || constraint.awesome_config.var
|
127
|
+
case key
|
128
|
+
when /^scoped_style_/
|
129
|
+
:scoped_styles
|
130
|
+
else
|
131
|
+
key
|
132
|
+
end
|
133
|
+
end
|
121
134
|
end
|
122
135
|
end
|
123
136
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
# Editing menu items
|
7
|
+
class MenuHacksController < DecidimAwesome::Admin::ApplicationController
|
8
|
+
include NeedsAwesomeConfig
|
9
|
+
helper ConfigConstraintsHelpers
|
10
|
+
|
11
|
+
layout "decidim/admin/decidim_awesome"
|
12
|
+
|
13
|
+
helper_method :current_items, :md5, :visibility_options, :target_options
|
14
|
+
|
15
|
+
before_action do
|
16
|
+
enforce_permission_to :edit_config, :menu
|
17
|
+
end
|
18
|
+
|
19
|
+
def index; end
|
20
|
+
|
21
|
+
def new
|
22
|
+
@form = form(MenuForm).instance
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@form = form(MenuForm).from_params(params)
|
27
|
+
CreateMenuHack.call(@form, current_menu_name) do
|
28
|
+
on(:ok) do
|
29
|
+
flash[:notice] = I18n.t("menu_hacks.create.success", scope: "decidim.decidim_awesome.admin")
|
30
|
+
redirect_to decidim_admin_decidim_awesome.menu_hacks_path
|
31
|
+
end
|
32
|
+
|
33
|
+
on(:invalid) do |message|
|
34
|
+
flash.now[:alert] = I18n.t("menu_hacks.create.error", error: message, scope: "decidim.decidim_awesome.admin")
|
35
|
+
render :new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def edit
|
41
|
+
@form = form(MenuForm).from_model(menu_item)
|
42
|
+
end
|
43
|
+
|
44
|
+
def update
|
45
|
+
@form = form(MenuForm).from_params(params)
|
46
|
+
UpdateMenuHack.call(@form, current_menu_name) do
|
47
|
+
on(:ok) do
|
48
|
+
flash[:notice] = I18n.t("menu_hacks.update.success", scope: "decidim.decidim_awesome.admin")
|
49
|
+
redirect_to decidim_admin_decidim_awesome.menu_hacks_path
|
50
|
+
end
|
51
|
+
|
52
|
+
on(:invalid) do |message|
|
53
|
+
flash.now[:alert] = I18n.t("menu_hacks.update.error", error: message, scope: "decidim.decidim_awesome.admin")
|
54
|
+
render :edit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy
|
60
|
+
DestroyMenuHack.call(menu_item, current_menu_name, current_organization) do
|
61
|
+
on(:ok) do
|
62
|
+
flash[:notice] = I18n.t("menu_hacks.destroy.success", scope: "decidim.decidim_awesome.admin")
|
63
|
+
end
|
64
|
+
on(:invalid) do |error|
|
65
|
+
flash[:alert] = I18n.t("menu_hacks.destroy.error", scope: "decidim.decidim_awesome.admin", error: error)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
redirect_to decidim_admin_decidim_awesome.menu_hacks_path
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def menu_item
|
74
|
+
item = current_items.find { |i| md5(i.url) == params[:id] }
|
75
|
+
raise ActiveRecord::RecordNotFound unless item
|
76
|
+
|
77
|
+
OpenStruct.new(
|
78
|
+
raw_label: item.try(:raw_label) || { current_organization.default_locale => item.label },
|
79
|
+
url: item.url,
|
80
|
+
position: item.position,
|
81
|
+
target: item.try(:target),
|
82
|
+
visibility: item.try(:visibility),
|
83
|
+
native?: !item.respond_to?(:overrided?)
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def current_items
|
88
|
+
@current_items ||= current_menu.items(true)
|
89
|
+
end
|
90
|
+
|
91
|
+
def current_menu
|
92
|
+
@current_menu ||= MenuHacker.new(current_menu_name, self)
|
93
|
+
end
|
94
|
+
|
95
|
+
def current_menu_name
|
96
|
+
:menu
|
97
|
+
end
|
98
|
+
|
99
|
+
def md5(text)
|
100
|
+
Digest::MD5.hexdigest(text)
|
101
|
+
end
|
102
|
+
|
103
|
+
def visibility_options
|
104
|
+
MenuForm::VISIBILITY_STATES.map { |key| [I18n.t(".menu_hacks.form.visibility.#{key}", scope: "decidim.decidim_awesome.admin"), key] }.to_h
|
105
|
+
end
|
106
|
+
|
107
|
+
def target_options
|
108
|
+
{
|
109
|
+
I18n.t(".menu_hacks.form.target.self", scope: "decidim.decidim_awesome.admin") => "",
|
110
|
+
I18n.t(".menu_hacks.form.target.blank", scope: "decidim.decidim_awesome.admin") => "_blank"
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module Decidim
|
4
4
|
module DecidimAwesome
|
5
5
|
module Admin
|
6
|
-
# A form object used to configure the endpoint.
|
7
|
-
#
|
8
6
|
class ConfigForm < Decidim::Form
|
9
7
|
attribute :allow_images_in_full_editor, Boolean
|
10
8
|
attribute :allow_images_in_small_editor, Boolean
|
@@ -12,10 +10,32 @@ module Decidim
|
|
12
10
|
attribute :use_markdown_editor, Boolean
|
13
11
|
attribute :allow_images_in_markdown_editor, Boolean
|
14
12
|
attribute :auto_save_forms, Boolean
|
13
|
+
attribute :scoped_styles, Hash
|
14
|
+
attribute :menu, Array[MenuForm]
|
15
15
|
attribute :intergram_for_admins, Boolean
|
16
16
|
attribute :intergram_for_admins_settings, IntergramForm
|
17
17
|
attribute :intergram_for_public, Boolean
|
18
18
|
attribute :intergram_for_public_settings, IntergramForm
|
19
|
+
|
20
|
+
# collect all keys anything not specified in the params (UpdateConfig command ignores it)
|
21
|
+
attr_accessor :valid_keys
|
22
|
+
|
23
|
+
validate :css_syntax, if: ->(form) { form.scoped_styles.present? }
|
24
|
+
|
25
|
+
def self.from_params(params, additional_params = {})
|
26
|
+
instance = super(params, additional_params)
|
27
|
+
instance.valid_keys = params.keys.map(&:to_sym) || []
|
28
|
+
instance
|
29
|
+
end
|
30
|
+
|
31
|
+
def css_syntax
|
32
|
+
scoped_styles.each do |key, code|
|
33
|
+
SassC::Engine.new(code).render
|
34
|
+
rescue SassC::SyntaxError => e
|
35
|
+
errors.add(:scoped_styles, I18n.t("config.form.errors.incorrect_css", key: key, scope: "decidim.decidim_awesome.admin"))
|
36
|
+
errors.add(key.to_sym, e.message)
|
37
|
+
end
|
38
|
+
end
|
19
39
|
end
|
20
40
|
end
|
21
41
|
end
|