diff --git a/include/staff/templates/list-item-row.tmpl.php b/include/staff/templates/list-item-row.tmpl.php index 7df1517ef7d37e9dc16e8462f5fdef0b5bd75a8b..267cb1e5e7e0ca7a2d1666bf8c1993ab93b82f76 100644 --- a/include/staff/templates/list-item-row.tmpl.php +++ b/include/staff/templates/list-item-row.tmpl.php @@ -32,6 +32,8 @@ </td> <?php $props = $item->getConfiguration(); foreach ($prop_fields as $F) { ?> - <td><?php echo $F->display($props[$F->get('id')]); ?></td> + <td style="max-width: 20%"><span class="truncate"><?php + echo $F->display($props[$F->get('id')]); + ?></span></td> <?php } ?> </tr> diff --git a/include/staff/templates/list-items.tmpl.php b/include/staff/templates/list-items.tmpl.php index e9d685024fce5c59513c55cfde819153ce4d7430..e57a8bf09fd5265c675447728c2aeb880e45e074 100644 --- a/include/staff/templates/list-items.tmpl.php +++ b/include/staff/templates/list-items.tmpl.php @@ -11,9 +11,25 @@ else $showing = __('Add a few initial items to the list'); ?> <div style="margin: 5px 0"> - <div class="pull-left"><em><?php echo $showing; ?></em></div> + <div class="pull-left"> + <input type="search" size="25" id="search" value="<?php + echo Format::htmlchars($_POST['search']); ?>"/> + <button type="submit" onclick="javascript: + event.preventDefault(); + $.pjax({type: 'POST', data: { search: $('#search').val() }, container: '#pjax-container'}); + return false; +"><?php echo __('Search'); ?></button> + <?php if ($_POST['search']) { ?> + <a href="#" onclick="javascript: + $.pjax.reload('#pjax-container'); return false; " + ><i class="icon-remove-sign"></i> <?php + echo __('clear'); ?></a> + <?php } ?> + </div> + <?php if ($list) { ?> <div class="pull-right"> - <?php if (!$list || $list->allowAdd()) { ?> + <em style="display:inline-block; padding-bottom: 3px;"><?php echo $showing; ?></em> + <?php if ($list->allowAdd()) { ?> <a class="action-button field-config" href="#list/<?php echo $list->getId(); ?>/item/add"> @@ -45,6 +61,7 @@ </ul> </div> </div> + <?php } ?> <div class="clear"></div> </div> @@ -66,10 +83,10 @@ if ($list) { } ?> - <table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2"> + <table class="form_table fixed" width="940" border="0" cellspacing="0" cellpadding="2"> <thead> <tr> - <th width="8" nowrap></th> + <th width="24" nowrap></th> <th><?php echo __('Value'); ?></th> <?php foreach ($prop_fields as $F) { ?> <th><?php echo $F->getLocal('label'); ?></th> @@ -77,13 +94,22 @@ if ($list) { </tr> </thead> - <tbody <?php if ($list->get('sort_mode') == 'SortCol') { ?> + <tbody <?php if (!isset($_POST['search']) && $list && $list->get('sort_mode') == 'SortCol') { ?> class="sortable-rows" data-sort="sort-"<?php } ?>> <?php if ($list) { $icon = ($list->get('sort_mode') == 'SortCol') ? '<i class="icon-sort"></i> ' : ''; - $items = $pageNav->paginate($list->getAllItems()); + $items = $list->getAllItems(); + if ($_POST['search']) { + $items->filter(Q::any(array( + 'value__contains'=>$_POST['search'], + 'extra__contains'=>$_POST['search'], + 'properties__contains'=>$_POST['search'], + ))); + $search = true; + } + $items = $pageNav->paginate($items); // Emit a marker for the first sort offset ?> <input type="hidden" id="sort-offset" value="<?php echo max($items[0]->sort, $pageNav->getStart()); ?>"/> @@ -94,6 +120,8 @@ if ($list) { } ?> </tbody> </table> +<?php if ($pageNav && $pageNav->getNumPages()) { ?> <div><?php echo __('Page').':'.$pageNav->getPageLinks('items', $pjax_container); ?></div> +<?php } ?> </div> diff --git a/scp/js/scp.js b/scp/js/scp.js index 9ac9e8f73eae53db1768095de2b04896b6ad934e..5e49989761d3b37bcb72fd58291c9a5cf0737e12 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -152,7 +152,7 @@ var scp_prep = function() { } }; - $("form#save :input").change(function() { + $("form#save :input[name]").change(function() { if (!$(this).is('.nowarn')) warnOnLeave($(this)); }); diff --git a/scp/lists.php b/scp/lists.php index 0d99e9cfc275afb7b83903c4005472b6a8d5bc30..628e60b059e73c564c5e23f5e10b7fbf2c0eb1ed 100644 --- a/scp/lists.php +++ b/scp/lists.php @@ -132,6 +132,7 @@ if($_POST) { } } break; + case 'import-items': if (!$list) { $errors['err']=sprintf(__('%s: Unknown or invalid ID.'),