Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
f65a3e7e
Commit
f65a3e7e
authored
Feb 08, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 371995: Allow the Product field to restrict visibility of custom fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
parent
88463d2b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
14 deletions
+52
-14
Field.pm
Bugzilla/Field.pm
+1
-1
Choice.pm
Bugzilla/Field/Choice.pm
+8
-1
Product.pm
Bugzilla/Product.pm
+23
-1
enter_bug.cgi
enter_bug.cgi
+4
-0
cf-js.js.tmpl
template/en/default/admin/custom_fields/cf-js.js.tmpl
+1
-1
edit.html.tmpl
template/en/default/bug/edit.html.tmpl
+5
-4
field.html.tmpl
template/en/default/bug/field.html.tmpl
+8
-4
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+2
-2
No files found.
Bugzilla/Field.pm
View file @
f65a3e7e
...
...
@@ -158,7 +158,7 @@ use constant DEFAULT_FIELDS => (
{
name
=>
'classification'
,
desc
=>
'Classification'
,
in_new_bugmail
=>
1
,
buglist
=>
1
},
{
name
=>
'product'
,
desc
=>
'Product'
,
in_new_bugmail
=>
1
,
buglist
=>
1
},
type
=>
FIELD_TYPE_SINGLE_SELECT
,
buglist
=>
1
},
{
name
=>
'version'
,
desc
=>
'Version'
,
in_new_bugmail
=>
1
,
buglist
=>
1
},
{
name
=>
'rep_platform'
,
desc
=>
'Platform'
,
in_new_bugmail
=>
1
,
...
...
Bugzilla/Field/Choice.pm
View file @
f65a3e7e
...
...
@@ -62,6 +62,7 @@ use constant VALIDATORS => {
use
constant
CLASS_MAP
=>
{
bug_status
=>
'Bugzilla::Status'
,
product
=>
'Bugzilla::Product'
,
};
use
constant
DEFAULT_MAP
=>
{
...
...
@@ -189,6 +190,13 @@ sub remove_from_db {
ThrowUserError
(
"fieldvalue_still_has_bugs"
,
{
field
=>
$self
->
field
,
value
=>
$self
});
}
$self
->
_check_if_controller
();
$self
->
SUPER::
remove_from_db
();
}
# Factored out to make life easier for subclasses.
sub
_check_if_controller
{
my
$self
=
shift
;
my
$vis_fields
=
$self
->
controls_visibility_of_fields
;
my
$values
=
$self
->
controlled_values
;
if
(
@$vis_fields
||
@$values
)
{
...
...
@@ -196,7 +204,6 @@ sub remove_from_db {
{
value
=>
$self
,
fields
=>
[
map
(
$_
->
name
,
@$vis_fields
)],
vals
=>
$values
});
}
$self
->
SUPER::
remove_from_db
();
}
...
...
Bugzilla/Product.pm
View file @
f65a3e7e
...
...
@@ -31,7 +31,9 @@ use Bugzilla::Install::Requirements;
use
Bugzilla::
Mailer
;
use
Bugzilla::
Series
;
use
base
qw(Bugzilla::Object)
;
# Currently, we only implement enough of the Bugzilla::Field::Choice
# interface to control the visibility of other fields.
use
base
qw(Bugzilla::Field::Choice)
;
use
constant
DEFAULT_CLASSIFICATION_ID
=>
1
;
...
...
@@ -40,6 +42,10 @@ use constant DEFAULT_CLASSIFICATION_ID => 1;
###############################
use
constant
DB_TABLE
=>
'products'
;
# Reset these back to the Bugzilla::Object defaults, instead of the
# Bugzilla::Field::Choice defaults.
use
constant
NAME_FIELD
=>
'name'
;
use
constant
LIST_ORDER
=>
'name'
;
use
constant
DB_COLUMNS
=>
qw(
id
...
...
@@ -372,6 +378,8 @@ sub remove_from_db {
$dbh
->
bz_start_transaction
();
$self
->
_check_if_controller
();
if
(
$self
->
bug_count
)
{
if
(
Bugzilla
->
params
->
{
'allowbugdeletion'
})
{
require
Bugzilla::
Bug
;
...
...
@@ -523,6 +531,20 @@ sub _check_votes {
return
$votes
;
}
#####################################
# Implement Bugzilla::Field::Choice #
#####################################
sub
field
{
my
$invocant
=
shift
;
my
$class
=
ref
$invocant
||
$invocant
;
my
$cache
=
Bugzilla
->
request_cache
;
$cache
->
{
"field_$class"
}
||=
new
Bugzilla::
Field
({
name
=>
'product'
});
return
$cache
->
{
"field_$class"
};
}
use
constant
is_default
=>
0
;
###############################
#### Methods ####
###############################
...
...
enter_bug.cgi
View file @
f65a3e7e
...
...
@@ -389,6 +389,10 @@ foreach my $field (@enter_bug_fields) {
$vars
->
{
$field
->
name
}
=
formvalue
(
$field
->
name
);
}
# This allows the Field visibility and value controls to work with the
# Product field as a parent.
$default
{
'product'
}
=
$product
->
name
;
if
(
$cloned_bug_id
)
{
$default
{
'component_'
}
=
$cloned_bug
->
component
;
...
...
template/en/default/admin/custom_fields/cf-js.js.tmpl
View file @
f65a3e7e
...
...
@@ -27,7 +27,7 @@ var select_values = new Array();
[% FOREACH sel_field = Bugzilla.get_fields({ is_select => 1 }) %]
select_values[[% sel_field.id FILTER js %]] = [
[% FOREACH legal_value = sel_field.legal_values %]
[[% legal_value.id FILTER js %], '[% legal_value.name FILTER
html
%]'][% ',' UNLESS loop.last %]
[[% legal_value.id FILTER js %], '[% legal_value.name FILTER
js
%]'][% ',' UNLESS loop.last %]
[% END %]
];
[% END %]
...
...
template/en/default/bug/edit.html.tmpl
View file @
f65a3e7e
...
...
@@ -369,11 +369,12 @@
[%#############%]
[%# PRODUCT #%]
[%#############%]
<tr>
<td class="field_label">
<label for="product" accesskey="p"><b><u>P</u>roduct</b></label>:
</td>
[% PROCESS select selname => "product"
%]
[% INCLUDE bug/field.html.tmpl
bug = bug, field = select_fields.product,
desc_url = 'describecomponents.cgi', value = bug.product
editable = bug.check_can_change_field('product', 0, 1)
%]
</tr>
[%###############%]
[%# Component #%]
...
...
template/en/default/bug/field.html.tmpl
View file @
f65a3e7e
...
...
@@ -30,6 +30,10 @@
# the field value.
# no_tds: boolean; if true, don't display the label <th> or the
# wrapping <td> for the field.
# desc_url: string; Normally the label of a non-custom field links to
# fields.html. If you want it to link elsewhere, specify the
# relative URL you want to link to, here. Remember to call
# url_quote on any query string arguments.
# bug (optional): The current Bugzilla::Bug being displayed, or a hash
# with default field values being displayed on a page.
#%]
...
...
@@ -49,13 +53,13 @@
[% IF editable %]
<label for="[% field.name FILTER html %]">
[% END %]
[% IF !field.custom %]
[% IF desc_url %]
<a href="[% desc_url FILTER html %]">
[% ELSIF !field.custom %]
<a href="page.cgi?id=fields.html#[% field.name FILTER url_quote %]">
[% END -%]
[% field_descs.${field.name} FILTER html %]:
[%- IF !field.custom %]
</a>
[% END %]
[%- '</a>' IF (!field.custom || desc_url) %]
[% '</label>' IF editable %]
</th>
[% END %]
...
...
template/en/default/global/user-error.html.tmpl
View file @
f65a3e7e
...
...
@@ -475,8 +475,8 @@
[% ELSIF error == "fieldvalue_is_controller" %]
[% title = "Value Controls Other Fields" %]
You cannot delete the
'[% value.name FILTER html %]' value for this
field because
You cannot delete the
[% value.field.description FILTER html %]
'[% value.name FILTER html %]' because
[% IF fields.size %]
it controls the visibility of the following fields:
[%+ fields.join(', ') FILTER html %].
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment