Git Product home page Git Product logo

Comments (3)

pnabutovsky avatar pnabutovsky commented on August 16, 2024 1

@Khizar-Hussian You are looking for conditional select options. That should be in the documentation link that was shared with you. Note that skip logic and conditional selects are not available for configuration via the UI. You need to set up a Ruby script to load it. See the link below for samples: https://github.com/primeroIMS/primero/tree/develop/db/configuration.

In Primero you will want to implement 2 separate fields. For example you may want to have a multiselect violence field with options values coming from a Primary Violence Type lookup:['physical_violence', 'mental_violence', 'neglect']. You will then need to define a lookup Secondary Violence Type lookup with values tagged according to the Primary Violence type. Eg:

Lookup.create_or_update!(
  unique_id: 'lookup-secondary-violence-type',
  name_en: 'Secondary Violence Type',
  lookup_values: [
    { id: 'beating', display_text: 'Beating, tags: %w[physical_violence] },
    { id: 'biting', display_text: 'Biting', tags: %w[physical_violence] },
    { id: 'physical_neglect', display_text: 'Physical Neglect', tags: %w[neglect] },
    ...
  ]
)

Lastly, you will need to define a violence_secondary field that displays options based on the `violence field. Something like:

Field.new(
  name: 'violence_secondary',
  type: 'select_box',
  display_name_en: 'Secondary Violence',
  option_strings_source: 'lookup lookup-secondary-violence-type',
  option_strings_condition: {
    'physical_violence' => { 'eq' => { 'violence' => 'physical_violence' } },
    'mental_violence' => { 'eq' => { 'violence' => 'mental_violence' } },
    'neglect' => { 'eq' => { 'violence' => 'neglect' } }
  }

from primero.

RobertMacTavish avatar RobertMacTavish commented on August 16, 2024

from primero.

Khizar-Hussian avatar Khizar-Hussian commented on August 16, 2024

@RobertMacTavish Thank you so much for the response!
Would you also kindly link me to a relevant doc for achieving conditional functionality on dropdowns. The basic idea is to have either

  1. Successive dropdowns whose fields are dependent on the choice in the previous dropdowns, or
  2. Have one massive cascading dropdown, there will be main fields and subfields, and selecting a subfield would automatically select the main field.

A very crude representation of what we're trying to achieve is attached as an image to this response. If you could point us in the right direction, that would be great!

image

image

from primero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.