committed by
Julius Härtl
parent
818ffa2d57
commit
66f6a3e193
@@ -25,7 +25,6 @@ namespace OCA\Deck\Controller;
|
|||||||
|
|
||||||
use OCA\Deck\Service\AssignmentService;
|
use OCA\Deck\Service\AssignmentService;
|
||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCA\Deck\Service\DashboardService;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
|
||||||
@@ -34,11 +33,10 @@ class CardController extends Controller {
|
|||||||
private $cardService;
|
private $cardService;
|
||||||
private $assignmentService;
|
private $assignmentService;
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, CardService $cardService, DashboardService $dashboardService, AssignmentService $assignmentService, $userId) {
|
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->cardService = $cardService;
|
$this->cardService = $cardService;
|
||||||
$this->dashboardService = $dashboardService;
|
|
||||||
$this->assignmentService = $assignmentService;
|
$this->assignmentService = $assignmentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ export default {
|
|||||||
name: 'CardMenu',
|
name: 'CardMenu',
|
||||||
components: { Actions, ActionButton, Modal, Multiselect },
|
components: { Actions, ActionButton, Modal, Multiselect },
|
||||||
props: {
|
props: {
|
||||||
/* id: {
|
|
||||||
type: Number,
|
|
||||||
default: null,
|
|
||||||
}, */
|
|
||||||
card: {
|
card: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
@@ -107,9 +103,6 @@ export default {
|
|||||||
currentBoard: state => state.currentBoard,
|
currentBoard: state => state.currentBoard,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/* card() {
|
|
||||||
return this.$store.getters.cardById(this.id)
|
|
||||||
}, */
|
|
||||||
isBoardAndStackChoosen() {
|
isBoardAndStackChoosen() {
|
||||||
if (this.selectedBoard === '' || this.selectedStack === '') {
|
if (this.selectedBoard === '' || this.selectedStack === '') {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -24,83 +24,92 @@
|
|||||||
<div>
|
<div>
|
||||||
<Controls :dashboard-name="filter" />
|
<Controls :dashboard-name="filter" />
|
||||||
|
|
||||||
<div v-if="filter=='due'" class="dashboard">
|
<div v-if="loading" key="loading" class="emptycontent">
|
||||||
<div class="dashboard-column">
|
<div class="icon icon-loading" />
|
||||||
<h2>overdue</h2>
|
<h2>{{ t('deck', 'Loading Dashboard') }}</h2>
|
||||||
<div v-for="card in withDueDashboardGroup.overdue" :key="card.id">
|
<p />
|
||||||
<CardItem :item="card" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
|
||||||
<h2>today</h2>
|
|
||||||
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
|
|
||||||
<CardItem :item="card" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
|
||||||
<h2>tomorrow</h2>
|
|
||||||
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
|
|
||||||
<CardItem :item="card" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
|
||||||
<h2>this week</h2>
|
|
||||||
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
|
|
||||||
<CardItem :item="card" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
|
||||||
<h2>later</h2>
|
|
||||||
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
|
|
||||||
<CardItem :item="card" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="filter=='assigned'" class="dashboard">
|
<div v-else>
|
||||||
<div class="dashboard-column">
|
|
||||||
<h2>no due</h2>
|
<div v-if="filter=='due'" class="dashboard">
|
||||||
<div v-for="card in withDueDashboardGroup.noDue" :key="card.id">
|
<div class="dashboard-column">
|
||||||
<CardItem :item="card" />
|
<h2>{{ t('deck', 'overdue') }}</h2>
|
||||||
|
<div v-for="card in dueOverdue" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-column">
|
||||||
|
<h2>{{ t('deck', 'today') }}</h2>
|
||||||
|
<div v-for="card in withDueDashboardGroup.today" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-column">
|
||||||
|
<h2>{{ t('deck', 'tomorrow') }}</h2>
|
||||||
|
<div v-for="card in withDueDashboardGroup.tomorrow" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-column">
|
||||||
|
<h2>{{ t('deck', 'this week') }}</h2>
|
||||||
|
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-column">
|
||||||
|
<h2>{{ t('deck', 'later') }}</h2>
|
||||||
|
<div v-for="card in withDueDashboardGroup.thisWeek" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div v-if="filter=='assigned'" class="dashboard">
|
||||||
<h2>overdue</h2>
|
<div class="dashboard-column">
|
||||||
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
|
<h2>{{ t('deck', 'no due') }}</h2>
|
||||||
<CardItem :item="card" />
|
<div v-for="card in assignedCardsDashboardGroup.nodue" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>today</h2>
|
<h2>{{ t('deck', 'overdue') }}</h2>
|
||||||
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
|
<div v-for="card in assignedCardsDashboardGroup.overdue" :key="card.id">
|
||||||
<CardItem :item="card" />
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>tomorrow</h2>
|
<h2>{{ t('deck', 'today') }}</h2>
|
||||||
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
|
<div v-for="card in assignedCardsDashboardGroup.today" :key="card.id">
|
||||||
<CardItem :item="card" />
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>this week</h2>
|
<h2>{{ t('deck', 'tomorrow') }}</h2>
|
||||||
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
|
<div v-for="card in assignedCardsDashboardGroup.tomorrow" :key="card.id">
|
||||||
<CardItem :item="card" />
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="dashboard-column">
|
<div class="dashboard-column">
|
||||||
<h2>this week</h2>
|
<h2>{{ t('deck', 'this week') }}</h2>
|
||||||
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
|
<div v-for="card in assignedCardsDashboardGroup.thisWeek" :key="card.id">
|
||||||
<CardItem :item="card" />
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-column">
|
||||||
|
<h2>{{ t('deck', 'later') }}</h2>
|
||||||
|
<div v-for="card in withDueDashboardGroup.later" :key="card.id">
|
||||||
|
<CardItem :item="card" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -126,10 +135,16 @@ export default {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
data: function() {
|
||||||
|
return {
|
||||||
|
loading: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'withDueDashboard',
|
'withDueDashboard',
|
||||||
'assignedCardsDashboard',
|
'assignedCardsDashboard',
|
||||||
|
'dueOverdue'
|
||||||
]),
|
]),
|
||||||
withDueDashboardGroup() {
|
withDueDashboardGroup() {
|
||||||
return this.groupByDue(this.withDueDashboard)
|
return this.groupByDue(this.withDueDashboard)
|
||||||
@@ -139,9 +154,31 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$store.dispatch('loadDashboards')
|
this.getData()
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
"$route.params.filter"() {
|
||||||
|
this.getData()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async getData() {
|
||||||
|
this.loading = true
|
||||||
|
try {
|
||||||
|
if (this.filter === 'due') {
|
||||||
|
await this.$store.dispatch('loadDueDashboard')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.filter === 'assigned') {
|
||||||
|
await this.$store.dispatch('loadAssignDashboard')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
groupByDue(dataset) {
|
groupByDue(dataset) {
|
||||||
const all = {
|
const all = {
|
||||||
nodue: [],
|
nodue: [],
|
||||||
@@ -156,20 +193,23 @@ export default {
|
|||||||
if (card.duedate === null) {
|
if (card.duedate === null) {
|
||||||
all.nodue.push(card)
|
all.nodue.push(card)
|
||||||
} else {
|
} else {
|
||||||
const days = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 / 24)
|
const hours = Math.floor(moment(card.duedate).diff(this.$root.time, 'seconds') / 60 / 60 )
|
||||||
if (days < 0) {
|
let d = new Date()
|
||||||
|
let currentHour = d.getHours()
|
||||||
|
console.log(card.title +' '+ hours )
|
||||||
|
if (hours < 0) {
|
||||||
all.overdue.push(card)
|
all.overdue.push(card)
|
||||||
}
|
}
|
||||||
if (days === 0) {
|
if (hours >= 0 && hours < (24 - currentHour)) {
|
||||||
all.today.push(card)
|
all.today.push(card)
|
||||||
}
|
}
|
||||||
if (days === 1) {
|
if (hours >= (24 - currentHour) && hours < (48 - currentHour)) {
|
||||||
all.tomorrow.push(card)
|
all.tomorrow.push(card)
|
||||||
}
|
}
|
||||||
if (days > 1 && days < 8) {
|
if (hours >= (48 - currentHour) && hours < (24 * 7)) {
|
||||||
all.thisWeek.push(card)
|
all.thisWeek.push(card)
|
||||||
}
|
}
|
||||||
if (days > 8) {
|
if (hours >= (24 * 7)) {
|
||||||
all.later.push(card)
|
all.later.push(card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,25 +194,4 @@ export class CardApi {
|
|||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
findAllWithDue(data) {
|
|
||||||
return axios.get(this.url(`/dashboard/due`))
|
|
||||||
.then(
|
|
||||||
(response) => Promise.resolve(response.data),
|
|
||||||
(err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
.catch((err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
findMyAssignedCards(data) {
|
|
||||||
return axios.get(this.url(`/dashboard/assigned`))
|
|
||||||
.then(
|
|
||||||
(response) => Promise.resolve(response.data),
|
|
||||||
(err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
.catch((err) => Promise.reject(err)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ export default {
|
|||||||
assignedCards: [],
|
assignedCards: [],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
dueOverdue: state => {
|
||||||
|
return state.withDue.filter((card) => {
|
||||||
|
return card
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
withDueDashboard: state => {
|
withDueDashboard: state => {
|
||||||
return state.withDue
|
return state.withDue
|
||||||
},
|
},
|
||||||
@@ -49,15 +55,16 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async loadDashboards({ commit }) {
|
async loadDueDashboard({ commit }) {
|
||||||
const withDue = await apiClient.findAllWithDue()
|
const withDue = await apiClient.findAllWithDue()
|
||||||
const withDueFlat = withDue.flat()
|
const withDueFlat = withDue.flat()
|
||||||
commit('setWithDueDashboard', withDueFlat)
|
commit('setWithDueDashboard', withDueFlat)
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadAssignDashboard({ commit }) {
|
||||||
const assignedCards = await apiClient.findMyAssignedCards()
|
const assignedCards = await apiClient.findMyAssignedCards()
|
||||||
const assignedCardsFlat = assignedCards.flat()
|
const assignedCardsFlat = assignedCards.flat()
|
||||||
commit('setAssignedCards', assignedCardsFlat)
|
commit('setAssignedCards', assignedCardsFlat)
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user