-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): Migrate admin settings to vue
Signed-off-by: Joas Schilling <coding@schilljs.com>
- Loading branch information
1 parent
b51a6c1
commit 3ebe05e
Showing
4 changed files
with
182 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> | ||
- | ||
- @author Joas Schilling <coding@schilljs.com> | ||
- | ||
- @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/>. | ||
--> | ||
|
||
<template> | ||
<NcSettingsSection :title="t('announcementcenter', 'Announcements')"> | ||
<NcSettingsSelectGroup v-model="adminGroups" | ||
:label="t('announcementcenter', 'These groups will be able to post announcements.')" | ||
@input="updateGroups" /> | ||
|
||
<NcCheckboxRadioSwitch :checked="createActivities" | ||
type="switch" | ||
@update:checked="toggleCreateActivities"> | ||
{{ t('announcementcenter', 'Create activities by default') }} | ||
</NcCheckboxRadioSwitch> | ||
<NcCheckboxRadioSwitch :checked="createNotifications" | ||
type="switch" | ||
@update:checked="toggleCreateNotifications"> | ||
{{ t('announcementcenter', 'Create notifications by default') }} | ||
</NcCheckboxRadioSwitch> | ||
<NcCheckboxRadioSwitch :checked="sendEmails" | ||
type="switch" | ||
@update:checked="toggleSendEmails"> | ||
{{ t('announcementcenter', 'Send emails by default') }} | ||
</NcCheckboxRadioSwitch> | ||
<NcCheckboxRadioSwitch :checked="allowComments" | ||
type="switch" | ||
@update:checked="toggleAllowComments"> | ||
{{ t('announcementcenter', 'Allow comments by default') }} | ||
</NcCheckboxRadioSwitch> | ||
</NcSettingsSection> | ||
</template> | ||
|
||
<script> | ||
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' | ||
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' | ||
import NcSettingsSelectGroup from '@nextcloud/vue/dist/Components/NcSettingsSelectGroup.js' | ||
import { loadState } from '@nextcloud/initial-state' | ||
import { showError, showSuccess } from '@nextcloud/dialogs' | ||
export default { | ||
name: 'AdminSettings', | ||
components: { | ||
NcCheckboxRadioSwitch, | ||
NcSettingsSection, | ||
NcSettingsSelectGroup, | ||
}, | ||
data() { | ||
return { | ||
adminGroups: loadState('announcementcenter', 'admin_groups'), | ||
createActivities: loadState('announcementcenter', 'create_activities'), | ||
createNotifications: loadState('announcementcenter', 'create_notifications'), | ||
sendEmails: loadState('announcementcenter', 'send_emails'), | ||
allowComments: loadState('announcementcenter', 'allow_comments'), | ||
} | ||
}, | ||
methods: { | ||
async toggleCreateActivities(config) { | ||
OCP.AppConfig.setValue('announcementcenter', 'create_activities', (config ? 'yes' : 'no'), { | ||
success: function() { | ||
this.createActivities = config | ||
showSuccess(t('announcementcenter', 'Setting changed')) | ||
}.bind(this), | ||
error() { | ||
showError(t('announcementcenter', 'An error occurred while changing the setting')) | ||
}, | ||
}) | ||
}, | ||
async toggleCreateNotifications(config) { | ||
OCP.AppConfig.setValue('announcementcenter', 'create_notifications', (config ? 'yes' : 'no'), { | ||
success: function() { | ||
this.createNotifications = config | ||
showSuccess(t('announcementcenter', 'Setting changed')) | ||
}.bind(this), | ||
error() { | ||
showError(t('announcementcenter', 'An error occurred while changing the setting')) | ||
}, | ||
}) | ||
}, | ||
async toggleSendEmails(config) { | ||
OCP.AppConfig.setValue('announcementcenter', 'send_emails', (config ? 'yes' : 'no'), { | ||
success: function() { | ||
this.sendEmails = config | ||
showSuccess(t('announcementcenter', 'Setting changed')) | ||
}.bind(this), | ||
error() { | ||
showError(t('announcementcenter', 'An error occurred while changing the setting')) | ||
}, | ||
}) | ||
}, | ||
async toggleAllowComments(config) { | ||
OCP.AppConfig.setValue('announcementcenter', 'allow_comments', (config ? 'yes' : 'no'), { | ||
success: function() { | ||
this.allowComments = config | ||
showSuccess(t('announcementcenter', 'Setting changed')) | ||
}.bind(this), | ||
error() { | ||
showError(t('announcementcenter', 'An error occurred while changing the setting')) | ||
}, | ||
}) | ||
}, | ||
async updateGroups(config) { | ||
OCP.AppConfig.setValue('announcementcenter', 'admin_groups', JSON.stringify(config), { | ||
success() { | ||
showSuccess(t('announcementcenter', 'Setting changed')) | ||
}, | ||
error() { | ||
showError(t('announcementcenter', 'An error occurred while changing the setting')) | ||
}, | ||
}) | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com> | ||
* | ||
* @author Joas Schilling <coding@schilljs.com> | ||
* | ||
* @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/>. | ||
* | ||
*/ | ||
|
||
script('announcementcenter', 'announcementcenter-admin'); | ||
|
||
/** @var array $_ */ | ||
/** @var \OCP\IL10N $l */ | ||
?> | ||
<div id="announcementcenter" class="section"> | ||
<h2 class="inlineblock"><?php p($l->t('Announcements')); ?></h2> | ||
|
||
<p> | ||
<input type="hidden" name="admin_groups" class="admin_groups" value="<?php p($_['adminGroups']) ?>" style="width: 320px;" /> | ||
<br /> | ||
<em><?php p($l->t('These groups will be able to post announcements.')); ?></em> | ||
</p> | ||
<br /> | ||
|
||
<p> | ||
<input id="announcementcenter_create_activities" name="create_activities" | ||
type="checkbox" class="checkbox" value="1" | ||
<?php if ($_['createActivities']) { | ||
print_unescaped('checked="checked"'); | ||
} ?> /> | ||
<label for="announcementcenter_create_activities"><?php p($l->t('Create activities by default'));?></label><br/> | ||
</p> | ||
|
||
<p> | ||
<input id="announcementcenter_create_notifications" name="create_notifications" | ||
type="checkbox" class="checkbox" value="1" | ||
<?php if ($_['createNotifications']) { | ||
print_unescaped('checked="checked"'); | ||
} ?> /> | ||
<label for="announcementcenter_create_notifications"><?php p($l->t('Create notifications by default'));?></label><br/> | ||
</p> | ||
|
||
<p> | ||
<input id="announcementcenter_send_emails" name="send_emails" | ||
type="checkbox" class="checkbox" value="1" | ||
<?php if ($_['sendEmails']) { | ||
print_unescaped('checked="checked"'); | ||
} ?> /> | ||
<label for="announcementcenter_send_emails"><?php p($l->t('Send emails by default'));?></label><br/> | ||
</p> | ||
|
||
<p> | ||
<input id="announcementcenter_allow_comments" name="allow_comments" | ||
type="checkbox" class="checkbox" value="1" | ||
<?php if ($_['allowComments']) { | ||
print_unescaped('checked="checked"'); | ||
} ?> /> | ||
<label for="announcementcenter_allow_comments"><?php p($l->t('Allow comments by default'));?></label><br/> | ||
</p> | ||
</div> | ||
<div id="announcementcenter" class="section"></div> |