fix search provider names/ids, set results thumbnail urls, use them in ref provider
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
@@ -26,13 +26,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Search;
|
||||
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCP\Search\SearchResultEntry;
|
||||
|
||||
class BoardSearchResultEntry extends SearchResultEntry {
|
||||
public function __construct(Board $board, $urlGenerator) {
|
||||
parent::__construct(
|
||||
'',
|
||||
$urlGenerator->getAbsoluteURL(
|
||||
$urlGenerator->imagePath(Application::APP_ID, 'deck-dark.svg')
|
||||
),
|
||||
$board->getTitle(),
|
||||
'',
|
||||
$urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId(),
|
||||
|
||||
@@ -49,7 +49,7 @@ class CardCommentProvider implements IProvider {
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
return 'deck-comment';
|
||||
return 'search-deck-comment';
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
@@ -65,7 +65,7 @@ class CardCommentProvider implements IProvider {
|
||||
$results
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return SearchResult::paginated(
|
||||
$this->l10n->t('Card comments'),
|
||||
$results,
|
||||
|
||||
@@ -26,6 +26,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Search;
|
||||
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\Stack;
|
||||
@@ -33,6 +34,14 @@ use OCP\Search\SearchResultEntry;
|
||||
|
||||
class CardSearchResultEntry extends SearchResultEntry {
|
||||
public function __construct(Board $board, Stack $stack, Card $card, $urlGenerator) {
|
||||
parent::__construct('', $card->getTitle(), $board->getTitle() . ' » ' . $stack->getTitle(), $urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId() . '/card/' . $card->getId(), 'icon-deck');
|
||||
parent::__construct(
|
||||
$urlGenerator->getAbsoluteURL(
|
||||
$urlGenerator->imagePath(Application::APP_ID, 'card.svg')
|
||||
),
|
||||
$card->getTitle(),
|
||||
$board->getTitle() . ' » ' . $stack->getTitle(),
|
||||
$urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId() . '/card/' . $card->getId(),
|
||||
'icon-deck'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\Deck\Search;
|
||||
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
@@ -36,7 +37,9 @@ class CommentSearchResultEntry extends SearchResultEntry {
|
||||
|
||||
public function __construct(string $commentId, string $commentMessage, string $commentAuthor, Card $card, IURLGenerator $urlGenerator, IL10N $l10n) {
|
||||
parent::__construct(
|
||||
'',
|
||||
$urlGenerator->getAbsoluteURL(
|
||||
$urlGenerator->imagePath('core', 'actions/comment.svg')
|
||||
),
|
||||
// TRANSLATORS This is describing the author and card title related to a comment e.g. "Jane on MyTask"
|
||||
$l10n->t('%s on %s', [$commentAuthor, $card->getTitle()]),
|
||||
$commentMessage,
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace OCA\Deck\Search;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Service\SearchService;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\Search\IProvider;
|
||||
@@ -36,30 +37,26 @@ use OCP\Search\ISearchQuery;
|
||||
use OCP\Search\SearchResult;
|
||||
|
||||
class DeckProvider implements IProvider {
|
||||
|
||||
/**
|
||||
* @var SearchService
|
||||
*/
|
||||
private $searchService;
|
||||
/**
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
private IL10N $l10n;
|
||||
private SearchService $searchService;
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
SearchService $searchService,
|
||||
IURLGenerator $urlGenerator
|
||||
IURLGenerator $urlGenerator,
|
||||
IL10N $l10n
|
||||
) {
|
||||
$this->l10n = $l10n;
|
||||
$this->searchService = $searchService;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
return 'deck';
|
||||
return 'search-deck-card-board';
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return 'Deck';
|
||||
return $this->l10n->t('Deck boards and cards');
|
||||
}
|
||||
|
||||
public function search(IUser $user, ISearchQuery $query): SearchResult {
|
||||
@@ -99,14 +96,14 @@ class DeckProvider implements IProvider {
|
||||
// if both cards and boards results are less then the limit, we know we won't get more
|
||||
if (count($resultEntries) < $query->getLimit()) {
|
||||
return SearchResult::complete(
|
||||
'Deck',
|
||||
$this->getName(),
|
||||
$resultEntries
|
||||
);
|
||||
}
|
||||
|
||||
$newCursor = $this->getNewCursor($boardObjects, $cardObjects);
|
||||
return SearchResult::paginated(
|
||||
'Deck',
|
||||
$this->getName(),
|
||||
$resultEntries,
|
||||
$newCursor
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user