Skip to content

Commit

Permalink
🚧 🏗️ replace file content
Browse files Browse the repository at this point in the history
with built Search / Replace All from text editor
- "Proposal" --> "Question"
- "proposal" --> "question"
  • Loading branch information
moustachu committed Jan 7, 2019
1 parent ef330ab commit c47e068
Show file tree
Hide file tree
Showing 441 changed files with 6,711 additions and 6,711 deletions.
22 changes: 11 additions & 11 deletions decidim-questions/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Decidim::Proposals
# Decidim::Questions

The Proposals module adds one of the main components of Decidim: allows users to contribute to a participatory process by creating proposals.
The Questions module adds one of the main components of Decidim: allows users to contribute to a participatory process by creating questions.

## Usage

Proposals will be available as a Component for a Participatory Process.
Questions will be available as a Component for a Participatory Process.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'decidim-proposals'
gem 'decidim-questions'
```

And then execute:
Expand All @@ -22,12 +22,12 @@ bundle

### Configuring Similarity

`pg_trgm` is a PostgreSQL extension providing simple fuzzy string matching used in the Proposal wizard to find similar published proposals (title and the body).
`pg_trgm` is a PostgreSQL extension providing simple fuzzy string matching used in the Question wizard to find similar published questions (title and the body).

Create config variables in your app's `/config/initializers/decidim-proposals.rb`:
Create config variables in your app's `/config/initializers/decidim-questions.rb`:

```ruby
Decidim::Proposals.configure do |config|
Decidim::Questions.configure do |config|
config.similarity_threshold = 0.25 # default value
config.similarity_limit = 10 # default value
end
Expand All @@ -41,15 +41,15 @@ end

This module includes the following models to Decidim's Global Search:

- `Proposals`
- `Questions`

## Participatory Texts

Participatory texts persist each section of the document in a Proposal.
Participatory texts persist each section of the document in a Question.

When importing participatory texts all formats are first transformed into Markdown and is the markdown that is parsed and processed to generate the corresponding Proposals.
When importing participatory texts all formats are first transformed into Markdown and is the markdown that is parsed and processed to generate the corresponding Questions.

When processing participatory text documents three kinds of secions are taken into account.
When processing participatory text documents three kinds of sections are taken into account.

- Section: each "Title 1" in the document becomes a section.
- Subsection: the rest of the titles become subsections.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//= link decidim/proposals/admin/proposals.js
//= link decidim/questions/admin/questions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
*= link decidim/proposals/social_share.css.scss
*= link decidim/questions/social_share.css.scss
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//= link decidim/proposals/social_share.js
//= link decidim/proposals/add_proposal.js
//= link decidim/proposals/admin/proposals_form.js
//= link decidim/questions/social_share.js
//= link decidim/questions/add_question.js
//= link decidim/questions/admin/questions_form.js
//= link_tree ../images/decidim
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$(() => {
window.DecidimProposals = window.DecidimProposals || {};
window.DecidimQuestions = window.DecidimQuestions || {};

window.DecidimProposals.bindProposalAddress = () => {
window.DecidimQuestions.bindQuestionAddress = () => {
const $checkbox = $("input:checkbox[name$='[has_address]']");
const $addressInput = $("#address_input");

Expand All @@ -18,5 +18,5 @@ $(() => {
}
};

window.DecidimProposals.bindProposalAddress();
window.DecidimQuestions.bindQuestionAddress();
});
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
// = require_self
$(document).ready(function () {
let selectedProposalsCount = function() {
return $('.table-list .js-check-all-proposal:checked').length
let selectedQuestionsCount = function() {
return $('.table-list .js-check-all-question:checked').length
}

window.selectedProposalsCountUpdate = function() {
if(selectedProposalsCount() == 0){
$("#js-selected-proposals-count").text("")
window.selectedQuestionsCountUpdate = function() {
if(selectedQuestionsCount() == 0){
$("#js-selected-questions-count").text("")
} else {
$("#js-selected-proposals-count").text(selectedProposalsCount());
$("#js-selected-questions-count").text(selectedQuestionsCount());
}

if(selectedProposalsCount() >= 2) {
$('button[data-action="merge-proposals"]').parent().show();
if(selectedQuestionsCount() >= 2) {
$('button[data-action="merge-questions"]').parent().show();
} else {
$('button[data-action="merge-proposals"]').parent().hide();
$('button[data-action="merge-questions"]').parent().hide();
}
}

let showBulkActionsButton = function() {
if(selectedProposalsCount() > 0){
if(selectedQuestionsCount() > 0){
$("#js-bulk-actions-button").removeClass('hide');
}
}

let hideBulkActionsButton = function(force = false) {
if(selectedProposalsCount() == 0 || force == true){
if(selectedQuestionsCount() == 0 || force == true){
$("#js-bulk-actions-button").addClass('hide');
$("#js-bulk-actions-dropdown").removeClass('is-open');
}
Expand Down Expand Up @@ -64,30 +64,30 @@ $(document).ready(function () {

// select all checkboxes
$(".js-check-all").change(function() {
$(".js-check-all-proposal").prop('checked', $(this).prop("checked"));
$(".js-check-all-question").prop('checked', $(this).prop("checked"));

if ($(this).prop("checked")) {
$(".js-check-all-proposal").closest('tr').addClass('selected');
$(".js-check-all-question").closest('tr').addClass('selected');
showBulkActionsButton();
} else {
$(".js-check-all-proposal").closest('tr').removeClass('selected');
$(".js-check-all-question").closest('tr').removeClass('selected');
hideBulkActionsButton();
}

selectedProposalsCountUpdate();
selectedQuestionsCountUpdate();
});

// proposal checkbox change
$('.table-list').on('change', '.js-check-all-proposal', function (e) {
let proposal_id = $(this).val()
// question checkbox change
$('.table-list').on('change', '.js-check-all-question', function (e) {
let question_id = $(this).val()
let checked = $(this).prop("checked")

// uncheck "select all", if one of the listed checkbox item is unchecked
if ($(this).prop("checked") === false) {
$(".js-check-all").prop('checked', false);
}
// check "select all" if all checkbox proposals are checked
if ($('.js-check-all-proposal:checked').length === $('.js-check-all-proposal').length) {
// check "select all" if all checkbox questions are checked
if ($('.js-check-all-question:checked').length === $('.js-check-all-question').length) {
$(".js-check-all").prop('checked', true);
showBulkActionsButton();
}
Expand All @@ -100,12 +100,12 @@ $(document).ready(function () {
$(this).closest('tr').removeClass('selected');
}

if ($('.js-check-all-proposal:checked').length === 0) {
if ($('.js-check-all-question:checked').length === 0) {
hideBulkActionsButton();
}

$('.js-bulk-action-form').find(".js-proposal-id-"+proposal_id).prop('checked', checked);
selectedProposalsCountUpdate();
$('.js-bulk-action-form').find(".js-question-id-"+question_id).prop('checked', checked);
selectedQuestionsCountUpdate();
});

$('.js-cancel-bulk-action').on('click', function (e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
$(() => {
const $form = $(".proposal_form_admin");
const $form = $(".question_form_admin");

if ($form.length > 0) {
const $proposalCreatedInMeeting = $form.find("#proposal_created_in_meeting");
const $proposalMeeting = $form.find("#proposal_meeting");
const $questionCreatedInMeeting = $form.find("#question_created_in_meeting");
const $questionMeeting = $form.find("#question_meeting");

const toggleDisabledHiddenFields = () => {
const enabledMeeting = $proposalCreatedInMeeting.prop("checked");
$proposalMeeting.find("select").attr("disabled", "disabled");
$proposalMeeting.hide();
const enabledMeeting = $questionCreatedInMeeting.prop("checked");
$questionMeeting.find("select").attr("disabled", "disabled");
$questionMeeting.hide();

if (enabledMeeting) {
$proposalMeeting.find("select").attr("disabled", !enabledMeeting);
$proposalMeeting.show();
$questionMeeting.find("select").attr("disabled", !enabledMeeting);
$questionMeeting.show();
}
};

$proposalCreatedInMeeting.on("change", toggleDisabledHiddenFields);
$questionCreatedInMeeting.on("change", toggleDisabledHiddenFields);
toggleDisabledHiddenFields();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "cell/partial"

module Decidim
module Proposals
module Questions
# This cell renders the collaborative_draft card for an instance of a CollaborativeDraft
# the default size is the Medium Card (:m)
class CollaborativeDraftCell < Decidim::ViewModel
Expand All @@ -22,7 +22,7 @@ def current_user
end

def card_size
"decidim/proposals/collaborative_draft_m"
"decidim/questions/collaborative_draft_m"
end

def resource_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@
require "cell/partial"

module Decidim
module Proposals
# This cell renders the link to the published proposal of a collaborative draft.
class CollaborativeDraftLinkToProposalCell < Decidim::ViewModel
module Questions
# This cell renders the link to the published question of a collaborative draft.
class CollaborativeDraftLinkToQuestionCell < Decidim::ViewModel
def show
render if proposal
render if question
end

private

def proposal
@proposal ||= model.linked_resources(:proposal, "created_from_collaborative_draft").first
def question
@question ||= model.linked_resources(:question, "created_from_collaborative_draft").first
end

def link_to_resource
link_to resource_locator(proposal).path, class: "button secondary light expanded button--sc mt-s" do
t("published_proposal", scope: "decidim.proposals.collaborative_drafts.show")
link_to resource_locator(question).path, class: "button secondary light expanded button--sc mt-s" do
t("published_question", scope: "decidim.questions.collaborative_drafts.show")
end
end

def link_header
content_tag :strong, class: "text-large text-uppercase" do
t("final_proposal", scope: "decidim.proposals.collaborative_drafts.show")
t("final_question", scope: "decidim.questions.collaborative_drafts.show")
end
end

def link_help_text
content_tag :span, class: "text-medium" do
t("final_proposal_help_text", scope: "decidim.proposals.collaborative_drafts.show")
t("final_question_help_text", scope: "decidim.questions.collaborative_drafts.show")
end
end

def link_to_versions
@path ||= decidim_proposals.collaborative_draft_versions_path(
@path ||= decidim_questions.collaborative_draft_versions_path(
collaborative_draft_id: model.id
)
link_to @path, class: "text-medium" do
content_tag :u do
t("version_history", scope: "decidim.proposals.collaborative_drafts.show")
t("version_history", scope: "decidim.questions.collaborative_drafts.show")
end
end
end
Expand All @@ -49,7 +49,7 @@ def decidim
Decidim::Core::Engine.routes.url_helpers
end

def decidim_proposals
def decidim_questions
Decidim::EngineRouter.main_proxy(model.component)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card__footer">
<div class="card__support">
<div class="card__support__data"></div>
<%= link_to t("decidim.proposals.collaborative_drafts.collaborative_draft.view_collaborative_draft"), resource_path, class: "card__button button small secondary" %>
<%= link_to t("decidim.questions.collaborative_drafts.collaborative_draft.view_collaborative_draft"), resource_path, class: "card__button button small secondary" %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render partial: "decidim/shared/tags.html", locals: { resource: model, tags_class_extra: "tags--proposal" } %>
<%= render partial: "decidim/shared/tags.html", locals: { resource: model, tags_class_extra: "tags--question" } %>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require "cell/partial"

module Decidim
module Proposals
# This cell renders a proposal with its M-size card.
module Questions
# This cell renders a question with its M-size card.
class CollaborativeDraftMCell < Decidim::CardMCell
include CollaborativeDraftCellsHelper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<a name="list-of-endorsements"></a>
<div class="row">
<div class="columns large-12">
<h4 class="section-heading"><%= t("decidim.proposals.proposals.show.endorsements_list") %></h4>
<h4 class="section-heading"><%= t("decidim.questions.questions.show.endorsements_list") %></h4>
</div>
<div class="columns large-12">
<%= cell(
"decidim/collapsible_list",
endorsers,
cell_name: "decidim/author",
cell_options: { extra_classes: ["author-data--small"] },
hidden_elements_count_i18n_key: "decidim.proposals.proposals.show.hidden_endorsers_count"
hidden_elements_count_i18n_key: "decidim.questions.questions.show.hidden_endorsers_count"
) %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
require "cell/partial"

module Decidim
module Proposals
# This cell renders the list of endorsers for the given Proposal.
module Questions
# This cell renders the list of endorsers for the given Question.
#
# Example:
#
# cell("decidim/proposals/endorsers_list", my_proposal)
# cell("decidim/questions/endorsers_list", my_question)
class EndorsersListCell < Decidim::ViewModel
include ProposalCellsHelper
include QuestionCellsHelper

def show
return unless endorsers.any?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% published_components.each do |component| %>
<%= cell "decidim/proposals/highlighted_proposals_for_component", component %>
<%= cell "decidim/questions/highlighted_questions_for_component", component %>
<% end %>
Loading

0 comments on commit c47e068

Please sign in to comment.