another display for modalcard accordeon, displaying note icon on mediumcard and refresh it updated in modale
This commit is contained in:
@@ -46,6 +46,7 @@ type Materiau implements NodeInterface & SearchResultInterface{
|
||||
reference: String
|
||||
samples: [Sample]
|
||||
note: Note
|
||||
note_id: Int
|
||||
# famille: String
|
||||
# index: Int
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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'))
|
||||
);
|
||||
}
|
||||
|
||||
// ___ _
|
||||
|
Reference in New Issue
Block a user