import { removeById } from '../../../../../../util/util';

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

/*@ngInject*/
function MCTaskTemplateOtherComponentController(processSelections, createProcess, toastr,
                                                previousStateService, $state, sampleLinker, processEdit,
                                                $stateParams) {
    var ctrl = this;
    ctrl.remove = removeById;
    ctrl.chooseSamples = _.partial(processSelections.selectSamples, ctrl.task.template.input_samples);
    ctrl.chooseInputFiles = _.partial(processSelections.selectFiles, ctrl.task.template.input_files);
    ctrl.chooseOutputFiles = _.partial(processSelections.selectFiles, ctrl.task.template.output_files);

    ctrl.linkFilesToSample = linkFilesToSample;

    ctrl.submit = submit;
    ctrl.submitAndAnother = submitAndAnother;
    //ctrl.cancel = _.partial(previousStateService.go, 'process_create_previous');

    // previousStateService.setMemo('process_create_previous', 'project.processes.create');

    function submitAndAnother() {
        var go = _.partial($state.go, 'project.processes.create', {
            template_id: ctrl.task.template.process_name,
            process_id: ''
        });
        performSubmit(go);
    }

    function submit() {
        var go = _.partial(previousStateService.go, 'process_create_previous');
        performSubmit(go);
    }

    function performSubmit(goFn) {
        createProcess($stateParams.project_id, ctrl.process)
            .then(
                function success() {
                    goFn();
                },

                function failure() {
                    toastr.error('Unable to create sample', 'Error', {closeButton: true});
                }
            );
    }

    function linkFilesToSample(sample, input_files, output_files) {
        sampleLinker.linkFilesToSample(sample, input_files, output_files).then(function(linkedFiles) {
            sample = processEdit.refreshSample(linkedFiles, sample);
        });
    }
}
@@ -1,63 +1,4 @@
-import %7B removeById %7D from '../../../../../../util/util';%0A%0A
 angu
@@ -341,1615 +341,105 @@
 ler(
-processSelections, createProcess, toastr,%0A                                                previousStateService, $state, sampleLinker, processEdit,%0A                                                $stateParams) %7B%0A    var ctrl = this;%0A    ctrl.remove = removeById;%0A    ctrl.chooseSamples = _.partial(processSelections.selectSamples, ctrl.task.template.input_samples);%0A    ctrl.chooseInputFiles = _.partial(processSelections.selectFiles, ctrl.task.template.input_files);%0A    ctrl.chooseOutputFiles = _.partial(processSelections.selectFiles, ctrl.task.template.output_files);%0A%0A    ctrl.linkFilesToSample = linkFilesToSample;%0A%0A    ctrl.submit = submit;%0A    ctrl.submitAndAnother = submitAndAnother;%0A    //ctrl.cancel = _.partial(previousStateService.go, 'process_create_previous');%0A%0A    // previousStateService.setMemo('process_create_previous', 'project.processes.create');%0A%0A    function submitAndAnother() %7B%0A        var go = _.partial($state.go, 'project.processes.create', %7B%0A            template_id: ctrl.task.template.process_name,%0A            process_id: ''%0A        %7D);%0A        performSubmit(go);%0A    %7D%0A%0A    function submit() %7B%0A        var go = _.partial(previousStateService.go, 'process_create_previous');%0A        performSubmit(go);%0A    %7D%0A%0A    function performSubmit(goFn) %7B%0A        createProcess($stateParams.project_id, ctrl.process)%0A            .then(%0A                function success() %7B%0A                    goFn();%0A                %7D,%0A%0A                function failure() %7B%0A                    toastr.error('Unable to create sample', 'Error', %7BcloseButton: true%7D);%0A                %7D%0A            );%0A    %7D
+sampleLinker, processEdit) %7B%0A    var ctrl = this;%0A    ctrl.linkFilesToSample = linkFilesToSample;
 %0A%0A  

Remove unused code.