mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
feat(teams): user preference toggle for mirroring
This commit is contained in:
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
&-modal {
|
&-modal {
|
||||||
&-bg { background: $maroon-100 !important; }
|
&-bg { background: $maroon-100 !important; }
|
||||||
&-headings { color: $white; }
|
&-headings { color: $white !important; }
|
||||||
&-icon { color: $maroon-100 !important; }
|
&-icon { color: $maroon-100 !important; }
|
||||||
&-text { color: $red-1 !important; }
|
&-text { color: $red-1 !important; }
|
||||||
&-content {
|
&-content {
|
||||||
|
|||||||
@@ -28,8 +28,16 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="create-task-area ml-auto d-flex align-items-top"
|
class="create-task-area ml-auto d-flex align-items-center"
|
||||||
>
|
>
|
||||||
|
<toggle-switch
|
||||||
|
id="taskMirrorToggle"
|
||||||
|
class="mr-3 mb-1"
|
||||||
|
:label="'Copy tasks'"
|
||||||
|
:checked="user.preferences.tasks.mirrorGroupTasks"
|
||||||
|
:hover-text="'Add assigned and open tasks to your personal task board'"
|
||||||
|
@change="changeMirrorPreference"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
class="day-start mb-auto d-flex align-items-center"
|
class="day-start mb-auto d-flex align-items-center"
|
||||||
v-html="$t('dayStart', { startTime: groupStartTime } )"
|
v-html="$t('dayStart', { startTime: groupStartTime } )"
|
||||||
@@ -94,6 +102,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
#taskMirrorToggle {
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
.svg-icon {
|
||||||
|
margin: 3px 6px 0px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-switch-description {
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import '~@/assets/scss/colors.scss';
|
@import '~@/assets/scss/colors.scss';
|
||||||
@import '~@/assets/scss/create-task.scss';
|
@import '~@/assets/scss/create-task.scss';
|
||||||
@@ -133,6 +159,9 @@ import taskDefaults from '@/../../common/script/libs/taskDefaults';
|
|||||||
import TaskColumn from '../tasks/column';
|
import TaskColumn from '../tasks/column';
|
||||||
import TaskModal from '../tasks/taskModal';
|
import TaskModal from '../tasks/taskModal';
|
||||||
import GroupPlanOverviewModal from './groupPlanOverviewModal';
|
import GroupPlanOverviewModal from './groupPlanOverviewModal';
|
||||||
|
import toggleSwitch from '@/components/ui/toggleSwitch';
|
||||||
|
|
||||||
|
import sync from '../../mixins/sync';
|
||||||
|
|
||||||
import positiveIcon from '@/assets/svg/positive.svg';
|
import positiveIcon from '@/assets/svg/positive.svg';
|
||||||
import filterIcon from '@/assets/svg/filter.svg';
|
import filterIcon from '@/assets/svg/filter.svg';
|
||||||
@@ -149,7 +178,9 @@ export default {
|
|||||||
TaskColumn,
|
TaskColumn,
|
||||||
TaskModal,
|
TaskModal,
|
||||||
GroupPlanOverviewModal,
|
GroupPlanOverviewModal,
|
||||||
|
toggleSwitch,
|
||||||
},
|
},
|
||||||
|
mixins: [sync],
|
||||||
props: ['groupId'],
|
props: ['groupId'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -239,6 +270,10 @@ export default {
|
|||||||
this.$set(this, 'searchId', to.params.groupId);
|
this.$set(this, 'searchId', to.params.groupId);
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
async beforeRouteLeave (to, from, next) {
|
||||||
|
await this.sync();
|
||||||
|
next();
|
||||||
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
if (!this.searchId) this.searchId = this.groupId;
|
if (!this.searchId) this.searchId = this.groupId;
|
||||||
this.load();
|
this.load();
|
||||||
@@ -369,6 +404,11 @@ export default {
|
|||||||
if (this.temporarilySelectedTags.indexOf(tagId) !== -1) return true;
|
if (this.temporarilySelectedTags.indexOf(tagId) !== -1) return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
changeMirrorPreference (newVal) {
|
||||||
|
this.$store.dispatch('user:set', {
|
||||||
|
'preferences.tasks.mirrorGroupTasks': newVal,
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1164,8 +1164,9 @@ export default {
|
|||||||
if (
|
if (
|
||||||
this.isGroupTask && direction === 'down'
|
this.isGroupTask && direction === 'down'
|
||||||
&& ['todo', 'daily'].indexOf(this.task.type) !== -1
|
&& ['todo', 'daily'].indexOf(this.task.type) !== -1
|
||||||
&& (!this.task.group.assignedUsersDetail
|
&& !((this.task.group.completedBy && this.task.group.completedBy.userId === this.user._id)
|
||||||
|| !this.task.group.assignedUsersDetail[this.user._id])
|
|| (this.task.group.assignedUsersDetail
|
||||||
|
&& this.task.group.assignedUsersDetail[this.user._id]))
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('tasks:needsWork', {
|
this.$store.dispatch('tasks:needsWork', {
|
||||||
taskId: this.task._id,
|
taskId: this.task._id,
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ async function getTasks (req, res, options = {}) {
|
|||||||
let query;
|
let query;
|
||||||
let limit;
|
let limit;
|
||||||
let sort;
|
let sort;
|
||||||
let upgradedGroups;
|
let upgradedGroups = [];
|
||||||
const owner = group || challenge || user;
|
const owner = group || challenge || user;
|
||||||
|
|
||||||
if (challenge) {
|
if (challenge) {
|
||||||
@@ -165,6 +165,7 @@ async function getTasks (req, res, options = {}) {
|
|||||||
} else if (group) {
|
} else if (group) {
|
||||||
query = { 'group.id': group._id };
|
query = { 'group.id': group._id };
|
||||||
} else {
|
} else {
|
||||||
|
if (user.preferences.tasks.mirrorGroupTasks) {
|
||||||
upgradedGroups = await Group.find(
|
upgradedGroups = await Group.find(
|
||||||
{
|
{
|
||||||
_id: { $in: user.guilds.concat(user.party._id) },
|
_id: { $in: user.guilds.concat(user.party._id) },
|
||||||
@@ -177,6 +178,7 @@ async function getTasks (req, res, options = {}) {
|
|||||||
},
|
},
|
||||||
{ _id: 1 },
|
{ _id: 1 },
|
||||||
).exec();
|
).exec();
|
||||||
|
}
|
||||||
if (upgradedGroups.length > 0) {
|
if (upgradedGroups.length > 0) {
|
||||||
const upgradedGroupIds = [];
|
const upgradedGroupIds = [];
|
||||||
for (const upgradedGroup of upgradedGroups) {
|
for (const upgradedGroup of upgradedGroups) {
|
||||||
@@ -210,7 +212,7 @@ async function getTasks (req, res, options = {}) {
|
|||||||
query.type = 'todo';
|
query.type = 'todo';
|
||||||
query.completed = true;
|
query.completed = true;
|
||||||
|
|
||||||
if (upgradedGroups && upgradedGroups.length > 0) {
|
if (upgradedGroups.length > 0) {
|
||||||
query.$or = [
|
query.$or = [
|
||||||
{ userId: user._id },
|
{ userId: user._id },
|
||||||
{ 'group.assignedUsers': user._id },
|
{ 'group.assignedUsers': user._id },
|
||||||
|
|||||||
@@ -582,6 +582,7 @@ export default new Schema({
|
|||||||
tasks: {
|
tasks: {
|
||||||
groupByChallenge: { $type: Boolean, default: false }, // @TODO remove? not used
|
groupByChallenge: { $type: Boolean, default: false }, // @TODO remove? not used
|
||||||
confirmScoreNotes: { $type: Boolean, default: false }, // @TODO remove? not used
|
confirmScoreNotes: { $type: Boolean, default: false }, // @TODO remove? not used
|
||||||
|
mirrorGroupTasks: { $type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
improvementCategories: {
|
improvementCategories: {
|
||||||
$type: Array,
|
$type: Array,
|
||||||
|
|||||||
Reference in New Issue
Block a user