diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 78de597dd..3a661cae0 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -54,6 +54,7 @@ use OCA\Deck\Notification\Notifier; use OCA\Deck\Reference\BoardReferenceProvider; use OCA\Deck\Reference\CardReferenceProvider; use OCA\Deck\Reference\CommentReferenceProvider; +use OCA\Deck\Reference\CreateCardReferenceProvider; use OCA\Deck\Search\CardCommentProvider; use OCA\Deck\Search\DeckProvider; use OCA\Deck\Service\PermissionService; @@ -129,6 +130,8 @@ class Application extends App implements IBootstrap { $context->registerSearchProvider(CardCommentProvider::class); $context->registerDashboardWidget(DeckWidget::class); + $context->registerReferenceProvider(CreateCardReferenceProvider::class); + // reference widget $context->registerReferenceProvider(CardReferenceProvider::class); $context->registerReferenceProvider(BoardReferenceProvider::class); diff --git a/lib/Controller/CardApiController.php b/lib/Controller/CardApiController.php index b864adc2a..bb1c8a880 100644 --- a/lib/Controller/CardApiController.php +++ b/lib/Controller/CardApiController.php @@ -82,8 +82,17 @@ class CardApiController extends ApiController { * * Get a specific card. */ - public function create($title, $type = 'plain', $order = 999, $description = '', $duedate = null) { + public function create($title, $type = 'plain', $order = 999, $description = '', $duedate = null, $labels = [], $users = []) { $card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId, $description, $duedate); + + foreach ($labels as $labelId) { + $this->cardService->assignLabel($card->id, $labelId); + } + + foreach ($users as $user) { + $this->assignmentService->assignUser($card->id, $user['id'], $user['type']); + } + return new DataResponse($card, HTTP::STATUS_OK); } diff --git a/lib/Controller/CardController.php b/lib/Controller/CardController.php index cc46a1a3b..2260d0dac 100644 --- a/lib/Controller/CardController.php +++ b/lib/Controller/CardController.php @@ -77,8 +77,18 @@ class CardController extends Controller { * @param int $order * @return \OCP\AppFramework\Db\Entity */ - public function create($title, $stackId, $type = 'plain', $order = 999, string $description = '') { - return $this->cardService->create($title, $stackId, $type, $order, $this->userId, $description); + public function create($title, $stackId, $type = 'plain', $order = 999, string $description = '', $duedate = null, $labels = [], $users = []) { + $card = $this->cardService->create($title, $stackId, $type, $order, $this->userId, $description, $duedate); + + foreach ($labels as $label) { + $this->assignLabel($card->id, $label); + } + + foreach ($users as $user) { + $this->assignmentService->assignUser($card->id, $user['id'], $user['type']); + } + + return $card; } /** diff --git a/lib/Reference/CreateCardReferenceProvider.php b/lib/Reference/CreateCardReferenceProvider.php new file mode 100644 index 000000000..5afaa555d --- /dev/null +++ b/lib/Reference/CreateCardReferenceProvider.php @@ -0,0 +1,78 @@ +l10n->t('Create a new deck card'); + } + + /** + * @inheritDoc + */ + public function getOrder(): int { + return 10; + } + + /** + * @inheritDoc + */ + public function getIconUrl(): string { + return $this->urlGenerator->getAbsoluteURL( + $this->urlGenerator->imagePath(Application::APP_ID, 'deck-dark.svg') + ); + } + + /** + * @inheritDoc + */ + public function matchReference(string $referenceText): bool { + return false; + } + + /** + * @inheritDoc + */ + public function resolveReference(string $referenceText): ?IReference { + return null; + } + + /** + * @inheritDoc + */ + public function getCachePrefix(string $referenceId): string { + return $this->userId ?? ''; + } + + /** + * We don't use the userId here but rather a reference unique id + * @inheritDoc + */ + public function getCacheKey(string $referenceId): ?string { + return $referenceId; + } +} diff --git a/src/CardCreateDialog.vue b/src/CardCreateDialog.vue index 604640a6f..e3241f6c6 100644 --- a/src/CardCreateDialog.vue +++ b/src/CardCreateDialog.vue @@ -22,101 +22,23 @@