Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
126 changes: 126 additions & 0 deletions asset/css/reference.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/* Reference pages */
.solr-list {
padding-left: 0;
}

.solr-pagination.pagination {
display: inline-block;
float: none;
margin: 12px 0;
padding: 0 0 1em;
height: auto;
width: auto;
}
.solr-pagination ul.pagination-list {
height: auto;
margin: auto;
padding: 0;
list-style: none;
cursor: default;
}
.solr-pagination li.pagination-range {
height: auto;
line-height: initial;
display: initial;
margin-right: 2px;
}
.solr-pagination li.pagination-range a,
.solr-pagination li.pagination-range span {
display: inline-block;
margin-right: 0px;
padding: 0.375em 9px;
vertical-align: top;
}
.solr-pagination li.pagination-range a {
border: 1px solid #000000;
text-decoration: none;
}
.solr-pagination li.pagination-range span {
border: 1px solid transparent;
}
.solr-pagination li.pagination-range a:hover {
background-color: #CCCCCC;
color: #000;
text-decoration: none;
}
.solr-pagination li.pagination-range.active a {
background-color: #DDDDDD;
}

ul.solr {
list-style: inside none disc;
}
ol.solr {
list-style: inside none decimal;
}
ul.solr ul,
ol.solr ul {
list-style: inside none circle;
margin-left: 15px;
}
ol.solr ol,
ul.solr ol {
list-style: inside none lower-latin;
margin-left: 15px;
}
ul.solr li {
margin-top: 12px;
margin-bottom: 12px;
}

/* Use flexbox when there is a thumbnail. */
.solr-record {
display: flex;
gap: 12px;
align-items: center;
}
.solr-record a {
display: inline-flex;
align-items: center;
}
.solr-record a img {
height: auto;
width: 36px;
margin-right: 6px;
}

/* Recursive list */
.list-unstyled {
padding-left: 0;
list-style: none;
}
.recursive-list .resource-link {
display: inline-flex;
align-items: center;
max-width: 100%;
min-width: 0;
}
.recursive-list .resource-link img {
height: 36px;
margin-right: 6px;
}
.recursive-list .resource-link .resource-name {
flex: 1;
min-width: 0;
}
.recursive-list .see-all {
font-style: italic;
list-style: none;
}

/* Grid */
.solr-grid {
display: flex;
flex-direction: column;
flex-wrap: wrap;
gap: 12px;
}
.solr-grid .reference-record a {
display: flex;
flex-direction: column;
align-items: initial;
}
.solr-grid .reference-record a img {
height: auto;
width: 200px;
}
106 changes: 106 additions & 0 deletions asset/js/glossaire-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* Dependent selects for Omeka-S Glossaire block
*
* - #o:index_id : the select of search index id
* - #search_field : the select of search field
* - availableFields is injected from PHP as window.availableFields
*/

(function ($) {

// Registry to avoid initializing the same block twice
const initializedBlocks = new WeakSet();

function initializeGlossaireForm() {

// Find ALL index selects (multiple blocks possible)
const indexSelects = document.querySelectorAll('[name$="[o\\:data][o\\:index_id]"]');

indexSelects.forEach(indexSelect => {

const block = indexSelect.closest('.block'); // real Omeka block wrapper

if (!block) return;

// Skip already initialized blocks
if (initializedBlocks.has(block)) return;
initializedBlocks.add(block);

// Find the field select in the same block
const fieldSelect = block.querySelector('[name$="[o\\:data][search_field]"]');
const resourceClassFieldSelect = block.querySelector('[name$="[o\\:data][resource_class_field]"]');
const languageFieldSelect = block.querySelector('[name$="[o\\:data][language_field]"]');

if (!fieldSelect) {
console.warn('Glossaire: field select not found, skipping block.');
return;
}

// -------------------------------
// Update field options
// -------------------------------
function updateFieldOptions(indexId) {
const facetFields = window.availableFacetFields[indexId] || {};
const searchFields = window.availableSearchFields[indexId] || {};
const sortFields = window.availableSortFields[indexId] || {};

fieldSelect.innerHTML = '';
resourceClassFieldSelect.innerHTML = '';
languageFieldSelect.innerHTML = '';

const opt2 = document.createElement('option');
opt2.value = '';
opt2.textContent = 'None';
resourceClassFieldSelect.appendChild(opt2);

const opt3 = document.createElement('option');
opt3.value = '';
opt3.textContent = 'None';
languageFieldSelect.appendChild(opt3);



Object.entries(facetFields).forEach(([value, label]) => {
const opt = document.createElement('option');
opt.value = value;
opt.textContent = label;
fieldSelect.appendChild(opt);

const opt2 = document.createElement('option');
opt2.value = value;
opt2.textContent = label;
resourceClassFieldSelect.appendChild(opt2);

const opt3 = document.createElement('option');
opt3.value = value;
opt3.textContent = label;
languageFieldSelect.appendChild(opt3);
});


}

// Bind change event ONCE
indexSelect.addEventListener('change', function () {
updateFieldOptions(this.value);
});
});
}

// ----------------------------------------
// Called when a block is added
// ----------------------------------------
$(document).on('o:block-added', function (event) {

initializeGlossaireForm();
});

// ----------------------------------------
// Called on page load (existing blocks)
// ----------------------------------------
$(document).ready(function () {

initializeGlossaireForm();
});

})(jQuery);
8 changes: 8 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,17 @@
'Solr\Form\Admin\SolrNodeForm' => Service\Form\SolrNodeFormFactory::class,
'Solr\Form\Admin\SolrMappingForm' => Service\Form\SolrMappingFormFactory::class,
'Solr\Form\Admin\SolrSearchFieldForm' => Service\Form\SolrSearchFieldFormFactory::class,
'Solr\Form\Admin\GlossrForm' => Service\Form\GlossrFormFactory::class,
],
'invokables' => [
'Solr\Form\Admin\SolrMappingImportForm' => Form\Admin\SolrMappingImportForm::class,
'Solr\Form\Element\Transformations' => Form\Element\Transformations::class,
'Solr\Form\Element\OptionalMulticheckbox' => Form\Element\OptionalMulticheckbox::class,
],
],
'block_layouts' => [
'factories' => [
'glossr' => Service\Site\BlockLayout\GlossrFactory::class,
],
],
'router' => [
Expand Down Expand Up @@ -235,6 +242,7 @@
],
'invokables' => [
'solrFormTransformations' => Form\View\Helper\FormTransformations::class,
'glossrFacetLink' => View\Helper\GlossrFacetLink::class,
],
],
'view_manager' => [
Expand Down
37 changes: 29 additions & 8 deletions src/Api/Adapter/SolrSearchFieldAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,51 @@ public function buildQuery(QueryBuilder $qb, array $query)

if (isset($query['facetable'])) {
if ($query['facetable']) {
$qb->andWhere($qb->expr()->isNotNull('omeka_root.facetField'));
$qb->andWhere($qb->expr()->andX(
$qb->expr()->isNotNull('omeka_root.facetField'),
$qb->expr()->not($qb->expr()->eq('omeka_root.facetField', '\'\''))));
} else {
$qb->andWhere($qb->expr()->isNull('omeka_root.facetField'));
$qb->andWhere($qb->expr()->orX(
$qb->expr()->isNull('omeka_root.facetField'),
$qb->expr()->eq('omeka_root.facetField', '\'\'')));
}
}

if (isset($query['sortable'])) {
if ($query['sortable']) {
$qb->andWhere($qb->expr()->isNotNull('omeka_root.sortField'));
$qb->andWhere($qb->expr()->andX(
$qb->expr()->isNotNull('omeka_root.sortField'),
$qb->expr()->not($qb->expr()->eq('omeka_root.sortField', '\'\''))
));
} else {
$qb->andWhere($qb->expr()->isNull('omeka_root.sortField'));
$qb->andWhere($qb->expr()->orX(
$qb->expr()->isNull('omeka_root.sortField'),
$qb->expr()->eq('omeka_root.sortFields', '\'\''))
);
}
}

if (isset($query['searchable'])) {
if ($query['searchable']) {
$qb->andWhere($qb->expr()->orX(
$qb->expr()->isNotNull('omeka_root.textFields'),
$qb->expr()->isNotNull('omeka_root.stringFields')
$qb->expr()->andX(
$qb->expr()->isNotNull('omeka_root.textFields'),
$qb->expr()->not($qb->expr()->eq('omeka_root.textFields', '\'\''))
),
$qb->expr()->andX(
$qb->expr()->isNotNull('omeka_root.stringFields'),
$qb->expr()->not($qb->expr()->eq('omeka_root.stringFields', '\'\''))
)
));
} else {
$qb->andWhere($qb->expr()->andX(
$qb->expr()->isNull('omeka_root.textFields'),
$qb->expr()->isNull('omeka_root.stringFields')
$qb->expr()->orX(
$qb->expr()->isNull('omeka_root.textFields'),
$qb->expr()->eq('omeka_root.textFields', '\'\'')),
$qb->expr()->orX(
$qb->expr()->isNull('omeka_root.stringFields'),
$qb->expr()->eq('omeka_root.stringFields', '\'\'')
)
));
}
}
Expand Down
Loading