<commit_before>import { MeetingSeries } from '/imports/meetingseries';
import { $ } from 'meteor/jquery';

function clearForm(template) {
    template.find("#id_meetingproject").value = "";
    template.find("#id_meetingname").value = "";
    template.find("#id_meetingproject").focus();
}

function escapeHandler(event) {
    event.preventDefault();

    let escapeWasPressed = event.key == 'Escape';

    // for browsers that do not support event.key yet
    escapeWasPressed |= event.keyCode === 27;

    if (escapeWasPressed) {
        $('#collapseMeetingSeriesAdd').collapse('hide');
    }
}

async function addMeetingSeries(template, optimisticUICallback, clearForm = true) {

    let aProject = template.find("#id_meetingproject").value;
    let aName = template.find("#id_meetingname").value;

    let ms = new MeetingSeries({
        project: aProject,
        name: aName,
        createdAt: new Date()
    });

    try {
        await ms.save(optimisticUICallback);
        if (clearForm) {
            clearForm(template);
        }
    } catch (error) {
        Session.set('errorTitle', 'Error');
        Session.set('errorReason', error.reason);
    }
}

Template.meetingSeriesAdd.events({<commit_msg>Bugfix: adding a new meeting series displayed always a empty error message.<commit_after>import { MeetingSeries } from '/imports/meetingseries';
import { $ } from 'meteor/jquery';

function clearForm(template) {
    template.find("#id_meetingproject").value = "";
    template.find("#id_meetingname").value = "";
    template.find("#id_meetingproject").focus();
}

function escapeHandler(event) {
    event.preventDefault();

    let escapeWasPressed = event.key == 'Escape';

    // for browsers that do not support event.key yet
    escapeWasPressed |= event.keyCode === 27;

    if (escapeWasPressed) {
        $('#collapseMeetingSeriesAdd').collapse('hide');
    }
}

async function addMeetingSeries(template, optimisticUICallback, doClearForm = true) {

    let aProject = template.find("#id_meetingproject").value;
    let aName = template.find("#id_meetingname").value;

    let ms = new MeetingSeries({
        project: aProject,
        name: aName,
        createdAt: new Date()
    });

    try {
        await ms.save(optimisticUICallback);
        if (doClearForm) {
            clearForm(template);
        }
    } catch (error) {
        Session.set('errorTitle', 'Error');
        Session.set('errorReason', error.reason);
    }
}

Template.meetingSeriesAdd.events({
{'fraction_non_alphanumeric': 0.13690952762209768, 'fraction_numerical': 0.0016012810248198558, 'mean_word_length': 3.286449399656947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6676', 'n_tokens_mistral': 745, 'n_tokens_neox': 723, 'n_words': 148}