- New implementation of the n-n link edition widget... almost complete.

SVN:trunk[659]
This commit is contained in:
Denis Flaven
2010-08-05 09:07:14 +00:00
parent 422ac56260
commit 279e0238cb
9 changed files with 74 additions and 56 deletions

View File

@@ -1050,7 +1050,15 @@ abstract class cmdbAbstractObject extends CMDBObject
$iKey = $this->GetKey();
$aDetails = array();
$aFieldsMap = array();
$oPage->add("<form id=\"form_{$this->m_iFormId}\" enctype=\"multipart/form-data\" method=\"post\" onSubmit=\"return CheckFields('form_{$this->m_iFormId}', true)\">\n");
if (!isset($aExtraParams['action']))
{
$sFormAction = $_SERVER['SCRIPT_NAME']; // No parameter in the URL, the only parameter will be the ones passed through the form
}
else
{
$sFormAction = $aExtraParams['action'];
}
$oPage->add("<form action=\"$sFormAction\" id=\"form_{$this->m_iFormId}\" enctype=\"multipart/form-data\" method=\"post\" onSubmit=\"return CheckFields('form_{$this->m_iFormId}', true)\">\n");
$oPage->AddTabContainer(OBJECT_PROPERTIES_TAB);
$oPage->SetCurrentTabContainer(OBJECT_PROPERTIES_TAB);

View File

@@ -571,9 +571,14 @@ class DisplayBlock
static $iSearchSectionId = 1;
$sStyle = (isset($aExtraParams['open']) && ($aExtraParams['open'] == 'true')) ? 'SearchDrawer' : 'SearchDrawer DrawerClosed';
$sHtml .= "<div id=\"Search_$iSearchSectionId\" class=\"$sStyle\">\n";
$oPage->add_ready_script("\$(\"#LnkSearch_$iSearchSectionId\").click(function() {\n" .
" \$(\"#Search_$iSearchSectionId\").slideToggle('normal');\n" .
" $(\"#LnkSearch_$iSearchSectionId\").toggleClass('open');});");
$oPage->add_ready_script(
<<<EOF
$("#LnkSearch_$iSearchSectionId").click( function() {
$("#Search_$iSearchSectionId").slideToggle('normal', function() { $("#Search_$iSearchSectionId").parent().resize(); } );
$("#LnkSearch_$iSearchSectionId").toggleClass('open');
});
EOF
);
$sHtml .= cmdbAbstractObject::GetSearchForm($oPage, $this->m_oSet, $aExtraParams);
$sHtml .= "</div>\n";
$sHtml .= "<div class=\"HRDrawer\"></div>\n";

View File

@@ -76,6 +76,8 @@ class UILinksWidget
}
}
}
$this->m_aTableConfig['static::key'] = array( 'label' => MetaModel::GetName($this->m_sRemoteClass), 'description' => MetaModel::GetClassDescription($this->m_sRemoteClass));
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
{
// TO DO: check the state of the attribute: hidden or visible ?
@@ -127,6 +129,7 @@ class UILinksWidget
}
}
$aRow['static::key'] = $oLinkedObj->GetHyperLink();
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
{
$aRow['static::'.$sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
@@ -342,12 +345,7 @@ EOF
protected function GetObjectPickerDialog($oPage)
{
$sHtml = "<div id=\"dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}\">";
//$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
$sHtml .= "<div class=\"wizContainer\">\n";
//$sHtml .= "<div class=\"page_header\">\n");
//$sHtml .= "<h1>".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."</h1>\n");
//$sHtml .= "</div>\n");
$sHtml .= "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
$oContext = new UserContext();
$iWidgetIndex = self::$iWidgetIndex;
$oFilter = $oContext->NewFilter($this->m_sRemoteClass);
@@ -355,16 +353,17 @@ EOF
$oBlock = new DisplayBlock($oFilter, 'search', false);
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", array('open' => true));
$sHtml .= "<form id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget$iWidgetIndex.DoAddObjects(this.id);\">\n";
$sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
$sHtml .= "<div style=\"height: 100px; background: #fff;border-color:#F6F6F1 #E6E6E1 #E6E6E1 #F6F6F1; border-style:solid; border-width:3px; text-align: center; vertical-align: center;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
$sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
$sHtml .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
$sHtml .= "</div>\n";
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\">&nbsp;&nbsp;<input type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">";
$sHtml .= "</div>\n";
$sHtml .= "</form>\n";
$sHtml .= "</div>\n";
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ autoOpen: false, modal: true });");
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass), "<span class=\"hilite\"> ZZZZ </span>")."'});");
$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('option', {title:'".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);");
return $sHtml;
}

View File

@@ -129,7 +129,7 @@ tr.clicked td {
td.label {
font-family: Tahoma, Verdana, Arial, Helvetica;
font-size: 8pt;
font-size: 12px;
color: #000000;
background-color:#f6f6f6;
padding: 0.25em;
@@ -161,33 +161,15 @@ td a.no-arrow:hover {
padding-left:0px;
background: inherit;
}
a.small_action {
font-family: Tahoma, Verdana, Arial, Helvetica;
font-size: 8pt;
color: #000000;
text-decoration:none;
}
.display_block {
noborder: 1px dashed #CCC;
padding:0.25em;
}
div#TopPane .display_block {
background: #fff;
padding:0.25em;
text-align:center;
}
div#TopPane label {
color:#000;
background: #fff;
}
div#TopPane td {
color:#000;
background: #fff;
}
.actions_details {
float:right;
margin-top:10px;
@@ -197,7 +179,6 @@ div#TopPane td {
padding-bottom: 2px;
background: url(../images/actions_left.png) no-repeat left;
}
.actions_details span{
background: url(../images/actions_right.png) no-repeat right;
color: #fff;
@@ -218,6 +199,7 @@ div#TopPane td {
input.textSearch {
border:1px solid #000;
font-family:Tahoma,Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color:#000000;
}
@@ -581,16 +563,11 @@ input.dp-applied {
color: #000;
padding: 10px;
margin: 0;
}
.SearchDrawer form table tbody tr td {
background: #d6e8ef;
color: #fff;
font-size: 10pt;
font-size: 12px;
}
.SearchDrawer label {
background: #d6e8ef;
color: #000;
padding-left: 10px;
}
.SearchDrawer h1 {
color: #000;
@@ -612,6 +589,7 @@ input.dp-applied {
margin-top: 0;
margin-bottom: 0;
display: block;
font-size: 12px;
}
div.HRDrawer {

View File

@@ -560,6 +560,7 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:Link_Class_Attributes' => '%1$s attributes',
'UI:SelectAllToggle+' => 'Select All / Deselect All',
'UI:AddObjectsOf_Class_LinkedWith_Class_Instance' => 'Add %1$s objects linked with %2$s: %3$s',
'UI:AddObjectsOf_Class_LinkedWith_Class' => 'Add %1$s objects to link with the %2$s',
'UI:ManageObjectsOf_Class_LinkedWith_Class_Instance' => 'Manage %1$s objects linked with %2$s: %3$s',
'UI:AddLinkedObjectsOf_Class' => 'Add %1$ss...',
'UI:RemoveLinkedObjectsOf_Class' => 'Remove selected objects',

View File

@@ -563,6 +563,7 @@ Dict::Add('FR FR', 'French', 'Français', array(
'UI:Link_Class_Attributes' => 'Attributs du type %1$s',
'UI:SelectAllToggle+' => 'Tout sélectionner / Tout déselectionner',
'UI:AddObjectsOf_Class_LinkedWith_Class_Instance' => 'Ajouter des objets de type %1$s liés à %3$s (%2$s)',
'UI:AddObjectsOf_Class_LinkedWith_Class' => 'Ajouter des objets de type %1$s à lier à cet objet de type %2$s',
'UI:ManageObjectsOf_Class_LinkedWith_Class_Instance' => 'Gérer les objets de type %1$s liés à %3$s (%2$s)',
'UI:AddLinkedObjectsOf_Class' => 'Ajouter des objets de type %1$s...',
'UI:RemoveLinkedObjectsOf_Class' => 'Enlever les objets sélectionnés',

View File

@@ -56,9 +56,8 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix)
this.AddObjects = function()
{
//$('#dlg_'+this.id).hide();
$('#dlg_'+me.id).dialog('open');
//alert('Not Yet Implemented !');
this.UpdateSizes(null, null);
}
this.SearchObjectsToAdd = function()
@@ -153,6 +152,7 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix)
$('#linkedset_'+me.id+' .listResults tbody').append(data);
$('#linkedset_'+me.id+' .listResults').trigger('update');
$('#linkedset_'+me.id+' .listResults').tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra']} ); // sortable and zebra tables
$('#linkedset_'+me.id+' :input').each( function() { $(this).trigger('validate', ''); }); // Validate newly added form fields...
}
},
'html'
@@ -160,4 +160,22 @@ function LinksWidget(id, sClass, sAttCode, iInputId, sSuffix)
$('#dlg_'+me.id).dialog('close');
return false;
}
this.UpdateSizes = function(event, ui)
{
var dlg = $('#dlg_'+me.id);
var searchForm = $('#SearchFormToAdd_'+me.id);
var results = $('#SearchResultsToAdd_'+me.id);
padding_right = parseInt(dlg.css('padding-right').replace('px', ''));
padding_left = parseInt(dlg.css('padding-left').replace('px', ''));
padding_top = parseInt(dlg.css('padding-top').replace('px', ''));
padding_bottom = parseInt(dlg.css('padding-bottom').replace('px', ''));
width = dlg.innerWidth() - padding_right - padding_left - 22; // 5 (margin-left) + 5 (padding-left) + 5 (padding-right) + 5 (margin-right) + 2 for rounding !
height = dlg.innerHeight() - padding_top - padding_bottom -22;
wizard = dlg.find('.wizContainer:first');
wizard.width(width);
wizard.height(height);
form_height = searchForm.outerHeight();
results.height(height - form_height - 40); // Leave some space for the buttons
}
}

View File

@@ -56,38 +56,40 @@ function UpdateFileName(id, sNewFileName)
*/
function ReloadSearchForm(divId, sClassName, sBaseClass)
{
$('#'+divId).block();
var formEvents = $('#'+divId+' form').data('events');
var bSubmitHookIsUsed = false;
var oDiv = $('#'+divId);
oDiv.block();
var oFormEvents = $('#'+divId+' form').data('events');
// Save the submit handlers
aSubmit = new Array();
if ( (formEvents != null) && (formEvents.submit != undefined))
if ( (oFormEvents != null) && (oFormEvents.submit != undefined))
{
aSubmit = formEvents.submit;
aSubmit = oFormEvents.submit;
}
$.post('ajax.render.php',
{ operation: 'search_form', className: sClassName, baseClass: sBaseClass, currentId: divId },
function(data){
$('#'+divId).empty();
$('#'+divId).append(data);
if (aSubmit.length > 0)
{
function(data) {
oDiv.empty();
oDiv.append(data);
if (aSubmit.length > 0)
{
var oForm = $('#'+divId+' form'); // Form was reloaded, recompute it
for(index = 0; index < aSubmit.length; index++)
{
// Restore the previously bound submit handlers
if (aSubmit[index].data != undefined)
{
$('#'+divId+' form').bind('submit.'+aSubmit[index].namespace, aSubmit[index].data, aSubmit[index].handler)
oForm.bind('submit.'+aSubmit[index].namespace, aSubmit[index].data, aSubmit[index].handler)
}
else
{
$('#'+divId+' form').bind('submit.'+aSubmit[index].namespace, aSubmit[index].handler)
oForm.bind('submit.'+aSubmit[index].namespace, aSubmit[index].handler)
}
}
}
$('#'+divId).unblock();
}
oDiv.unblock();
oDiv.parent().resize(); // Inform the parent that the form has just been (potentially) resized
}
);
}

View File

@@ -68,6 +68,7 @@ switch($operation)
$oLinksWizard->DisplayAddForm($oPage, $oContext);
break;
// ui.linkswidget
case 'searchObjectsToAdd':
$sRemoteClass = utils::ReadParam('sRemoteClass', '');
$sAttCode = utils::ReadParam('sAttCode', '');
@@ -78,6 +79,7 @@ switch($operation)
$oWidget->SearchObjectsToAdd($oPage, $oContext, $sRemoteClass, $aAlreadyLinked);
break;
// ui.linkswidget
case 'doAddObjects':
$sAttCode = utils::ReadParam('sAttCode', '');
$iInputId = utils::ReadParam('iInputId', '');
@@ -223,15 +225,18 @@ switch($operation)
break;
case 'ui.linkswidget':
/*
$sClass = utils::ReadParam('sclass', 'bizContact');
$sAttCode = utils::ReadParam('attCode', 'name');
$sOrg = utils::ReadParam('org_id', '');
$sName = utils::ReadParam('q', '');
$iMaxCount = utils::ReadParam('max', 30);
UILinksWidget::Autocomplete($oPage, $oContext, $sClass, $sAttCode, $sName, $iMaxCount);
*/
break;
case 'ui.linkswidget.linkedset':
/*
$sClass = utils::ReadParam('sclass', 'bizContact');
$sJSONSet = stripslashes(utils::ReadParam('sset', ''));
$sExtKeyToMe = utils::ReadParam('sextkeytome', '');
@@ -240,6 +245,7 @@ switch($operation)
UILinksWidget::RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId);
$iFieldId = utils::ReadParam('myid', '-1');
$oPage->add_ready_script("$('#{$iFieldId}').trigger('validate');");
*/
break;
case 'autocomplete':