Project

General

Profile

Actions

Feature #41151

closed

[view-customize plugin] I want to control the items displayed in the pull-down menu.

Added by rito matsu 3 days ago. Updated 3 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Custom fields
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid

Description

I want to use the redmine-view-customize plugin to display pull-down custom fields.
The following code works in my local environment, but did not work when written to Redmine.
If there is an error in the code or the use of the plugin, please let me know.
I am having trouble understanding how to check the logs.

path-pattern

/issues/[0-9]+

project-pattern

/sandbox

$(document).ready(function () {
    var parentField = 'issue_custom_field_values_1';
    var childField = 'issue_custom_field_values_2';

    var narrowChildField = function() {
          var optionList = [
            {parent: 36, children: [57, 59, 60, 20]},
            {parent: 42, children: [59, 61]},
            {parent: 43, children: [60]},
            {parent: 0, children: [57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 20]}
        ];

          var parentId = parseInt($('#' + parentField + ' > option:selected').data('select2-id'), 10);
          if (isNaN(parentId)) {
            console.error("Invalid Children ID.");
            return;
          }

          var selectedOption = optionList.find(o => o.parent === parentId);
        var childIds = selectedOption ? selectedOption.children : [];

          $('#' + childField + ' > option').each(function() {
            var childId = parseInt($(this).data('select2-id'), 10);
            if (isNaN(childId)) {
              console.error("Invalid child ID for option:", $(this).text());
              return;
            }

            if (childIds.includes(childId)) {
                  $(this).show();
            } else {
                  $(this).hide();
            }
          });
    };

    // 初期ロード時にフィルタリングを適用
    narrowChildField();

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

    if (typeof replaceIssueFormWith === 'function') {
        var _replaceIssueFormWith = replaceIssueFormWith;
        replaceIssueFormWith = function(html){
            _replaceIssueFormWith(html);
            narrowChildField();
          };
    }
});

Thank you in advance for your help.

Actions #1

Updated by Go MAEDA 3 days ago

  • Status changed from New to Closed
  • Resolution set to Invalid

Please use forums for asking questions. The Issues page is for reporting bugs, suggesting new features, or submitting patches. It may be helpful for you to read the How to request help.

Actions

Also available in: Atom PDF