Allow to use card item without being available in global card store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -66,10 +66,6 @@ return [
|
|||||||
['name' => 'card#assignUser', 'url' => '/cards/{cardId}/assign', 'verb' => 'POST'],
|
['name' => 'card#assignUser', 'url' => '/cards/{cardId}/assign', 'verb' => 'POST'],
|
||||||
['name' => 'card#unassignUser', 'url' => '/cards/{cardId}/unassign', 'verb' => 'PUT'],
|
['name' => 'card#unassignUser', 'url' => '/cards/{cardId}/unassign', 'verb' => 'PUT'],
|
||||||
|
|
||||||
// dashboard
|
|
||||||
['name' => 'card#findAllWithDue', 'url' => '/dashboard/due', 'verb' => 'GET'],
|
|
||||||
['name' => 'card#findMyAssignedCards', 'url' => '/dashboard/assigned', 'verb' => 'GET'],
|
|
||||||
|
|
||||||
// attachments
|
// attachments
|
||||||
['name' => 'attachment#getAll', 'url' => '/cards/{cardId}/attachments', 'verb' => 'GET'],
|
['name' => 'attachment#getAll', 'url' => '/cards/{cardId}/attachments', 'verb' => 'GET'],
|
||||||
['name' => 'attachment#create', 'url' => '/cards/{cardId}/attachment', 'verb' => 'POST'],
|
['name' => 'attachment#create', 'url' => '/cards/{cardId}/attachment', 'verb' => 'POST'],
|
||||||
@@ -138,5 +134,9 @@ return [
|
|||||||
['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'],
|
['name' => 'comments_api#create', 'url' => '/api/v1.0/cards/{cardId}/comments', 'verb' => 'POST'],
|
||||||
['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
|
['name' => 'comments_api#update', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'PUT'],
|
||||||
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
['name' => 'comments_api#delete', 'url' => '/api/v1.0/cards/{cardId}/comments/{commentId}', 'verb' => 'DELETE'],
|
||||||
|
|
||||||
|
// dashboard
|
||||||
|
['name' => 'dashboard_api#findAllWithDue', 'url' => '/api/v1.0/dashboard/dashboard/due', 'verb' => 'GET'],
|
||||||
|
['name' => 'dashboard_api#findAssignedCards', 'url' => '/api/v1.0/dashboard/assigned', 'verb' => 'GET'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@@ -167,20 +167,4 @@ class CardController extends Controller {
|
|||||||
public function unassignUser($cardId, $userId, $type = 0) {
|
public function unassignUser($cardId, $userId, $type = 0) {
|
||||||
return $this->assignmentService->unassignUser($cardId, $userId, $type);
|
return $this->assignmentService->unassignUser($cardId, $userId, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function findAllWithDue($userId) {
|
|
||||||
return $this->dashboardService->findAllWithDue($userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function findMyAssignedCards($userId) {
|
|
||||||
return $this->dashboardService->findMyAssignedCards($userId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
56
lib/Controller/DashboardApiController.php
Normal file
56
lib/Controller/DashboardApiController.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2020 Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @author Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @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\DashboardService;
|
||||||
|
use OCP\IRequest;
|
||||||
|
use OCP\AppFramework\Controller;
|
||||||
|
|
||||||
|
class DashboardApiController extends OCSController {
|
||||||
|
private $userId;
|
||||||
|
private $cardService;
|
||||||
|
|
||||||
|
public function __construct($appName, IRequest $request, DashboardService $dashboardService, $userId) {
|
||||||
|
parent::__construct($appName, $request);
|
||||||
|
$this->userId = $userId;
|
||||||
|
$this->dashboardService = $dashboardService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function findAllWithDue($userId) {
|
||||||
|
return $this->dashboardService->findAllWithDue($userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function findAssignedCards($userId) {
|
||||||
|
return $this->dashboardService->findAssignedCards($userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -149,7 +149,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
return $this->findEntities($sql, [$boardId]);
|
return $this->findEntities($sql, [$boardId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findMyAssignedCards($boardId, $username) {
|
public function findAssignedCards($boardId, $username) {
|
||||||
$sql = 'SELECT c.* FROM `*PREFIX*deck_cards` c
|
$sql = 'SELECT c.* FROM `*PREFIX*deck_cards` c
|
||||||
INNER JOIN `*PREFIX*deck_stacks` s ON s.id = c.stack_id
|
INNER JOIN `*PREFIX*deck_stacks` s ON s.id = c.stack_id
|
||||||
INNER JOIN `*PREFIX*deck_boards` b ON b.id = s.board_id
|
INNER JOIN `*PREFIX*deck_boards` b ON b.id = s.board_id
|
||||||
|
|||||||
@@ -583,8 +583,8 @@ class CardService {
|
|||||||
* @throws \OCA\Deck\NoPermissionException
|
* @throws \OCA\Deck\NoPermissionException
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function findMyAssignedCards($userId) {
|
public function findAssignedCards($userId) {
|
||||||
$cards = $this->cardMapper->findMyAssignedCards($userId);
|
$cards = $this->cardMapper->findAssignedCards($userId);
|
||||||
|
|
||||||
return $cards;
|
return $cards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class DashboardService {
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function findMyAssignedCards($userId) {
|
public function findAssignedCards($userId) {
|
||||||
$userInfo = $this->getBoardPrerequisites();
|
$userInfo = $this->getBoardPrerequisites();
|
||||||
$userBoards = $this->findAllBoardsFromUser($userInfo);
|
$userBoards = $this->findAllBoardsFromUser($userInfo);
|
||||||
$allAssignedCards = [];
|
$allAssignedCards = [];
|
||||||
@@ -155,7 +155,7 @@ class DashboardService {
|
|||||||
$cardData = $card->jsonSerialize();
|
$cardData = $card->jsonSerialize();
|
||||||
$cardData['boardId'] = $userBoard->getId();
|
$cardData['boardId'] = $userBoard->getId();
|
||||||
return $cardData;
|
return $cardData;
|
||||||
}, $this->cardMapper->findMyAssignedCards($userBoard->getId(), $this->userId));
|
}, $this->cardMapper->findAssignedCards($userBoard->getId(), $this->userId));
|
||||||
}
|
}
|
||||||
return $allAssignedCards;
|
return $allAssignedCards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.$store.dispatch('loadBoards')
|
this.$store.dispatch('loadBoards')
|
||||||
this.$store.dispatch('loadSharees')
|
this.$store.dispatch('loadSharees')
|
||||||
this.$store.dispatch('loadDashboards')
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="badges">
|
<div v-if="card" class="badges">
|
||||||
<div v-if="card.commentsUnread > 0" class="icon icon-comment" />
|
<div v-if="card.commentsUnread > 0" class="icon icon-comment" />
|
||||||
|
|
||||||
<div v-if="card.description && checkListCount > 0" class="card-tasks icon icon-checkmark">
|
<div v-if="card.description && checkListCount > 0" class="card-tasks icon icon-checkmark">
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<AvatarList :users="card.assignedUsers" />
|
<AvatarList :users="card.assignedUsers" />
|
||||||
|
|
||||||
<CardMenu :id="id" />
|
<CardMenu :id="card.id" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -45,8 +45,8 @@ export default {
|
|||||||
name: 'CardBadges',
|
name: 'CardBadges',
|
||||||
components: { AvatarList, CardMenu },
|
components: { AvatarList, CardMenu },
|
||||||
props: {
|
props: {
|
||||||
id: {
|
card: {
|
||||||
type: Number,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -57,9 +57,6 @@ export default {
|
|||||||
checkListCheckedCount() {
|
checkListCheckedCount() {
|
||||||
return (this.card.description.match(/^\s*([*+-]|(\d\.))\s+\[\s*x\s*\](.*)$/gim) || []).length
|
return (this.card.description.match(/^\s*([*+-]|(\d\.))\s+\[\s*x\s*\](.*)$/gim) || []).length
|
||||||
},
|
},
|
||||||
card() {
|
|
||||||
return this.$store.getters.cardById(this.id)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AttachmentDragAndDrop :card-id="id" class="drop-upload--card">
|
<AttachmentDragAndDrop v-if="card" :card-id="card.id" class="drop-upload--card">
|
||||||
<div :class="{'compact': compactMode, 'current-card': currentCard, 'has-labels': card.labels && card.labels.length > 0, 'is-editing': editing}"
|
<div :class="{'compact': compactMode, 'current-card': currentCard, 'has-labels': card.labels && card.labels.length > 0, 'is-editing': editing}"
|
||||||
tag="div"
|
tag="div"
|
||||||
class="card"
|
class="card"
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<div v-show="!compactMode" class="card-controls compact-item" @click="openCard">
|
<div v-show="!compactMode" class="card-controls compact-item" @click="openCard">
|
||||||
<CardBadges :id="id" />
|
<CardBadges :card="card" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AttachmentDragAndDrop>
|
</AttachmentDragAndDrop>
|
||||||
@@ -95,6 +95,10 @@ export default {
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -113,10 +117,10 @@ export default {
|
|||||||
'isArchived',
|
'isArchived',
|
||||||
]),
|
]),
|
||||||
card() {
|
card() {
|
||||||
return this.$store.getters.cardById(this.id)
|
return this.item ? this.item : this.$store.getters.cardById(this.id)
|
||||||
},
|
},
|
||||||
currentCard() {
|
currentCard() {
|
||||||
return this.$route.params.cardId === this.id
|
return this.card && this.$route && this.$route.params.cardId === this.card.id
|
||||||
},
|
},
|
||||||
relativeDate() {
|
relativeDate() {
|
||||||
const diff = moment(this.$root.time).diff(this.card.duedate, 'seconds')
|
const diff = moment(this.$root.time).diff(this.card.duedate, 'seconds')
|
||||||
@@ -144,7 +148,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openCard() {
|
openCard() {
|
||||||
this.$router.push({ name: 'card', params: { cardId: this.id } }).catch(() => {})
|
const boardId = this.item ? this.item.boardId : this.$route.params.id
|
||||||
|
this.$router.push({ name: 'card', params: { id: boardId, cardId: this.card.id } }).catch(() => {})
|
||||||
},
|
},
|
||||||
startEditing(card) {
|
startEditing(card) {
|
||||||
this.copiedCard = Object.assign({}, card)
|
this.copiedCard = Object.assign({}, card)
|
||||||
|
|||||||
@@ -28,24 +28,29 @@
|
|||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>overdue</h2>
|
<h2>overdue</h2>
|
||||||
<div v-for="card in withDueDashboardGroup.overdue" :key="card.id">
|
<div v-for="card in withDueDashboardGroup.overdue" :key="card.id">
|
||||||
<!-- <CardItem :id="card.id" /> -->
|
<CardItem :item="card" />
|
||||||
{{ card.title }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>today</h2>
|
<h2>today</h2>
|
||||||
{{ withDueDashboardGroup.today }}
|
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>tomorrow</h2>
|
<h2>tomorrow</h2>
|
||||||
{{ withDueDashboardGroup.tomorrow }}
|
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>this week</h2>
|
<h2>this week</h2>
|
||||||
{{ withDueDashboardGroup.thisWeek }}
|
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -53,26 +58,31 @@
|
|||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>overdue</h2>
|
<h2>overdue</h2>
|
||||||
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
|
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
|
||||||
{{ card.title }}
|
<CardItem :item="card" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>today</h2>
|
<h2>today</h2>
|
||||||
{{ assignedCardsDashboardGroup.today }}
|
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>tomorrow</h2>
|
<h2>tomorrow</h2>
|
||||||
{{ assignedCardsDashboardGroup.tomorrow }}
|
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>this week</h2>
|
<h2>this week</h2>
|
||||||
{{ assignedCardsDashboardGroup.thisWeek }}
|
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -81,6 +91,7 @@
|
|||||||
import Controls from '../Controls'
|
import Controls from '../Controls'
|
||||||
import CardItem from '../cards/CardItem'
|
import CardItem from '../cards/CardItem'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
import moment from '@nextcloud/moment'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Dashboards',
|
name: 'Dashboards',
|
||||||
@@ -106,6 +117,9 @@ export default {
|
|||||||
return this.groupByDue(this.assignedCardsDashboard)
|
return this.groupByDue(this.assignedCardsDashboard)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.$store.dispatch('loadDashboards')
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
groupByDue(dataset) {
|
groupByDue(dataset) {
|
||||||
const all = {
|
const all = {
|
||||||
|
|||||||
53
src/services/DashboardApi.js
Normal file
53
src/services/DashboardApi.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* @copyright Copyright (c) 2020 Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @author Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import axios from '@nextcloud/axios'
|
||||||
|
import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router'
|
||||||
|
|
||||||
|
export class DashboardApi {
|
||||||
|
|
||||||
|
url(url) {
|
||||||
|
url = `/apps/deck${url}`
|
||||||
|
return generateOcsUrl(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
findAllWithDue(data) {
|
||||||
|
return axios.get(this.url(`/api/v1.0/dashboard/dashboard/due`))
|
||||||
|
.then(
|
||||||
|
(response) => Promise.resolve(response.data),
|
||||||
|
(err) => Promise.reject(err)
|
||||||
|
)
|
||||||
|
.catch((err) => Promise.reject(err)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
findMyAssignedCards(data) {
|
||||||
|
return axios.get(this.url(`/ocs/v2.php/apps/deck/api/v1.0/dashboard/assigned`))
|
||||||
|
.then(
|
||||||
|
(response) => Promise.resolve(response.data),
|
||||||
|
(err) => Promise.reject(err)
|
||||||
|
)
|
||||||
|
.catch((err) => Promise.reject(err)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import { CardApi } from '../services/CardApi'
|
import { DashboardApi } from '../services/DashboardApi'
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
const apiClient = new CardApi()
|
const apiClient = new DashboardApi()
|
||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
withDue: [],
|
withDue: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user