{"size": 2512, "ext": "js", "max_stars_repo_path": "module/front/web/script/createdTask.js", "max_stars_repo_name": "mkhorin/evado-app-bugs", "max_stars_repo_stars_event_min_datetime": "2020-10-03T22:49:45.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-25T10:08:28.000Z", "max_issues_repo_path": "module/front/web/script/createdTask.js", "max_issues_repo_name": "mkhorin/evado-app-bugs", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "module/front/web/script/createdTask.js", "max_forks_repo_name": "mkhorin/evado-app-bugs", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.9047619048, "max_line_length": 99, "alphanum_fraction": 0.4641719745}
'use strict';

Vue.component('created-task', {
    props: {
        task: String
    },
    data () {
        return {
            id: null,
            project: null,
            assignee: null,
            author: null,
            priority: null,
            state: null,
            stateTitle: null,
            createdAt: null,
            summary: null,
            description: null,
            timeSpent: null
        };
    },
    computed: {
        isDone () {
            return this.state === 'done';
        },
        isClosed () {
            return this.state === 'closed';
        }
    },
    async created () {
        this.$on('load', this.onLoad);
        await this.reload();
    },
    methods: {
        async onClose () {
            await this.transit('close');
        },
        async onReject () {
            await Jam.dialog.confirm('Return this task to work?');
            await this.transit('reject');
        },
        async onReopen () {
            await Jam.dialog.confirm('Reopen this task now?');
            await this.transit('reopen');
        },
        async transit (transition) {
            try {
                await this.fetchText('transit', {
                    class: 'task',
                    id: this.task,
                    transition
                });
                await this.reload();
            } catch (err) {
                this.showError(err);
            }
        },
        async reload () {
            await this.load(this.task);
        },
        async load (id) {
            const data = await this.fetchJson('read', {
                class: 'task',
                view: 'edit',
                id
            });
            this.$emit('load', data);
        },
        onLoad (data) {
            this.id = data._id;
            this.project = this.getValueTitle('project', data);
            this.assignee = Jam.FormatHelper.asNotSetOnEmpty(this.getValueTitle('assignee', data));
            this.author = this.getValueTitle('author', data);
            this.priority = this.getValueTitle('priority', data);
            this.state = data._state;
            this.stateTitle = Jam.t(this.getValueTitle('_state', data), 'meta');
            this.createdAt = Jam.FormatHelper.asDatetime(data._createdAt);
            this.summary = data.summary;
            this.description = data.description;
            this.timeSpent = Jam.FormatHelper.asNotSetOnEmpty(data.timeSpent);
        }
    },
    template: '#created-task'
});