diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 9a7b9c2ef..7423f2cb1 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -201,7 +201,7 @@ abstract class cmdbAbstractObject extends CMDBObject $sLinkedClass = $oAttDef->GetLinkedClass(); $oLinkingAttDef = MetaModel::GetAttributeDef($sLinkedClass, $oAttDef->GetExtKeyToRemote()); $sTargetClass = $oLinkingAttDef->GetTargetClass(); - $oPage->p(MetaModel::GetClassIcon($sTargetClass)." ".$oAttDef->GetDescription()); + $oPage->p(MetaModel::GetClassIcon($sTargetClass)." ".$oAttDef->GetDescription().''); $sValue = $this->Get($sAttCode); $sDisplayValue = $this->GetEditValue($sAttCode); diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php index 4cec00017..d9aec58a7 100644 --- a/application/ui.linkswidget.class.inc.php +++ b/application/ui.linkswidget.class.inc.php @@ -37,7 +37,6 @@ class UILinksWidget protected $m_sLinkedClass; protected $m_sRemoteClass; protected $m_bDuplicatesAllowed; - protected static $iWidgetIndex = 0; public function __construct($sClass, $sAttCode, $iInputId, $sNameSuffix = '', $bDuplicatesAllowed = false) { @@ -47,7 +46,6 @@ class UILinksWidget $this->m_iInputId = $iInputId; $this->m_bDuplicatesAllowed = $bDuplicatesAllowed; $this->m_aEditableFields = array(); - self::$iWidgetIndex++; $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode); $this->m_sLinkedClass = $oAttDef->GetLinkedClass(); @@ -60,7 +58,7 @@ class UILinksWidget $this->m_aEditableFields = array(); $this->m_aTableConfig = array(); - $this->m_aTableConfig['form::checkbox'] = array( 'label' => "m_sAttCode}{$this->m_sNameSuffix} .selection', this.checked); oWidget".self::$iWidgetIndex.".OnSelectChange();\">", 'description' => Dict::S('UI:SelectAllToggle+')); + $this->m_aTableConfig['form::checkbox'] = array( 'label' => "m_sAttCode}{$this->m_sNameSuffix} .selection', this.checked); oWidget".$this->m_iInputId.".OnSelectChange();\">", 'description' => Dict::S('UI:SelectAllToggle+')); foreach(MetaModel::ListAttributeDefs($this->m_sLinkedClass) as $sAttCode=>$oAttDef) { @@ -109,7 +107,7 @@ class UILinksWidget $sPrefix .= "[$key]["; $sNameSuffix = "]"; // To make a tabular form $aArgs['prefix'] = $sPrefix; - $aRow['form::checkbox'] = ""; + $aRow['form::checkbox'] = "m_iInputId.".OnSelectChange();\" value=\"$key\">"; $aRow['form::checkbox'] .= ""; foreach($this->m_aEditableFields as $sFieldCode) { @@ -123,7 +121,7 @@ class UILinksWidget $sPrefix .= "[$linkObjOrId]["; $sNameSuffix = "]"; // To make a tabular form $aArgs['prefix'] = $sPrefix; - $aRow['form::checkbox'] = ""; + $aRow['form::checkbox'] = "m_iInputId.".OnSelectChange();\" value=\"$linkObjOrId\">"; $aRow['form::checkbox'] .= ""; foreach($this->m_aEditableFields as $sFieldCode) { @@ -209,7 +207,6 @@ class UILinksWidget */ public function Display(WebPage $oPage, DBObjectSet $oValue, $aArgs = array()) { - $iWidgetIndex = self::$iWidgetIndex; $sHtmlValue = ''; $sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode); $sHtmlValue .= "
m_sAttCode}{$this->m_sNameSuffix}\">\n"; @@ -226,12 +223,12 @@ class UILinksWidget $sHtmlValue .= $this->DisplayFormTable($oPage, $this->m_aTableConfig, $aForm); $sDuplicates = ($this->m_bDuplicatesAllowed) ? 'true' : 'false'; $oPage->add_ready_script(<<m_sAttCode}{$this->m_sNameSuffix}', '{$this->m_sClass}', '{$this->m_sAttCode}', '{$this->m_iInputId}', '{$this->m_sNameSuffix}', $sDuplicates); - oWidget$iWidgetIndex.Init(); + oWidget{$this->m_iInputId} = new LinksWidget('{$this->m_sAttCode}{$this->m_sNameSuffix}', '{$this->m_sClass}', '{$this->m_sAttCode}', '{$this->m_iInputId}', '{$this->m_sNameSuffix}', $sDuplicates); + oWidget{$this->m_iInputId}.Init(); EOF ); - $sHtmlValue .= "     m_sAttCode}{$this->m_sNameSuffix}_btnRemove\" type=\"button\" value=\"".Dict::S('UI:RemoveLinkedObjectsOf_Class')."\" onClick=\"oWidget$iWidgetIndex.RemoveSelected();\" >"; - $sHtmlValue .= "   m_sAttCode}{$this->m_sNameSuffix}_btnAdd\" type=\"button\" value=\"".Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sRemoteClass))."\" onClick=\"oWidget$iWidgetIndex.AddObjects();\">\n"; + $sHtmlValue .= "     m_sAttCode}{$this->m_sNameSuffix}_btnRemove\" type=\"button\" value=\"".Dict::S('UI:RemoveLinkedObjectsOf_Class')."\" onClick=\"oWidget{$this->m_iInputId}.RemoveSelected();\" >"; + $sHtmlValue .= "   m_sAttCode}{$this->m_sNameSuffix}_btnAdd\" type=\"button\" value=\"".Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sRemoteClass))."\" onClick=\"oWidget{$this->m_iInputId}.AddObjects();\">\n"; $sHtmlValue .= "

 

\n"; $sHtmlValue .= "
\n"; $oPage->add_at_the_end($this->GetObjectPickerDialog($oPage)); // To prevent adding forms inside the main form @@ -348,12 +345,11 @@ EOF { $sHtml = "
m_sAttCode}{$this->m_sNameSuffix}\">"; $sHtml .= "
\n"; - $iWidgetIndex = self::$iWidgetIndex; $oFilter = new DBObjectSearch($this->m_sRemoteClass); $oSet = new CMDBObjectSet($oFilter); $oBlock = new DisplayBlock($oFilter, 'search', false); $sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", array('open' => true)); - $sHtml .= "
m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget$iWidgetIndex.DoAddObjects(this.id);\">\n"; + $sHtml .= "m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\">\n"; $sHtml .= "
m_sAttCode}{$this->m_sNameSuffix}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n"; $sHtml .= "

".Dict::S('UI:Message:EmptyList:UseSearchForm')."

\n"; $sHtml .= "
\n"; @@ -361,10 +357,10 @@ EOF $sHtml .= "
\n"; $sHtml .= "\n"; $sHtml .= "
\n"; - $oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oWidget$iWidgetIndex.UpdateSizes });"); + $oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oWidget{$this->m_iInputId}.UpdateSizes });"); $oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".addslashes(Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass)))."'});"); - $oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix} form').bind('submit.uilinksWizard', oWidget$iWidgetIndex.SearchObjectsToAdd);"); - $oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}').resize(oWidget$iWidgetIndex.UpdateSizes);"); + $oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix} form').bind('submit.uilinksWizard', oWidget{$this->m_iInputId}.SearchObjectsToAdd);"); + $oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}').resize(oWidget{$this->m_iInputId}.UpdateSizes);"); return $sHtml; } diff --git a/js/linkswidget.js b/js/linkswidget.js index e137ab97b..4102e0c4a 100644 --- a/js/linkswidget.js +++ b/js/linkswidget.js @@ -93,6 +93,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates) theMap.operation = 'searchObjectsToAdd'; // Override what is defined in the form itself sSearchAreaId = '#SearchResultsToAdd_'+me.id; + $(sSearchAreaId).block(); // Run the query and display the results $.post( 'ajax.render.php', theMap, @@ -101,7 +102,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates) $(sSearchAreaId).html(data); $(sSearchAreaId+' .listResults').tableHover(); $(sSearchAreaId+' .listResults').tablesorter( { headers: {0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables - + $(sSearchAreaId).unblock(); }, 'html' ); @@ -144,7 +145,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates) } ); theMap['operation'] = 'doAddObjects'; - + $('#busy_'+me.iInputId).html(' '); // Run the query and display the results $.post( 'ajax.render.php', theMap, function(data) @@ -158,6 +159,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix, bDuplicates) $('#linkedset_'+me.id+' .listResults').tableHover(); $('#linkedset_'+me.id+' .listResults').trigger('update').trigger("applyWidgets"); // table is already sortable, just refresh it $('#linkedset_'+me.id+' :input').each( function() { $(this).trigger('validate', ''); }); // Validate newly added form fields... + $('#busy_'+me.iInputId).html(''); } }, 'html'