Skip to content

Commit

Permalink
hide column background if task too close
Browse files Browse the repository at this point in the history
  • Loading branch information
paglias committed Aug 6, 2017
1 parent 5f4fb62 commit 25d9064
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions website/client/components/tasks/column.vue
Expand Up @@ -9,7 +9,7 @@
:class="{active: activeFilter.label === filter.label}",
@click="activateFilter(type, filter)",
) {{ $t(filter.label) }}
.tasks-list
.tasks-list(ref="taskList")
task(
v-for="task in taskList",
:key="task.id", :task="task",
Expand All @@ -18,7 +18,11 @@
@editTask="editTask",
)
.bottom-gradient
.column-background(v-if="isUser === true", :class="{'initial-description': tasks[`${type}s`].length === 0}")
.column-background(
v-if="isUser === true",
:class="{'initial-description': tasks[`${type}s`].length === 0}",
ref="columnBackground",
)
.svg-icon(v-html="icons[type]", :class="`icon-${type}`", v-once)
h3(v-once) {{$t('theseAreYourTasks', {taskType: `${type}s`})}}
.small-text {{$t(`${type}sDesc`)}}
Expand Down Expand Up @@ -139,6 +143,7 @@ import dailyIcon from 'assets/svg/daily.svg';
import todoIcon from 'assets/svg/todo.svg';
import rewardIcon from 'assets/svg/reward.svg';
import bModal from 'bootstrap-vue/lib/components/modal';
import throttle from 'lodash/throttle';
export default {
components: {
Expand Down Expand Up @@ -206,6 +211,17 @@ export default {
return this.tasks[`${this.type}s`];
},
},
watch: {
taskList: {
handler: throttle(function setColumnBackgroundVisibility () {
this.setColumnBackgroundVisibility();
}, 250),
deep: true,
},
},
mounted () {
this.setColumnBackgroundVisibility();
},
methods: {
...mapActions({loadCompletedTodos: 'tasks:fetchCompletedTodos'}),
editTask (task) {
Expand All @@ -217,6 +233,23 @@ export default {
}
this.activeFilter = filter;
},
setColumnBackgroundVisibility () {
this.$nextTick(() => {
const taskListEl = this.$refs.taskList;
const tasklistHeight = taskListEl.offsetHeight;
let combinedTasksHeights = 0;
Array.from(taskListEl.getElementsByClassName('task')).forEach(el => {
combinedTasksHeights += el.offsetHeight;
});
const columnBackgroundStyle = this.$refs.columnBackground.style;
if (tasklistHeight - combinedTasksHeights < 150) {
columnBackgroundStyle.display = 'none';
} else {
columnBackgroundStyle.display = 'block';
}
});
},
filterTask (task) {
// View
if (!this.activeFilter.filter(task)) return false;
Expand Down

0 comments on commit 25d9064

Please sign in to comment.