Add sortkey for versions
parent
36905704ea
commit
1433ff9073
|
@ -618,6 +618,7 @@ use constant ABSTRACT_SCHEMA => {
|
||||||
id => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
|
id => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
|
||||||
value => {TYPE => 'varchar(255)', NOTNULL => 1},
|
value => {TYPE => 'varchar(255)', NOTNULL => 1},
|
||||||
product_id => {TYPE => 'INT4', NOTNULL => 1, REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}},
|
product_id => {TYPE => 'INT4', NOTNULL => 1, REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}},
|
||||||
|
sortkey => {TYPE => 'INT4', NOTNULL => 1, DEFAULT => 0},
|
||||||
isactive => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'},
|
isactive => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'},
|
||||||
],
|
],
|
||||||
INDEXES => [
|
INDEXES => [
|
||||||
|
|
|
@ -861,6 +861,8 @@ WHERE description LIKE \'%[CC:%]%\'');
|
||||||
$dbh->bz_alter_column('bugs', $_->name, Bugzilla::Field->SQL_DEFINITIONS->{FIELD_TYPE_NUMERIC()});
|
$dbh->bz_alter_column('bugs', $_->name, Bugzilla::Field->SQL_DEFINITIONS->{FIELD_TYPE_NUMERIC()});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dbh->bz_add_column('versions', 'sortkey');
|
||||||
|
|
||||||
_move_old_defaults($old_params);
|
_move_old_defaults($old_params);
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
|
@ -43,6 +43,7 @@ use constant DB_COLUMNS => qw(
|
||||||
id
|
id
|
||||||
value
|
value
|
||||||
product_id
|
product_id
|
||||||
|
sortkey
|
||||||
isactive
|
isactive
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -54,11 +55,13 @@ use constant REQUIRED_CREATE_FIELDS => qw(
|
||||||
use constant UPDATE_COLUMNS => qw(
|
use constant UPDATE_COLUMNS => qw(
|
||||||
value
|
value
|
||||||
isactive
|
isactive
|
||||||
|
sortkey
|
||||||
);
|
);
|
||||||
|
|
||||||
use constant VALIDATORS => {
|
use constant VALIDATORS => {
|
||||||
product => \&_check_product,
|
product => \&_check_product,
|
||||||
isactive => \&Bugzilla::Object::check_boolean,
|
isactive => \&Bugzilla::Object::check_boolean,
|
||||||
|
sortkey => \&_check_sortkey,
|
||||||
};
|
};
|
||||||
|
|
||||||
use constant UPDATE_VALIDATORS => {
|
use constant UPDATE_VALIDATORS => {
|
||||||
|
@ -107,7 +110,7 @@ sub _do_list_select
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $list = $self->SUPER::_do_list_select(@_);
|
my $list = $self->SUPER::_do_list_select(@_);
|
||||||
return [ sort { vers_cmp(lc($a->{value}), lc($b->{value})) } @$list ];
|
return [ sort { ($a->{sortkey} <=> $b->{sortkey}) || vers_cmp(lc $a->{value}, lc $b->{value}) } @$list ];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_create_validators
|
sub run_create_validators
|
||||||
|
@ -180,6 +183,7 @@ sub update
|
||||||
|
|
||||||
sub product_id { return $_[0]->{product_id}; }
|
sub product_id { return $_[0]->{product_id}; }
|
||||||
sub is_active { return $_[0]->{isactive}; }
|
sub is_active { return $_[0]->{isactive}; }
|
||||||
|
sub sortkey { return $_[0]->{sortkey}; }
|
||||||
|
|
||||||
sub product
|
sub product
|
||||||
{
|
{
|
||||||
|
@ -195,6 +199,7 @@ sub product
|
||||||
|
|
||||||
sub set_name { $_[0]->set('value', $_[1]); }
|
sub set_name { $_[0]->set('value', $_[1]); }
|
||||||
sub set_is_active { $_[0]->set('isactive', $_[1]); }
|
sub set_is_active { $_[0]->set('isactive', $_[1]); }
|
||||||
|
sub set_sortkey { $_[0]->set('sortkey', $_[1]); }
|
||||||
|
|
||||||
sub _check_value
|
sub _check_value
|
||||||
{
|
{
|
||||||
|
@ -226,6 +231,12 @@ sub _check_product
|
||||||
return Bugzilla->user->check_can_admin_product($product->name);
|
return Bugzilla->user->check_can_admin_product($product->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _check_sortkey
|
||||||
|
{
|
||||||
|
my ($invocant, $sortkey) = @_;
|
||||||
|
return int($sortkey || 0);
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
|
@ -122,6 +122,7 @@ if ($action eq 'new')
|
||||||
my $version = Bugzilla::Version->create({
|
my $version = Bugzilla::Version->create({
|
||||||
name => $version_name,
|
name => $version_name,
|
||||||
product => $product,
|
product => $product,
|
||||||
|
sortkey => $ARGS->{sortkey} || 0,
|
||||||
});
|
});
|
||||||
delete_token($token);
|
delete_token($token);
|
||||||
$vars->{message} = 'version_created';
|
$vars->{message} = 'version_created';
|
||||||
|
@ -210,6 +211,7 @@ if ($action eq 'update')
|
||||||
|
|
||||||
$version->set_name($version_name);
|
$version->set_name($version_name);
|
||||||
$version->set_is_active($isactive);
|
$version->set_is_active($isactive);
|
||||||
|
$version->set_sortkey($ARGS->{sortkey});
|
||||||
my $changes = $version->update();
|
my $changes = $version->update();
|
||||||
|
|
||||||
$changes->{control_lists} = 1 if $version->field->update_control_lists($version->id, $ARGS);
|
$changes->{control_lists} = 1 if $version->field->update_control_lists($version->id, $ARGS);
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
<th class="field_label"><label for="version">Version:</label></th>
|
<th class="field_label"><label for="version">Version:</label></th>
|
||||||
<td><input id="version" size="64" maxlength="64" name="version" id="version" value="[%- version.name | html %]" /></td>
|
<td><input id="version" size="64" maxlength="64" name="version" id="version" value="[%- version.name | html %]" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="field_label"><label for="sortkey">Sortkey:</label></th>
|
||||||
|
<td><input id="sortkey" size="20" maxlength="20" name="sortkey" value="[%- version.sortkey | html %]" /></td>
|
||||||
|
</tr>
|
||||||
[% IF version.id %]
|
[% IF version.id %]
|
||||||
<tr>
|
<tr>
|
||||||
<th class="field_label"><label for="isactive">Enabled For [% terms.Bugs %]:</label></th>
|
<th class="field_label"><label for="isactive">Enabled For [% terms.Bugs %]:</label></th>
|
||||||
|
|
Loading…
Reference in New Issue