Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/0.26 stable bcn #21

Draft
wants to merge 42 commits into
base: release/0.26-stable
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
de63857
focus mode integration
microstudi Apr 5, 2022
ed847db
Add timeline entry title in Accountability projects (#9127)
microstudi May 5, 2022
10680bf
fix rails 6.0 migrations
microstudi May 5, 2022
1c7e7ac
Merge remote-tracking branch 'upstream/release/0.26-stable' into cust…
microstudi May 12, 2022
9e199c7
Merge branch 'upstream/release/0.26-stable' into custom/0.26
agustibr Jun 20, 2022
b2c058a
fix(initiatives): admin can manage components
agustibr Jun 22, 2022
4e1df15
fix(initiatives): participants can view components
agustibr Jun 22, 2022
2b675ea
Merge branch 'release/0.26-stable' of github.com:decidim/decidim into…
verarojman Jul 14, 2022
677bd35
Fix rubocop offenses
verarojman Jul 14, 2022
581f74e
Fix rubocop offenses
verarojman Jul 14, 2022
62c8ba7
Fix error in date range cell
verarojman Jul 18, 2022
1fd6023
Remove unmatched end tag in .erb
verarojman Jul 19, 2022
0f8993b
Lint js
verarojman Jul 19, 2022
c894c54
Lint scss
verarojman Jul 19, 2022
a411dc2
Normalize locales
verarojman Jul 19, 2022
27d7a41
Fix tests
fblupi Aug 18, 2022
f6152a0
Merge branch 'custom/0.26' of github.com:AjuntamentdeBarcelona/decidi…
fblupi Sep 6, 2022
715fc31
Merge pull request #24 from AjuntamentdeBarcelona/chore/update-custom…
fblupi Sep 19, 2022
da45a25
Fix doorkeeper initialization after 5.6.0 release (#9785)
ahukkanen Sep 12, 2022
9de919d
Show user profile on iniciative
fblupi Oct 4, 2022
be68cef
Remove unused language key
fblupi Oct 4, 2022
5e6112a
Add unit test
fblupi Oct 5, 2022
43c6b7c
Merge pull request #25 from AjuntamentdeBarcelona/feat/show-user-prof…
verarojman Oct 5, 2022
1f4a870
Fix initiative authors style
fblupi Oct 5, 2022
2e904af
Merge pull request #26 from AjuntamentdeBarcelona/fix/fix-initiative-…
verarojman Oct 5, 2022
7ae038a
Fix resource_icon with component or manifest nil
fblupi Nov 15, 2022
eb79021
Add paper_trail to initiatives_votes
fblupi Nov 15, 2022
4d3d9c0
Add safe navigator to icon_helper to avoid undefined method error
fblupi Nov 16, 2022
cd6b318
Fix with respond_to? and present?
fblupi Nov 16, 2022
f4cf37e
Merge pull request #28 from AjuntamentdeBarcelona/fix/resource-icon-w…
fblupi Nov 16, 2022
4a3fb9e
Merge pull request #29 from AjuntamentdeBarcelona/feat/add-paper-trai…
fblupi Nov 16, 2022
cf6741f
Merge branch 'release/0.26-stable-bcn' of github.com:AjuntamentdeBarc…
fblupi Nov 24, 2022
b96e90d
Show initiative coauthorships
fblupi Dec 13, 2022
bbcc41b
Fix style
fblupi Dec 14, 2022
b5b4a4e
Fix test
fblupi Dec 19, 2022
64face6
Merge pull request #33 from AjuntamentdeBarcelona/fix/initiative-coau…
rafaelpoza Dec 22, 2022
530a590
Merge branch 'release/0.26-stable-bcn' of github.com:AjuntamentdeBarc…
fblupi Dec 22, 2022
073a850
Remove extra_small class from coauthorships cell
fblupi Dec 22, 2022
e58655f
Merge branch 'release/0.26-stable-bcn' of github.com:AjuntamentdeBarc…
fblupi Dec 22, 2022
5884ea4
Merge branch 'release/0.26-stable' of github.com:AjuntamentdeBarcelon…
fblupi Jan 19, 2023
d8d945f
Merge pull request #32 from AjuntamentdeBarcelona/chore/update-custom…
fblupi Feb 7, 2023
f7e6972
Merge branch 'release/0.26-stable' of github.com:AjuntamentdeBarcelon…
fblupi Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -25,13 +25,14 @@ def call

private

attr_reader :timeline_entry
attr_reader :timeline_entry, :form

def create_timeline_entry
@timeline_entry = TimelineEntry.create!(
decidim_accountability_result_id: @form.decidim_accountability_result_id,
entry_date: @form.entry_date,
description: @form.description
decidim_accountability_result_id: form.decidim_accountability_result_id,
entry_date: form.entry_date,
title: form.title,
description: form.description
)
end
end
Original file line number Diff line number Diff line change
@@ -34,8 +34,9 @@ def call

def update_timeline_entry
timeline_entry.update!(
entry_date: @form.entry_date,
description: @form.description
entry_date: form.entry_date,
title: form.title,
description: form.description
)
end
end
Original file line number Diff line number Diff line change
@@ -10,10 +10,11 @@ class TimelineEntryForm < Decidim::Form

attribute :decidim_accountability_result_id, Integer
attribute :entry_date, Decidim::Attributes::LocalizedDate
translatable_attribute :title, String
translatable_attribute :description, String

validates :entry_date, presence: true
validates :description, translatable_presence: true
validates :title, translatable_presence: true
end
end
end
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ module Accountability
class TimelineEntry < Accountability::ApplicationRecord
include Decidim::TranslatableResource

translatable_fields :title
translatable_fields :description
belongs_to :result, foreign_key: "decidim_accountability_result_id", class_name: "Decidim::Accountability::Result", inverse_of: :timeline_entries
end
Original file line number Diff line number Diff line change
@@ -9,7 +9,11 @@
</div>

<div class="row column">
<%= form.translated :text_field, :description %>
<%= form.translated :text_field, :title %>
</div>

<div class="row column">
<%= form.translated :editor, :description %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -13,15 +13,15 @@
<thead>
<tr>
<th><%= t("models.timeline_entry.fields.entry_date", scope: "decidim.accountability") %></th>
<th><%= t("models.timeline_entry.fields.description", scope: "decidim.accountability") %></th>
<th><%= t("models.timeline_entry.fields.title", scope: "decidim.accountability") %></th>
<th class="actions"><%= t("actions.title", scope: "decidim.accountability") %></th>
</tr>
</thead>
<tbody>
<% timeline_entries.each do |timeline_entry| %>
<tr data-id="<%= timeline_entry.id %>">
<td><%= l timeline_entry.entry_date, format: :decidim_short %><br></td>
<td><%= translated_attribute(timeline_entry.description) %></td>
<td><%= translated_attribute(timeline_entry.title) %></td>
<td class="table-list__actions">
<% if allowed_to? :update, :timeline_entry, timeline_entry: timeline_entry %>
<%= icon_link_to "pencil", edit_result_timeline_entry_path(timeline_entry.result, timeline_entry), t("actions.edit", scope: "decidim.accountability"), class: "action-icon--edit" %>
Original file line number Diff line number Diff line change
@@ -13,8 +13,14 @@
<%= l timeline_entry.entry_date, format: :decidim_short %>
</span>
<h4 class="timeline__title">
<%= translated_attribute timeline_entry.description %>
<%= translated_attribute timeline_entry.title %>
</h4>

<% if translated_attribute(timeline_entry.description).present? %>
<div class="timeline__description__description">
<%== translated_attribute timeline_entry.description %>
</div>
<% end %>
</div>
</div>
</li>
3 changes: 2 additions & 1 deletion decidim-accountability/config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ en:
timeline_entry:
description: Description
entry_date: Date
title: Title
models:
decidim/accountability/proposal_linked_event: Proposal included in a result
decidim/accountability/result_progress_updated_event: Result progress updated
@@ -179,8 +180,8 @@ en:
progress: Progress
timeline_entry:
fields:
description: Description
entry_date: Date
title: Title
result_m:
executed: Executed
view: View
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddTitleToTimelineEntries < ActiveRecord::Migration[6.0]
def change
add_column :decidim_accountability_timeline_entries, :title, :jsonb
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class MoveLegacyDescriptionToTitleOfTimelineEntries < ActiveRecord::Migration[6.0]
class TimelineEntry < ApplicationRecord
self.table_name = :decidim_accountability_timeline_entries
end

def up
TimelineEntry.find_each do |timeline_entry|
timeline_entry.update!(title: timeline_entry.description, description: nil)
end
end
end
Original file line number Diff line number Diff line change
@@ -159,7 +159,8 @@
rand(0..5).times do |i|
child_result.timeline_entries.create!(
entry_date: child_result.start_date + i.days,
description: Decidim::Faker::Localized.sentence(word_count: 2)
title: Decidim::Faker::Localized.sentence(word_count: 2),
description: Decidim::Faker::Localized.paragraph(sentence_count: 1)
)
end

Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@
factory :timeline_entry, class: "Decidim::Accountability::TimelineEntry" do
result { create(:result) }
entry_date { "12/7/2017" }
title { generate_localized_title }
description { generate_localized_title }
end
end
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ class TimelineEntryType < Decidim::Api::Types::BaseObject

field :id, GraphQL::Types::ID, "The internal ID for this timeline entry", null: false
field :entry_date, Decidim::Core::DateType, "The entry date for this timeline entry", null: true
field :title, Decidim::Core::TranslatedFieldType, "The title for this timeline entry", null: true
field :description, Decidim::Core::TranslatedFieldType, "The description for this timeline entry", null: true
field :created_at, Decidim::Core::DateTimeType, "When this timeline entry was created", null: true
field :updated_at, Decidim::Core::DateTimeType, "When this timeline entry was updated", null: true
Original file line number Diff line number Diff line change
@@ -12,13 +12,15 @@ module Decidim::Accountability
let(:result) { create :result, component: current_component }

let(:date) { "2017-8-23" }
let(:title) { "Title" }
let(:description) { "description" }

let(:form) do
double(
invalid?: invalid,
decidim_accountability_result_id: result.id,
entry_date: date,
title: { en: title },
description: { en: description }
)
end
@@ -44,6 +46,11 @@ module Decidim::Accountability
expect(timeline_entry.entry_date).to eq(Date.new(2017, 8, 23))
end

it "sets the title" do
subject.call
expect(translated(timeline_entry.title)).to eq title
end

it "sets the description" do
subject.call
expect(translated(timeline_entry.description)).to eq description
Original file line number Diff line number Diff line change
@@ -14,12 +14,14 @@ module Decidim::Accountability
let(:timeline_entry) { create :timeline_entry, result: result }

let(:date) { "2017-9-23" }
let(:title) { "New title" }
let(:description) { "new description" }

let(:form) do
double(
invalid?: invalid,
entry_date: date,
title: { en: title },
description: { en: description }
)
end
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@ module Decidim::Accountability
let(:result) { create :result, component: current_component }

let(:entry_date) { "12/3/2017" }
let(:title) do
Decidim::Faker::Localized.sentence(word_count: 3)
end
let(:description) do
Decidim::Faker::Localized.sentence(word_count: 3)
end
@@ -26,6 +29,7 @@ module Decidim::Accountability
{
decidim_accountability_result_id: result.id,
entry_date: entry_date,
title_en: title[:en],
description_en: description[:en]
}
end
@@ -38,10 +42,16 @@ module Decidim::Accountability
it { is_expected.not_to be_valid }
end

describe "when title is missing" do
let(:title) { { en: nil } }

it { is_expected.not_to be_valid }
end

describe "when description is missing" do
let(:description) { { en: nil } }

it { is_expected.not_to be_valid }
it { is_expected.to be_valid }
end
end
end
7 changes: 7 additions & 0 deletions decidim-accountability/spec/types/integration_schema_spec.rb
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
"timelineEntries" => [
{
"createdAt" => result.timeline_entries.first.created_at.iso8601.to_s.gsub("Z", "+00:00"),
"title" => { "translation" => result.timeline_entries.first.title[locale] },
"description" => { "translation" => result.timeline_entries.first.description[locale] },
"entryDate" => result.timeline_entries.first.entry_date.to_s,
"id" => result.timeline_entries.first.id.to_s,
@@ -159,6 +160,9 @@
timelineEntries {
id
createdAt
title {
translation(locale:"#{locale}")
}
description {
translation(locale:"#{locale}")
}
@@ -265,6 +269,9 @@
timelineEntries {
id
createdAt
title {
translation(locale:"#{locale}")
}
description {
translation(locale:"#{locale}")
}
8 changes: 8 additions & 0 deletions decidim-accountability/spec/types/timeline_entry_type_spec.rb
Original file line number Diff line number Diff line change
@@ -26,6 +26,14 @@ module Accountability
end
end

describe "title" do
let(:query) { '{ title { translation(locale:"en")}}' }

it "returns the title field" do
expect(response["title"]["translation"]).to eq(model.title["en"])
end
end

describe "description" do
let(:query) { '{ description { translation(locale:"en")}}' }

Original file line number Diff line number Diff line change
@@ -54,7 +54,12 @@ def permissions_context
end

def layout
current_participatory_space_manifest.context(current_participatory_space_context).layout
space_manifest = if current_participatory_space_manifest.is_a? Decidim::ResourceManifest
Decidim.participatory_space_manifests.find { |manifest| manifest.model_class_name == current_participatory_space.class.name }
else
current_participatory_space_manifest
end
space_manifest.context(current_participatory_space_context).layout
end
end
end
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ class BudgetInformationModalCell < BaseCell
alias budget model

def more_information
translated_attribute(current_settings.more_information_modal).presence || translated_attribute(settings.more_information_modal)
translated_attribute(current_settings.more_information_modal).presence || translated_attribute(settings.more_information_modal).presence
end

def component_name
1 change: 0 additions & 1 deletion decidim-budgets/app/cells/decidim/budgets/budget_m_cell.rb
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ module Budgets
# This cell renders the Medium (:m) budget card
# for an given instance of a Decidim::Budgets::Budget
class BudgetMCell < Decidim::CardMCell
include ActiveSupport::NumberHelper
include Decidim::Budgets::ProjectsHelper

def statuses
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ class BudgetsHeaderCell < BaseCell
def landing_page_content
translated_attribute(current_settings.landing_page_content).presence || translated_attribute(settings.landing_page_content)
end

def landing_page_instructions
translated_attribute(current_settings.landing_page_instructions).presence || translated_attribute(settings.landing_page_instructions)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -12,6 +12,12 @@
<%= cell "decidim/budgets/project_tags", model, context: { extra_classes: ["tags--project"] } %>
</div>

<% unless voting_finished? %>
<div class="hide-for-medium">
<%= budget_to_currency(model.budget_amount) %>
</div>
<% end %>

<div class="budget-list__data__number budget-list__number hide-for-medium">
<%= cell("decidim/budgets/project_votes_count",
model,
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ module Budgets
# This cell renders a horizontal project card
# for an given instance of a Project in a budget list
class ProjectListItemCell < Decidim::ViewModel
include ActiveSupport::NumberHelper
include Decidim::LayoutHelper
include Decidim::ActionAuthorizationHelper
include Decidim::Budgets::ProjectsHelper
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ module Budgets
# This cell renders the Medium (:m) project card
# for an given instance of a Project
class ProjectMCell < Decidim::CardMCell
include ActiveSupport::NumberHelper
include Decidim::Budgets::ProjectsHelper

private
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
disable: true,
budget: model.budget_amount,
allocation: resource_allocation,
"redirect-url": resource_path
"redirect-url": budget_projects_path(model.budget)
},
disabled: vote_button_disabled?,
title: vote_button_label do %>
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ module Budgets
# Note that it inherits from `Decidim::Components::BaseController`, which
# override its layout and provide all kinds of useful methods.
class ApplicationController < Decidim::Components::BaseController
helper Decidim::FocusModeHelper
helper_method :current_workflow, :voting_finished?, :voting_open?

def current_workflow
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ module Decidim
module Budgets
# A helper to render order and budgets actions
module ProjectsHelper
include ActiveSupport::NumberHelper

# Render a budget as a currency
#
# budget - A integer to represent a budget
@@ -13,7 +15,7 @@ def budget_to_currency(budget)

# Return a percentage of the current order budget from the total budget
def current_order_budget_percent
current_order&.budget_percent.to_f.floor
current_order&.budget_percent.to_f.floor.clamp(0, 100)
end

# Return the minimum percentage of the current order budget from the total budget
Loading