Permalink
Browse files

port to jqgrid

  • Loading branch information...
flack committed Aug 20, 2018
1 parent 7aea282 commit 8499670daebd96a37a8bf15fbc58b2dd0b781ad0
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
use midcom\grid\provider;
/**
* Welcome interface
*
@@ -88,14 +90,12 @@ public function _handler_welcome($handler_id, array $args, array &$data)
$data['view_title'] = $this->_l10n->get('asgard');
if ( isset($_POST['execute_mass_action'])
&& !empty($_POST['selections'])
&& isset($_POST['mass_action'])) {
$method_name = "_mass_{$_POST['mass_action']}";
$this->$method_name($_POST['selections']);
if ( !empty($_POST['action'])
&& !empty($_POST['entries'])) {
$method_name = "_mass_{$_POST['action']}";
$this->$method_name($_POST['entries']);
}
$data['revised'] = [];
if (isset($_REQUEST['revised_after'])) {
$data['revised_after'] = $_REQUEST['revised_after'];
if ($data['revised_after'] != 'any') {
@@ -127,9 +127,15 @@ public function _handler_welcome($handler_id, array $args, array &$data)
$this->_prepare_tabledata($objects);
midcom::get()->head->add_jsfile(MIDCOM_STATIC_URL . '/jQuery/jquery.tablesorter.pack.js');
midcom::get()->head->add_jsfile(MIDCOM_STATIC_URL . '/midgard.admin.asgard/jquery.batch_process.js');
$this->add_stylesheet(MIDCOM_STATIC_URL . '/midgard.admin.asgard/tablewidget.css');
$data['action_options'] = [
'none' => ['label' => $this->_l10n->get('apply to selected')],
'delete' => [
'label' => $this->_l10n_midcom->get('delete'),
],
'approve' => [
'label' => $this->_l10n_midcom->get('approve'),
]
];
$this->_populate_toolbar();
return new midgard_admin_asgard_response($this, '_show_welcome');
@@ -164,23 +170,24 @@ private function _load_activities()
private function _prepare_tabledata(array $objects)
{
$this->_request_data['revised'] = [];
$rows = [];
foreach ($objects as $data) {
$object = $data['object'];
$reflector = midcom_helper_reflector::get($object);
$row = [
'icon' => $reflector->get_object_icon($object),
'revision' => $object->metadata->revision,
'revised' => $object->metadata->revised,
'guid' => $object->guid,
'class' => get_class($object)
'id' => $object->guid,
'class' => get_class($object),
];
$row['approved'] = ($object->is_approved()) ? strftime('%x %X', $object->metadata->approved) : $this->_l10n->get('not approved');
$title = substr($reflector->get_object_label($object), 0, 60);
$row['title'] = ($title) ?: '[' . $this->_l10n->get('no title') . ']';
$title = $reflector->get_object_label($object);
$link = $this->router->generate('object_' . $this->_request_data['default_mode'], ['guid' => $object->guid]);
$row['index_title'] = ($title) ?: '[' . $this->_l10n->get('no title') . ']';
$row['title'] = '<a href="' . $link . '" title="' . $row['class'] . '">' . $reflector->get_object_icon($object) . ' ' . $row['index_title'] . '</a>';
if (empty($data['revisor'])) {
$row['revisor'] = $this->_l10n_midcom->get('unknown');
@@ -196,8 +203,10 @@ private function _prepare_tabledata(array $objects)
$row['review_date'] = strftime('%x', $review_date);
}
}
$this->_request_data['revised'][] = $row;
$rows[] = $row;
}
$provider = new provider($rows, 'local');
$this->_request_data['grid'] = $provider->get_grid('revised');
}
private function _populate_toolbar()
@@ -103,76 +103,29 @@
</div>
<h2><?php echo $data['l10n']->get('recent changes'); ?></h2>
<form name="latest_objects_mass_action" method="post">
<table class="results table_widget" id="batch_process">
<thead>
<tr>
<th class="selection">&nbsp;</th>
<th class="icon">&nbsp;</th>
<th class="title"><?php echo $data['l10n_midcom']->get('title'); ?></th>
<?php
if ($data['config']->get('enable_review_dates')) {
echo " <th class=\"review_by\">" . $data['l10n']->get('review date') . "</th>\n";
} ?>
<?php
$grid_id = $data['grid']->get_identifier();
$data['grid']->set_column('title', $data['l10n_midcom']->get('title'), 'width: 150', 'string');
<th class="revised"><?php echo midcom::get()->i18n->get_string('revised', 'midcom.admin.folder'); ?></th>
<th class="revisor"><?php echo midcom::get()->i18n->get_string('revisor', 'midcom.admin.folder'); ?></th>
<th class="approved"><?php echo $data['l10n_midcom']->get('approved'); ?></th>
<th class="revision"><?php echo midcom::get()->i18n->get_string('revision', 'midcom.admin.folder'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<label for="select_all">
<input type="checkbox" name="select_all" id="select_all" value="" onclick="jQuery(this).check_all('#batch_process tbody');" /><?php echo $data['l10n']->get('select all');?>
</label>
<label for="invert_selection">
<input type="checkbox" name="invert_selection" id="invert_selection" value="" onclick="jQuery(this).invert_selection('#batch_process tbody');" /><?php echo $data['l10n']->get('invert selection'); ?>
</label>
</td>
</tr>
</tfoot>
<tbody>
<?php
foreach ($data['revised'] as $row) {
$link = $data['router']->generate('object_' . $data['default_mode'], ['guid' => $row['guid']]);
if ($data['config']->get('enable_review_dates')) {
$data['grid']->set_column('review_date', $data['l10n_midcom']->get('review date'));
}
$data['grid']->set_column('revised', midcom::get()->i18n->get_string('revised', 'midcom.admin.folder'), 'fixed: true, width: 180, align: "center", formatter: "date", formatoptions: {srcformat: "U", newformat: "ISO8601Long"}')
->set_column('revisor', midcom::get()->i18n->get_string('revisor', 'midcom.admin.folder'), 'width: 70')
->set_column('approved', $data['l10n_midcom']->get('approved'), 'width: 50')
->set_column('revision', midcom::get()->i18n->get_string('revision', 'midcom.admin.folder'), 'fixed: true, width: 95, template: "integer"')
echo " <tr>\n";
echo " <td class=\"selection\"><input type=\"checkbox\" name=\"selections[]\" value=\"{$row['guid']}\" /></td>\n";
echo " <td class=\"icon\">" . $row['icon'] . "</td>\n";
echo " <td class=\"title\"><a href=\"{$link}\" title=\"{$row['class']}\">" . $row['title'] . "</a></td>\n";
->set_option('multiselect', true);
if (isset($row['review_date'])) {
echo " <td class=\"review_by\">" . $row['review_date'] . "</td>\n";
}
$data['grid']->render();
?>
<form id="form_&(grid_id);" method="post" action="">
</form>
echo " <td class=\"revised\">" . strftime('%x %X', $row['revised']) . "</td>\n";
echo " <td class=\"revisor\">{$row['revisor']}</td>\n";
echo " <td class=\"approved\">{$row['approved']}</td>\n";
echo " <td class=\"revision\">{$row['revision']}</td>\n";
echo " </tr>\n";
}?>
</tbody>
</table>
<script type="text/javascript">
// <![CDATA[
jQuery('#batch_process').tablesorter(
{
widgets: ['zebra'],
sortList: [[2,0]]
});
// ]]>
midcom_grid_batch_processing.initialize({
id: '&(grid_id);',
options: <?php echo json_encode($data['action_options']); ?>
});
</script>
<div class="actions">
<div class="action">
<select name="mass_action" id="mass_action">
<option value=""><?php echo $data['l10n']->get('choose action'); ?></option>
<option value="delete"><?php echo $data['l10n_midcom']->get('delete'); ?></option>
<option value="approve"><?php echo $data['l10n_midcom']->get('approve'); ?></option>
</select>
</div>
<input type="submit" name="execute_mass_action" value="<?php echo $data['l10n']->get('apply to selected'); ?>" />
</div>
</form>
</div>
@@ -1043,3 +1043,18 @@ body.loading #load-indicator
{
display: block
}
.asgard .ui-jqgrid-htable thead
{
background-color: #555753;
}
.asgard .ui-jqgrid-htable thead th
{
color: #ffffff;
}
.asgard .ui-jqgrid-htable thead th div
{
text-shadow: none;
font-weight: bold;
}

0 comments on commit 8499670

Please sign in to comment.