This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, master has been updated
via f083dc627bfb82d240cb781a0197091abfc0a353 (commit)
via 8acb8884118bc3aeb6562da7c33e3cf2890e0d1d (commit)
from b05b3b8069b2ac010a77d8036b67cd87ba469da6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=f083dc627bfb82d240cb781a0197091abfc0a353
commit f083dc627bfb82d240cb781a0197091abfc0a353
Author: Franck Villaume <[email protected]>
Date: Tue Nov 8 20:32:08 2016 +0100
fix wrong var
diff --git a/src/common/tracker/actions/detail.php
b/src/common/tracker/actions/detail.php
index cbe8239..26e7cbb 100644
--- a/src/common/tracker/actions/detail.php
+++ b/src/common/tracker/actions/detail.php
@@ -158,8 +158,8 @@ foreach ($pluginsListeners as $pluginsListener) {
<?php } ?>
<?php if (forge_get_config('use_object_associations')) {
$anf = '';
- if ($this->getAssociationCounter()) {
- $anf = ' ('.$this->getAssociationCounter().')';
+ if ($ah->getAssociationCounter()) {
+ $anf = ' ('.$ah->getAssociationCounter().')';
} ?>
<li><a href="#tabber-object-associations"><?php echo
_('Associations').$anf; ?></a></li>
<?php } ?>
diff --git a/src/common/tracker/actions/mod-limited.php
b/src/common/tracker/actions/mod-limited.php
index dbb0160..d0579fe 100644
--- a/src/common/tracker/actions/mod-limited.php
+++ b/src/common/tracker/actions/mod-limited.php
@@ -187,8 +187,8 @@ foreach ($pluginsListeners as $pluginsListener) {
<?php } ?>
<?php if (forge_get_config('use_object_associations')) {
$anf = '';
- if ($this->getAssociationCounter()) {
- $anf = ' ('.$this->getAssociationCounter().')';
+ if ($ah->getAssociationCounter()) {
+ $anf = ' ('.$ah->getAssociationCounter().')';
} ?>
<li><a href="#tabber-object-associations"><?php echo
_('Associations').$anf; ?></a></li>
<?php } ?>
diff --git a/src/common/tracker/actions/mod.php
b/src/common/tracker/actions/mod.php
index 209ed3a..1189604 100644
--- a/src/common/tracker/actions/mod.php
+++ b/src/common/tracker/actions/mod.php
@@ -227,8 +227,8 @@ foreach ($pluginsListeners as $pluginsListener) {
<?php } ?>
<?php if (forge_get_config('use_object_associations')) {
$anf = '';
- if ($this->getAssociationCounter()) {
- $anf = ' ('.$this->getAssociationCounter().')';
+ if ($ah->getAssociationCounter()) {
+ $anf = ' ('.$ah->getAssociationCounter().')';
} ?>
<li><a href="#tabber-object-associations"><?php echo
_('Associations').$anf; ?></a></li>
<?php } ?>
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=8acb8884118bc3aeb6562da7c33e3cf2890e0d1d
commit 8acb8884118bc3aeb6562da7c33e3cf2890e0d1d
Author: Stéphane-Eymeric Bredthauer <[email protected]>
Date: Tue Nov 8 20:26:20 2016 +0100
Tracker: Release extra field type
diff --git a/src/common/include/utils.php b/src/common/include/utils.php
index 0b97a92..efbe460 100644
--- a/src/common/include/utils.php
+++ b/src/common/include/utils.php
@@ -9,6 +9,7 @@
* Thorsten Glaser <[email protected]>
* Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
* Copyright 2013,2016, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivalDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
@@ -1754,6 +1755,10 @@ function utils_headers_download($filename, $mimetype,
$size) {
header('X-Content-Type-Options: nosniff');
}
+function compareObjectName ($a, $b) {
+ return strcoll($a->getName(),$b->getName()) ;
+}
+
// Local Variables:
// mode: php
// c-file-style: "bsd"
diff --git a/src/common/tracker/ArtifactExtraField.class.php
b/src/common/tracker/ArtifactExtraField.class.php
index aefebd3..4b27221 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -36,10 +36,16 @@ define('ARTIFACT_EXTRAFIELDTYPE_STATUS',7);
//define('ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE',8);
define('ARTIFACT_EXTRAFIELDTYPE_RELATION',9);
define('ARTIFACT_EXTRAFIELDTYPE_INTEGER',10);
+/* reserved for aljeux extension, for merge into FusionForge */
define('ARTIFACT_EXTRAFIELDTYPE_FORMULA',11);
+/* reserved for Evolvis extension, for merge into FusionForge */
define('ARTIFACT_EXTRAFIELDTYPE_DATETIME',12);
+/* 12: reserved DATETIME*/
+/* 13: reserved SLA */
define('ARTIFACT_EXTRAFIELDTYPE_SLA',13);
define('ARTIFACT_EXTRAFIELDTYPE_USER',14);
+/* 15: reserved MULTIUSER */
+define('ARTIFACT_EXTRAFIELDTYPE_RELEASE',16);
define ("ARTIFACT_EXTRAFIELDTYPE_SINGLECHOICETYPE", serialize (array
(ARTIFACT_EXTRAFIELDTYPE_SELECT, ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_STATUS)));
define ("ARTIFACT_EXTRAFIELDTYPE_MULTICHOICETYPE", serialize (array
(ARTIFACT_EXTRAFIELDTYPE_CHECKBOX, ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)));
@@ -555,7 +561,7 @@ class ArtifactExtraField extends FFError {
$this->setError(_('Unable to set default
value')._(':').$default);
$return = false;
}
- } elseif (in_array($type,
unserialize(ARTIFACT_EXTRAFIELDTYPE_VALUETYPE)) || $type ==
ARTIFACT_EXTRAFIELDTYPE_USER) {
+ } elseif (in_array($type,
unserialize(ARTIFACT_EXTRAFIELDTYPE_VALUETYPE)) || $type ==
ARTIFACT_EXTRAFIELDTYPE_USER || $type == ARTIFACT_EXTRAFIELDTYPE_RELEASE) {
$efID = $this->getID();
$res = db_query_params ('SELECT default_value FROM
artifact_extra_field_default WHERE extra_field_id=$1',
array ($efID)) ;
@@ -603,6 +609,7 @@ class ArtifactExtraField extends FFError {
* @return string|integer|array
*/
function getDefaultValues() {
+ $return = false;
$res = db_query_params ('SELECT default_value FROM
artifact_extra_field_default WHERE extra_field_id=$1',
array ($this->getID()));
$type = $this->getType();
@@ -612,7 +619,7 @@ class ArtifactExtraField extends FFError {
if ($type == ARTIFACT_EXTRAFIELDTYPE_INTEGER &&
is_null($return)) {
$return = 0;
}
- } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_USER) {
+ } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_USER || $type ==
ARTIFACT_EXTRAFIELDTYPE_RELEASE) {
$row = db_fetch_array($res);
if (!$row) {
$return = 100;
@@ -647,7 +654,8 @@ class ArtifactExtraField extends FFError {
ARTIFACT_EXTRAFIELDTYPE_STATUS => _('Status'),
ARTIFACT_EXTRAFIELDTYPE_RELATION => _('Relation between
artifacts'),
ARTIFACT_EXTRAFIELDTYPE_INTEGER => _('Integer'),
- ARTIFACT_EXTRAFIELDTYPE_USER => _('User Select Box')
+ ARTIFACT_EXTRAFIELDTYPE_USER => _('User'),
+ ARTIFACT_EXTRAFIELDTYPE_RELEASE => _('Release')
);
}
@@ -691,7 +699,7 @@ class ArtifactExtraField extends FFError {
}
$return[] = $row;
}
- } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_USER) {
+ } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_USER ||
$type == ARTIFACT_EXTRAFIELDTYPE_RELEASE) {
while ($row = db_fetch_array($res)) {
if ($row['element_id']==$default) {
$row['is_default']=1;
@@ -797,12 +805,11 @@ class ArtifactExtraField extends FFError {
$autoassign = ($autoassign ? 1 : 0);
$is_hidden_on_submit = ($is_hidden_on_submit ? 1 : 0);
$is_disabled = ($is_disabled ? 1 : 0);
- $parent = (is_integer($parent) ? $parent : 100);
+ $parent = ((integer)$parent ? $parent : 100);
if (!($alias = $this->generateAlias($alias,$name))) {
return false;
}
-
$result = db_query_params ('UPDATE artifact_extra_field_list
SET field_name = $1,
description = $2,
diff --git a/src/common/tracker/ArtifactExtraFieldElement.class.php
b/src/common/tracker/ArtifactExtraFieldElement.class.php
index 1a18ba2..bc3d565 100644
--- a/src/common/tracker/ArtifactExtraFieldElement.class.php
+++ b/src/common/tracker/ArtifactExtraFieldElement.class.php
@@ -241,7 +241,19 @@ class ArtifactExtraFieldElement extends FFError {
* @return string The name.
*/
function getName() {
- return $this->data_array['element_name'];
+ switch ($this->ArtifactExtraField->getType()) {
+ case ARTIFACT_EXTRAFIELDTYPE_USER:
+ $role =
RBACEngine::getInstance()->getRoleById($this->data_array['element_name']);
+ $name = $role->getName();
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ $package =
frspackage_get_object($this->data_array['element_name']);
+ $name = $package->getName();
+ break;
+ default:
+ $name = $this->data_array['element_name'];
+ }
+ return $name;
}
/**
diff --git a/src/common/tracker/ArtifactType.class.php
b/src/common/tracker/ArtifactType.class.php
index db3ed55..3ceec01 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -470,6 +470,7 @@ class ArtifactType extends FFError {
WHERE group_artifact_id=$2',
array ($extra_field_id,
$this->getID()));
+ $this->fetchData($this->getID());
return $res;
}
@@ -493,6 +494,7 @@ class ArtifactType extends FFError {
WHERE group_artifact_id=$2',
array ($extra_field_id,
$this->getID()));
+ $this->fetchData($this->getID());
return $res;
}
diff --git a/src/common/tracker/actions/admin-updates.php
b/src/common/tracker/actions/admin-updates.php
index 0e764ca..03d3470 100644
--- a/src/common/tracker/actions/admin-updates.php
+++ b/src/common/tracker/actions/admin-updates.php
@@ -245,7 +245,13 @@ if (getStringFromRequest('add_extrafield')) {
$autoassign = getStringFromRequest('autoassign');
$is_hidden_on_submit = getStringFromRequest('is_hidden_on_submit');
$is_disabled = getStringFromRequest('is_disabled');
- $default = getStringFromRequest('default', false);
+ $defaultArr = getArrayFromRequest('extra_fields', false);
+ if (isset($defaultArr[$id])) {
+ $default = $defaultArr[$id];
+ } else {
+ $default = false;
+ }
+
$ac = new ArtifactExtraField($ath, $id);
if (!$ac || !is_object($ac)) {
$error_msg .= _('Unable to create ArtifactExtraField Object');
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php
b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 8cac2bb..0dab69f 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -339,119 +339,15 @@ class ArtifactTypeHtml extends ArtifactType {
}
} elseif ($efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_USER) {
$str =
$this->renderUserField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false,
$attrs);
+ } elseif ($efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_RELEASE) {
+ $str =
$this->renderReleaseField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false,
$attrs);
}
$template =
str_replace('{$PostName:'.$efarr[$i]['field_name'].'}',$post_name,$template);
$template =
str_replace('{$'.$efarr[$i]['field_name'].'}',$str,$template);
}
if($template != NULL){
if ($mode == 'UPDATE' || $mode == 'NEW') {
- $jsvariable ="
- var invalidSelectMsg = '"._("One or more of the selected options is not
allowed")."';
- var invalidInputMsg = '". _("This choice is not allowed")."';";
- $javascript = <<<'EOS'
- $.expr[':'].invalid = function(elem, index, match) {
- for (let invalid of document.querySelectorAll(':invalid') ) {
- if (elem === invalid) { return true; }
- }
- return false;
- };
- $(".autoassign[name^='extra_fields']").on('change', function(){
- if ($(this).prop('tagName') == 'SELECT') {
- var elmnts = $(this).children('option:selected');
- } else {
- var elmnts = $(this).siblings('input:checked');
- }
- elmnts.each(function(i){
- var aat = $(this).data("autoassignto");
- $("select#tracker-assigned_to
option[value="+aat.id+"]").prop('selected', true);
- $("span#tracker-assigned_to").text(aat.name);
- });
- });
- $(".with-depcy[name^='extra_fields']").on('change', function(){
- if ($(this).prop('tagName') == 'SELECT') {
- var elmnts = $(this).children('option:selected');
- } else {
- var elmnts = $(this).siblings('input:checked');
- }
- elmnts.each(function(i){
- var dep = $(this).data("dependency");
- if (this.value!='100') {
- $(dep).each(function(j, val) {
-
$("select[name^='extra_fields["+val.field+"]']:invalid,
input[name^='extra_fields["+val.field+"]']:invalid").each(function() {
- this.setCustomValidity("");
- $(this).off("change.invalid");
- });
-
$("select[name^='extra_fields["+val.field+"]'] option").each(function(k,opt){
- if (this.value!='100') {
- if
($.inArray(parseInt(this.value),val.elmnt)>-1) {
-
$(this).prop('disabled', false).removeClass('option_disabled');
- } else if (i==0) {
-
$(this).prop('disabled', true);
-
$(this).addClass('option_disabled');
- }
- }
- });
-
$("input[name^='extra_fields["+val.field+"]']").each(function(k,opt){
- if (this.value!='100') {
- if
($.inArray(parseInt(this.value),val.elmnt)>-1) {
-
$(this).prop('disabled', false).removeClass($(this).attr('type')+'_disabled');
- } else if (i==0) {
-
$(this).prop('disabled', true);
-
$(this).addClass($(this).attr('type')+'_disabled');
- }
- }
- });
- });
- } else {
- $(dep.fields).each(function(j, val) {
-
$("select[name^='extra_fields["+val+"]']:invalid,
input[name^='extra_fields["+val+"]']:invalid").each(function() {
- this.setCustomValidity("");
- });
-
$("select[name^='extra_fields["+val+"]']
option.option_disabled").each(function() {
- $(this).prop('disabled',
false).removeClass('option_disabled');
- });
-
$("input.radio_disable[name^='extra_fields["+val+"]']").each(function() {
- $(this).prop('disabled',
false).removeClass('radio_disabled');
- });
-
$("input.checkbox_disabled[name^='extra_fields["+val+"]']").each(function() {
- $(this).prop('disabled',
false).removeClass('checkbox_disabled');
- });
- });
- }
- });
- $("select[name^='extra_fields']
option:selected:disabled").parent().each(function() {
-
$(this).children('option:selected:disabled').prop('disabled', false);
- this.setCustomValidity(invalidSelectMsg);
- $(this).on("change.invalid", function() {
-
$(this).children('option.option_disabled:not(:disabled):not(:selected)').prop('disabled',
true);
- if
(!$(this).children('option.option_disabled:selected').length) {
- this.setCustomValidity("");
- $(this).off("change.invalid");
- }
- });
- });
-
$("input[name^='extra_fields']:checked:disabled").each(function() {
- $(this).prop('disabled', false);
- this.setCustomValidity(invalidInputMsg);
- if ($(this).attr('type') == 'radio') {
-
$(this).siblings('input[type="radio"]').on("change.invalid", function() {
-
$(this).siblings('input[type="radio"]:invalid').prop('disabled',
true).addClass('input_disabled').each(function() {
- this.setCustomValidity("");
- });
-
$(this).siblings('input[type="radio"]').off("change.invalid");
- $(this).off("change.invalid");
- });
- } else {
- $(this).on("change.invalid", function() {
- $(this).prop('disabled', true);
- this.setCustomValidity("");
- $(this).off("change.invalid");
- });
- }
- });
- });
-EOS;
- echo html_e('script', array(
'type'=>'text/javascript'),
'//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$javascript.'});'."\n".'//]]>');
+ echo $this->javascript();
}
echo $template;
}
@@ -607,7 +503,8 @@ EOS;
$efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_RADIO ||
$efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_MULTISELECT ||
$efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_STATUS ||
- $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_USER) {
+ $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_USER ||
+ $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_RELEASE ) {
$return .= '
<td class="halfwidth top">'.$name.'<br
/>{$'.$efarr[$i]['field_name'].'}</td>';
@@ -728,7 +625,7 @@ EOS;
}
/**
- * renderUserField - this function builds pop up box with choices.
+ * renderUserField - this function builds pop up box with users.
*
* @param int $extra_field_id The ID of this field.
* @param string $checked The item that should be
checked
@@ -769,6 +666,74 @@ EOS;
}
/**
+ * renderReleaseField - this function builds 2 pop up boxes with
packages & releases.
+ *
+ * @param int $extra_field_id The ID of this field.
+ * @param string $checked The item that should be
checked
+ * @param bool|string $show_100 Whether to show the
'100 row'
+ * @param string $text_100 What to call the '100
row'
+ * @param bool $show_any
+ * @param string $text_any
+ * @param bool $allowed
+ * @param array $attrs
+ * @return string HTML code for the box and choices
+ */
+ function renderReleaseField
($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any',
$allowed=false, $attrs = array ()) {
+ if ($text_100 == 'none'){
+ $text_100=_('None');
+ }
+
+ $releasesArray = array();
+ $defaultRelease = $checked;
+ $releaseAttrs = $attrs;
+ $releasesAttrs = array();
+
+ $packagesArray = array();
+ $defaultPackage = 100;
+ $packageAttrs = array('class'=>'package');
+ $packagesAttrs = array();
+
+ $arr = $this->getExtraFieldElements($extra_field_id);
+ $selectedPackagesId = array();
+ for ($i=0; $i<count($arr); $i++) {
+ $selectedPackagesId[$i]=$arr[$i]['element_name'];
+ }
+ $packages = get_frs_packages($this->getGroup());
+
+ if ((integer)$defaultRelease!=0 && $defaultRelease!=100) {
+ $releaseObj = frsrelease_get_object($defaultRelease);
+ $defaultPackage = $releaseObj->getFRSPackage()->getID();
+ }
+
+ uasort($packages, 'compareObjectName');
+ foreach ($packages as $package) {
+ if (in_array($package->getID(), $selectedPackagesId)) {
+ $packagesArray[$package->getID()] =
$package->getName();
+ $releasesList = '';
+ $releases = $package->getReleases();
+ uasort($releases, 'compareObjectName');
+ foreach ($releases as $release) {
+ $releasesArray[$release->getID()] =
$release->getName();
+ $releasesList .= (empty($releasesList)
? '':', ').$release->getID();
+ if ($defaultPackage == 100 ||
$defaultPackage==$package->getID()) {
+ $allowed[] = $release->getID();
+ }
+ }
+ $releasesList = '{"field": '.$extra_field_id.',
"elmnt": ['.$releasesList.']}';
+ $packagesAttrs [] =
array('data-releases'=>$releasesList);
+ }
+ }
+ $keys = array_keys($packagesArray);
+ $vals = array_values($packagesArray);
+
+ $return = html_build_select_box_from_arrays
($keys,$vals,'package['.$extra_field_id.']',$defaultPackage,$show_100,$text_100,$show_any,$text_any,
false, $packageAttrs, $packagesAttrs);
+ $keys = array_keys($releasesArray);
+ $vals = array_values($releasesArray);
+ $return .= html_build_select_box_from_arrays
($keys,$vals,'extra_fields['.$extra_field_id.']',$defaultRelease,$show_100,$text_100,$show_any,$text_any,
$allowed, $releaseAttrs, $releasesAttrs);
+ return $return;
+ }
+
+ /**
* renderRadio - this function builds radio buttons.
*
* @param int $extra_field_id The $int ID of this field.
@@ -1095,6 +1060,143 @@ EOS;
return
html_build_select_box($this->getStatuses(),$name,$checked,$show_100,$text_100);
}
+ function javascript() {
+ $jsvariable ="
+ var invalidSelectMsg = '"._("One or more of the selected options is not
allowed")."';
+ var invalidInputMsg = '". _("This choice is not allowed")."';";
+ $javascript = <<<'EOS'
+ $.expr[':'].invalid = function(elem, index, match) {
+ for (let invalid of document.querySelectorAll(':invalid') ) {
+ if (elem === invalid) { return true; }
+ }
+ return false;
+ };
+ $(".package").on('change', function(){
+ $(this).children('option:selected').each(function(i){
+ var releases = $(this).data("releases");
+
$("select[name^='extra_fields["+releases.field+"]']")[0].setCustomValidity("");
+ $("select[name^='extra_fields["+releases.field+"]']
option").not( "[value='100']" ).each(function(j,opt){
+ if (this.value!='100') {
+ if
($.inArray(parseInt(this.value),releases.elmnt)>-1) {
+ $(this).prop('disabled',
false).removeClass('option_disabled');
+ } else {
+ $(this).prop('disabled', true);
+
$(this).addClass('option_disabled');
+ }
+ }
+ });
+ $("select[name^='extra_fields["+releases.field+"]']
option:selected:disabled").parent().each(function() {
+
$(this).children('option:selected:disabled').prop('disabled', false);
+ this.setCustomValidity(invalidSelectMsg);
+ $(this).on("change.invalid", function() {
+
$(this).children('option.option_disabled:not(:disabled):not(:selected)').prop('disabled',
true);
+ if
(!$(this).children('option.option_disabled:selected').length) {
+ this.setCustomValidity("");
+ $(this).off("change.invalid");
+ }
+ });
+ });
+ });
+ });
+ $(".autoassign[name^='extra_fields']").on('change', function(){
+ if ($(this).prop('tagName') == 'SELECT') {
+ var elmnts = $(this).children('option:selected');
+ } else {
+ var elmnts = $(this).siblings('input:checked');
+ }
+ elmnts.each(function(i){
+ var aat = $(this).data("autoassignto");
+ $("select#tracker-assigned_to
option[value="+aat.id+"]").prop('selected', true);
+ $("span#tracker-assigned_to").text(aat.name);
+ });
+ });
+ $(".with-depcy[name^='extra_fields']").on('change', function(){
+ if ($(this).prop('tagName') == 'SELECT') {
+ var elmnts = $(this).children('option:selected');
+ } else {
+ var elmnts = $(this).siblings('input:checked');
+ }
+ elmnts.each(function(i){
+ var dep = $(this).data("dependency");
+ if (this.value!='100') {
+ $(dep).each(function(j, val) {
+
$("select[name^='extra_fields["+val.field+"]']:invalid,
input[name^='extra_fields["+val.field+"]']:invalid").each(function() {
+ this.setCustomValidity("");
+ $(this).off("change.invalid");
+ });
+
$("select[name^='extra_fields["+val.field+"]'] option").each(function(k,opt){
+ if (this.value!='100') {
+ if
($.inArray(parseInt(this.value),val.elmnt)>-1) {
+
$(this).prop('disabled', false).removeClass('option_disabled');
+ } else if (i==0) {
+
$(this).prop('disabled', true);
+
$(this).addClass('option_disabled');
+ }
+ }
+ });
+
$("input[name^='extra_fields["+val.field+"]']").each(function(k,opt){
+ if (this.value!='100') {
+ if
($.inArray(parseInt(this.value),val.elmnt)>-1) {
+
$(this).prop('disabled', false).removeClass($(this).attr('type')+'_disabled');
+ } else if (i==0) {
+
$(this).prop('disabled', true);
+
$(this).addClass($(this).attr('type')+'_disabled');
+ }
+ }
+ });
+ });
+ } else {
+ $(dep.fields).each(function(j, val) {
+
$("select[name^='extra_fields["+val+"]']:invalid,
input[name^='extra_fields["+val+"]']:invalid").each(function() {
+ this.setCustomValidity("");
+ });
+
$("select[name^='extra_fields["+val+"]']
option.option_disabled").each(function() {
+ $(this).prop('disabled',
false).removeClass('option_disabled');
+ });
+
$("input.radio_disable[name^='extra_fields["+val+"]']").each(function() {
+ $(this).prop('disabled',
false).removeClass('radio_disabled');
+ });
+
$("input.checkbox_disabled[name^='extra_fields["+val+"]']").each(function() {
+ $(this).prop('disabled',
false).removeClass('checkbox_disabled');
+ });
+ });
+ }
+ });
+ $("select[name^='extra_fields']
option:selected:disabled").parent().each(function() {
+
$(this).children('option:selected:disabled').prop('disabled', false);
+ this.setCustomValidity(invalidSelectMsg);
+ $(this).on("change.invalid", function() {
+
$(this).children('option.option_disabled:not(:disabled):not(:selected)').prop('disabled',
true);
+ if
(!$(this).children('option.option_disabled:selected').length) {
+ this.setCustomValidity("");
+ $(this).off("change.invalid");
+ }
+ });
+ });
+
$("input[name^='extra_fields']:checked:disabled").each(function() {
+ $(this).prop('disabled', false);
+ this.setCustomValidity(invalidInputMsg);
+ if ($(this).attr('type') == 'radio') {
+
$(this).siblings('input[type="radio"]').on("change.invalid", function() {
+
$(this).siblings('input[type="radio"]:invalid').prop('disabled',
true).addClass('input_disabled').each(function() {
+ this.setCustomValidity("");
+ });
+
$(this).siblings('input[type="radio"]').off("change.invalid");
+ $(this).off("change.invalid");
+ });
+ } else {
+ $(this).on("change.invalid", function() {
+ $(this).prop('disabled', true);
+ this.setCustomValidity("");
+ $(this).off("change.invalid");
+ });
+ }
+ });
+ });
+EOS;
+ return html_e('script', array( 'type'=>'text/javascript'),
'//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$javascript.'});'."\n".'//]]>');
+ }
+
}
// Local Variables:
diff --git a/src/common/tracker/views/form-addextrafield.php
b/src/common/tracker/views/form-addextrafield.php
index 1d5b7de..9cef46e 100644
--- a/src/common/tracker/views/form-addextrafield.php
+++ b/src/common/tracker/views/form-addextrafield.php
@@ -102,18 +102,29 @@ if ($rows > 0) {
$rolesarray[$role->getID()]=$role->getName();
}
}
+ if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELEASE
&& !isset($packages)) {
+ $packagesarray = array();
+ $packages = $packages =
get_frs_packages($ath->getGroup());
+ foreach ($packages as $package) {
+
$packagesarray[$package->getID()]=$package->getName();
+ }
+ }
if (!empty($elearray)) {
$optrows=count($elearray);
echo '<td>';
for ($j=0; $j <$optrows; $j++) {
-
- if ($efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_USER) {
- echo
$rolesarray[$elearray[$j]['element_name']];
- } else {
- echo $elearray[$j]['element_name'];
- echo
util_make_link('/tracker/admin/?update_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
$HTML->getEditFilePic(_('Edit')));
+ switch ($efarr[$i]['field_type']) {
+ case ARTIFACT_EXTRAFIELDTYPE_USER:
+ echo
$rolesarray[$elearray[$j]['element_name']];
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ echo
$packagesarray[$elearray[$j]['element_name']];
+ break;
+ default:
+ echo
$elearray[$j]['element_name'];
+ echo
util_make_link('/tracker/admin/?update_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
$HTML->getEditFilePic(_('Edit')));
}
echo
util_make_link('/tracker/admin/?delete_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
$HTML->getDeletePic(_('Delete')));
echo '<br />';
@@ -121,19 +132,22 @@ if ($rows > 0) {
} else {
echo '<td>';
}
-
echo "</td>\n";
echo "<td>\n";
- if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT
- || $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_RADIO
- || $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX
- || $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_MULTISELECT
- || $efarr[$i]['field_type'] ==
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+ switch ($efarr[$i]['field_type']) {
+ case ARTIFACT_EXTRAFIELDTYPE_USER:
+ echo
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
'['._('Add/remove roles for user choices').']');
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ echo
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
'['._('Add/remove packages for release choices').']');
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_SELECT:
+ case ARTIFACT_EXTRAFIELDTYPE_RADIO:
+ case ARTIFACT_EXTRAFIELDTYPE_CHECKBOX:
+ case ARTIFACT_EXTRAFIELDTYPE_MULTISELECT:
+ case ARTIFACT_EXTRAFIELDTYPE_STATUS:
echo
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
'['._('Add/Reorder choices').']');
}
- if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_USER) {
- echo
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
'['._('Add/remove roles for user choices').']');
- }
echo "</td>\n";
echo "</tr>\n";
}
@@ -183,53 +197,71 @@ $jsvariable ="
var size = '"._("Size")."';
var maxLength = '". _("Maxlength")."';
var rows = '"._("Rows")."';
- var columns = '". _("Columns")."';";
+ var columns = '". _("Columns")."';
+ var typeSelect = ".ARTIFACT_EXTRAFIELDTYPE_SELECT.";
+ var typeCheckBox = ".ARTIFACT_EXTRAFIELDTYPE_CHECKBOX.";
+ var typeRadio = ".ARTIFACT_EXTRAFIELDTYPE_RADIO.";
+ var typeText = ".ARTIFACT_EXTRAFIELDTYPE_TEXT.";
+ var typeMultiSelect = ".ARTIFACT_EXTRAFIELDTYPE_MULTISELECT.";
+ var typeTextArea = ".ARTIFACT_EXTRAFIELDTYPE_TEXTAREA.";
+ var typeStatus = ".ARTIFACT_EXTRAFIELDTYPE_STATUS.";
+ var typeRelation = ".ARTIFACT_EXTRAFIELDTYPE_RELATION.";
+ var typeInteger = ".ARTIFACT_EXTRAFIELDTYPE_INTEGER.";
+ var typeFormula = ".ARTIFACT_EXTRAFIELDTYPE_FORMULA.";
+ var typeDateTime = ".ARTIFACT_EXTRAFIELDTYPE_DATETIME.";
+ var typeUser = ".ARTIFACT_EXTRAFIELDTYPE_USER.";
+ var typeRelease = ".ARTIFACT_EXTRAFIELDTYPE_RELEASE.";";
+
$javascript = <<<'EOS'
$("p[class^='for-']").hide()
- $("input[value=1]").on('change', function(){
+ $("input[value="+typeSelect+"]").on('change', function(){
$("p.for-select").show();
$("p[class^='for-']:not(.for-select)").hide();
});
- $("input[value=2]").on('change', function(){
+ $("input[value="+typeCheckBox+"]").on('change', function(){
$("p.for-check").show();
$("p[class^='for-']:not(.for-check)").hide();
});
- $("input[value=3]").on('change', function(){
+ $("input[value="+typeRadio+"]").on('change', function(){
$("p.for-radio").show();
$("p[class^='for-']:not(.for-radio)").hide();
});
- $("input[value=4]").on('change', function(){
+ $("input[value="+typeText+"]").on('change', function(){
$("label[for='attribute1']").text(size);
$("label[for='attribute2']").text(maxLength);
$("p.for-text").show();
$("p[class^='for-']:not(.for-text)").hide();
});
- $("input[value=5]").on('change', function(){
+ $("input[value="+typeMultiSelect+"]").on('change', function(){
$("p.for-multiselect").show();
$("p[class^='for-']:not(.for-multiselect)").hide();
});
- $("input[value=6]").on('change', function(){
+ $("input[value="+typeTextArea+"]").on('change', function(){
$("label[for='attribute1']").text(rows);
$("label[for='attribute2']").text(columns);
$("p.for-textarea").show();
$("p[class^='for-']:not(.for-textarea)").hide();
});
- $("input[value=9]").on('change', function(){
+ $("input[value="+typeRelation+"]").on('change', function(){
$("label[for='attribute1']").text(size);
$("label[for='attribute2']").text(maxLength);
$("p.for-relation").show();
$("p[class^='for-']:not(.for-relation)").hide();
});
- $("input[value=10]").on('change', function(){
+ $("input[value="+typeInteger+"]").on('change', function(){
$("label[for='attribute1']").text(size);
$("label[for='attribute2']").text(maxLength);
$("p.for-integer").show();
$("p[class^='for-']:not(.for-integer)").hide();
});
- $("input[value=14]").on('change', function(){
+ $("input[value="+typeUser+"]").on('change', function(){
$("p.for-user").show();
$("p[class^='for-']:not(.for-user)").hide();
});
+ $("input[value="+typeRelease+"]").on('change', function(){
+ $("p.for-release").show();
+ $("p[class^='for-']:not(.for-release)").hide();
+ });
EOS;
echo html_e('script', array( 'type'=>'text/javascript'),
'//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$javascript.'});'."\n".'//]]>');
@@ -251,16 +283,12 @@ echo html_e('label', array('for'=>'attribute2'),
_('Maxlength')._(':'));
echo html_e('input', array('type'=>'text', 'name'=>'attribute2',
'value'=>'80', 'size'=>'2', 'maxlength'=>'2')).html_e('br');
echo html_ac(html_ap() - 1);
-echo html_ao('p', array('class'=>'for-text for-textarea for-integer'));
-
-echo html_ac(html_ap() - 1);
-
echo html_ao('p', array('class'=>'for-text'));
echo _('Pattern');
echo html_e('input', array('type'=>'text', 'name'=>'pattern', 'value'=>'',
'size'=>'50', 'maxlength'=>'255')).html_e('br');
echo html_ac(html_ap() - 1);
-echo html_ao('p', array('class'=>'for-select for-multiselect for-radio
for-check'));
+echo html_ao('p', array('class'=>'for-select for-multiselect for-radio
for-check for-release'));
echo html_build_checkbox('hide100', false, false);
echo html_e('label', array('for'=>'hide100'), _('Hide the default none
value'));
echo html_e('br');
diff --git a/src/common/tracker/views/form-addextrafieldoption.php
b/src/common/tracker/views/form-addextrafieldoption.php
index 41a15fb..c624666 100644
--- a/src/common/tracker/views/form-addextrafieldoption.php
+++ b/src/common/tracker/views/form-addextrafieldoption.php
@@ -36,127 +36,157 @@ if (!$ac || !is_object($ac)) {
exit_error($ac->getErrorMessage(),'tracker');
} else {
// $efearr=$ath->getExtraFieldElements($boxid);
+ $efType = $ac->getType();
$efearr=$ac->getAvailableValues();
- $title = sprintf(_('Add/Update Custom Field Elements in %s'),
$ath->getName());
+ switch ($efType) {
+ case ARTIFACT_EXTRAFIELDTYPE_USER:
+ $title = sprintf(_('Add/Update Roles for user choices
in %s'), $ath->getName());
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ $title = sprintf(_('Add/Update Packages for user
choices in %s'), $ath->getName());
+ break;
+ default:
+ $title = sprintf(_('Add/Update Custom Field Elements in
%s'), $ath->getName());
+ }
$ath->adminHeader(array('title'=>$title, 'modal'=>1));
echo html_e('h2', array(), _('Custom Field Name')._(':
').$ac->getName());
- $efType = $ac->getType();
- if ($efType != ARTIFACT_EXTRAFIELDTYPE_USER) {
- $rows=count($efearr);
- if ($rows > 0) {
+ switch ($efType) {
+ case ARTIFACT_EXTRAFIELDTYPE_USER:
+ $vals = array();
+ // specific for user select box
+ echo html_e('p',array(),_('Choose roles used for the
user select box'));
+ $g=$ath->getGroup();
+ $roles = $g->getRoles();
+ foreach ($roles as $role) {
+ if (!in_array(get_class($role),
array('RoleLoggedIn','RoleAnonymous'))){
+ $vals[$role->getID()]=$role->getName();
+ }
+ }
+ // end
+ asort($vals,SORT_FLAG_CASE);
+ $rows=count($efearr);
+ // change by:
+ // $checked_array = array_column($efearr,
'element_name');
+ // for php>=5.5.0
+ $checked_array = array();
+ for ($i=0; $i < $rows; $i++) {
+ $checked_array []= $efearr[$i]['element_name'];
+ }
echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid,
'method' => 'post'));
- $title_arr=array();
- $title_arr[]=_('Current/New positions');
- if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
- $title_arr[] = _('Mapping');
+ echo html_e('input', array('type'=>'hidden',
'name'=>'update_checked_opt', 'value'=>'y'));
+ echo html_build_checkboxes_from_array($vals, 'element',
$checked_array, true);
+ echo html_e('input', array('type'=>'submit',
'name'=>'post_changes', 'value'=>_('Submit')));
+ echo $HTML->closeForm();
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ $vals = array();
+ // specific for release select box
+ echo html_e('p',array(),_('Choose packages used for the
release select box'));
+ $g=$ath->getGroup();
+ $packages = get_frs_packages($g);
+ foreach ($packages as $package) {
+ $vals[$package->getID()]=$package->getName();
}
- $title_arr[]=_('Up/Down positions');
- $title_arr[]=_('Elements Defined');
- if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_CHOICETYPE))) {
- $title_arr[]=_('Default');
+ // end
+ asort($vals,SORT_FLAG_CASE);
+ $rows=count($efearr);
+ $checked_array = array();
+ for ($i=0; $i < $rows; $i++) {
+ $checked_array []= $efearr[$i]['element_name'];
}
- $title_arr[]='';
- echo $HTML->listTableTop ($title_arr,false, ' ');
- if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_SINGLECHOICETYPE))) {
- $row_attrs =
array('class'=>$HTML->boxGetAltRowStyle(-1,true));
- $cells = array();
- $cells[] = array('', 'class'=>'align-right');
+ echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid,
'method' => 'post'));
+ echo html_e('input', array('type'=>'hidden',
'name'=>'update_checked_opt', 'value'=>'y'));
+ echo html_build_checkboxes_from_array($vals, 'element',
$checked_array, true);
+ echo html_e('input', array('type'=>'submit',
'name'=>'post_changes', 'value'=>_('Submit')));
+ echo $HTML->closeForm();
+ break;
+ default:
+ $rows=count($efearr);
+ if ($rows > 0) {
+ echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid,
'method' => 'post'));
+ $title_arr=array();
+ $title_arr[]=_('Current/New positions');
if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
- $cells[] = array('');
+ $title_arr[] = _('Mapping');
}
- $cells[] = array('', 'class'=>'align-center');
- $cells[] = array(_('None'));
- $content =
html_build_radio_button('is_default', 100, true);
- $cells[] = array($content,
'class'=>'align-center');
- $cells[] = array('', 'class'=>'align-center');
- echo $HTML->multiTableRow($row_attrs, $cells);
- }
- for ($i=0; $i < $rows; $i++) {
- $row_attrs =
array('class'=>$HTML->boxGetAltRowStyle($i,true));
+ $title_arr[]=_('Up/Down positions');
+ $title_arr[]=_('Elements Defined');
+ if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_CHOICETYPE))) {
+ $title_arr[]=_('Default');
+ }
+ $title_arr[]='';
+ echo $HTML->listTableTop ($title_arr,false, '
');
+ if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_SINGLECHOICETYPE))) {
+ $row_attrs =
array('class'=>$HTML->boxGetAltRowStyle(-1,true));
+ $cells = array();
+ $cells[] = array('',
'class'=>'align-right');
+ if ($efType ==
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+ $cells[] = array('');
+ }
+ $cells[] = array('',
'class'=>'align-center');
+ $cells[] = array(_('None'));
+ $content =
html_build_radio_button('is_default', 100, true);
+ $cells[] = array($content,
'class'=>'align-center');
+ $cells[] = array('',
'class'=>'align-center');
+ echo $HTML->multiTableRow($row_attrs,
$cells);
+ }
+ for ($i=0; $i < $rows; $i++) {
+ $row_attrs =
array('class'=>$HTML->boxGetAltRowStyle($i,true));
+ $cells = array();
+ $content = ($i + 1).'
-->'.html_e('input', array('type'=>'text', 'name'=>'order['.
$efearr[$i]['element_id'] .']', 'value'=>'', 'size'=>'3', 'maxlength'=>'3'));
+ $cells[] = array($content,
'class'=>'align-right');
+ if ($efType ==
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+ $cells[] =
array($ath->getStatusName($efearr[$i]['status_id']));
+ }
+ $content =
util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i
== 0)? $i + 1 : $i), html_image('ic/btn_up.png','19','18',array('alt'=>'Up',
'title'=>_('Move Up this custom field element'))));
+ $content .=
util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i
== $rows - 1)? $i + 1 : $i + 2),
html_image('ic/btn_down.png','19','18',array('alt'=>'Down', 'title'=>_('Move
Down this custom field element'))));
+ $cells[] = array($content,
'class'=>'align-center');
+ $cells[] =
array($efearr[$i]['element_name']);
+ if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_MULTICHOICETYPE))) {
+ $content =
html_build_checkbox('is_default['. $efearr[$i]['element_id'] .']', false,
$efearr[$i]['is_default']);
+ $cells[] = array($content,
'class'=>'align-center');
+ } elseif (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_SINGLECHOICETYPE))) {
+ $content =
html_build_radio_button('is_default', $efearr[$i]['element_id'],
$efearr[$i]['is_default']);
+ $cells[] = array($content,
'class'=>'align-center');
+ }
+ $content =
util_make_link('/tracker/admin/?update_opt=1&id='.$efearr[$i]['element_id'].'&boxid='.$boxid.'&group_id='.$group_id.'&atid='.
$ath->getID(), html_image('ic/configure.png','22','22',array('alt'=>_('Edit'),
'title'=>_('Edit custom field element'))));
+ $cells[] = array($content,
'class'=>'align-center');
+ echo $HTML->multiTableRow($row_attrs,
$cells);
+ }
+ $row_attrs = array('class'=>'noborder');
$cells = array();
- $content = ($i + 1).' -->'.html_e('input',
array('type'=>'text', 'name'=>'order['. $efearr[$i]['element_id'] .']',
'value'=>'', 'size'=>'3', 'maxlength'=>'3'));
+ $content = html_e('input',
array('type'=>'submit', 'name'=>'post_changes_order', 'value'=>_('Reorder')));
$cells[] = array($content,
'class'=>'align-right');
+ $cells[] = array('');
if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
- $cells[] =
array($ath->getStatusName($efearr[$i]['status_id']));
+ $cells[] = array('');
}
- $content =
util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i
== 0)? $i + 1 : $i), html_image('ic/btn_up.png','19','18',array('alt'=>'Up',
'title'=>_('Move Up this custom field element'))));
- $content .=
util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i
== $rows - 1)? $i + 1 : $i + 2),
html_image('ic/btn_down.png','19','18',array('alt'=>'Down', 'title'=>_('Move
Down this custom field element'))));
- $cells[] = array($content,
'class'=>'align-center');
- $cells[] = array($efearr[$i]['element_name']);
-
- if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_MULTICHOICETYPE))) {
- $content =
html_build_checkbox('is_default['. $efearr[$i]['element_id'] .']', false,
$efearr[$i]['is_default']);
- $cells[] = array($content,
'class'=>'align-center');
- } elseif (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_SINGLECHOICETYPE))) {
- $content =
html_build_radio_button('is_default', $efearr[$i]['element_id'],
$efearr[$i]['is_default']);
+ $content = html_e('input',
array('type'=>'submit', 'name'=>'post_changes_alphaorder',
'value'=>_('Alphabetical order')));
+ $cells[] = array($content,
'class'=>'align-left');
+ if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_CHOICETYPE))) {
+ $content = html_e('input',
array('type'=>'submit', 'name'=>'post_changes_default', 'value'=>_('Update
default')));
$cells[] = array($content,
'class'=>'align-center');
}
-
- $content =
util_make_link('/tracker/admin/?update_opt=1&id='.$efearr[$i]['element_id'].'&boxid='.$boxid.'&group_id='.$group_id.'&atid='.
$ath->getID(), html_image('ic/configure.png','22','22',array('alt'=>_('Edit'),
'title'=>_('Edit custom field element'))));
- $cells[] = array($content,
'class'=>'align-center');
echo $HTML->multiTableRow($row_attrs, $cells);
+ echo $HTML->listTableBottom();
+ echo $HTML->closeForm();
+ } else {
+ echo html_e('strong', array(), _('You have not
defined any elements.'));
}
- $row_attrs = array('class'=>'noborder');
- $cells = array();
- $content = html_e('input', array('type'=>'submit',
'name'=>'post_changes_order', 'value'=>_('Reorder')));
- $cells[] = array($content, 'class'=>'align-right');
- $cells[] = array('');
+ echo html_e('br').html_e('br');
+ echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&boxid='.$boxid.'&atid='.$ath->getID(),
'method' => 'post'));
+ echo html_e('input', array('type'=>'hidden',
'name'=>'add_opt', 'value'=>'y'));
+ echo html_e('label',
array('for'=>'name'),html_e('strong', array(), _('Add New Element')._(':')));
+ echo html_e('input', array('type'=>'text',
'id'=>'name', 'name'=>'name', 'value'=>'', 'size'=>'15', 'maxlength'=>'30'));
+ // Show a pop-up box to choose the possible statuses
that this element will map to
if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
- $cells[] = array('');
- }
- $content = html_e('input', array('type'=>'submit',
'name'=>'post_changes_alphaorder', 'value'=>_('Alphabetical order')));
- $cells[] = array($content, 'class'=>'align-left');
- if (in_array($efType,
unserialize(ARTIFACT_EXTRAFIELDTYPE_CHOICETYPE))) {
- $content = html_e('input',
array('type'=>'submit', 'name'=>'post_changes_default', 'value'=>_('Update
default')));
- $cells[] = array($content,
'class'=>'align-center');
+ echo html_e('strong', array(), _('Status'));
+ echo $ath->statusBox('status_id',1,false,false);
}
- echo $HTML->multiTableRow($row_attrs, $cells);
- echo $HTML->listTableBottom();
+ echo html_e('input', array( 'type'=>'submit',
'name'=>'post_changes', 'value'=>_('Submit')));
echo $HTML->closeForm();
- } else {
- echo html_e('strong', array(), _('You have not defined
any elements.'));
- }
- echo html_e('br').html_e('br');
- echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&boxid='.$boxid.'&atid='.$ath->getID(),
'method' => 'post'));
- echo html_e('input', array('type'=>'hidden', 'name'=>'add_opt',
'value'=>'y'));
- echo html_e('label', array('for'=>'name'),html_e('strong',
array(), _('Add New Element')._(':')));
- echo html_e('input', array('type'=>'text', 'id'=>'name',
'name'=>'name', 'value'=>'', 'size'=>'15', 'maxlength'=>'30'));
- // Show a pop-up box to choose the possible statuses that this
element will map to
- if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
- echo html_e('strong', array(), _('Status'));
- echo $ath->statusBox('status_id',1,false,false);
- }
- echo html_e('input', array( 'type'=>'submit',
'name'=>'post_changes', 'value'=>_('Submit')));
- echo $HTML->closeForm();
- } else {
- // $efType == ARTIFACT_EXTRAFIELDTYPE_USER
- $vals = array();
- // specific for user select box
- echo html_e('p',array(),_('Choose roles used for the user
select box'));
- $g=$ath->getGroup();
- $roles = $g->getRoles();
- foreach ($roles as $role) {
- if (!in_array(get_class($role),
array('RoleLoggedIn','RoleAnonymous'))){
- $vals[$role->getID()]=$role->getName();
- }
- }
- // end
- asort($vals,SORT_FLAG_CASE);
- $rows=count($efearr);
- // change by:
- // $checked_array = array_column($efearr, 'element_name');
- // for php>=5.5.0
- $checked_array = array();
- for ($i=0; $i < $rows; $i++) {
- $checked_array []= $efearr[$i]['element_name'];
- }
-
- echo $HTML->openForm(array('action' =>
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid,
'method' => 'post'));
- echo html_e('input', array('type'=>'hidden',
'name'=>'update_checked_opt', 'value'=>'y'));
- echo html_build_checkboxes_from_array($vals, 'element',
$checked_array, true);
- echo html_e('input', array('type'=>'submit',
'name'=>'post_changes', 'value'=>_('Submit')));
- echo $HTML->closeForm();
}
+ if ($efType != ARTIFACT_EXTRAFIELDTYPE_USER) {} else {}
$ath->footer();
}
diff --git a/src/common/tracker/views/form-updateextrafield.php
b/src/common/tracker/views/form-updateextrafield.php
index 9bca1e7..9e3ba7f 100644
--- a/src/common/tracker/views/form-updateextrafield.php
+++ b/src/common/tracker/views/form-updateextrafield.php
@@ -113,7 +113,7 @@ if (!$ac || !is_object($ac)) {
} else {
echo html_e('input', array('type'=>'hidden', 'name'=>'pattern',
'value'=>''));
}
- if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)))
{
+ if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT,ARTIFACT_EXTRAFIELDTYPE_USER,ARTIFACT_EXTRAFIELDTYPE_RELEASE)))
{
echo html_ao('p');
echo html_build_checkbox('hide100', false, !$ac->getShow100());
echo html_e('label', array('for'=>'hide100'), _('Hide the
default none value'));
@@ -123,7 +123,11 @@ if (!$ac || !is_object($ac)) {
echo html_e('label', array('for'=>'show100label'), html_e('b',
array(), _('Label for the none value')).html_e('br'));
echo html_e('input', array('type'=>'text',
'name'=>'show100label', 'value'=>$ac->getShow100label(), 'size'=>'30'));
echo html_ac(html_ap() - 1);
-
+ } else {
+ echo html_e('input', array('type'=>'hidden', 'name'=>'hide100',
'value'=>0));
+ echo html_e('input', array('type'=>'hidden',
'name'=>'show100label', 'value'=>''));
+ }
+ if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT)))
{
$pfarr =
$ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX,ARTIFACT_EXTRAFIELDTYPE_SELECT,ARTIFACT_EXTRAFIELDTYPE_MULTISELECT));
$parentField = array();
$progenyField = $ac->getProgeny();
@@ -139,11 +143,9 @@ if (!$ac || !is_object($ac)) {
echo
html_build_select_box_from_arrays(array_keys($parentField),
array_values($parentField), 'parent', $ac->getParent(), true,
'none').html_e('br');
echo html_ac(html_ap() - 1);
} else {
- echo html_e('input', array('type'=>'hidden', 'name'=>'hide100',
'value'=>0));
- echo html_e('input', array('type'=>'hidden',
'name'=>'show100label', 'value'=>''));
echo html_e('input', array('type'=>'hidden', 'name'=>'parent',
'value'=>100));
}
- if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_SELECT))) {
+ if (in_array($efType, array(ARTIFACT_EXTRAFIELDTYPE_RADIO,
ARTIFACT_EXTRAFIELDTYPE_SELECT, ARTIFACT_EXTRAFIELDTYPE_RELEASE))) {
echo html_ao('p');
echo html_build_checkbox('autoassign', false,
$ac->isAutoAssign());
echo html_e('label', array('for'=>'autoassign'), _('Field that
triggers auto-assignment rules'));
@@ -155,58 +157,37 @@ if (!$ac || !is_object($ac)) {
switch ($efType) {
case ARTIFACT_EXTRAFIELDTYPE_TEXT:
echo html_ao('p');
- echo html_e('label', array('for'=>'default'),_('Default
value'));
- $attrs = array('type'=>'text', 'id'=>'default',
'name'=>'default', 'value'=>$ac->getDefaultValues(),
'size'=>$ac->getAttribute1(), 'maxlength'=>$ac->getAttribute2());
- if ($ac->getPattern() != '') {
- $attrs['pattern'] = $ac->getPattern();
- }
- echo html_e('input', $attrs);
+ echo html_e('label',
array('for'=>'extra_fields['.$ac->getID().']'),_('Default value'));
+ echo
$ath->renderTextField($ac->getID(),$ac->getDefaultValues(),
$ac->getAttribute1(), $ac->getAttribute2());
echo html_ac(html_ap() - 1);
break;
case ARTIFACT_EXTRAFIELDTYPE_TEXTAREA:
echo html_ao('p');
- echo html_e('label', array('for'=>'default'),_('Default
value'));
- echo html_e('textarea', array('id'=>'default',
'name'=>'default', 'value'=>$ac->getDefaultValues(),
'rows'=>$ac->getAttribute1(), 'cols'=>$ac->getAttribute2()));
+ echo html_e('label',
array('for'=>'extra_fields['.$ac->getID().']'),_('Default value'));
+ echo html_e('br');
+ echo
$ath->renderTextArea($ac->getID(),$ac->getDefaultValues(),
$ac->getAttribute1(), $ac->getAttribute2());
echo html_ac(html_ap() - 1);
break;
case ARTIFACT_EXTRAFIELDTYPE_INTEGER:
echo html_ao('p');
- echo html_e('label', array('for'=>'default'),_('Default
value'));
- $attrs = array('type'=>'number', 'id'=>'default',
'name'=>'default', 'value'=>$ac->getDefaultValues(),
'size'=>$ac->getAttribute1(), 'maxlength'=>$ac->getAttribute2(), 'min'=>0);
- if ($ac->getPattern() != '') {
- $attrs['pattern'] = $ac->getPattern();
- }
- echo html_e('input', $attrs);
+ echo html_e('label',
array('for'=>'extra_fields['.$ac->getID().']'),_('Default value'));
+ echo
$ath->renderIntegerField($ac->getID(),$ac->getDefaultValues(),
$ac->getAttribute1(), $ac->getAttribute2());
echo html_ac(html_ap() - 1);
break;
// case ARTIFACT_EXTRAFIELDTYPE_DATETIME:
case ARTIFACT_EXTRAFIELDTYPE_USER:
echo html_ao('p');
- echo html_e('label', array('for'=>'default'),_('Default
value'));
- $arr = $ac->getAvailableValues();
- $selectedRolesId = array();
- for ($i=0; $i<count($arr); $i++) {
- $selectedRolesId[$i]=$arr[$i]['element_name'];
- }
- $roles = $ac->getArtifactType()->getGroup()->getRoles();
- $userArray = array();
- foreach ($roles as $role) {
- if (in_array($role->getID(), $selectedRolesId))
{
- foreach ($role->getUsers() as $user) {
- $userArray[$user->getID()] =
$user->getRealName().(($user->getStatus()=='S') ? ' '._('[SUSPENDED]') : '');
- }
- }
- }
- $default = $ac->getDefaultValues();
- if (is_integer($default) &&
!isset($userArray[$default]) && $default!=100) {
- $checkedUser = user_get_object($default);
- $userArray[$checkedUser->getID()] =
$checkedUser->getRealName().' '._('[DELETED]');
- }
- asort($userArray,SORT_FLAG_CASE | SORT_STRING);
- $keys = array_keys($userArray);
- $vals = array_values($userArray);
- echo html_build_select_box_from_arrays
($keys,$vals,'default',$default,true,'nobody');
+ echo html_e('label',
array('for'=>'extra_fields['.$ac->getID().']'),_('Default value'));
+ echo
$ath->renderUserField($ac->getID(),$ac->getDefaultValues(),true,'nobody');
echo html_ac(html_ap() - 1);
+ break;
+ case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
+ echo $ath->javascript();
+ echo html_ao('p');
+ echo html_e('label',
array('for'=>'extra_fields['.$ac->getID().']'),_('Default value'));
+ echo
$ath->renderReleaseField($ac->getID(),$ac->getDefaultValues(),true,'none');
+ echo html_ac(html_ap() - 1);
+ break;
}
echo $HTML->warning_msg(_('It is not recommended that you change the
custom field name because other things are dependent upon it. When you change
the custom field name, all related items will be changed to the new name.'));
diff --git a/src/www/include/html.php b/src/www/include/html.php
index ed9e28a..733048a 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -648,7 +648,7 @@ function html_build_select_box_from_arrays($vals, $texts,
$select_name,
//we don't always want the default Any row shown
if ($show_any) {
$opt_attrs = array('value' => '');
- if ($checked_val)
+ if ($checked_val ='')
$opt_attrs['selected'] = 'selected';
$return .= html_e('option', $opt_attrs,
util_html_secure($text_any), false);
$have_a_subelement = true;
@@ -662,8 +662,9 @@ function html_build_select_box_from_arrays($vals, $texts,
$select_name,
if (!empty($attrs_100)) {
$opt_attrs = array_merge($opt_attrs, $attrs_100);
}
- if ($checked_val)
+ if ($checked_val == '100') {
$opt_attrs['selected'] = 'selected';
+ }
$return .= html_e('option', $opt_attrs,
util_html_secure($text_100), false);
$have_a_subelement = true;
}
-----------------------------------------------------------------------
Summary of changes:
src/common/include/utils.php | 5 +
src/common/tracker/ArtifactExtraField.class.php | 19 +-
.../tracker/ArtifactExtraFieldElement.class.php | 14 +-
src/common/tracker/ArtifactType.class.php | 2 +
src/common/tracker/actions/admin-updates.php | 8 +-
src/common/tracker/actions/detail.php | 4 +-
src/common/tracker/actions/mod-limited.php | 4 +-
src/common/tracker/actions/mod.php | 4 +-
.../tracker/include/ArtifactTypeHtml.class.php | 320 ++++++++++++++-------
src/common/tracker/views/form-addextrafield.php | 88 ++++--
.../tracker/views/form-addextrafieldoption.php | 232 ++++++++-------
src/common/tracker/views/form-updateextrafield.php | 67 ++---
src/www/include/html.php | 5 +-
13 files changed, 473 insertions(+), 299 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits