Skip to content

Commit ea67956

Browse files
authored
Merge pull request #2658 from BKapelari/More-Dashboard-Widgets-#2643
2 parents 8aa4fdc + 7c774bd commit ea67956

11 files changed

Lines changed: 519 additions & 57 deletions

File tree

l10n/de_DE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,4 @@
325325
"Limit deck usage of groups" : "Nutzung auf Gruppen einschränken",
326326
"Limiting Deck will block users not part of those groups from creating their own boards. Users will still be able to work on boards that have been shared with them." : "Wenn Sie Deck einschränken, können Benutzer, die nicht zu diesen Gruppen gehören, keine eigenen Boards erstellen. Die Benutzer können weiterhin an Boards arbeiten, die für sie freigegeben wurden."
327327
},"pluralForm" :"nplurals=2; plural=(n != 1);"
328-
}
328+
}

lib/AppInfo/Application.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
use OCA\Deck\Capabilities;
3131
use OCA\Deck\Collaboration\Resources\ResourceProvider;
3232
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
33-
use OCA\Deck\Dashboard\DeckWidget;
33+
use OCA\Deck\Dashboard\DeckWidgetToday;
34+
use OCA\Deck\Dashboard\DeckWidgetTomorrow;
35+
use OCA\Deck\Dashboard\DeckWidgetUpcoming;
3436
use OCA\Deck\Db\Acl;
3537
use OCA\Deck\Db\CardMapper;
3638
use OCA\Deck\Event\AclCreatedEvent;
@@ -135,7 +137,9 @@ public function register(IRegistrationContext $context): void {
135137

136138
$context->registerSearchProvider(DeckProvider::class);
137139
$context->registerSearchProvider(CardCommentProvider::class);
138-
$context->registerDashboardWidget(DeckWidget::class);
140+
$context->registerDashboardWidget(DeckWidgetUpcoming::class);
141+
$context->registerDashboardWidget(DeckWidgetToday::class);
142+
$context->registerDashboardWidget(DeckWidgetTomorrow::class);
139143

140144
$context->registerReferenceProvider(CreateCardReferenceProvider::class);
141145

lib/Dashboard/DeckWidgetToday.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
7+
*
8+
* @author Julius Härtl <jus@bitgrid.net>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OCA\Deck\Dashboard;
28+
29+
use OCP\Dashboard\IWidget;
30+
use OCP\IL10N;
31+
32+
class DeckWidgetToday implements IWidget {
33+
34+
/**
35+
*
36+
* @var IL10N
37+
*/
38+
private $l10n;
39+
40+
public function __construct(IL10N $l10n) {
41+
$this->l10n = $l10n;
42+
}
43+
44+
/**
45+
* @inheritDoc
46+
*/
47+
public function getId(): string {
48+
return 'deckToday';
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
public function getTitle(): string {
55+
return $this->l10n->t('Cards due today');
56+
}
57+
58+
/**
59+
* @inheritDoc
60+
*/
61+
public function getOrder(): int {
62+
return 20;
63+
}
64+
65+
/**
66+
* @inheritDoc
67+
*/
68+
public function getIconClass(): string {
69+
return 'icon-deck';
70+
}
71+
72+
/**
73+
* @inheritDoc
74+
*/
75+
public function getUrl(): ?string {
76+
return null;
77+
}
78+
79+
/**
80+
* @inheritDoc
81+
*/
82+
public function load(): void {
83+
\OCP\Util::addScript('deck', 'dashboard');
84+
}
85+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
7+
*
8+
* @author Julius Härtl <jus@bitgrid.net>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OCA\Deck\Dashboard;
28+
29+
use OCP\Dashboard\IWidget;
30+
use OCP\IL10N;
31+
32+
class DeckWidgetTomorrow implements IWidget {
33+
34+
/**
35+
*
36+
* @var IL10N
37+
*/
38+
private $l10n;
39+
40+
public function __construct(IL10N $l10n) {
41+
$this->l10n = $l10n;
42+
}
43+
44+
/**
45+
* @inheritDoc
46+
*/
47+
public function getId(): string {
48+
return 'deckTomorrow';
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
public function getTitle(): string {
55+
return $this->l10n->t('Cards due tomorrow');
56+
}
57+
58+
/**
59+
* @inheritDoc
60+
*/
61+
public function getOrder(): int {
62+
return 20;
63+
}
64+
65+
/**
66+
* @inheritDoc
67+
*/
68+
public function getIconClass(): string {
69+
return 'icon-deck';
70+
}
71+
72+
/**
73+
* @inheritDoc
74+
*/
75+
public function getUrl(): ?string {
76+
return null;
77+
}
78+
79+
/**
80+
* @inheritDoc
81+
*/
82+
public function load(): void {
83+
\OCP\Util::addScript('deck', 'dashboard');
84+
}
85+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
use OCP\IURLGenerator;
4141
use OCP\Util;
4242

43-
class DeckWidget implements IAPIWidget, IButtonWidget, IIconWidget {
43+
class DeckWidgetUpcoming implements IAPIWidget, IButtonWidget, IIconWidget {
4444
private IL10N $l10n;
4545
private OverviewService $dashboardService;
4646
private IURLGenerator $urlGenerator;

src/components/dashboard/Card.vue

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<template>
2+
<a :key="card.id"
3+
:href="cardLink"
4+
target="_blank"
5+
class="card">
6+
<div class="card--header">
7+
<DueDate class="right" :card="card" />
8+
<span class="title">{{ card.title }}</span>
9+
</div>
10+
<ul v-if="card.labels && card.labels.length"
11+
class="labels">
12+
<li v-for="label in card.labels" :key="label.id" :style="labelStyle(label)">
13+
<span>{{ label.title }}</span>
14+
</li>
15+
</ul>
16+
</a>
17+
</template>
18+
19+
<script>
20+
import DueDate from '../cards/badges/DueDate.vue'
21+
import { generateUrl } from '@nextcloud/router'
22+
import labelStyle from '../../mixins/labelStyle.js'
23+
24+
export default {
25+
name: 'Card',
26+
components: { DueDate },
27+
mixins: [labelStyle],
28+
props: {
29+
card: {
30+
type: Object,
31+
required: true,
32+
},
33+
},
34+
computed: {
35+
cardLink() {
36+
return generateUrl('/apps/deck') + `#/board/${this.card.boardId}/card/${this.card.id}`
37+
},
38+
},
39+
}
40+
</script>
41+
42+
<style lang="scss" scoped>
43+
@import '../../css/labels';
44+
45+
.card {
46+
display: block;
47+
border-radius: var(--border-radius-large);
48+
padding: 8px;
49+
height: 60px;
50+
51+
&:hover {
52+
background-color: var(--color-background-hover);
53+
}
54+
}
55+
56+
.card--header {
57+
overflow: hidden;
58+
.title {
59+
overflow: hidden;
60+
text-overflow: ellipsis;
61+
white-space: nowrap;
62+
display: block;
63+
}
64+
}
65+
66+
.labels {
67+
margin-left: 0;
68+
}
69+
70+
.duedate:deep(.due) {
71+
margin: 0 0 0 10px;
72+
padding: 2px 4px;
73+
font-size: 90%;
74+
}
75+
76+
.right {
77+
float: right;
78+
}
79+
</style>

src/init-dashboard.js

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,64 @@ import './shared-init.js'
2626

2727
const debug = process.env.NODE_ENV !== 'production'
2828

29+
let _imports = null
30+
31+
const getAsyncImports = async () => {
32+
if (_imports) {
33+
return _imports
34+
}
35+
36+
const { default: Vue } = await import('vue')
37+
const { default: Vuex } = await import('vuex')
38+
const { default: dashboard } = await import('./store/dashboard.js')
39+
40+
Vue.prototype.t = t
41+
Vue.prototype.n = n
42+
Vue.prototype.OC = OC
43+
Vue.use(Vuex)
44+
45+
const store = new Vuex.Store({
46+
modules: {
47+
dashboard,
48+
},
49+
strict: debug,
50+
})
51+
52+
_imports = {
53+
store, Vue,
54+
}
55+
56+
return _imports
57+
}
58+
2959
document.addEventListener('DOMContentLoaded', () => {
3060
OCA.Dashboard.register('deck', async (el) => {
31-
const { default: Vue } = await import('vue')
32-
const { default: Vuex } = await import('vuex')
33-
const { default: dashboard } = await import('./store/dashboard.js')
34-
35-
const { default: Dashboard } = await import('./views/Dashboard.vue')
36-
Vue.prototype.t = t
37-
Vue.prototype.n = n
38-
Vue.prototype.OC = OC
39-
Vue.use(Vuex)
40-
41-
const store = new Vuex.Store({
42-
modules: {
43-
dashboard,
44-
},
45-
strict: debug,
46-
})
47-
const View = Vue.extend(Dashboard)
61+
const { Vue, store } = await getAsyncImports()
62+
const { default: DashboardUpcoming } = await import('./views/DashboardUpcoming.vue')
63+
64+
const View = Vue.extend(DashboardUpcoming)
65+
const vm = new View({
66+
propsData: {},
67+
store,
68+
}).$mount(el)
69+
return vm
70+
})
71+
72+
OCA.Dashboard.register('deckToday', async (el) => {
73+
const { Vue, store } = await getAsyncImports()
74+
const { default: DashboardToday } = await import('./views/DashboardToday.vue')
75+
const View = Vue.extend(DashboardToday)
76+
const vm = new View({
77+
propsData: {},
78+
store,
79+
}).$mount(el)
80+
return vm
81+
})
82+
83+
OCA.Dashboard.register('deckTomorrow', async (el) => {
84+
const { Vue, store } = await getAsyncImports()
85+
const { default: DashboardTomorrow } = await import('./views/DashboardTomorrow.vue')
86+
const View = Vue.extend(DashboardTomorrow)
4887
const vm = new View({
4988
propsData: {},
5089
store,

0 commit comments

Comments
 (0)