mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-16 22:08:44 +02:00
N°931 TagSet widget enabling / disabling in bulk edit
- rename ToogleField -> ToggleField - for the set input, use the same ID as other fields (used by ToggleField method) - disable the set widget if needed on opening - binds the update event to enable / disable at will
This commit is contained in:
@@ -2043,9 +2043,9 @@ EOF
|
||||
|
||||
/** @var \ormSet $value */
|
||||
$sJson = $oAttDef->GetJsonForWidget($value, $aArgs);
|
||||
$sInputId = "attr_{$sFormPrefix}{$sAttCode}";
|
||||
$sHTMLValue = "<div class=\"field_input_zone field_input_set\"><input id='$sInputId' name='$sInputId' type='hidden' value='$sJson'></div>{$sValidationSpan}{$sReloadSpan}";
|
||||
$sScript = "$('#$sInputId').set_widget();";
|
||||
$sSetInputName = "attr_{$sFormPrefix}{$sAttCode}";
|
||||
$sHTMLValue = "<div class=\"field_input_zone field_input_set\"><input id='$iId' name='$sSetInputName' type='hidden' value='$sJson'></div>{$sValidationSpan}{$sReloadSpan}";
|
||||
$sScript = "$('#$iId').set_widget();";
|
||||
$oPage->add_ready_script($sScript);
|
||||
break;
|
||||
|
||||
@@ -3978,7 +3978,7 @@ EOF
|
||||
}
|
||||
}
|
||||
// Now create an object that has values for the homogeneous values only
|
||||
/** @var DBObject $oDummyObj */
|
||||
/** @var \cmdbAbstractObject $oDummyObj */
|
||||
$oDummyObj = new $sClass(); // @@ What if the class is abstract ?
|
||||
$aComments = array();
|
||||
function MyComparison($a, $b) // Sort descending
|
||||
@@ -4021,9 +4021,9 @@ EOF
|
||||
$sReadyScript .= "$('#multi_values_$sAttCode').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );";
|
||||
|
||||
$oDummyObj->Set($sAttCode, null);
|
||||
$aComments[$sAttCode] = '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToogleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
$aComments[$sAttCode] = '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
$aComments[$sAttCode] .= '<div class="multi_values" id="multi_values_'.$sAttCode.'"> ? </div>';
|
||||
$sReadyScript .= 'ToogleField(false, \''.$iFormId.'_'.$sAttCode.'\');'."\n";
|
||||
$sReadyScript .= 'ToggleField(false, \''.$iFormId.'_'.$sAttCode.'\');'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4039,7 +4039,7 @@ EOF
|
||||
$aComments[$sAttCode] = '';
|
||||
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass))
|
||||
{
|
||||
$aComments[$sAttCode] .= '<input type="checkbox" checked id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToogleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
$aComments[$sAttCode] .= '<input type="checkbox" checked id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
}
|
||||
$aComments[$sAttCode] .= '<div class="mono_value">1</div>';
|
||||
}
|
||||
@@ -4098,11 +4098,11 @@ EOF
|
||||
$aComments[$sAttCode] = '';
|
||||
if ($sAttCode != MetaModel::GetStateAttributeCode($sClass))
|
||||
{
|
||||
$aComments[$sAttCode] .= '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToogleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
$aComments[$sAttCode] .= '<input type="checkbox" id="enable_'.$iFormId.'_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$iFormId.'_'.$sAttCode.'\')"/>';
|
||||
}
|
||||
$aComments[$sAttCode] .= '<div class="multi_values" id="multi_values_'.$sAttCode.'">'.$iCount.'</div>';
|
||||
}
|
||||
$sReadyScript .= 'ToogleField('.(($iCount == 1) ? 'true' : 'false').', \''.$iFormId.'_'.$sAttCode.'\');'."\n";
|
||||
$sReadyScript .= 'ToggleField('.(($iCount == 1) ? 'true' : 'false').', \''.$iFormId.'_'.$sAttCode.'\');'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ $.widget('itop.set_widget',
|
||||
|
||||
this._initWidgetData($this.val());
|
||||
this._generateSelectionWidget($this);
|
||||
this._bindEvents($this);
|
||||
},
|
||||
|
||||
// events bound via _bind are removed automatically
|
||||
@@ -112,10 +113,14 @@ $.widget('itop.set_widget',
|
||||
|
||||
_generateSelectionWidget: function ($widgetElement) {
|
||||
var $parentElement = $widgetElement.parent(),
|
||||
isWidgetElementDisabled = $widgetElement.prop("disabled"),
|
||||
inputId = $widgetElement.attr("id") + "-setwidget-values";
|
||||
|
||||
$parentElement.append("<input id='" + inputId + "' value='" + this.originalValue.join(" ") + "'>");
|
||||
var $inputWidget = $("#" + inputId);
|
||||
if (isWidgetElementDisabled) {
|
||||
$inputWidget.prop("disabled", true);
|
||||
}
|
||||
|
||||
// create closure to have both set widget and Selectize instances available in callbacks
|
||||
// selectize instance could also be retrieve on the source input DOM node (selectize property)
|
||||
@@ -150,6 +155,19 @@ $.widget('itop.set_widget',
|
||||
this.selectizeWidget = $inputWidget[0].selectize; // keeping this for set widget public methods
|
||||
},
|
||||
|
||||
_bindEvents: function($widgetElement) {
|
||||
var setWidget = this;
|
||||
$widgetElement.bind("update", function() {
|
||||
console.debug("update event in Selectize !", this);
|
||||
var $this = $(this);
|
||||
if ($this.prop("disabled")) {
|
||||
setWidget.disable();
|
||||
} else {
|
||||
setWidget.enable();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function () {
|
||||
if (this.options.isDebug) {
|
||||
console.debug("refresh");
|
||||
@@ -188,6 +206,7 @@ $.widget('itop.set_widget',
|
||||
/**
|
||||
* <p>Updating selection widget :
|
||||
* <ul>
|
||||
* <li>handles bulk edit disabling on widget opening
|
||||
* <li>adding specific CSS class to parent node
|
||||
* <li>adding specific CSS classes to item node
|
||||
* <li>items to have a specific rendering for partial codes.
|
||||
@@ -205,6 +224,10 @@ $.widget('itop.set_widget',
|
||||
console.debug("onInit", inputWidget, setWidget);
|
||||
}
|
||||
|
||||
if (inputWidget.$input.prop("disabled")) {
|
||||
inputWidget.disable(); // can't use this.selectizeWidget for now
|
||||
}
|
||||
|
||||
inputWidget.$control.addClass(setWidget.PARENT_CSS_CLASS);
|
||||
|
||||
inputWidget.items.forEach(function (setItemCode) {
|
||||
|
||||
@@ -356,7 +356,7 @@ function CheckAll(sSelector, bValue) {
|
||||
/**
|
||||
* Toggle (enabled/disabled) the specified field of a form
|
||||
*/
|
||||
function ToogleField(value, field_id) {
|
||||
function ToggleField(value, field_id) {
|
||||
if (value) {
|
||||
$('#'+field_id).prop('disabled', false);
|
||||
// In case the field is rendered as a div containing several inputs (e.g. RedundancySettings)
|
||||
@@ -410,7 +410,7 @@ function PropagateCheckBox(bCurrValue, aFieldsList, bCheck) {
|
||||
if (bCurrValue == bCheck) {
|
||||
for (var i = 0; i < aFieldsList.length; i++) {
|
||||
$('#enable_'+aFieldsList[i]).prop('checked', bCheck);
|
||||
ToogleField(bCheck, aFieldsList[i]);
|
||||
ToggleField(bCheck, aFieldsList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1244,7 +1244,7 @@ EOF
|
||||
}
|
||||
$aArgs = array('this' => $oObj);
|
||||
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oP, $sClass, $sAttCode, $oAttDef, $oObj->Get($sAttCode), $oObj->GetEditValue($sAttCode), $sAttCode, '', $iExpectCode, $aArgs);
|
||||
$sComments = '<input type="checkbox" checked id="enable_'.$sAttCode.'" onClick="ToogleField(this.checked, \''.$sAttCode.'\')"/>';
|
||||
$sComments = '<input type="checkbox" checked id="enable_'.$sAttCode.'" onClick="ToggleField(this.checked, \''.$sAttCode.'\')"/>';
|
||||
if (!isset($aValues[$sAttCode]))
|
||||
{
|
||||
$aValues[$sAttCode] = array();
|
||||
|
||||
Reference in New Issue
Block a user