another display for modalcard accordeon, displaying note icon on mediumcard and refresh it updated in modale

This commit is contained in:
2021-03-10 11:54:08 +01:00
parent 4894f88c6d
commit fbf509a005
10 changed files with 96 additions and 15 deletions

View File

@@ -46,6 +46,7 @@ type Materiau implements NodeInterface & SearchResultInterface{
reference: String
samples: [Sample]
note: Note
note_id: Int
# famille: String
# index: Int
}

View File

@@ -14,6 +14,10 @@ extend type Query {
searchresults(ids: [Int], lang: String): [SearchResultInterface]
}
extend type Query {
searchresult(id: Int!, lang: String): SearchResultInterface
}
extend type Query {
article(id: Int!, lang: String): Article
}

View File

@@ -365,6 +365,33 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('id', $builder->fromParent())
)
);
$registry->addFieldResolver('Materiau', 'note_id',
$builder->compose(
$builder->callback(function($parent, $args){
// get the current user id
$user = \Drupal::currentUser()->id();
// get the current material id
$target = $parent->id();
// query the note for these user AND material (if any)
// if null, UI will create it with rest api
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$query = $entity_storage->getQuery()
->condition('type', 'note')
->condition('uid', $user)
->condition('field_target', $target)
->accessCheck(TRUE);
$results = $query->execute();
// $test="test";
return array_shift($results);
}),
$builder->produce('entity_load')
->map('type', $builder->fromValue('node'))
->map('bundle', $builder->fromValue('note'))
->map('id', $builder->fromParent()),
$builder->produce('entity_id')
->map('entity', $builder->fromParent())
)
);
}
// _ _ _
@@ -419,6 +446,13 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('ids', $builder->fromArgument('ids'))
->map('language', $builder->fromArgument('lang'))
);
$registry->addFieldResolver('Query', 'searchresult',
$builder->produce('entity_load')
->map('type', $builder->fromValue('node'))
->map('id', $builder->fromArgument('id'))
->map('language', $builder->fromArgument('lang'))
);
}
// ___ _