<commit_before>class MCTaskTemplateCreateSamplesComponentController {
    /*@ngInject*/
    constructor(prepareCreatedSample, focus, $mdDialog) {
        this.lastId = 0;
        this.prepareCreatedSample = prepareCreatedSample;
        this.focus = focus;
        this.$mdDialog = $mdDialog;

        if (!this.task.template.samples) {
            let id = 'sample_' + this.lastId++;
            this.task.template.samples = [];
        }
    }

    addSample() {
        let id = 'sample_' + this.lastId++;

        this.task.template.samples.push({
            name: '',
            id: id
        });
        this.focus(id);
    }

    addMultipleSamples() {
        this.$mdDialog.show({
            templateUrl: 'app/project/experiments/experiment/components/tasks/components/add-multiple-samples-dialog.html',
            controller: AddMultipleSamplesDialogController,
            controllerAs: '$ctrl',
            bindToController: true,
            locals: {
                lastId: this.lastId
            }
        }).then(
            (addedSamples, nextId) => {
                this.task.template.samples = this.task.template.samples.concat(addedSamples);
                this.lastId = nextId;
            }
        )
    }

    prepareSample() {
        this.prepareCreatedSample.filloutComposition(this.sample, this.composition);
        this.prepareCreatedSample.setupSampleGroup(this.sample, this.sampleGroup, this.sampleGroupSizing,
            this.sampleGroupSize);
        this.prepareCreatedSample.addSampleInputFiles(this.sample, this.process.input_files);
    }
}

angular.module('materialscommons').component('mcTaskTemplateCreateSamples', {
    templateUrl: 'app/project/experiments/experiment/components/tasks/components/mc-task-template-create-samples.html',
    controller: MCTaskTemplateCreateSamplesComponentController,
    bindings: {
        task: '='
    }
});

class AddMultipleSamplesDialogController {
    /*@ngInject*/
    constructor($mdDialog) {
        this.$mdDialog = $mdDialog;
        this.nameTemplate = "";
        this.count = 2;
    }

    done() {
        let addedSamples = [];
        for (let i = 0; i < this.count; i++) {
            let id = "sample_" + i,
                entry = {
                    name: 'sample_' + (i + 1),
                    id: id
                };
            addedSamples.push(entry);
        }
        console.log(addedSamples.length);
        this.$mdDialog.hide(addedSamples);
    }

    cancel() {
        this.$mdDialog.cancel();
    }
}
<commit_msg>Pass in and change the lastId to the dialog.<commit_after>class MCTaskTemplateCreateSamplesComponentController {
    /*@ngInject*/
    constructor(prepareCreatedSample, focus, $mdDialog) {
        this.lastId = 0;
        this.prepareCreatedSample = prepareCreatedSample;
        this.focus = focus;
        this.$mdDialog = $mdDialog;

        if (!this.task.template.samples) {
            let id = 'sample_' + this.lastId++;
            this.task.template.samples = [];
        }
    }

    addSample() {
        let id = 'sample_' + this.lastId++;

        this.task.template.samples.push({
            name: '',
            id: id
        });
        this.focus(id);
    }

    addMultipleSamples() {
        this.$mdDialog.show({
            templateUrl: 'app/project/experiments/experiment/components/tasks/components/add-multiple-samples-dialog.html',
            controller: AddMultipleSamplesDialogController,
            controllerAs: '$ctrl',
            bindToController: true,
            locals: {
                lastId: this.lastId
            }
        }).then(
            (addedSamples, nextId) => {
                this.task.template.samples = this.task.template.samples.concat(addedSamples);
                this.lastId = nextId;
            }
        )
    }

    prepareSample() {
        this.prepareCreatedSample.filloutComposition(this.sample, this.composition);
        this.prepareCreatedSample.setupSampleGroup(this.sample, this.sampleGroup, this.sampleGroupSizing,
            this.sampleGroupSize);
        this.prepareCreatedSample.addSampleInputFiles(this.sample, this.process.input_files);
    }
}

angular.module('materialscommons').component('mcTaskTemplateCreateSamples', {
    templateUrl: 'app/project/experiments/experiment/components/tasks/components/mc-task-template-create-samples.html',
    controller: MCTaskTemplateCreateSamplesComponentController,
    bindings: {
        task: '='
    }
});

class AddMultipleSamplesDialogController {
    /*@ngInject*/
    constructor($mdDialog) {
        this.$mdDialog = $mdDialog;
        this.nameTemplate = "";
        this.count = 2;
    }

    done() {
        let addedSamples = [];
        for (let i = 0; i < this.count; i++) {
            let id = "sample_" + i,
                entry = {
                    name: 'sample_' + (i + 1),
                    id: id
                };
            addedSamples.push(entry);
        }
        let nextId = this.lastId + addedSamples.length;
        console.log(addedSamples.length);
        this.$mdDialog.hide(addedSamples);
    }

    cancel() {
        this.$mdDialog.cancel();
    }
}

{'fraction_non_alphanumeric': 0.11994583091507062, 'fraction_numerical': 0.0015476881408396208, 'mean_word_length': 2.0128205128205128, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5666018', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1403, 'n_words': 216}