View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
1133 | RackTables | default | public | 2014-01-10 11:48 | 2014-01-18 20:47 |
Reporter | blaza-pl | Assigned To | adoom42 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 0.20.6 | ||||
Target Version | 0.20.7 | Fixed in Version | 0.20.7 | ||
Summary | 1133: Add Propoerties tab to Row to allow Row to have attributes | ||||
Description | Row as other objects should also have attributes and allow users to modify them. | ||||
Tags | No tags attached. | ||||
row-attributes_interface.php.patch (6,645 bytes)
--- inc/interface.php 2013-06-06 12:25:49.249182131 +0200 +++ inc/interface.php 2013-06-12 12:34:27.565135511 +0200 @@ -614,22 +614,34 @@ $rowInfo = getRowInfo ($row_id); $cellfilter = getCellFilter(); $rackList = filterCellList (listCells ('rack', $row_id), $cellfilter['expression']); + + $summary = array(); + $summary['Name'] = $rowInfo['name']; + if ($rowInfo['location_id']) + $summary['Location'] = mkA ($rowInfo['location'], 'location', $rowInfo['location_id']); + $summary['Racks'] = $rowInfo['count']; + $summary['Units'] = $rowInfo['sum']; + $summary['% used'] = getProgressBar(getRSUforRow($rackList)); + foreach (getAttrValues ($row_id) as $record) + { + if($record['type'] == "hyperlink" ) + { + preg_match('@^(?:http[s]*://)?([^/]+)@i',$record['value'], $matches); + $record['href'] = $record['value']; + $record['a_value'] = $matches[1]; + } + + if(strlen ($record['value']) and permitted (NULL, NULL, NULL, array (array ('tag' => '$attr_' . $record['id'])))) + $summary['{sticker}' . $record['name']] = formatAttributeValue ($record); + } + // Main layout starts. echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; - // Left portlet with row information. echo "<tr><td class=pcleft>"; - startPortlet ($rowInfo['name']); - echo "<table border=0 cellspacing=0 cellpadding=3 width='100%'>\n"; - if ($rowInfo['location_id']) - echo "<tr><th width='50%' class=tdright>Location:</th><td class=tdleft>".mkA ($rowInfo['location'], 'location', $rowInfo['location_id'])."</td></tr>\n"; - echo "<tr><th width='50%' class=tdright>Racks:</th><td class=tdleft>${rowInfo['count']}</td></tr>\n"; - echo "<tr><th width='50%' class=tdright>Units:</th><td class=tdleft>${rowInfo['sum']}</td></tr>\n"; - echo "<tr><th width='50%' class=tdright>% used:</th><td class=tdleft>"; - renderProgressBar (getRSUforRow ($rackList)); - echo "</td></tr>\n"; - echo "</table><br>\n"; - finishPortlet(); + + renderEntitySummary($rowInfo,'Summary',$summary); + renderCellFilterPortlet ($cellfilter, 'rack', $rackList, array ('row_id' => $row_id)); renderFilesPortlet ('row',$row_id); @@ -665,6 +677,96 @@ echo "</td></tr></table>"; } +//Row Properties edit form +function renderRowEditForm($row_id) +{ + global $pageno; + $row = getRowInfo ($row_id); + amplifyCell ($row); + + startPortlet ('Attributes'); + printOpFormIntro ('updateRow'); + echo '<table border=0 align=center>'; + echo "<tr><td> </td><th class=tdright>Location:</th><td class=tdleft>"; + $locations = array (); + $locations[0] = '-- NOT SET --'; + foreach (listCells ('location') as $id => $locationInfo) + $locations[$id] = $locationInfo['name']; + natcasesort($locations); + printSelect ($locations, array ('name' => 'location_id'), $row['location_id']); + echo "</td></tr>\n"; + echo "<tr><td> </td><th class=tdright>Name (required):</th><td class=tdleft><input type=text name=name value='${row['name']}'></td></tr> +\n"; + // optional attributes + $values = getAttrValues ($row_id); + $num_attrs = count($values); + echo "<input type=hidden name=num_attrs value=${num_attrs}>\n"; + $i = 0; + foreach ($values as $record) + { + echo "<input type=hidden name=${i}_attr_id value=${record['id']}>"; + echo '<tr><td>'; + if (strlen ($record['value'])) + { + echo "<a href='".makeHrefProcess(array('op'=>'clearSticker', 'attr_id'=>$record['id']))."'" . + " onclick=\"javascript:return confirm('Are you sure you want to clear attribute value?')\">"; + printImageHREF ('clear', 'Clear value'); + echo '</a>'; + } + else + echo ' '; + echo '</td>'; + echo "<th class=sticker>${record['name']}:</th><td class=tdleft>"; + switch ($record['type']) + { + case 'uint': + case 'float': + case 'string': + case 'hyperlink': + echo "<input type=text name=${i}_value value='${record['value']}'>"; + break; + case 'dict': + $chapter = readChapter ($record['chapter_id'], 'o'); + $chapter[0] = '-- NOT SET --'; + $chapter = cookOptgroups ($chapter, 1562, $record['key']); + printNiftySelect ($chapter, array ('name' => "${i}_value"), $record['key']); + break; + } + echo "</td></tr>\n"; + $i++; + } + + /* + echo "<tr><td> </td><th class=tdright>Has problems:</th><td class=tdleft><input type=checkbox name=has_problems"; + if ($row['has_problems'] == 'yes') + echo ' checked'; + echo "></td></tr>\n"; + */ + + echo "<tr><td> </td><th class=tdright>Actions:</th><td class=tdleft>"; + if ($row['count']) + printImageHREF ('nodestroy', "${row['count']} rack(s) here"); + else + { + echo "<a href=\"" . makeHrefProcess(array('op'=>'deleteRow', 'row_id'=>$row_id)) . "\">"; + printImageHREF ('destroy', 'Delete row'); + echo "</a>"; + } + echo " </td></tr>\n"; + + + //echo "<tr><td colspan=3><b>Comment:</b><br><textarea name=comment rows=10 cols=80>${row['comment']}</textarea></td></tr>"; + echo "<tr><td class=submit colspan=3>"; + printImageHREF ('SAVE', 'Save changes', TRUE); + echo "</td></tr>\n"; + echo '</form></table><br>'; + finishPortlet(); + + startPortlet ('History'); + renderObjectHistory ($row_id); + finishPortlet(); +} + // Used by renderRack() function printObjectDetailsForRenderRack ($object_id) { @@ -4260,7 +4362,6 @@ printImageHREF ('add', '', TRUE); echo ' '; $objtypes = readChapter (CHAP_OBJTYPE, 'o'); - unset ($objtypes[1561]); // attributes may not be assigned to rows yet printNiftySelect (cookOptgroups ($objtypes), array ('name' => 'objtype_id', 'tabindex' => 101)); echo ' <select name=chapter_no tabindex=102><option value=0>-- dictionary chapter for [D] attributes --</option>'; foreach (getChapterList() as $chapter) |
|
row-attributes_navigation.php.patch (1,127 bytes)
--- ../racktables-prod/inc/navigation.php 2013-04-30 11:43:31.985196298 +0200 +++ inc/navigation.php 2013-06-12 12:06:13.061232457 +0200 @@ -100,11 +100,13 @@ $page['row']['bypass_type'] = 'uint'; $page['row']['parent'] = 'rackspace'; $tab['row']['default'] = 'View'; +$tab['row']['edit'] = 'Properties'; $tab['row']['editracks'] = 'Manage racks'; $tab['row']['newrack'] = 'Add new rack'; $tab['row']['tagroller'] = 'Tag roller'; $tab['row']['files'] = 'Files'; $tabhandler['row']['default'] = 'renderRow'; +$tabhandler['row']['edit'] = 'renderRowEditForm'; $tabhandler['row']['editracks'] = 'renderRackSortForm'; $tabhandler['row']['newrack'] = 'renderNewRackForm'; $tabhandler['row']['tagroller'] = 'renderTagRollerForRow'; @@ -114,6 +116,8 @@ $ophandler['row']['files']['addFile'] = 'addFileToEntity'; $ophandler['row']['files']['linkFile'] = 'linkFileToEntity'; $ophandler['row']['files']['unlinkFile'] = 'unlinkFile'; +$ophandler['row']['edit']['deleteRow'] = 'deleteRow'; +$ophandler['row']['edit']['updateRow'] = 'updateRow'; $page['rack']['bypass'] = 'rack_id'; $page['rack']['bypass_type'] = 'uint'; |
|
row-attributes_ophandlers.php.patch (678 bytes)
--- ../racktables-prod/inc/ophandlers.php 2013-06-11 15:01:30.997198478 +0200 +++ inc/ophandlers.php 2013-06-12 12:05:39.305303818 +0200 @@ -1921,10 +1921,18 @@ $msgcode['updateRow']['OK'] = 6; function updateRow () { + global $pageno; + assertUIntArg ('row_id'); assertUIntArg ('location_id', TRUE); assertStringArg ('name'); + if ($pageno = 'row') + { + commitUpdateObject ($_REQUEST['row_id'], $_REQUEST['name'], NULL, NULL, NULL, NULL); + updateObjectAttributes ($_REQUEST['row_id']); + } + else commitUpdateObject ($_REQUEST['row_id'], $_REQUEST['name'], NULL, NULL, NULL, NULL); $rowData = spotEntity ('row', $_REQUEST['row_id']); |
|
Thanks for the patch. I excluded code related to 'hyperlink' attributes as those don't exist in the mainstream distro. | |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-01-10 11:48 | blaza-pl | New Issue | |
2014-01-10 11:48 | blaza-pl | File Added: row-attributes_interface.php.patch | |
2014-01-10 11:49 | blaza-pl | File Added: row-attributes_navigation.php.patch | |
2014-01-10 11:49 | blaza-pl | File Added: row-attributes_ophandlers.php.patch | |
2014-01-18 20:47 | adoom42 | Note Added: 0002083 | |
2014-01-18 20:47 | adoom42 | Assigned To | => adoom42 |
2014-01-18 20:47 | adoom42 | Status | new => closed |
2014-01-18 20:47 | adoom42 | Resolution | open => fixed |
2014-01-18 20:47 | adoom42 | Fixed in Version | => 0.20.7 |
2014-01-18 20:47 | adoom42 | Target Version | => 0.20.7 |