<commit_before>import React from 'react/addons';
import Reflux from 'reflux';

import newFormMixin from '../editorMixins/newForm';
import editableFormMixin from '../editorMixins/editableForm';
import existingFormMixin from '../editorMixins/existingForm';
import Select from 'react-select';
import ui from '../ui';
import bem from '../bem';

import {Navigation} from 'react-router';
import {session} from '../stores';

let newFormMixins = [
    Navigation,
    Reflux.ListenerMixin,
    editableFormMixin,
    newFormMixin,
];
import {dataInterface} from '../dataInterface';
import {
  t,
} from '../utils';

export var NewForm = React.createClass({
  mixins: [
    Navigation,
    Reflux.ListenerMixin,
  ],
  createAsset () {
    var getNodeVal = (att)=> {
      return this.refs[att].getDOMNode().value;
    }
    dataInterface.createResource({
      name: getNodeVal('name'),
      settings: {
        description: getNodeVal('description'),
        sector: getNodeVal('sector'),
        country: getNodeVal('country'),
        'share-metadata': getNodeVal('share-metadata'),
      },
      asset_type: 'survey',
    }).done((asset) => {
      var isNewForm = false;
      if (isNewForm) {
        this.transitionTo('form-landing', {assetid: asset.uid})
      } else {
        this.transitionTo('form-edit', {assetid: asset.uid})
      }
    });
  },
  getInitialState () {
    return {
      sessionLoaded: !!session.currentAccount,
    }
  },
  componentDidMount () {
    this.listenTo(session, (session) => {
      this.setState({
        sessionLoaded: true,
      });
    });
  },
  routeBack () {
    this.transitionTo('forms');
  },
  render () {
    if (!this.state.sessionLoaded) {
      return (
          <bem.Loading>
            <bem.Loading__inner>
              <i />
              {t('loading...')} 
            </bem.Loading__inner>
          </bem.Loading>
        )
    }
    var acct = session.currentAccount;
    var fromFile = false;
    var sectors = acct.available_sectors;
    var countries = acct.available_countries;
    return (
      <ui.Modal open onClose={this.routeBack} title={t('Create New Project from Scratch')}>
        <ui.Modal.Body>
          <bem.FormModal>
            <bem.FormModal__item>
              <label htmlFor="name">
                {t('Project Name')}
              </label>
              <input type="text"
                  ref="name"
                  id="name"
                  placeholder={t('Enter title of project here')}
                />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label htmlFor="description">
                {t('Description')}
              </label>
              <textarea type="text" ref="description"
                  id="description"
                  placeholder={t('Enter short description here')}
                />
            </bem.FormModal__item>

            <bem.FormModal__item>
              <label className="long">
                {t('Please specify the country and the sector where this project will be deployed.')}
                {t('This information will be used to help you filter results on the project list page.')}
              </label>
              <label htmlFor="sector">
                {t('Sector')}
              </label>
              <Select name="sector"
                  ref="sector"
                  id="sector"
                  options={sectors}
                />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label htmlFor="country">
                {t('Country')}
              </label>
              <Select name="country"
                id="country"
                ref="country"
                options={countries}
              />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label className="long">
                {t('Help KoboToolbox improve this product by sharing the sector and country where this project will be deployed.')}<commit_msg>fixes issue with certain details not being sent<commit_after>import React from 'react/addons';
import Reflux from 'reflux';

import newFormMixin from '../editorMixins/newForm';
import editableFormMixin from '../editorMixins/editableForm';
import existingFormMixin from '../editorMixins/existingForm';
import Select from 'react-select';
import ui from '../ui';
import bem from '../bem';

import {Navigation} from 'react-router';
import {session} from '../stores';

let newFormMixins = [
    Navigation,
    Reflux.ListenerMixin,
    editableFormMixin,
    newFormMixin,
];
import {dataInterface} from '../dataInterface';
import {
  t,
} from '../utils';

export var NewForm = React.createClass({
  mixins: [
    Navigation,
    Reflux.ListenerMixin,
  ],
  countryChange (val) {
    this.setState({
      countryVal: val
    });
  },
  sectorChange (val) {
    this.setState({
      sectorVal: val
    });
  },
  createAsset () {
    var getNodeVal = (att)=> {
      return this.refs[att].getDOMNode().value;
    }
    dataInterface.createResource({
      name: getNodeVal('name'),
      settings: {
        description: getNodeVal('description'),
        sector: this.state.sectorVal,
        country: this.state.countryVal,
        'share-metadata': getNodeVal('share-metadata') === "on",
      },
      asset_type: 'survey',
    }).done((asset) => {
      var isNewForm = false;
      if (isNewForm) {
        this.transitionTo('form-landing', {assetid: asset.uid})
      } else {
        this.transitionTo('form-edit', {assetid: asset.uid})
      }
    });
  },
  getInitialState () {
    return {
      sessionLoaded: !!session.currentAccount,
      sectorVal: '',
      countryVal: '',
    }
  },
  componentDidMount () {
    this.listenTo(session, (session) => {
      this.setState({
        sessionLoaded: true,
      });
    });
  },
  routeBack () {
    this.transitionTo('forms');
  },
  render () {
    if (!this.state.sessionLoaded) {
      return (
          <bem.Loading>
            <bem.Loading__inner>
              <i />
              {t('loading...')} 
            </bem.Loading__inner>
          </bem.Loading>
        )
    }
    var acct = session.currentAccount;
    var fromFile = false;
    var sectors = acct.available_sectors;
    var countries = acct.available_countries;
    return (
      <ui.Modal open onClose={this.routeBack} title={t('Create New Project from Scratch')}>
        <ui.Modal.Body>
          <bem.FormModal>
            <bem.FormModal__item>
              <label htmlFor="name">
                {t('Project Name')}
              </label>
              <input type="text"
                  ref="name"
                  id="name"
                  placeholder={t('Enter title of project here')}
                />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label htmlFor="description">
                {t('Description')}
              </label>
              <textarea type="text" ref="description"
                  id="description"
                  placeholder={t('Enter short description here')}
                />
            </bem.FormModal__item>

            <bem.FormModal__item>
              <label className="long">
                {t('Please specify the country and the sector where this project will be deployed.')}
                {t('This information will be used to help you filter results on the project list page.')}
              </label>
              <label htmlFor="sector">
                {t('Sector')}
              </label>
              <Select name="sector"
                  ref="sector"
                  id="sector"
                  value={this.state.sectorVal}
                  onChange={this.sectorChange}
                  options={sectors}
                />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label htmlFor="country">
                {t('Country')}
              </label>
              <Select name="country"
                id="country"
                ref="country"
                value={this.state.countryVal}
                onChange={this.countryChange}
                options={countries}
              />
            </bem.FormModal__item>
            <bem.FormModal__item>
              <label className="long">
                {t('Help KoboToolbox improve this product by sharing the sector and country where this project will be deployed.')}
{'fraction_non_alphanumeric': 0.12761158594491928, 'fraction_numerical': 0.0, 'mean_word_length': 1.778693931398417, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 73, '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': '4873775', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2292, 'n_words': 507}