Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    FNGR2911
    @FNGR2911
    Hi! Sorry, maybe a stupid question, but: I just a "Sass::SyntaxError in Static#home File to import not found or unreadable: selectivity." some ideas why? thank you!
    Konrad Jurkowski
    @msx2
    Can you show me your stylesheet? I don’t recall any “selectivity.” being used in the styles
    Valentin Trinqué
    @ValentinTrinque
    Hi !
    I am experiencing trouble with the selectivity-backdrop using selectivity.
    This has been patched fe days after your last update
    I acknowledge that you want to distribute the latest stable version by default, but coud you update the selectivity gem to the latest version in a "edge" branch ?
    Valentin Trinqué
    @ValentinTrinque
    @msx2 This would be great, thanks
    Valentin Trinqué
    @ValentinTrinque
    Is this chat still active ?
    Konrad Jurkowski
    @msx2
    @ValentinTrinque I actually don’t mind using current edge version. Update script downloads selectivity straight from master branch. I will update the code in a few hours, sorry for the delay
    Valentin Trinqué
    @ValentinTrinque
    No problem ! Thank you for your feed back. I opened an issue concerning the vendor:update script. It's broken because the original repo does not expose the dist/ directory anymore. We have to npm run build it.
    Konrad Jurkowski
    @msx2
    Well, yeah, I can see that selectivity repository changed quite a bit in last 1-2 months. Thanks for reporting this, I didn’t have much free time lately so I’m not really up to date with everything :grimacing:
    Valentin Trinqué
    @ValentinTrinque
    Come on that's normal. We can pair on it if you want.
    I use your tool in my company's project so I can dedicate time to help you. I have to make it work anyway. So let me know how I can support you
    Konrad Jurkowski
    @msx2
    As a quick fix I will just update the code manually to the latest possible version that had distfolder (will do that in a few minutes I think, just need to finish the task on hand). And in longer run it’s definitely required to create a new vendor:update script. If you really have some time to spend on this, it would be really awesome :smile:
    And it’s really nice to hear you’re using it in a company’s project :fireworks:
    Valentin Trinqué
    @ValentinTrinque
    no problem ! we will need it for the long-run so support is definitely an option
    thanks a lot for your investment and quick response
    Valentin Trinqué
    @ValentinTrinque

    Hi @msx2 ! Is this possible to use Selectivity with form_for rails helper ?

    Here the slim I have :

    = form_for @letter do |f|
       .field
        = f.label :contacts
         #search-contact.selectivity-input
      .actions
        = f.submit

    The thing is I want to send the contact ids I selected along with for rest of the form. Contact and Letter have a many to many relation. Is it achievable ?

    Valentin Trinqué
    @ValentinTrinque
    ??
    Valentin Trinqué
    @ValentinTrinque
    @msx2 Ping ?
    Konrad Jurkowski
    @msx2
    @ValentinTrinque Sorry, I had to take some time off. If you want to go with form_for or simple_form_for I’d advise initlizing selectivity on actual select elements. Like I did here as an example: https://github.com/msx2/selectivity-rails-sample-app/blob/master/app/views/home/index.html.slim. Then you won’t have to add additional code in order to set a value in input anywhere, because it will be initialized on form element using traditional module.
    Valentin Trinqué
    @ValentinTrinque
    Oh ok ! Hope you enjoyed it :) Thank you, I will try. I'll tell you
    Valentin Trinqué
    @ValentinTrinque

    Hi @msx2 , how are you ? It's been a while ! I have 2 issues with the code you provided :

    First, I adaped your technique to the default rails helper :

    = form_for @letter do |f|
      - if @letter.errors.any?
        #error_explanation
          h2 = "#{pluralize(@letter.errors.count, "error")} prohibited this letter from being saved:"
          ul
            - @letter.errors.full_messages.each do |message|
              li = message
    
      .field
        = f.label :senders
       = f.select :sender_ids, [], {}, {multiple: "multiple", data: {id: "search-contact"}}
      .actions = f.submit

    After having selected some items & submit, I got this in my controller :

    "letter"=>{"sender_ids"=>[""]}

    If I deactivate Selectivity, it correctly retrieve the ids in my payload, succesfully saved and displayed.

    Secondly, I have some records with associated senders . When I use selectivity, it's not display in the input box. It's just blank. Also, it works when I use the basic select, without selectivity.

    The only way to patch this for me, now, is to use JS to dynamically listen the change event and update both Rails and Selectivity hidden fields. Does your code example work without JS synchronisation ?

    Any ideas ? I would really appreciate your lights on that. Thanks <3

    Konrad Jurkowski
    @msx2
    @ValentinTrinque, well, honestyly I don’t have any other idea at the moment other that you don’t have a traditional module included in Selectivity bundle :grimacing: I will do some more digging in the test app after I finish my today’s work and let you know
    Valentin Trinqué
    @ValentinTrinque
    Thank you very much ! I'm impatient to hear you back :D
    Konrad Jurkowski
    @msx2
    @ValentinTrinque Sorry it takes so long, I didn’t forget about it, just couldn’t spend time on it back then. Will do it over the weekend for sure. Sorry again!
    Valentin Trinqué
    @ValentinTrinque
    There is problem
    There is no problem , thanks a lot for helping me
    Konrad Jurkowski
    @msx2

    @ValentinTrinque Okay, I’ve been playing a bit with the code. The issue here is that ajax module is not really designed to work properly with traditional module. :grimacing: The code does work if you pass your data to the template, e.g.

    = form_for :test, url: form_for_path do |form|
      h3 Standard select fields
      .row
        .col-sm-6.col-md-4 = form.select :multiple_select, I18n.t('countries'), {},
                                        multiple: 'multiple', data: {toggle: 'selectivity'}

    (variation from the test app, but not using simple_form)

    It passes the data correctly:

    {
      "multiple_select": [
        "",
        "Bosnia and Herzegovina",
        "Czech Republic"
      ]
    }

    It’s far from the ideal solution, but it’s the easiest one - once you have your data from the backend, just insert them into <select> element, and then reinitialize selectivity on it. Would such solution work for you here or not really?

    I actually never tried AJAX requests in selectivity-rails, and I have an issue created for this purpose as it will not be testable using the gem - msx2/selectivity-rails#5

    On the other hand, if you have the data added by AJAX request into the selectivity input, you should just add data-item-id attribute to the result, so it is like this:

    <div class="selectivity-result-item" data-item-id="Armenia">Armenia</div>

    and it should insert <option> into the <select> with this value

    Have you tried this? Do you have a selectivity-result-items in your DOM properly after the request is completed and handled?
    Valentin Trinqué
    @ValentinTrinque
    @msx2 Thanks a lot for investigating all of that. This solution may work but is indeed not ideal. Maybe, we should add some very basic AJAX piece of code to the gem, to allow asynchronous search. Another solution could be to directly PR the official selectivity repository to change this behavior and allow the definition of an hidden field; which will hold the selected data for us. What do you think ?
    Valentin Trinqué
    @ValentinTrinque
    We could override the template to match Rails form_for function
    I will try to create a template to handle asynchronous multiple selection of associated model
    Valentin Trinqué
    @ValentinTrinque
    For example : imagine we have a Usermodel with a has_many :houses relation on model House model. The idea is to allow the addition / removal of houses through a form. But we potentially have a very long list of houses, so it requires asynchronous search to avoid heavy loading. We will have an hidden input holding the selected record ids, with name=user[house_ids]. With the custom template, I guess we can handle that properly !
    Valentin Trinqué
    @ValentinTrinque
    Hey ! I was walking through the colde of selectivity and... woaw, lot of changes happened... we definitely have to update the update-script
    Konrad Jurkowski
    @msx2
    @ValentinTrinque Yeah, I know. Arend let me know on Twitter over the weekend that 3.0.0 beta has been released, in which there’s a React optional component. A lot of stuff to do… :grimacing: Overriding the template sounds good to me!