HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/assets/vue/widgets/Worklist/components/TasksByDay.vue
<template>
  <div v-show="buckets.length">
    <h4 class="card-title notification-title bg-light">
      {{ taskHeadLabel }}
    </h4>
    <task-bucket
      v-for="(bucket, index) in buckets"
      :key="index"
      :bucket="bucket"
      @close_bucket="deleteBucket(index)"
    ></task-bucket>
  </div>
</template>
<script>
import { chunkArrayInGroups } from '../../../utils/util';
import TaskBucket from './TaskBucket.vue';
import * as _ from 'lodash';
export default {
  components: {
    TaskBucket,
  },
  props: {
    task: {
      type: Object,
      required: true,
    },
    bucketLimit: {
      type: Number,
      required: true,
    },
  },
  data() {
    return {
      tasks: this.task.tasks,
      buckets: chunkArrayInGroups([...this.task.tasks], this.bucketLimit),
    };
  },
  methods: {
    deleteBucket(index) {
      this.buckets = _.filter(this.buckets, (b, i) => i !== index);
    },
  },
  computed: {
    taskHeadLabel() {
      if (this.tasks[0]['istoday'] === true) return 'Today';
      if (this.tasks[0]['isyesterday'] === true) return 'Yesterday';
      return this.tasks[0]['dateFormattedString'];
    },
  },
  watch: {
    tasks(v, oldv) {
      if (!_.isEqual(v.tasks, oldv.tasks)) {
        this.tasks = [...v.tasks];
        this.buckets = chunkArrayInGroups([...this.tasks], this.bucketLimit);
      }
    },
  },
};
</script>