Search
Project
General
Profile
Home
Projects
Help
Sign in
Register
Search
:
Redmine
All Projects
Redmine
Overview
Download
Activity
Roadmap
Issues
News
Wiki
Plugins
Forums
Repository
Download (1.36 KB)
Feature #2500
» dynamic-mandatory-issue-field.js
Javascript for theme to check custom fields in transition. -
Sébastien Gripon
, 2011-11-02 18:13
// When the Status field is set to "Done", check that the Resolution field is not empty
var
k_resolutionFieldId
=
"
issue_custom_field_values_14
"
;
// Our status are "New" and "Done"
function
isIssueStatusNew
()
{
var
elt
=
document
.
getElementById
(
"
issue_status_id
"
);
if
(
elt
.
selectedIndex
==
-
1
||
elt
.
options
[
elt
.
selectedIndex
].
text
==
"
New
"
)
{
return
true
;
}
return
false
;
}
function
onSubmit
(
e
)
{
var
selectStatus
=
document
.
getElementById
(
"
issue_status_id
"
);
if
(
selectStatus
==
null
)
{
// No status field
return
;
}
var
selectResol
=
document
.
getElementById
(
k_resolutionFieldId
);
if
(
selectResol
==
null
)
{
// No Resolution field
return
;
}
if
(
isIssueStatusNew
()
)
{
// "New" status, no check needed
return
;
}
if
(
selectResol
.
selectedIndex
==
-
1
||
selectResol
.
options
[
selectResol
.
selectedIndex
].
text
==
""
)
{
// Resolution missing
alert
(
"
Please set Resolution
"
);
e
.
preventDefault
();
return
;
}
}
function
onDocumentLoaded
()
{
// If this is not an issue form, do nothing
var
form
=
document
.
getElementById
(
"
issue-form
"
)
if
(
form
==
null
)
{
return
;
// Other page
}
Event
.
observe
(
form
,
"
submit
"
,
onSubmit
);
}
Event
.
observe
(
window
,
'
load
'
,
onDocumentLoaded
);
(1-1/1)
Loading...