Skip to content

Drupal 10 Upgrade #2

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
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions finto_taxonomy.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Finto Taxonomy
type: module
core: 8.x
core_version_requirement: ">=8"
package: Kirjastot.fi
description: "Integrate querying Finto vocabularies with taxonomy"
dependencies:
Expand Down
2 changes: 2 additions & 0 deletions finto_taxonomy.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ kifiform-tags-plugin:
public/js/kifiform-tags-plugin.js: {}
dependencies:
- kifiform/autocomplete-tags
- core/jquery
- core/once
7 changes: 4 additions & 3 deletions finto_taxonomy.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Drupal\Core\Entity\Element\EntityAutocomplete;
use Drupal\Core\Form\FormStateInterface;
use Drupal\finto_taxonomy\TaxonomyHelper;
Expand All @@ -8,7 +9,7 @@ use Drupal\finto_taxonomy\Element\EntityAutocomplete as FintoEntityAutocomplete;

use Drupal\finto_taxonomy\Plugin\LanguageNegotiation\AutoCompleteRoute;

function finto_taxonomy_field_widget_form_alter(array &$parent, FormStateInterface $form_state, $context) {
function finto_taxonomy_field_widget_single_element_form_alter(array &$parent, FormStateInterface $form_state, $context) {
// Autocomplete widget wraps the actual widgets inside a redundant array.
if (empty($parent['target_id'])) {
return;
Expand All @@ -21,7 +22,7 @@ function finto_taxonomy_field_widget_form_alter(array &$parent, FormStateInterfa
$finto_tids = [];

foreach ($parent['target_id']['#default_value'] as $term) {
if ($term->getVocabularyId() == $finto_vid) {
if ($term->bundle() == $finto_vid) {
$finto_tids[] = $term->id();
}
}
Expand All @@ -31,6 +32,6 @@ function finto_taxonomy_field_widget_form_alter(array &$parent, FormStateInterfa
}

function finto_taxonomy_language_negotiation_info_alter(&$negotiation_info) {
$method_id = \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::METHOD_ID;
$method_id = LanguageNegotiationUrl::METHOD_ID;
$negotiation_info[$method_id]['class'] = AutoCompleteRoute::class;
}
3 changes: 1 addition & 2 deletions public/js/kifiform-tags-plugin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(function($) {
"use strict";

$("input.form-autocomplete")
.once("finto-taxonomy-tag-insert")
$(once("finto-taxonomy-tag-insert", "input.form-autocomplete"))
.on("kififormtaginsert", function(event, ui) {
var tids = ui.autocomplete[0].dataset.finto_taxonomyTerms.split(/,/);

Expand Down