-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: Add simple proposals and Awesome private fields for proposals (
#45) * add simple proposals * Add simple proposal and decidim awesome's correct branch The simple proposal module is on my personal fork because modifications to the position of the field were necessary. The decidim awesome one is on an octree fork because the private proposals feature is yet to be merge into the main decidim awesome repo * fix Gemfile for decidim-simple_proposal overload * Rubocop & ERB Lint * Add missing migration * rubocop * Fix proposal creation for SimpleProposal x Awesome proposal private fields - remove old proposals_controller.rb overload - overload SimpleProposals proposals_controller_override.rb * Fix i18n locales * Fix tests i18n * rubocop * fix: Remove exports from Phone AH * fix: Deactivate factory_bot * lint: Fix rubocop offense * fix: reversibility private body * fix: Move address field in edit form * fix: Add missing simple proposal translation * fix: Scopes order in dropdown (#44) * fix: Scopes order in dropdown * fix: Ensure scopes are only those in current_organization --------- Co-authored-by: Simonas <[email protected]> Co-authored-by: quentinchampenois <[email protected]> Co-authored-by: Lucie Grau <[email protected]>
- Loading branch information
1 parent
1aade3c
commit 2b6ff4a
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module ScopesHelperExtend | ||
extend ActiveSupport::Concern | ||
included do | ||
private | ||
|
||
def ancestors(organization = current_organization) | ||
@ancestors ||= Decidim::Scope.where(parent_id: nil, organization: organization).sort_by do |scope| | ||
translated_attribute(scope.name) | ||
end | ||
end | ||
|
||
def children_after_parent(ancestor, array, prefix) | ||
array << ["#{prefix} #{translated_attribute(ancestor.name)}", ancestor.id] | ||
children = ancestor.children.sort_by do |scope| | ||
translated_attribute(scope.name) | ||
end | ||
children.each do |child| | ||
children_after_parent(child, array, "#{prefix}-") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim | ||
describe ScopesHelper, type: :helper do | ||
describe "scopes_picker_tag" do | ||
let(:scope) { create(:scope) } | ||
|
||
it "works wrong" do | ||
actual = helper.scopes_picker_tag("my_scope_input", scope.id) | ||
|
||
expected = <<~HTML | ||
<div id="my_scope_input" class="data-picker picker-single" data-picker-name="my_scope_input"> | ||
<div class="picker-values"> | ||
<div> | ||
<a href="/scopes/picker?current=#{scope.id}&field=my_scope_input" data-picker-value="#{scope.id}"> | ||
#{scope.name["en"]} (#{scope.scope_type.name["en"]}) | ||
</a> | ||
</div> | ||
</div> | ||
<div class="picker-prompt"> | ||
<a href="/scopes/picker?field=my_scope_input" role="button" aria-label="Select a scope (currently: Global scope)">Global scope</a> | ||
</div> | ||
</div> | ||
HTML | ||
|
||
expect(actual).to have_equivalent_markup_to(expected) | ||
end | ||
end | ||
|
||
describe "#ancestors" do | ||
let!(:organization) { create(:organization) } | ||
let!(:last_scope) { create(:scope, name: { en: "ZZZ scope" }, organization: organization) } | ||
let!(:first_scope) { create(:scope, name: { en: "AAA scope" }, organization: organization) } | ||
let!(:first_subscope) { create(:scope, name: { en: "AAA subscope" }, parent: first_scope, organization: organization) } | ||
let!(:last_subscope) { create(:scope, name: { en: "ZZZ subscope" }, parent: first_scope, organization: organization) } | ||
let!(:middle_subscope) { create(:scope, name: { en: "DDD subscope" }, parent: first_scope, organization: organization) } | ||
let(:expected) { [first_scope, last_scope] } | ||
let!(:not_in_organization) { create(:scope) } | ||
|
||
it "returns the scopes with no parent" do | ||
actual = helper.send(:ancestors, organization) | ||
|
||
expect(actual.count).to eq(2) | ||
expect(actual).to eq(expected) | ||
expect(actual).not_to include(not_in_organization) | ||
end | ||
end | ||
|
||
describe "#children_after_parent" do | ||
let!(:organization) { create(:organization) } | ||
let!(:last_scope) { create(:scope, name: { en: "ZZZ scope" }, organization: organization) } | ||
let!(:first_scope) { create(:scope, name: { en: "AAA scope" }, organization: organization) } | ||
let!(:first_subscope) { create(:scope, name: { en: "AAA subscope" }, parent: first_scope, organization: organization) } | ||
let!(:last_subscope) { create(:scope, name: { en: "ZZZ subscope" }, parent: first_scope, organization: organization) } | ||
let!(:middle_subscope) { create(:scope, name: { en: "DDD subscope" }, parent: first_scope, organization: organization) } | ||
let(:expected) { [[" AAA scope", first_scope.id], ["- AAA subscope", first_subscope.id], ["- DDD subscope", middle_subscope.id], ["- ZZZ subscope", last_subscope.id]] } | ||
|
||
it "returns the scopes with children" do | ||
array = [] | ||
helper.send(:children_after_parent, first_scope, array, "") | ||
expect(array).to eq(expected) | ||
end | ||
end | ||
end | ||
end |