Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved tags handling, collections browsing, dashboard #946

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4546665
Added items count for recent collections
DBinaghi Mar 31, 2021
46ca5c0
Added recent_admin setting option
DBinaghi Mar 31, 2021
b65690c
Added default value for recent_admin setting
DBinaghi Mar 31, 2021
90401ce
Added recent_admin option
DBinaghi Mar 31, 2021
663e468
Update AppearanceSettings.php
DBinaghi Mar 31, 2021
c89d27b
Added recent_admin option
DBinaghi Mar 31, 2021
68f36ac
Added recent_admin option
DBinaghi Mar 31, 2021
fbb28aa
Added recent_admin option
DBinaghi Mar 31, 2021
f97c1bb
Added option for recent Items and Collections
DBinaghi Mar 31, 2021
abe7a9b
Added styling for input type=email
DBinaghi Mar 31, 2021
89c4c93
Added styling for .inputs input[type=email]
DBinaghi Mar 31, 2021
d4b13a0
Corrected typo
DBinaghi Mar 31, 2021
16b3e75
Added Delete link to Collections
DBinaghi Mar 31, 2021
3b40cae
Added quick-filters.php file
DBinaghi Mar 31, 2021
a5fb02d
Added quick-filters
DBinaghi Mar 31, 2021
37eefbf
Added styling for collection-filters
DBinaghi Mar 31, 2021
5117c19
Added collection_search_filters function
DBinaghi Mar 31, 2021
7c4a23b
Added file
DBinaghi Mar 31, 2021
524de44
Added details handling
DBinaghi Mar 31, 2021
2e23da0
Provided details handling during browsing
DBinaghi Mar 31, 2021
83846d4
Fixed Details blue button visualization
DBinaghi Mar 31, 2021
d46af0e
Added autosuggest for tag field
DBinaghi Mar 31, 2021
cc11a98
Added mergeTags function
DBinaghi Apr 1, 2021
4a8fd1b
Added code to delete tags if not used anymore
DBinaghi Apr 1, 2021
457b676
Cleaned up indentation
DBinaghi Apr 1, 2021
bd08d16
Extended delete function, added merge capability
DBinaghi Apr 1, 2021
d33ffbd
Added specification to page title
DBinaghi Apr 1, 2021
44f78e0
Hide sort options when no results are available
DBinaghi Apr 9, 2021
3f09e28
Merge branch 'master' into master
DBinaghi Oct 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions admin/themes/default/collections/browse.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
queue_js_file('collections-browse');
$pageTitle = __('Browse Collections') . ' ' . __('(%s total)', $total_results);
$totalItemsWithoutCollection = get_db()->getTable('Item')->count(array('collection' => 0));
echo head(array('title'=>$pageTitle, 'bodyclass'=>'collections browse'));
echo flash();
echo collection_search_filters();
?>

<?php if (total_records('Collection') > 0): ?>
Expand All @@ -12,6 +14,7 @@
<?php echo __('Add a Collection'); ?>
</a>
<?php endif; ?>
<?php echo common('quick-filters', array(), 'collections'); ?>
<p class="not-in-collections">
<?php if ($totalItemsWithoutCollection):
$withoutCollectionMessage = __(plural('%s%d item%s has no collection.', "%s%d items%s aren't in a collection.",
Expand Down Expand Up @@ -85,7 +88,17 @@
<?php if (is_allowed('Collections', 'add')): ?>
<a href="<?php echo html_escape(url('collections/add')); ?>" class="green button"><?php echo __('Add a Collection'); ?></a>
<?php endif; ?>
<?php echo common('quick-filters', array(), 'collections'); ?>
<p class="not-in-collections"><?php echo $withoutCollectionMessage; ?></p>

<script type="text/javascript">
Omeka.addReadyCallback(Omeka.CollectionsBrowse.setupDetails, [
<?php echo js_escape(__('Details')); ?>,
<?php echo js_escape(__('Show Details')); ?>,
<?php echo js_escape(__('Hide Details')); ?>
]);
</script>

<?php else: ?>
<p><?php echo __('There are no collections on this page.'); ?> <?php echo link_to('collections', null, __('View All Collections')); ?></p>
<?php endif; ?>
Expand Down
11 changes: 11 additions & 0 deletions admin/themes/default/collections/quick-filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<ul class="quick-filter-wrapper">
<li><a href="#"><?php echo __('Quick Filter'); ?></a>
<ul class="dropdown">
<li><span class="quick-filter-heading"><?php echo __('Quick Filter') ?></span></li>
<li><a href="<?php echo url('collections/browse'); ?>"><?php echo __('View All') ?></a></li>
<li><a href="<?php echo url('collections/browse', array('public' => 1)); ?>"><?php echo __('Public'); ?></a></li>
<li><a href="<?php echo url('collections/browse', array('public' => 0)); ?>"><?php echo __('Private'); ?></a></li>
<li><a href="<?php echo url('collections/browse', array('featured' => 1)); ?>"><?php echo __('Featured'); ?></a></li>
</ul>
</li>
</ul>
89 changes: 88 additions & 1 deletion admin/themes/default/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions admin/themes/default/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<?php ob_start(); ?>
<h2><?php echo __('Recent Items'); ?></h2>
<?php
set_loop_records('items', get_recent_items(5));
set_loop_records('items', get_recent_items(get_option('recent_admin')));
foreach (loop('items') as $item):
?>
<div class="recent-row">
Expand All @@ -69,7 +69,7 @@
<?php ob_start(); ?>
<h2><?php echo __('Recent Collections'); ?></h2>
<?php
$collections = get_recent_collections(5);
$collections = get_recent_collections(get_option('recent_admin'));
set_loop_records('collections', $collections);
foreach (loop('collections') as $collection):
?>
Expand Down
10 changes: 10 additions & 0 deletions admin/themes/default/items/batch-edit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
queue_js_file('items');
$tagDelimiter = get_option('tag_delimiter');
$title = __('Batch Edit Items');
if (!$isPartial):
echo head(
Expand All @@ -12,6 +14,14 @@
<div title="<?php echo $title; ?>">

<form id="batch-edit-form" action="<?php echo html_escape(url('items/batch-edit-save')); ?>" method="post" accept-charset="utf-8">
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function () {
Omeka.Items.tagDelimiter = <?php echo js_escape($tagDelimiter); ?>;
Omeka.Items.tagChoices('#metadata-tags', <?php echo js_escape(url(array('controller' => 'tags', 'action' => 'autocomplete'), 'default', array(), true)); ?>);
});
//]]>
</script>
<section class="seven columns alpha">
<fieldset id="item-list" class="panel">
<h2><?php echo __('Items'); ?></h2>
Expand Down
39 changes: 39 additions & 0 deletions admin/themes/default/javascripts/collections-browse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if (!Omeka) {
var Omeka = {};
}

Omeka.CollectionsBrowse = {};

(function ($) {
Omeka.CollectionsBrowse.setupDetails = function (detailsText, showDetailsText, hideDetailsText) {
$('.details').hide();
$('.action-links').prepend('<li class="details-link">' + detailsText + '</li> ');

$('tr.collection').each(function() {
var collectionDetails = $(this).find('.details');
if ($.trim(collectionDetails.html()) != '') {
$(this).find('.details-link').css({'color': '#4E7181', 'cursor': 'pointer'}).click(function() {
collectionDetails.slideToggle('fast');
});
}
});

var toggleList = '<a href="#" class="toggle-all-details small blue button">' + showDetailsText + '</a>';

$('.quick-filter-wrapper').before(toggleList);

// Toggle collection details.
var detailsShown = false;
$('.toggle-all-details').click(function (e) {
e.preventDefault();
if (detailsShown) {
$('.toggle-all-details').text(showDetailsText);
$('.details').slideUp('fast');
} else {
$('.toggle-all-details').text(hideDetailsText);
$('.details').slideDown('fast');
}
detailsShown = !detailsShown;
});
};
})(jQuery);
1 change: 1 addition & 0 deletions application/controllers/AppearanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AppearanceController extends Omeka_Controller_AbstractActionController
const DEFAULT_FULLSIZE_CONSTRAINT = 800;
const DEFAULT_THUMBNAIL_CONSTRAINT = 200;
const DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT = 200;
const DEFAULT_RECENT_ADMIN = 5;
const DEFAULT_PER_PAGE_ADMIN = 10;
const DEFAULT_PER_PAGE_PUBLIC = 10;

Expand Down
28 changes: 26 additions & 2 deletions application/controllers/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ protected function _getBrowseDefaultSort()
return array('name', 'a');
}

protected function _getDeleteConfirmMessage($tag)
{
return __('This will delete the tag "%s" from all records associated to it.', $tag->name);
}

/**
* Redirect to another page after a record is successfully deleted.
*
* The default is to redirect to this controller's browse page.
*
* @param Omeka_Record_AbstractRecord $record
*/
protected function _redirectAfterDelete($record)
{
$this->_helper->redirector('browse');
}

public function autocompleteAction()
{
$tagText = $this->_getParam('term');
Expand All @@ -109,8 +126,15 @@ public function renameAjaxAction()

$oldTag->name = $newName;
$this->_helper->viewRenderer->setNoRender();
if ($csrf->isValid($_POST) && $oldTag->save(false)) {
$this->getResponse()->setBody($newName);
if ($csrf->isValid($_POST)) {
if ($oldTag->save(false)) {
$this->getResponse()->setBody($newName);
} else {
$newTag = $this->_helper->db->findOrNew($newName);
$newTagId = $newTag->id;
$count = $this->_helper->db->mergeTags($oldTagId, $newTagId);
$this->getResponse()->setBody($newName);
}
} else {
$this->getResponse()->setHttpResponseCode(500);
$this->getResponse()->setBody($error);
Expand Down
9 changes: 8 additions & 1 deletion application/forms/AppearanceSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public function init()
'required' => true,
));

$this->addElement('text', 'recent_admin', array(
'label' => __('Recents Items/Collections (admin)'),
'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface.'),
'validators' => array('Digits'),
'required' => true,
));

$this->addElement('text', 'per_page_admin', array(
'label' => __('Results Per Page (admin)'),
'description' => __('Limit the number of results displayed per page in the administrative interface.'),
Expand Down Expand Up @@ -101,7 +108,7 @@ public function init()

$this->addDisplayGroup(
array(
'use_square_thumbnail', 'link_to_file_metadata', 'per_page_admin', 'per_page_public',
'use_square_thumbnail', 'link_to_file_metadata', 'recent_admin', 'per_page_admin', 'per_page_public',
'show_empty_elements', 'show_element_set_headings',
),
'display-settings', array('legend' => __('Display Settings'))
Expand Down
13 changes: 11 additions & 2 deletions application/forms/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Omeka_Form_Install extends Omeka_Form
const DEFAULT_FULLSIZE_CONSTRAINT = 800;
const DEFAULT_THUMBNAIL_CONSTRAINT = 200;
const DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT = 200;
const DEFAULT_RECENT_ADMIN = 5;
const DEFAULT_PER_PAGE_ADMIN = 10;
const DEFAULT_PER_PAGE_PUBLIC = 10;
const DEFAULT_SHOW_EMPTY_ELEMENTS = false;
Expand Down Expand Up @@ -213,6 +214,14 @@ public function init()
'required' => true
));

$this->addElement('text', 'recent_admin', array(
'label' => __('Recent Items/Collections (admin)'),
'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface.'),
'value' => self::DEFAULT_RECENT_ADMIN,
'validators' => array('Digits'),
'required' => true
));

$this->addElement('text', 'per_page_admin', array(
'label' => __('Items Per Page (admin)'),
'description' => __('Limit the number of items displayed per page in the administrative interface.'),
Expand Down Expand Up @@ -275,8 +284,8 @@ public function init()
array('administrator_email', 'site_title', 'description',
'copyright', 'author', 'tag_delimiter', 'fullsize_constraint',
'thumbnail_constraint', 'square_thumbnail_constraint',
'per_page_admin', 'per_page_public', 'show_empty_elements',
'path_to_convert'),
'recent_admin', 'per_page_admin', 'per_page_public',
'show_empty_elements', 'path_to_convert'),
'site_settings',
array('legend' => __('Site Settings'))
);
Expand Down
13 changes: 13 additions & 0 deletions application/libraries/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,19 @@ function item_search_filters(array $params = null)
return get_view()->itemSearchFilters($params);
}

/**
* Get a list of the current search collection filters in use.
*
* @package Omeka\Function\Search
* @uses Omeka_View_Helper_SearchFilters::searchFilters()
* @params array $params Params to override the ones read from the request.
* @return string
*/
function collection_search_filters(array $params = null)
{
return get_view()->collectionSearchFilters($params);
}

/**
* Get metadata for a record.
*
Expand Down
1 change: 1 addition & 0 deletions application/models/Installer/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private function _addOptions()
'thumbnail_constraint' => $this->_getValue('thumbnail_constraint'),
'square_thumbnail_constraint' => $this->_getValue('square_thumbnail_constraint'),
'fullsize_constraint' => $this->_getValue('fullsize_constraint'),
'recent_admin' => $this->_getValue('recent_admin'),
'per_page_admin' => $this->_getValue('per_page_admin'),
'per_page_public' => $this->_getValue('per_page_public'),
'show_empty_elements' => $this->_getValue('show_empty_elements'),
Expand Down
1 change: 1 addition & 0 deletions application/models/Installer/Task/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Installer_Task_Options implements Installer_TaskInterface
'thumbnail_constraint',
'square_thumbnail_constraint',
'fullsize_constraint',
'recent_admin',
'per_page_admin',
'per_page_public',
'show_empty_elements',
Expand Down
1 change: 1 addition & 0 deletions application/models/Installer/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Installer_Test extends Installer_Default
'thumbnail_constraint' => Omeka_Form_Install::DEFAULT_THUMBNAIL_CONSTRAINT,
'square_thumbnail_constraint' => Omeka_Form_Install::DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT,
'fullsize_constraint' => Omeka_Form_Install::DEFAULT_FULLSIZE_CONSTRAINT,
'recent_admin' => Omeka_Form_Install::DEFAULT_RECENT_ADMIN,
'per_page_admin' => Omeka_Form_Install::DEFAULT_PER_PAGE_ADMIN,
'per_page_public' => Omeka_Form_Install::DEFAULT_PER_PAGE_PUBLIC,
'show_empty_elements' => Omeka_Form_Install::DEFAULT_SHOW_EMPTY_ELEMENTS,
Expand Down
Loading