Skip to content
Snippets Groups Projects
Select Git revision
  • cf961f344e929ff56d8f98154b6de2601355bf16
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

CoursewareModule.class.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    CoursewareDateInput.vue 1.19 KiB
    <template>
        <input :value="formattedDate" @input="onInput" type="date" :min="formattedMinDate" />
    </template>
    
    <script>
    const fromISO8601 = (string) => new Date(string);
    const toISO8601 = (date) => date.toISOString();
    const pad = (what, length = 2) => `00000000${what}`.substr(-length);
    
    export default {
        props: ['value', 'min'],
        data: () => ({
            date: new Date(),
            submissionDate: new Date()
        }),
        computed: {
            formattedDate() {
                return `${this.date.getFullYear()}-${pad(this.date.getMonth() + 1)}-${pad(this.date.getDate())}`;
            },
            formattedMinDate() {
                return `${this.submissionDate.getFullYear()}-${pad(this.submissionDate.getMonth() + 1)}-${pad(this.submissionDate.getDate())}`;
            }
        },
        methods: {
            onInput({ target }) {
                const newValue = toISO8601(target.valueAsDate);
                if (newValue !== this.value) {
                    this.$emit('input', newValue);
                }
            },
        },
        beforeMount() {
            if (this.value) {
                this.date = fromISO8601(this.value);
            }
            if (this.min) {
                this.submissionDate = fromISO8601(this.min);
            }
        },
    };
    </script>