Skip to content

Feature/2348 proposal selection from accountability with autoComplete#2584

Merged
josepjaume merged 53 commits intomasterfrom
feature/2348-proposal_selection_from_accountability-autoComplete
Mar 5, 2018
Merged

Feature/2348 proposal selection from accountability with autoComplete#2584
josepjaume merged 53 commits intomasterfrom
feature/2348-proposal_selection_from_accountability-autoComplete

Conversation

@tramuntanal
Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal commented Jan 26, 2018

🎩 What? Why?

Widget to allow the administrators to associate Proposals to results in a more agile manner.

📌 Related Issues

📋 Subtasks

  • Add CHANGELOG entry
  • Refactor code
  • When a proposal is related from the result this proposal should automatically have the label Accepted.
  • NOTE: we are going to need this feature to be usable for the relation between proposals-components core team should review it.

📷 Screenshots (optional)

Description

@ghost ghost assigned tramuntanal Jan 26, 2018
@ghost ghost added the in-progress label Jan 26, 2018
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 31, 2018

Codecov Report

Merging #2584 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2584      +/-   ##
==========================================
+ Coverage   98.73%   98.73%   +<.01%     
==========================================
  Files        1647     1649       +2     
  Lines       39070    39172     +102     
==========================================
+ Hits        38575    38677     +102     
  Misses        495      495

@Crashillo
Copy link
Copy Markdown
Contributor

You may take a look at #2684. The mentions component contains the autocomplete functionality, handled by the front-end.
We should agree on how to get the data between back & front. cc/ @decidim/lot-core

@tramuntanal
Copy link
Copy Markdown
Contributor Author

@Crashillo , @decidim/lot-core I'm not sure about the callbacks this new component offers but what I see in #2684 is different from what I need.

  • Use case 1: If text starts with # then the autocomplete search is by ID
  • Use case 2: Autocomplete starts by default no symbol for starting it is required, autocompletion is done by title.

@decidim/product @decidim/lot-core I also think that this issue should have been taken into account before implementing a custom autocomplete solution because it took 2 weeks of work to have the current implementation with data-picker and now we're ignoring it and:

  • trying to add a new autocompletion solution when here we already had a flexible one.
  • modifying the design (seems small changes, but many javascript work for the data-picker and poup coordination will have to be thrown away?)

@Crashillo
Copy link
Copy Markdown
Contributor

The good point of Tribute.js is that you can initialize it whatever you want with.
We can define a set of rules for each use case, for instance, talking about hashtags, the trigger is # and the values (the source) points to an endpoint which returns an array object-like json with all the hashtags we're dealing with.
Same history, for the autocomplete, it triggers when a user types something, and points to a json with the data required to fill out the input.

@tramuntanal
Copy link
Copy Markdown
Contributor Author

Yes, the same characteristics as the ultra fast autoComplete 👅

Also we have a collision with symbol '#' wich will have different use cases. I think it is better to stay with autoComplete for this issue.

@tramuntanal tramuntanal force-pushed the feature/2348-proposal_selection_from_accountability-autoComplete branch from 50fbadd to 4f98de6 Compare February 26, 2018 10:28
@isaacmg410 isaacmg410 changed the title [WIP] Feature/2348 proposal selection from accountability with autoComplete Feature/2348 proposal selection from accountability with autoComplete Feb 26, 2018
@tramuntanal
Copy link
Copy Markdown
Contributor Author

Hi @decidim/lot-core, how can I make jquery-autocomplete.css and .js files being ignored by codeclimate? I'm adding it into codeclimate.yml excludes but keeps analyzing them.

@mrcasals
Copy link
Copy Markdown
Contributor

@tramuntanal please rebase against master, move those files to the vendor folder and remove the changes in the .codeclimate.yml file, I think that should fix it.

@ghost ghost assigned agustibr Mar 1, 2018
@tramuntanal
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core all checks pass now 😄

Copy link
Copy Markdown
Contributor

@josepjaume josepjaume left a comment

Choose a reason for hiding this comment

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

Please just remove these comment lines and that's it!

end
end

#-----------------------------------------------------------------------
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.

This is now not needed since there's nothing in the middle haha


private

#-----------------------------------------------------------------------
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.

Now there's no need to have this here 👍

def proposals
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_feature)&.order(title: :asc)&.pluck(:title, :id)
@proposals ||= Decidim.find_resource_manifest(:proposals)
.try(:resource_scope, current_feature)
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.

Fix identation 😄

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.

I think it's a bug that rubocop didn't catch this. I reported it: rubocop/rubocop#5621...

},
renderItem: function (item, search) {
let sanitizedSearch= search.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
let re= new RegExp(`(${sanitizedSearch.split(' ').join('|')})`, "gi");
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.

Please add spaces between the variable name and = 😄

{},
{ multiple: true, class: "chosen-select" }
%>
<% picker_options= { id: "decidim_accountability_proposals", class: "picker-multiple", name: 'result[proposal_ids]', multiple: true }
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals Mar 2, 2018

Choose a reason for hiding this comment

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

Space between variable name and = please 😄

#
# Returns an html String.
def data_picker(attribute, options = {}, prompt_params = {})
picker_options = { id: "#{@object_name}_#{attribute}", class: "picker-#{options[:multiple] ? "multiple" : "single"}",
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.

Can you normalize this hash please? Each key in a single line, etc

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.

Note that rubocop explicitly accepts this style and this file is using that same style in other places, so I think it's fine to leave it since otherwise we're introducing "in-file" inconsistency.

As a note, I made a very related feature request to rubocop a while ago, but nobody has stepped to implement it. It's not even clear if it should be a different cop or a configuration option for existing cops.

end
end

#-----------------------------------------------------------------------
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.

@tramuntanal remember to remove this :)


private

#-----------------------------------------------------------------------
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.

Aaand this :)

@tramuntanal
Copy link
Copy Markdown
Contributor Author

This PR is ready again @decidim/lot-core

@mrcasals
Copy link
Copy Markdown
Contributor

mrcasals commented Mar 5, 2018

@tramuntanal I still see some comments that have not been addressed yet, can you remove those extra lines please?

@josepjaume
Copy link
Copy Markdown
Contributor

@tramuntanal - @mrcasals is referring to the comment lines (#------) and the identation issues. Once that's solved, we can merge this! We'll release 0.10-pre tomorrow morning and it'd be nice to have this!

@josepjaume josepjaume added this to the Release v.0.10.0 milestone Mar 5, 2018
@tramuntanal
Copy link
Copy Markdown
Contributor Author

@decidim/lot-core I've removed both better readability lines on your command, feeling bad about that.

@josepjaume
Copy link
Copy Markdown
Contributor

@tramuntanal hey no prob! There's a lot of things going on right now, only natural to forget about some comments now and then 👍

@josepjaume josepjaume dismissed mrcasals’s stale review March 5, 2018 19:23

Delegated approval to me via telegram xD

@josepjaume
Copy link
Copy Markdown
Contributor

Merging!! 🎉 🎉 🎉 🎉 🎉 🎉 🎉

@josepjaume josepjaume merged commit 5e5377b into master Mar 5, 2018
@ghost ghost removed the in-review label Mar 5, 2018
@josepjaume josepjaume deleted the feature/2348-proposal_selection_from_accountability-autoComplete branch March 5, 2018 19:23
@tramuntanal
Copy link
Copy Markdown
Contributor Author

@josepjaume I was sad for having to remove the lines that I think were positive because they added better readability to code but well..

Merged at the end 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉

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.

6 participants