Add backend for assigning groups to cards

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-03-22 14:49:40 +01:00
parent 097e8df2ad
commit 3c6a177da9
11 changed files with 348 additions and 147 deletions

View File

@@ -25,6 +25,7 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Service\AssignmentService;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -39,6 +40,7 @@
class CardApiController extends ApiController {
private $cardService;
private $userId;
private $assignmentService;
/**
* @param string $appName
@@ -46,10 +48,11 @@ class CardApiController extends ApiController {
* @param CardService $cardService
* @param $userId
*/
public function __construct($appName, IRequest $request, CardService $cardService, $userId) {
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
parent::__construct($appName, $request);
$this->cardService = $cardService;
$this->userId = $userId;
$this->assignmentService = $assignmentService;
}
/**
@@ -135,10 +138,10 @@ class CardApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*
* Unassign a user from a card
* Assign a user to a card
*/
public function unassignUser($userId) {
$card = $this->cardService->unassignUser($this->request->getParam('cardId'), $userId);
public function assignUser($cardId, $userId, $type = 0) {
$card = $this->assignmentService->assignUser($cardId, $userId, $type);
return new DataResponse($card, HTTP::STATUS_OK);
}
@@ -147,10 +150,10 @@ class CardApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*
* Assign a user to a card
* Unassign a user from a card
*/
public function assignUser($userId) {
$card = $this->cardService->assignUser($this->request->getParam('cardId'), $userId);;
public function unassignUser($cardId, $userId, $type = 0) {
$card = $this->assignmentService->unassignUser($cardId, $userId, $type);
return new DataResponse($card, HTTP::STATUS_OK);
}

View File

@@ -5,24 +5,25 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Controller;
use OCA\Deck\Service\AssignmentService;
use OCA\Deck\Service\CardService;
use OCP\IRequest;
use OCP\AppFramework\Controller;
@@ -31,11 +32,13 @@ class CardController extends Controller {
private $userId;
private $cardService;
private $assignmentService;
public function __construct($appName, IRequest $request, CardService $cardService, $userId) {
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
parent::__construct($appName, $request);
$this->userId = $userId;
$this->cardService = $cardService;
$this->assignmentService = $assignmentService;
}
/**
@@ -153,15 +156,15 @@ class CardController extends Controller {
/**
* @NoAdminRequired
*/
public function assignUser($cardId, $userId) {
return $this->cardService->assignUser($cardId, $userId);
public function assignUser($cardId, $userId, $type = 0) {
return $this->assignmentService->assignUser($cardId, $userId, $type);
}
/**
* @NoAdminRequired
*/
public function unassignUser($cardId, $userId) {
return $this->cardService->unassignUser($cardId, $userId);
public function unassignUser($cardId, $userId, $type = 0) {
return $this->assignmentService->unassignUser($cardId, $userId, $type);
}