Feature #22026

Conditional custom fields

Added by Anh Le Giang over 1 year ago. Updated 3 months ago.

Status:NewStart date:
Priority:HighDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:-
Resolution:

Description

Like the very old topic below, I'd like to request "Conditional custom fields" feature for Redmine custom field, especially Issue object type.
conditional custom fields?

Example: Since we are mobile game developer, we have Device OS field which is a select custom field with value: Android, iOS, Windows Phone. And we have the sub fields OS version (Or even some fields like: Android version, iOS version and Windows Phone version). When reporter selects Android, the OS version field will be enable (show) with a list of version (could be text field or select field): 5.0, 5.1, 6.0, 4.4, etc.
Ref:
https://d1eipm3vz40hy0.cloudfront.net/images/p-apps-marketplace/apps/19078/screenshot-1.png
https://www.zendesk.com/apps/conditional-fields/

Thanks.


Related issues

Related to Redmine - Feature #6717: Custom list field with dynamic list content New 2010-10-21
Related to Redmine - Feature #9734: Custom field , value list from database query New
Related to Redmine - Feature #13143: Populate dropdown custom field list based on previous ano... New
Related to Redmine - Feature #22621: Linked/conditional custom fields Closed

History

#1 Updated by Toshi MARUYAMA over 1 year ago

  • Description updated (diff)

#2 Updated by Toshi MARUYAMA over 1 year ago

  • Description updated (diff)

#3 Updated by Hide MATSUTANI over 1 year ago

+1

#4 Updated by Hide MATSUTANI over 1 year ago

Let me introduce that redmine-view-customize plugin could help the requirement.
Please refer to the following blog. (Japanese site)

http://blog.enjoyxstudy.com/entry/2016/04/03/000000

#5 Updated by Anh Le Giang over 1 year ago

Hide MATSUTANI wrote:

Let me introduce that redmine-view-customize plugin could help the requirement.
Please refer to the following blog. (Japanese site)

http://blog.enjoyxstudy.com/entry/2016/04/03/000000

Could you please update English?

#6 Updated by Hide MATSUTANI over 1 year ago

Okay, I'll try...

Conditional custom fields can be made by following procedure.

(1) Pre-condition
Custom Fileds cf_1 and cf_2 are defined in your Redmine.
Value lists are defined like follows.
Say, cf_1 is a parent and cf_2 is a child.

  • cf_1
    • A
    • B
  • cf_2
    • A-1
    • A-2
    • B-1
    • B-2

You will know the parentFieldId and the childFieldId when you check the html source code.

(2) Install redmine-view-customize plugin

cd {RAILS_ROOT}/plugins
git clone https://github.com/onozaty/redmine-view-customize.git view_customize
cd ../
rake redmine:plugins:migrate RAILS_ENV=production

Note that the target directory name is different from the repository name.

When you finish installing, you can find 'view customize' in your Administration menu.

(3) Select 'view customize', then create 'New view customize' and set as follows:
Type

JavaScript

Path Pattern
/issues/

Code
$(function() {

  // Note that you should change these IDs according to your environment.
  var parentFieldId = 'issue_custom_field_values_1';
  var childFieldId = 'issue_custom_field_values_2';

  // define Conditions
  var isTarget = function(child, parent) {
    // This is a left-hand match sample
    return child.text().indexOf(parent.text()) == 0;
  }

  var narrowChildField = function() {

    var parentSelected = $('#' + parentFieldId + ' > option:selected');

    $('#' + childFieldId + ' > option').each(function() {

      var child = $(this);

      if (isTarget(child, parentSelected)) {
        child.show();
      } else {
        child.hide();
      }
    });
  }

  narrowChildField();

  $('#all_attributes').change(function(e) {
    if (e.target.id == parentFieldId) {
      narrowChildField();
    }
  });

  var _replaceIssueFormWith = replaceIssueFormWith;
  replaceIssueFormWith = function(html){

    _replaceIssueFormWith(html);

    narrowChildField();
  };
});

Then you can get the conditional custom fields.
When you select in the parent as 'A', you can only select 'A-1' or 'A-2' in the child field.

Is this clear?

Original information:
http://blog.enjoyxstudy.com/entry/2016/04/03/000000
https://github.com/onozaty/redmine-view-customize

#7 Updated by Dipan Mehta over 1 year ago

The case listed in the description is indeed very relevant. However, in my view - the most simple yet generic way you can get this done well is to implement feature #6717 and related #9734. You can have list of possible values as a dynamic set based on some other field value. There are many issues related to #6717 which are similar to this one.

Do add related #6717, #9734, #13143.

#8 Updated by Hide MATSUTANI over 1 year ago

Dipan Mehta wrote:

The case listed in the description is indeed very relevant. However, in my view - the most simple yet generic way you can get this done well is to implement feature #6717 and related #9734. You can have list of possible values as a dynamic set based on some other field value. There are many issues related to #6717 which are similar to this one.

Do add related #6717, #9734, #13143.

#13143 is the same as #22026. Actually these issues can be merged. My previous post could be a provisional way to achieve the purpose until this feature is formally implemented.
#6717, #9734 are similar to this from a user point of view, but I think they are different because #22026,#13143 actually use a client-side technology, whereas #6717, #9734 are server-side technology.

I feel the client-side technology is better because it should be responsive -- as it is discussed in the #22026
http://railscasts.com/episodes/88-dynamic-select-menus

#9 Updated by Toshi MARUYAMA over 1 year ago

  • Related to Feature #6717: Custom list field with dynamic list content added

#10 Updated by Toshi MARUYAMA over 1 year ago

  • Related to Feature #9734: Custom field , value list from database query added

#11 Updated by Toshi MARUYAMA over 1 year ago

  • Related to Feature #13143: Populate dropdown custom field list based on previous another selection added

#12 Updated by Toshi MARUYAMA over 1 year ago

#13 Updated by Stephane Evr about 1 year ago

+1

#14 Updated by Sonia Zh 11 months ago

+1

#15 Updated by Nova Pun 11 months ago

Where can i find the custom_field_id ? I try to use "3" and "4" from address:

"http://ils.rainbowconcept.com:3000/custom_fields/3/edit" "http://ils.rainbowconcept.com:3000/custom_fields/4/edit"

, but it's no work ! thanks !

#16 Updated by Roberto Tavares 5 months ago

Hello!

Is it possible to customize project custom fields the same way as issues custom fields? Than I use "/projects/" in the "Path Pattern" field in the plugin... but besides this, where I have to adapt the code?

Thanks a lot!

Hide MATSUTANI wrote:

Okay, I'll try...

Conditional custom fields can be made by following procedure.

(1) Pre-condition
Custom Fileds cf_1 and cf_2 are defined in your Redmine.
Value lists are defined like follows.
Say, cf_1 is a parent and cf_2 is a child.

  • cf_1
    • A
    • B
  • cf_2
    • A-1
    • A-2
    • B-1
    • B-2

You will know the parentFieldId and the childFieldId when you check the html source code.

(2) Install redmine-view-customize plugin

[...]
Note that the target directory name is different from the repository name.

When you finish installing, you can find 'view customize' in your Administration menu.

(3) Select 'view customize', then create 'New view customize' and set as follows:
Type
[...]
Path Pattern
[...]
Code
[...]

Then you can get the conditional custom fields.
When you select in the parent as 'A', you can only select 'A-1' or 'A-2' in the child field.

Is this clear?

Original information:
http://blog.enjoyxstudy.com/entry/2016/04/03/000000
https://github.com/onozaty/redmine-view-customize

#17 Updated by 膺升 陳 4 months ago

Hi all,

We got a problem as below,
After installing the plug-in,we can see "view customize" in Administrator menu,it is fine.
And then we just follow the steps as MATSUTANI mentioned,seems like it cannot work normally.
When we select parent as "A",not only "A-1","A-2" can be selected but also "B-1" and "B-2".
Could anyone give us a favor?Thanks in advanced.

Hide MATSUTANI wrote:

Okay, I'll try...

Conditional custom fields can be made by following procedure.

(1) Pre-condition
Custom Fileds cf_1 and cf_2 are defined in your Redmine.
Value lists are defined like follows.
Say, cf_1 is a parent and cf_2 is a child.

  • cf_1
    • A
    • B
  • cf_2
    • A-1
    • A-2
    • B-1
    • B-2

You will know the parentFieldId and the childFieldId when you check the html source code.

(2) Install redmine-view-customize plugin

[...]
Note that the target directory name is different from the repository name.

When you finish installing, you can find 'view customize' in your Administration menu.

(3) Select 'view customize', then create 'New view customize' and set as follows:
Type
[...]
Path Pattern
[...]
Code
[...]

Then you can get the conditional custom fields.
When you select in the parent as 'A', you can only select 'A-1' or 'A-2' in the child field.

Is this clear?

Original information:
http://blog.enjoyxstudy.com/entry/2016/04/03/000000
https://github.com/onozaty/redmine-view-customize

#18 Updated by chris k 3 months ago

Hi,

only for custom fields it works??? Thnx

Hide MATSUTANI wrote:

Okay, I'll try...

Conditional custom fields can be made by following procedure.

(1) Pre-condition
Custom Fileds cf_1 and cf_2 are defined in your Redmine.
Value lists are defined like follows.
Say, cf_1 is a parent and cf_2 is a child.

  • cf_1
    • A
    • B
  • cf_2
    • A-1
    • A-2
    • B-1
    • B-2

You will know the parentFieldId and the childFieldId when you check the html source code.

(2) Install redmine-view-customize plugin

[...]
Note that the target directory name is different from the repository name.

When you finish installing, you can find 'view customize' in your Administration menu.

(3) Select 'view customize', then create 'New view customize' and set as follows:
Type
[...]
Path Pattern
[...]
Code
[...]

Then you can get the conditional custom fields.
When you select in the parent as 'A', you can only select 'A-1' or 'A-2' in the child field.

Is this clear?

Original information:
http://blog.enjoyxstudy.com/entry/2016/04/03/000000
https://github.com/onozaty/redmine-view-customize

Also available in: Atom PDF