Bug 69325 - A setting to clone or not to clone custom fields

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@980 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-10-07 11:31:09 +00:00
parent e811fde11b
commit 9e27432a7d
8 changed files with 62 additions and 17 deletions

View File

@ -99,6 +99,7 @@ use constant DB_COLUMNS => qw(
sortkey
obsolete
enter_bug
clone_bug
buglist
visibility_field_id
value_field_id
@ -107,12 +108,13 @@ use constant DB_COLUMNS => qw(
use constant REQUIRED_CREATE_FIELDS => qw(name description);
use constant VALIDATORS => {
custom => \&_check_custom,
custom => \&Bugzilla::Object::check_boolean,
description => \&_check_description,
enter_bug => \&_check_enter_bug,
enter_bug => \&Bugzilla::Object::check_boolean,
clone_bug => \&Bugzilla::Object::check_boolean,
buglist => \&Bugzilla::Object::check_boolean,
mailhead => \&_check_mailhead,
obsolete => \&_check_obsolete,
mailhead => \&Bugzilla::Object::check_boolean,
obsolete => \&Bugzilla::Object::check_boolean,
sortkey => \&_check_sortkey,
type => \&_check_type,
visibility_field_id => \&_check_visibility_field_id,
@ -128,6 +130,7 @@ use constant UPDATE_COLUMNS => qw(
sortkey
obsolete
enter_bug
clone_bug
buglist
visibility_field_id
value_field_id
@ -251,8 +254,6 @@ sub match {
# Validators #
##############
sub _check_custom { return $_[1] ? 1 : 0; }
sub _check_description {
my ($invocant, $desc) = @_;
$desc = clean_text($desc);
@ -260,10 +261,6 @@ sub _check_description {
return $desc;
}
sub _check_enter_bug { return $_[1] ? 1 : 0; }
sub _check_mailhead { return $_[1] ? 1 : 0; }
sub _check_name {
my ($invocant, $name, $is_custom) = @_;
$name = lc(clean_text($name));
@ -293,8 +290,6 @@ sub _check_name {
return $name;
}
sub _check_obsolete { return $_[1] ? 1 : 0; }
sub _check_sortkey {
my ($invocant, $sortkey) = @_;
my $skey = $sortkey;
@ -444,6 +439,18 @@ sub enter_bug { return $_[0]->{enter_bug} }
=over
=item C<clone_bug>
A boolean specifying whether or not this field should be copied on bug clone
=back
=cut
sub clone_bug { return $_[0]->{clone_bug} }
=over
=item C<buglist>
A boolean specifying whether or not this field is selectable
@ -637,6 +644,8 @@ They will throw an error if you try to set the values to something invalid.
=item C<set_enter_bug>
=item C<set_clone_bug>
=item C<set_obsolete>
=item C<set_sortkey>
@ -655,6 +664,7 @@ They will throw an error if you try to set the values to something invalid.
sub set_description { $_[0]->set('description', $_[1]); }
sub set_enter_bug { $_[0]->set('enter_bug', $_[1]); }
sub set_clone_bug { $_[0]->set('clone_bug', $_[1]); }
sub set_obsolete { $_[0]->set('obsolete', $_[1]); }
sub set_sortkey { $_[0]->set('sortkey', $_[1]); }
sub set_in_new_bugmail { $_[0]->set('mailhead', $_[1]); }

View File

@ -99,7 +99,7 @@ sub process
my $pk = $f->{filename};
$pk =~ s/\W+/_/gso;
$pk = "Bugzilla::Hook::$pk";
$sub = eval "package $pk; sub { my (\$args) = \@_; $sub; return 1; };";
$sub = eval "package $pk; sub { my (\$args) = \@_;\n#line 1 \"$f->{filename}\"\n$sub; return 1; };";
if ($@)
{
warn __PACKAGE__."::process(): error during loading $f->{filename} into a subroutine (note that Bugzilla->hook_args was replaced by \$args): $@";

View File

@ -63,6 +63,7 @@ elsif ($action eq 'new') {
sortkey => scalar $cgi->param('sortkey'),
mailhead => scalar $cgi->param('new_bugmail'),
enter_bug => scalar $cgi->param('enter_bug'),
clone_bug => scalar $cgi->param('clone_bug'),
obsolete => scalar $cgi->param('obsolete'),
custom => 1,
buglist => (scalar $cgi->param('type') == FIELD_TYPE_MULTI_SELECT ? 0 : 1),
@ -107,9 +108,10 @@ elsif ($action eq 'update') {
# TODO enter_bug could be edited for non-custom fields, too.
# At the moment, though, it has no effect for non-custom fields.
$field->set_enter_bug($cgi->param('enter_bug'));
$field->set_visibility_field($cgi->param('visibility_field_id'));
$field->set_clone_bug($cgi->param('clone_bug'));
$field->set_visibility_field($cgi->param('visibility_field_id'));
$field->set_visibility_values([ $cgi->param('visibility_value_id') ]);
$field->set_value_field($cgi->param('value_field_id'));
$field->set_value_field($cgi->param('value_field_id'));
}
$field->update();

View File

@ -479,7 +479,14 @@ if ($cloned_bug_id) {
$vars->{cc} = join ', ', @cc;
foreach my $field (@enter_bug_fields) {
# Copy values of custom fields marked with 'clone_bug = TRUE'
# But don't copy values of custom fields which are invisible for the new product
my @clone_bug_fields = grep { $_->clone_bug &&
(!$_->visibility_field || $_->visibility_field->name ne 'product' ||
$_->has_visibility_value($product))
} Bugzilla->active_custom_fields;
foreach my $field (@clone_bug_fields)
{
my $field_name = $field->name;
$vars->{$field_name} = $cloned_bug->$field_name;
}

View File

@ -93,3 +93,6 @@ $schema->{globalauth} = {
globalauth_primary_idx => { FIELDS => ['id'], TYPE => 'UNIQUE' },
],
};
# Bug 69325 - Настройка копирования / не копирования значения поля при клонировании бага
push @{$schema->{fielddefs}->{FIELDS}}, clone_bug => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 1};

View File

@ -182,3 +182,9 @@ if (!$dbh->selectrow_array('SELECT name FROM setting_value WHERE name=\'csv_char
{
$dbh->do('INSERT INTO setting_value (name, value, sortindex) VALUES (\'csv_charset\', \'utf-8\', 10), (\'csv_charset\', \'windows-1251\', 20), (\'csv_charset\', \'koi8-r\', 30)');
}
# Bug 69325 - Настройка копирования / не копирования значения поля при клонировании бага
if (!$dbh->bz_column_info('fielddefs', 'clone_bug'))
{
$dbh->bz_add_column('fielddefs', clone_bug => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 1});
}

View File

@ -63,6 +63,13 @@
onchange="toggleCheckbox(this, 'new_bugmail');">
</td>
</tr>
<tr>
<td colspan="2"></td>
<th align="right">
<label for="clone_bug">Is copied into the cloned [% terms.bug %]:</label>
</th>
<td><input type="checkbox" id="clone_bug" name="clone_bug" value="1" checked="checked" /></td>
</tr>
<tr>
<th align="right"><label for="desc">Description:</label></th>
<td><input type="text" id="desc" name="desc" value="" size="40"></td>

View File

@ -51,9 +51,19 @@
</th>
<td><input type="checkbox" id="enter_bug" name="enter_bug" value="1"
[%- " checked" IF field.enter_bug %]
onchange="toggleCheckbox(this, 'new_bugmail');"></td>
onchange="toggleCheckbox(this, 'new_bugmail');" /></td>
[% END %]
</tr>
[% IF field.custom %]
<tr>
<td colspan="2"></td>
<th align="right">
<label for="clone_bug">Is copied into the cloned [% terms.bug %]:</label>
</th>
<td><input type="checkbox" id="clone_bug" name="clone_bug" value="1"
[%- " checked" IF field.clone_bug %] /></td>
</tr>
[% END %]
<tr>
<th align="right"><label for="desc">Description:</label></th>
<td><input type="text" id="desc" name="desc" size="40"