onozaty / redmine-view-customize-scripts

Code examples for "Redmine View Customize Plugin"
https://github.com/onozaty/redmine-view-customize
110 stars 26 forks source link

The カスタムフィールドを連動させる(親の値に応じて、子を絞り込む) Plugin doesn't work #3

Closed lilyroselily closed 8 years ago

lilyroselily commented 8 years ago

@onozaty , hi onozaty

firstly,thanks a lot for the script on http://blog.enjoyxstudy.com/entry/2016/04/03/000000. and i install the plugin:https://github.com/onozaty/redmine-view-customize successfully, then set the redmine as the comments of the plugin. but the plugin doesn't work .

there are some mistakes that i install and set process?

may u check the attacth file to tell me the mistakes that i made.

thanks so much

best wishes

The カスタムフィールドを連動させる(親の値に応じて、子を絞り込む) Plugin doesn't work.docx .

archonwang commented 8 years ago

+1 and what's your environment?

onozaty commented 8 years ago

hi @lilyroselily

Would you please attach the html of new issue page? I will check it.

Thanks

lilyroselily commented 8 years ago

@archonwang thanks but may u give me the sample ,environment? my redmine is :bitnami-redmine-3.3.0-1-windows my explorer:IE or Edge anything else?

best regards

lilyroselily commented 8 years ago

@onozaty thanks for reply soon but the GitHub doesn't support the html,css files to upload and notice just as "Unfortunately, we don’t support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, PDF, or ZIP. " so there are other ways to upload html and css files? best regards

archonwang commented 8 years ago

@lilyroselily , you can get it on adminstration / information to get it.

onozaty commented 8 years ago

@lilyroselily Please upload to compress the html into a zip file. Or changing the extension of the html file to .txt. I want to see the contents of the html file. css is not required.

lilyroselily commented 8 years ago

@onozaty the html and css files ,please check thanks New issue - Redmine.txt application.css.txt jquery-ui-1.11.0.css.txt jstoolbar.css.txt responsive.css.txt

lilyroselily commented 8 years ago

@archonwang hi,archonwang thanks for info my redmine environment as attachment file redmine environment

onozaty commented 8 years ago

@lilyroselily Thank you for the information.

I have one more question. Would you tell me the browser you are using?

lilyroselily commented 8 years ago

@onozaty the browser that I use is Internet Explorer11 Version:11.589.10586.0 UpdateVersion:11.0.35(KB3185319) ProductID:00150-20000-00003-AA459 thanks a lot

onozaty commented 8 years ago

@lilyroselily Sorry, this script not work in IE. In IE, will not be able to hide the option tag.

lilyroselily commented 8 years ago

@onozaty
the explorer that the script can work, would u like teach? thanks

onozaty commented 8 years ago

@lilyroselily IE will not be able to hide the option tag. However, since can be disabled, please try the following.

$(function() {

  var parentFieldId = 'issue_custom_field_values_1';
  var childFieldId = 'issue_custom_field_values_2';

  // 表示条件
  var isTarget = function(child, parent) {
    // 前方一致のものを対象に
    return child.text().indexOf(parent.text()) == 0;
  }

  // 子フィールドの絞り込み
  var narrowChildField = function() {

    // 親で選択している項目
    var parentSelected = $('#' + parentFieldId + ' > option:selected');

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

      var child = $(this);

      // 一致したものだけに絞り込む
      // IEの場合はoptionがdisplay:noneで非表示にならないのでdisabledで
      if (isTarget(child, parentSelected)) {
        child.show();
        child.prop('disabled', false);
      } else {
        child.hide();
        child.prop('disabled', true);
      }
    });
  }

  // 現時点のもので子を絞り込み
  narrowChildField();

  // 親フィールドが変わった際に子フィールドを絞り込み
  $('#all_attributes').change(function(e) {
    if (e.target.id == parentFieldId) {
      narrowChildField();
    }
  });

  // ステータス変更時などにDOMが差し替えられるので
  // フォームの内容が書き変わるたびに絞り込みを反映
  var _replaceIssueFormWith = replaceIssueFormWith;
  replaceIssueFormWith = function(html){

    _replaceIssueFormWith(html);

    narrowChildField();
  };
});

Added "child.prop('disabled', false)" and "child.prop('disabled', false)". This code to disable the option.

lilyroselily commented 8 years ago

@onozaty thanks a lot the above script , can work rightly in my IE, thanks once again best regards :)

nova168168 commented 7 years ago

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

"http://abc.com:3000/custom_fields/3/edit" "http://abc.com:3000/custom_fields/4/edit"

, but it's not work ! thanks !

archonwang commented 7 years ago

try to get the custom field id from html source code.

nova168168 commented 7 years ago

@archonwang I got the id , thanks !