decidim-decidim_awesome 0.6.0 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -14
- data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +1 -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/legacy_map.js.es6 +14 -4
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/legacy_proposals.js.es6 +82 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +13 -2
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +15 -13
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +29 -13
- data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +1 -1
- data/app/assets/stylesheets/decidim/decidim_awesome/admin.scss +4 -0
- data/app/awesome_overrides/presenters/decidim/menu_presenter_override.rb +31 -0
- data/app/awesome_overrides/presenters/decidim/proposals/proposal_presenter_override.rb +31 -5
- 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 +1 -1
- data/app/commands/decidim/decidim_awesome/admin/update_menu_hack.rb +47 -0
- data/app/commands/decidim/decidim_awesome/create_editor_image.rb +5 -3
- data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +4 -3
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +38 -2
- 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/controllers/decidim/decidim_awesome/editor_images_controller.rb +1 -1
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +11 -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/forms/decidim/decidim_awesome/editor_image_form.rb +2 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +5 -1
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +11 -1
- data/app/models/decidim/decidim_awesome/editor_image.rb +4 -3
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +19 -0
- data/app/permissions/decidim/decidim_awesome/permissions.rb +2 -0
- data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +9 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +27 -0
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +1 -1
- 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/iframe_component/iframe/show.html.erb +6 -1
- data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +40 -18
- data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +10 -0
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +1 -1
- 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 +96 -9
- data/config/locales/cs.yml +91 -4
- data/config/locales/en.yml +70 -4
- data/config/locales/es.yml +125 -38
- data/config/locales/eu.yml +212 -0
- data/config/locales/fr.yml +90 -3
- data/config/locales/nl.yml +212 -0
- data/config/locales/sv.yml +90 -3
- 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 +8 -0
- data/lib/decidim/decidim_awesome/config.rb +13 -12
- data/lib/decidim/decidim_awesome/engine.rb +1 -1
- data/lib/decidim/decidim_awesome/iframe_component/component.rb +3 -3
- data/lib/decidim/decidim_awesome/map_component/component.rb +6 -0
- data/lib/decidim/decidim_awesome/menu_hacker.rb +88 -0
- data/lib/decidim/decidim_awesome/test/factories.rb +1 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +4 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +71 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +71 -0
- data/lib/decidim/decidim_awesome/version.rb +1 -2
- data/vendor/assets/javascripts/jsrender.min.js +4 -0
- metadata +26 -3
@@ -12,7 +12,7 @@
|
|
12
12
|
// Redefines Quill editor with images
|
13
13
|
if(exports.DecidimAwesome.allow_images_in_full_editor || exports.DecidimAwesome.allow_images_in_small_editor || exports.DecidimAwesome.use_markdown_editor) {
|
14
14
|
|
15
|
-
const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image"];
|
15
|
+
const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image", "alt"];
|
16
16
|
|
17
17
|
const createQuillEditor = (container) => {
|
18
18
|
const toolbar = $(container).data("toolbar");
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Decidim::MenuPresenter.class_eval do
|
4
|
+
def evaluated_menu
|
5
|
+
@evaluated_menu ||= if Decidim::DecidimAwesome.config.send(@name) == :disabled
|
6
|
+
begin
|
7
|
+
menu = Decidim::Menu.new(@name)
|
8
|
+
menu.build_for(@view)
|
9
|
+
menu
|
10
|
+
end
|
11
|
+
else
|
12
|
+
Decidim::DecidimAwesome::MenuHacker.new(@name, @view)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Decidim::MenuItemPresenter.class_eval do
|
18
|
+
def link_to(name = nil, options = nil, html_options = nil, &block)
|
19
|
+
html_options ||= {}
|
20
|
+
html_options[:target] = @menu_item.try(:target)
|
21
|
+
|
22
|
+
options ||= html_options
|
23
|
+
@view.link_to(name, options, html_options, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def active
|
27
|
+
return @menu_item.active.call(url, @view) if @menu_item.try(:active).respond_to?(:call)
|
28
|
+
|
29
|
+
@menu_item&.active
|
30
|
+
end
|
31
|
+
end
|
@@ -2,8 +2,30 @@
|
|
2
2
|
|
3
3
|
# Tune Proposal presenter to use markdown if configured
|
4
4
|
Decidim::Proposals::ProposalPresenter.class_eval do
|
5
|
-
|
6
|
-
|
5
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
6
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
7
|
+
def body(links: false, extras: true, strip_tags: false, all_locales: false)
|
8
|
+
return unless proposal
|
9
|
+
|
10
|
+
if defined? handle_locales
|
11
|
+
return handle_locales(proposal.body, all_locales) do |content|
|
12
|
+
content = strip_tags(sanitize_text(content)) if strip_tags
|
13
|
+
|
14
|
+
renderer = Decidim::ContentRenderers::HashtagRenderer.new(content)
|
15
|
+
content = renderer.render(links: links, extras: extras).html_safe
|
16
|
+
|
17
|
+
if use_markdown?(proposal) && !all_locales # avoid rendering in editors
|
18
|
+
content = render_markdown(content)
|
19
|
+
elsif links
|
20
|
+
content = Decidim::ContentRenderers::LinkRenderer.new(content).render
|
21
|
+
end
|
22
|
+
content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
26
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
27
|
+
|
28
|
+
if defined? translated_attribute
|
7
29
|
text = translated_attribute(proposal.body)
|
8
30
|
|
9
31
|
text = strip_tags(sanitize_text(text)) if strip_tags
|
@@ -17,9 +39,7 @@ Decidim::Proposals::ProposalPresenter.class_eval do
|
|
17
39
|
text = renderer.render(links: links, extras: extras).html_safe
|
18
40
|
|
19
41
|
if use_markdown? proposal
|
20
|
-
text =
|
21
|
-
# HACK: to avoid the replacement of lines to <br> that simple_format does
|
22
|
-
text = text.gsub(">\n", ">").gsub("\n<", "<")
|
42
|
+
text = render_markdown(text)
|
23
43
|
elsif links
|
24
44
|
text = Decidim::ContentRenderers::LinkRenderer.new(text).render
|
25
45
|
end
|
@@ -35,4 +55,10 @@ Decidim::Proposals::ProposalPresenter.class_eval do
|
|
35
55
|
config.context_from_component proposal
|
36
56
|
config.enabled_for? :use_markdown_editor
|
37
57
|
end
|
58
|
+
|
59
|
+
def render_markdown(content)
|
60
|
+
content = Decidim::DecidimAwesome::ContentRenderers::MarkdownRenderer.new(content).render
|
61
|
+
# HACK: to avoid the replacement of lines to <br> that simple_format does
|
62
|
+
content.gsub(">\n", ">").gsub("\n<", "<")
|
63
|
+
end
|
38
64
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class CreateMenuHack < 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
|
+
return broadcast(:invalid, I18n.t("menu_hacks.url_exists", scope: "decidim.decidim_awesome.admin")) if url_exists?
|
23
|
+
|
24
|
+
menu.value = [] unless menu.value.is_a? Array
|
25
|
+
menu.value << to_params
|
26
|
+
menu.save!
|
27
|
+
broadcast(:ok, menu)
|
28
|
+
rescue StandardError => e
|
29
|
+
broadcast(:invalid, e.message)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :form, :menu
|
35
|
+
|
36
|
+
def url_exists?
|
37
|
+
return false unless menu
|
38
|
+
|
39
|
+
menu.value&.detect { |i| i["url"] == form.url.gsub(/\?.*/, "") }
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_params
|
43
|
+
params = form.to_params
|
44
|
+
url = Addressable::URI.parse(params[:url])
|
45
|
+
params[:url] = url.path if url.host == form.current_organization.host
|
46
|
+
params
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -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
|
@@ -23,7 +23,7 @@ module Decidim
|
|
23
23
|
begin
|
24
24
|
form.attributes.each do |key, val|
|
25
25
|
# ignore nil attributes (must specifically be set to false if necessary)
|
26
|
-
next
|
26
|
+
next unless form.valid_keys.include?(key)
|
27
27
|
|
28
28
|
setting = AwesomeConfig.find_or_initialize_by(var: key, organization: form.current_organization)
|
29
29
|
|
@@ -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
|
@@ -19,12 +19,14 @@ module Decidim
|
|
19
19
|
def call
|
20
20
|
return broadcast(:invalid) if form.invalid?
|
21
21
|
|
22
|
-
image = EditorImage.
|
23
|
-
image: form.image,
|
22
|
+
image = EditorImage.new(
|
24
23
|
path: form.path,
|
25
24
|
decidim_author_id: form.current_user.id,
|
26
|
-
organization: form.
|
25
|
+
organization: form.organization,
|
26
|
+
image: form.image
|
27
27
|
)
|
28
|
+
|
29
|
+
image.save!
|
28
30
|
broadcast(:ok, image)
|
29
31
|
end
|
30
32
|
|
@@ -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,14 +12,16 @@ 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")
|
@@ -33,11 +35,45 @@ module Decidim
|
|
33
35
|
end
|
34
36
|
end
|
35
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")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
redirect_to decidim_admin_decidim_awesome.config_path(:styles)
|
64
|
+
end
|
65
|
+
|
36
66
|
private
|
37
67
|
|
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
|