Skip to content

Survey questions can be sorted using drag and drop#1373

Merged
beagleknight merged 10 commits intofeature/surveysfrom
feature/surveys-question-position
May 22, 2017
Merged

Survey questions can be sorted using drag and drop#1373
beagleknight merged 10 commits intofeature/surveysfrom
feature/surveys-question-position

Conversation

@beagleknight
Copy link
Copy Markdown
Contributor

🎩 What? Why?

An Admin should be able to reorder survey questions. The list can be reordered using simple drag and drop. I reused some code from @mrcasals #137 and created an abstraction.

📌 Related Issues

📷 Screenshots and 👻 GIF


def update_survey_questions
@form.questions.each do |form_question|
question_attributes = { body: form_question.body, position: form_question.position }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary spacing detected.

@beagleknight beagleknight changed the title Feature/surveys question position Survey questions can be sorted using drag and drop May 18, 2017
@beagleknight beagleknight self-assigned this May 18, 2017
@mention-bot
Copy link
Copy Markdown

@beagleknight, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mrcasals and @josepjaume to be potential reviewers.

@beagleknight beagleknight force-pushed the feature/surveys-question-position branch from a64d712 to 8411171 Compare May 18, 2017 10:38
Copy link
Copy Markdown
Contributor

@oriolgual oriolgual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests?

@@ -0,0 +1,5 @@
class AddPositionToSurveysQuestions < ActiveRecord::Migration[5.0]
def change
add_column :decidim_surveys_survey_questions, :position, :integer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index: true

@codecov
Copy link
Copy Markdown

codecov bot commented May 18, 2017

Codecov Report

Merging #1373 into feature/surveys will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/surveys    #1373      +/-   ##
===================================================
+ Coverage            94.81%   94.83%   +0.02%     
===================================================
  Files                  444      269     -175     
  Lines                 7543     4593    -2950     
===================================================
- Hits                  7152     4356    -2796     
+ Misses                 391      237     -154
Impacted Files Coverage Δ
...cidim-surveys/app/models/decidim/surveys/survey.rb 100% <100%> (ø) ⬆️
...orms/decidim/surveys/admin/survey_question_form.rb 100% <100%> (ø) ⬆️
...pp/commands/decidim/surveys/admin/update_survey.rb 100% <100%> (ø) ⬆️
...dim-core/app/helpers/decidim/attachments_helper.rb
...decidim/participatory_process_groups_controller.rb
...core/lib/decidim/core/api/translated_field_type.rb
decidim-core/app/forms/decidim/form.rb
decidim-core/lib/decidim/filter_form_builder.rb
decidim-core/lib/decidim/core/engine.rb
...idim-core/app/models/decidim/application_record.rb
... and 168 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 225a854...fa2f237. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov bot commented May 18, 2017

Codecov Report

Merging #1373 into feature/surveys will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/surveys    #1373      +/-   ##
===================================================
+ Coverage            94.81%   94.83%   +0.02%     
===================================================
  Files                  444      269     -175     
  Lines                 7543     4593    -2950     
===================================================
- Hits                  7152     4356    -2796     
+ Misses                 391      237     -154
Impacted Files Coverage Δ
...pp/commands/decidim/surveys/admin/update_survey.rb 100% <100%> (ø) ⬆️
...orms/decidim/surveys/admin/survey_question_form.rb 100% <100%> (ø) ⬆️
...cidim-surveys/app/models/decidim/surveys/survey.rb 100% <100%> (ø) ⬆️
decidim-api/lib/decidim/api/query_type.rb
...es/decidim/organization_participatory_processes.rb
...im-core/app/helpers/decidim/decidim_form_helper.rb
...idim-core/lib/decidim/attributes/time_with_zone.rb
.../app/controllers/decidim/application_controller.rb
...e/app/models/decidim/participatory_process_step.rb
...im-core/app/constraints/decidim/current_feature.rb
... and 168 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 225a854...fa2f237. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov bot commented May 18, 2017

Codecov Report

Merging #1373 into feature/surveys will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/surveys    #1373      +/-   ##
===================================================
+ Coverage            94.81%   94.81%   +<.01%     
===================================================
  Files                  444      444              
  Lines                 7543     7546       +3     
===================================================
+ Hits                  7152     7155       +3     
  Misses                 391      391
Impacted Files Coverage Δ
...orms/decidim/surveys/admin/survey_question_form.rb 100% <100%> (ø) ⬆️
...cidim-surveys/app/models/decidim/surveys/survey.rb 100% <100%> (ø) ⬆️
...pp/commands/decidim/surveys/admin/update_survey.rb 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 225a854...7fb4633. Read the comment docs.

it "the questions are ordered by position" do
visit_feature

form_fields = all('.answer-survey .field')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

it "the questions are ordered by position" do
visit_feature

form_fields = all('.answer-survey .field')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

oriolgual
oriolgual previously approved these changes May 18, 2017
@beagleknight beagleknight mentioned this pull request May 18, 2017
8 tasks
@beagleknight beagleknight merged commit 2e44b7a into feature/surveys May 22, 2017
@beagleknight beagleknight deleted the feature/surveys-question-position branch May 22, 2017 08:08
beagleknight added a commit that referenced this pull request May 31, 2017
* Add basic drag and drop features

* Refactor JS and minor adjustments

* Add missing documentation

* Minor label adjustments

* Fix rubocop complains

* Add missing index

* Add missing feature test

* Fix rubocop issues

* Fix lint errors

* Fix broken specs
beagleknight added a commit that referenced this pull request Jun 2, 2017
* Add basic drag and drop features

* Refactor JS and minor adjustments

* Add missing documentation

* Minor label adjustments

* Fix rubocop complains

* Add missing index

* Add missing feature test

* Fix rubocop issues

* Fix lint errors

* Fix broken specs
beagleknight added a commit that referenced this pull request Jun 5, 2017
* Add basic drag and drop features

* Refactor JS and minor adjustments

* Add missing documentation

* Minor label adjustments

* Fix rubocop complains

* Add missing index

* Add missing feature test

* Fix rubocop issues

* Fix lint errors

* Fix broken specs
josepjaume pushed a commit that referenced this pull request Jun 6, 2017
* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Survey questions can be sorted using drag and drop (#1373)

* Add basic drag and drop features

* Refactor JS and minor adjustments

* Add missing documentation

* Minor label adjustments

* Fix rubocop complains

* Add missing index

* Add missing feature test

* Fix rubocop issues

* Fix lint errors

* Fix broken specs

* Admin can mark question as mandatory

* Restore missing PRs in feature/surveys (#1421)

* Add custom styles

* Change from toc to tos

* Fix broken tests

* Fix typo

* Fix spec

* Fix rubocop issues

* Add Surveys engine MVP (#1364)

* Add engine skeleton

* Add feature test

* An admin can update a survey without questions

* Admin can add n questions to a survey

* Admin can edit survey questions

* An admin can remove questions from surveys

* Admin can publish a survey

* Minor refactor

* Users answer surveys

* Fix minor errors

* Rubocop

* Add model validations

* Fix minor things

* Fix hound complains

* Fix more complains

* Fix broken specs

* Add some feedback

* Add some permissions

* Add missing translation

* Fix rubocop issues

* Add tests to the CI

* Fix broken test suite

* Normalize locales

* Admin can mark question as mandatory (#1386)

* Admin can mark question as mandatory

* Users must respond mandatory questions

* Fix problems with poltergeist

* Fix rubocop complains

* Fix i18n-issues

* Add feedback

* Fix rubocop complains

* Huge refactor templates

* Fix rubocop issues

* Admins can select question type

* Factor out auto label position code

* Moar refactor

* Huge JS refactor

* Add dynamic answer options for a question

* Admin survey form working with dynamic answer options

* Single and multiple options working

* Fixed rubocop issues

* Fix i18n problems

* Ignore unused i18n

* Add ignore unused

* Add answer option default value

* Fix rectify problem

* Fix minor issues

* Fix a few bad merges

* Fix broken specs

* Add survey exports (#1417)

* Add user answers serializer

* Finish export and serializer

* Add admin feature specs

* Fix rubocop issues

* Add allow_answers step setting (#1430)

* Admin cannot modify questions if already answered

* Add step setting to allow/disallow answers

* Fix rubocop issues

* Replace answered? with questions_editable?

* Use available_locales instead of Decidim locales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants