Only offer on/off setting when a board is not shared
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -92,16 +92,27 @@ class NotificationHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Once assigning users is possible, those should be notified instead of all users of the board
|
|
||||||
$boardId = $this->cardMapper->findBoardId($card->getId());
|
$boardId = $this->cardMapper->findBoardId($card->getId());
|
||||||
$board = $this->getBoard($boardId);
|
$board = $this->getBoard($boardId, false, true);
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
foreach ($this->permissionService->findUsers($boardId) as $user) {
|
foreach ($this->permissionService->findUsers($boardId) as $user) {
|
||||||
$notificationSetting = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'board:' . $boardId . ':notify-due', ConfigService::SETTING_BOARD_NOTIFICATION_DUE_DEFAULT);
|
$notificationSetting = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'board:' . $boardId . ':notify-due', ConfigService::SETTING_BOARD_NOTIFICATION_DUE_DEFAULT);
|
||||||
if (
|
|
||||||
$notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ALL ||
|
if ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_OFF) {
|
||||||
($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignedUsersMapper->isUserAssigned($card->getId(), $user->getUID()))
|
continue;
|
||||||
) {
|
}
|
||||||
|
|
||||||
|
$shouldNotify = $notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ALL;
|
||||||
|
|
||||||
|
if ($user->getUID() === $board->getOwner() && count($board->getAcl()) === 0) {
|
||||||
|
// Notify if all or assigned is configured for unshared boards
|
||||||
|
$shouldNotify = true;
|
||||||
|
} else if ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignedUsersMapper->isUserAssigned($card->getId(), $user->getUID())) {
|
||||||
|
// Notify if the user is assigned and has the assigned setting selected
|
||||||
|
$shouldNotify = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($shouldNotify) {
|
||||||
$notification = $this->notificationManager->createNotification();
|
$notification = $this->notificationManager->createNotification();
|
||||||
$notification
|
$notification
|
||||||
->setApp('deck')
|
->setApp('deck')
|
||||||
@@ -187,9 +198,9 @@ class NotificationHelper {
|
|||||||
* @return Board
|
* @return Board
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
*/
|
*/
|
||||||
private function getBoard($boardId) {
|
private function getBoard($boardId, bool $withLabels = false, bool $withAcl = false) {
|
||||||
if (!array_key_exists($boardId, $this->boards)) {
|
if (!array_key_exists($boardId, $this->boards)) {
|
||||||
$this->boards[$boardId] = $this->boardMapper->find($boardId);
|
$this->boards[$boardId] = $this->boardMapper->find($boardId, $withLabels, $withAcl);
|
||||||
}
|
}
|
||||||
return $this->boards[$boardId];
|
return $this->boards[$boardId];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,13 +65,28 @@
|
|||||||
{{ t('deck', 'Archive board') }}
|
{{ t('deck', 'Archive board') }}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
|
||||||
<ActionButton :icon="!showDueSettings ? 'icon-notifications-dark' : 'icon-view-previous' " @click="showDueSettings=!showDueSettings">
|
<!-- Due date reminder settings -->
|
||||||
|
|
||||||
|
<ActionButton v-if="showDueSettings"
|
||||||
|
:icon="updateDueSetting ? 'icon-loading-small' : 'icon-view-previous'"
|
||||||
|
:disabled="updateDueSetting"
|
||||||
|
@click="showDueSettings=false">
|
||||||
{{ t('deck', 'Due date reminders') }}
|
{{ t('deck', 'Due date reminders') }}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
<ActionButton v-else-if="board.acl.length > 0"
|
||||||
|
:title="t('deck', 'Due date reminders')"
|
||||||
|
:icon="dueDateReminderIcon"
|
||||||
|
@click="showDueSettings=true">
|
||||||
|
{{ dueDateReminderText }}
|
||||||
|
</ActionButton>
|
||||||
|
<ActionButton v-else :icon="board.settings['notify-due'] === 'off' ? 'icon-sound' : 'icon-sound-off'" @click="board.settings['notify-due'] === 'off' ? updateSetting('notify-due', 'all') : updateSetting('notify-due', 'off')">
|
||||||
|
{{ board.settings['notify-due'] === 'off' ? t('deck', 'Turn on due date reminders') : t('deck', 'Turn off due date reminders') }}
|
||||||
|
</ActionButton>
|
||||||
|
|
||||||
<ActionButton v-if="showDueSettings"
|
<ActionButton v-if="showDueSettings"
|
||||||
name="notification"
|
name="notification"
|
||||||
icon="icon-sound"
|
icon="icon-sound"
|
||||||
|
:disabled="updateDueSetting"
|
||||||
:class="{ 'forced-active': board.settings['notify-due'] === 'all' }"
|
:class="{ 'forced-active': board.settings['notify-due'] === 'all' }"
|
||||||
@click="updateSetting('notify-due', 'all')">
|
@click="updateSetting('notify-due', 'all')">
|
||||||
{{ t('deck', 'All cards') }}
|
{{ t('deck', 'All cards') }}
|
||||||
@@ -79,6 +94,7 @@
|
|||||||
<ActionButton v-if="showDueSettings"
|
<ActionButton v-if="showDueSettings"
|
||||||
name="notification"
|
name="notification"
|
||||||
icon="icon-user"
|
icon="icon-user"
|
||||||
|
:disabled="updateDueSetting"
|
||||||
:class="{ 'forced-active': board.settings['notify-due'] === 'assigned' }"
|
:class="{ 'forced-active': board.settings['notify-due'] === 'assigned' }"
|
||||||
@click="updateSetting('notify-due', 'assigned')">
|
@click="updateSetting('notify-due', 'assigned')">
|
||||||
{{ t('deck', 'Assigned cards') }}
|
{{ t('deck', 'Assigned cards') }}
|
||||||
@@ -86,6 +102,7 @@
|
|||||||
<ActionButton v-if="showDueSettings"
|
<ActionButton v-if="showDueSettings"
|
||||||
name="notification"
|
name="notification"
|
||||||
icon="icon-sound-off"
|
icon="icon-sound-off"
|
||||||
|
:disabled="updateDueSetting"
|
||||||
:class="{ 'forced-active': board.settings['notify-due'] === 'off' }"
|
:class="{ 'forced-active': board.settings['notify-due'] === 'off' }"
|
||||||
@click="updateSetting('notify-due', 'off')">
|
@click="updateSetting('notify-due', 'off')">
|
||||||
{{ t('deck', 'No notifications') }}
|
{{ t('deck', 'No notifications') }}
|
||||||
@@ -145,6 +162,7 @@ export default {
|
|||||||
editTitle: '',
|
editTitle: '',
|
||||||
editColor: '',
|
editColor: '',
|
||||||
showDueSettings: false,
|
showDueSettings: false,
|
||||||
|
updateDueSetting: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -166,6 +184,26 @@ export default {
|
|||||||
canManage() {
|
canManage() {
|
||||||
return this.board.permissions.PERMISSION_MANAGE
|
return this.board.permissions.PERMISSION_MANAGE
|
||||||
},
|
},
|
||||||
|
dueDateReminderIcon() {
|
||||||
|
if (this.board.settings['notify-due'] === 'all') {
|
||||||
|
return 'icon-sound'
|
||||||
|
} else if (this.board.settings['notify-due'] === 'assigned') {
|
||||||
|
return 'icon-user'
|
||||||
|
} else if (this.board.settings['notify-due'] === 'off') {
|
||||||
|
return 'icon-sound-off'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
dueDateReminderText() {
|
||||||
|
if (this.board.settings['notify-due'] === 'all') {
|
||||||
|
return t('deck', 'All cards')
|
||||||
|
} else if (this.board.settings['notify-due'] === 'assigned') {
|
||||||
|
return t('deck', 'Only assigned cards')
|
||||||
|
} else if (this.board.settings['notify-due'] === 'off') {
|
||||||
|
return t('deck', 'No reminder')
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {},
|
watch: {},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -262,9 +300,12 @@ export default {
|
|||||||
this.$router.push(route)
|
this.$router.push(route)
|
||||||
},
|
},
|
||||||
async updateSetting(key, value) {
|
async updateSetting(key, value) {
|
||||||
|
this.updateDueSetting = value
|
||||||
const setting = {}
|
const setting = {}
|
||||||
setting['board:' + this.board.id + ':' + key] = value
|
setting['board:' + this.board.id + ':' + key] = value
|
||||||
await this.$store.dispatch('setConfig', setting)
|
await this.$store.dispatch('setConfig', setting)
|
||||||
|
this.showDueSettings = false
|
||||||
|
this.updateDueSetting = null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inject: [
|
inject: [
|
||||||
|
|||||||
Reference in New Issue
Block a user