-
Notifications
You must be signed in to change notification settings - Fork 4
Add a quick mapping feature to quickly map properties as a group #52
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
Open
Bebel00
wants to merge
7
commits into
master
Choose a base branch
from
quick-mapping
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+256
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74ac668
Add quick mapping action and button
Bebel00 c74c17f
Fix code style
jajm 25c9bfd
Remove commented code
jajm a6b2350
Remove debug logs
jajm 94742e0
Create all mappings at once with batchCreate
jajm bf253b7
Apply chosen only to source and field-name select
jajm 71fa06b
Escape translation in JS code to avoid XSS vulnerability
jajm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
|
|
||
| namespace Solr\Form\Admin; | ||
|
|
||
| use Laminas\Form\Form; | ||
| use Laminas\Form\Element; | ||
| use Laminas\Form\Fieldset; | ||
| use Solr\Form\Element\Transformations; | ||
| use Laminas\I18n\Translator\TranslatorAwareInterface; | ||
| use Laminas\I18n\Translator\TranslatorAwareTrait; | ||
|
|
||
| class SolrQuickMappingForm extends Form implements TranslatorAwareInterface | ||
| { | ||
| use TranslatorAwareTrait; | ||
|
|
||
| protected $transformationManager; | ||
|
|
||
| public function init() | ||
| { | ||
| $translator = $this->getTranslator(); | ||
|
|
||
| $this->add([ | ||
| 'name' => 'o:source', | ||
| 'type' => Element\Select::class, | ||
| 'options' => [ | ||
| 'label' => $translator->translate('Sources'), | ||
| 'value_options' => array_combine( | ||
| $this->options['terms'], | ||
| $this->options['terms'] | ||
| ), | ||
| ], | ||
| 'attributes' => [ | ||
| 'id' => 'source', | ||
| 'multiple' => true, | ||
| 'required' => true, | ||
| ], | ||
| ]); | ||
|
|
||
| $this->add([ | ||
| 'name' => 'o:field_name', | ||
| 'type' => Element\Select::class, | ||
| 'options' => [ | ||
| 'label' => $translator->translate('Solr fields'), | ||
| 'value_options' => array_combine( | ||
| $this->options['dynamic_fields'], | ||
| $this->options['dynamic_fields'] | ||
| ), | ||
| ], | ||
| 'attributes' => [ | ||
| 'id' => 'field-name', | ||
| 'multiple' => true, | ||
| 'required' => true, | ||
| ], | ||
| ]); | ||
|
|
||
| $settingsFieldset = new Fieldset('o:settings'); | ||
|
|
||
| $transformationNames = $this->transformationManager->getRegisteredNames($sortAlpha = true); | ||
| $transformationValueOptions = []; | ||
| foreach ($transformationNames as $name) { | ||
| $transformation = $this->transformationManager->get($name); | ||
| $transformationValueOptions[] = [ | ||
| 'value' => $name, | ||
| 'label' => $transformation->getLabel(), | ||
| 'empty_option' => '', | ||
| ]; | ||
| } | ||
|
|
||
| $settingsFieldset->add([ | ||
| 'name' => 'transformations', | ||
| 'type' => Transformations::class, | ||
| 'options' => [ | ||
| 'label' => 'Transformations', // @translate | ||
| 'value_options' => $transformationValueOptions, | ||
| 'empty_option' => '', | ||
| ], | ||
| ]); | ||
|
|
||
| $this->add($settingsFieldset); | ||
| } | ||
|
|
||
| public function setTransformationManager(\Solr\Transformation\Manager $transformationManager) | ||
| { | ||
| $this->transformationManager = $transformationManager; | ||
| } | ||
|
|
||
| public function getTransformationManager(): \Solr\Transformation\Manager | ||
| { | ||
| return $this->transformationManager; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
| namespace Solr\Service\Form; | ||
|
|
||
| use Interop\Container\ContainerInterface; | ||
| use Laminas\ServiceManager\Factory\FactoryInterface; | ||
| use Solr\Form\Admin\SolrQuickMappingForm; | ||
|
|
||
| class SolrQuickMappingFormFactory implements FactoryInterface | ||
| { | ||
| public function __invoke(ContainerInterface $services, $requestedName, array $options = null) | ||
| { | ||
| $form = new SolrQuickMappingForm; | ||
| $form->setTranslator($services->get('MvcTranslator')); | ||
|
|
||
| $solrNode = $services->get('Omeka\ApiManager')->read('solr_nodes', $options['solr_node_id'])->getContent(); | ||
| $dynamicFieldsAux = $solrNode->schema()->getDynamicFields(); | ||
|
|
||
| $dynamicFields = []; | ||
| foreach ($dynamicFieldsAux as $dynamicField) { | ||
| $dynamicFields[] = $dynamicField['name']; | ||
| } | ||
|
|
||
| $properties = $services->get('Omeka\ApiManager')->search('properties')->getContent(); | ||
| $terms = []; | ||
| foreach ($properties as $property) { | ||
| $terms[] = $property->term(); | ||
| } | ||
|
|
||
| $form->setOption('terms', $terms); | ||
| $form->setOption('dynamic_fields', $dynamicFields); | ||
|
|
||
| $transformationManager = $services->get('Solr\TransformationManager'); | ||
| $form->setTransformationManager($transformationManager); | ||
|
|
||
| return $form; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
| /* | ||
| * Copyright BibLibre, 2017 | ||
| * | ||
| * This software is governed by the CeCILL license under French law and abiding | ||
| * by the rules of distribution of free software. You can use, modify and/ or | ||
| * redistribute the software under the terms of the CeCILL license as circulated | ||
| * by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". | ||
| * | ||
| * As a counterpart to the access to the source code and rights to copy, modify | ||
| * and redistribute granted by the license, users are provided only with a | ||
| * limited warranty and the software's author, the holder of the economic | ||
| * rights, and the successive licensors have only limited liability. | ||
| * | ||
| * In this respect, the user's attention is drawn to the risks associated with | ||
| * loading, using, modifying and/or developing or reproducing the software by | ||
| * the user in light of its specific status of free software, that may mean that | ||
| * it is complicated to manipulate, and that also therefore means that it is | ||
| * reserved for developers and experienced professionals having in-depth | ||
| * computer knowledge. Users are therefore encouraged to load and test the | ||
| * software's suitability as regards their requirements in conditions enabling | ||
| * the security of their systems and/or data to be ensured and, more generally, | ||
| * to use and operate it in the same conditions as regards security. | ||
| * | ||
| * The fact that you are presently reading this means that you have had | ||
| * knowledge of the CeCILL license and that you accept its terms. | ||
| */ | ||
| ?> | ||
|
|
||
| <?php echo $this->pageTitle($this->translate('Quickly add Solr mappings')); ?> | ||
|
|
||
| <?php echo $this->partial('solr/admin/mapping/form'); ?> | ||
|
|
||
| <script> | ||
| (function ($) { | ||
| $(document).ready(function () { | ||
| const placeholder = <?= json_encode($this->translate('Search and select...')) ?>; | ||
| // Activate Chosen | ||
| $('select#source, select#field-name').chosen({ | ||
| allow_single_deselect: true, | ||
| width: '100%', | ||
| search_contains: true, | ||
| placeholder_text_multiple: placeholder, | ||
| placeholder_text_single: placeholder, | ||
| }); | ||
| }); | ||
| })(jQuery); | ||
| </script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.