diff --git a/module/bug/js/batchcreate.js b/module/bug/js/batchcreate.js index ca5552b022..091963078f 100644 --- a/module/bug/js/batchcreate.js +++ b/module/bug/js/batchcreate.js @@ -4,8 +4,93 @@ $(function() var $titleCol = $('#batchCreateForm table thead tr th.c-title'); if($titleCol.width() < 150) $titleCol.width(150); + + $('#customField').click(function() + { + hiddenRequireFields(); + }); + + /* Implement a custom form without feeling refresh. */ + $('#formSettingForm .btn-primary').click(function() + { + var fields = ''; + $('#formSettingForm > .checkboxes > .checkbox-primary > input:checked').each(function() + { + fields += ',' + $(this).val(); + }); + + var link = createLink('custom', 'ajaxSaveCustomFields', 'module=bug§ion=custom&key=batchCreateFields'); + $.post(link, {'fields' : fields}, function() + { + checkedShowFields(fields); + $('#formSetting').parent().removeClass('open'); + + if($('#batchCreateForm table thead tr th.c-title').width() < 150) $titleCol.width(150); + + var fieldCount = $('#batchCreateForm .table thead>tr>th:visible').length; + $('.form-actions').attr('colspan', fieldCount); + + if(fieldCount > 10) + { + $('#batchCreateForm > .table-responsive').removeClass('scroll-none'); + $('#batchCreateForm > .table-responsive').css('overflow', 'auto'); + } + else + { + $('#batchCreateForm > .table-responsive').addClass('scroll-none'); + $('#batchCreateForm > .table-responsive').css('overflow', 'visible'); + } + }); + + return false; + }); }) +/** + * Checked show fields. + * + * @param string fields + * @access public + * @return void + */ +function checkedShowFields(fields) +{ + var fieldList = ',' + fields + ','; + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var $field = $('[name^=' + $(this).val() + ']'); + var required = ',' + requiredFields + ','; + var $fieldBox = $('.' + $(this).val() + 'Box' ); + if(fieldList.indexOf(field) >= 0 || required.indexOf(field) >= 0) + { + $fieldBox.removeClass('hidden'); + $field.removeAttr('disabled'); + } + else if(!$fieldBox.hasClass('hidden')) + { + $fieldBox.addClass('hidden'); + $field.attr('disabled', true); + } + }); +} + +/** + * Hidden require field. + * + * @access public + * @return void + */ +function hiddenRequireFields() +{ + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var required = ',' + requiredFields + ','; + if(required.indexOf(field) >= 0) $(this).closest('div').addClass('hidden'); + }); +} + /** * Set opened builds. * diff --git a/module/bug/view/batchcreate.html.php b/module/bug/view/batchcreate.html.php index 91c02ab591..2785a6a1b6 100755 --- a/module/bug/view/batchcreate.html.php +++ b/module/bug/view/batchcreate.html.php @@ -14,6 +14,24 @@ include '../../common/view/header.html.php'; js::set('requiredFields', $config->bug->create->requiredFields); ?> +bug->create->requiredFields) as $field) +{ + if($field) + { + $requiredFields[$field] = ''; + if(strpos(",{$config->bug->list->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = ''; + } +} +?> +