Merge branch 'master' into dependabot/npm_and_yarn/mixin-deep-1.3.2

This commit is contained in:
Nicolas Maillat
2019-11-13 18:46:12 +01:00
committed by GitHub
7 changed files with 53 additions and 9 deletions

0
cache/.gitkeep vendored Normal file
View File

View File

@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\SearchEngine\Elastic\Indexer\Record\Hydrator;
use Alchemy\Phrasea\SearchEngine\Elastic\Exception\Exception;
use Alchemy\Phrasea\SearchEngine\Elastic\RecordHelper;
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\GlobalStructure;
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus;
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\CandidateTerms;
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\Concept;
@@ -27,7 +28,7 @@ class ThesaurusHydrator implements HydratorInterface
private $thesaurus;
private $candidate_terms;
public function __construct(Structure $structure, Thesaurus $thesaurus, CandidateTerms $candidate_terms)
public function __construct(GlobalStructure $structure, Thesaurus $thesaurus, CandidateTerms $candidate_terms)
{
$this->structure = $structure;
$this->thesaurus = $thesaurus;
@@ -67,7 +68,13 @@ class ThesaurusHydrator implements HydratorInterface
$terms = array();
$filters = array();
$field_names = array();
/** @var Field[] $dbFields */
$dbFields = $this->structure->getAllFieldsByDatabox($record['databox_id']);
foreach ($fields as $name => $field) {
if(!array_key_exists($name, $dbFields) || !$dbFields[$name]->get_generate_cterms()) {
continue;
}
$root_concepts = $field->getThesaurusRoots();
// Loop through all values to prepare bulk query
$field_values = \igorw\get_in($record, explode('.', $index_fields[$name]));
@@ -98,10 +105,7 @@ class ThesaurusHydrator implements HydratorInterface
}
}
else {
$field = $fields[$name];
if($field->get_generate_cterms()) {
$this->candidate_terms->insert($field_names[$offset], $values[$offset]);
}
$this->candidate_terms->insert($field_names[$offset], $values[$offset]);
}
}
}

View File

@@ -24,6 +24,11 @@ class Field implements Typed
*/
private $name;
/**
* @var int
*/
private $databox_id;
/**
* @var string
*/
@@ -73,6 +78,7 @@ class Field implements Typed
}
return new self($field->get_name(), $type, [
'databox_id' => $databox->get_sbas_id(),
'searchable' => $field->is_indexable(),
'private' => $field->isBusiness(),
'facet' => $facet,
@@ -102,6 +108,7 @@ class Field implements Typed
{
$this->name = (string) $name;
$this->type = $type;
$this->databox_id = \igorw\get_in($options, ['databox_id'], 0);
$this->is_searchable = \igorw\get_in($options, ['searchable'], true);
$this->is_private = \igorw\get_in($options, ['private'], false);
$this->facet = \igorw\get_in($options, ['facet']);
@@ -126,6 +133,7 @@ class Field implements Typed
public function withOptions(array $options)
{
return new self($this->name, $this->type, $options + [
'databox_id' => $this->databox_id,
'searchable' => $this->is_searchable,
'private' => $this->is_private,
'facet' => $this->facet,
@@ -155,6 +163,11 @@ class Field implements Typed
return sprintf('concept_path.%s', $this->name);
}
public function get_databox_id()
{
return $this->databox_id;
}
public function getType()
{
return $this->type;

View File

@@ -14,6 +14,12 @@ final class GlobalStructure implements Structure
*/
private $fields = array();
/**
* @var Field[][]
*/
private $fieldsByDatabox = [];
/**
* @var Field[]
* */
@@ -119,6 +125,10 @@ final class GlobalStructure implements Structure
public function add(Field $field)
{
// store info for each field, not still merged by databox
$this->fieldsByDatabox[$field->get_databox_id()][$field->getName()] = $field;
// store merged infos (same field name)
$name = $field->getName();
if (isset($this->fields[$name])) {
@@ -152,6 +162,11 @@ final class GlobalStructure implements Structure
return $this->fields;
}
public function getAllFieldsByDatabox($databox_id)
{
return $this->fieldsByDatabox[$databox_id];
}
/**
* @return Field[]
*/

View File

@@ -302,8 +302,18 @@
$(document).ready(function () {
$('body').on('click', '#help-trigger', function (event) {
$('#mainMenu .helpcontextmenu').toggleClass('shown');
console.log('mety');
});
$(document).on('click', function (e) {
if($('#mainMenu .helpcontextmenu').hasClass('shown')) {
var $this = $(e.target);
if ($this.closest('#mainMenu .helpcontextmenu.shown, .help-trigger').length == 0 && $this[0].id != "toggle") {
$('#mainMenu .helpcontextmenu').removeClass('shown');
}
}
});
// var key = 'help';
var configurationSettingLinks = {{ configuration|json_encode|raw }};
//seperate array based on location of link

View File

@@ -36,6 +36,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
$field->isFacet()->willReturn(false);
$field->hasConceptInference()->willReturn(false);
$field->getDependantCollections()->willReturn(['1']);
$field->get_databox_id()->willReturn('1');
$structure->add($field->reveal());
$this->assertCount(1, $structure->getAllFields());
@@ -60,6 +61,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
$field->isPrivate()->willReturn(false);
$field->isFacet()->willReturn(false);
$field->hasConceptInference()->willReturn(false);
$field->get_databox_id()->willReturn('1');
$other = new Field('foo', FieldMapping::TYPE_STRING);

View File

@@ -5978,9 +5978,9 @@ lodash.keys@~2.4.1:
lodash.isobject "~2.4.1"
lodash.merge@^4.6.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash.restparam@^3.0.0:
version "3.6.1"