<commit_before><div ng-controller="StudyAttributeEditorController">

  <div class="row">
    <div class="col-md-12">
      <p class="text-muted">
        This creates all the available study attributes. Each attribute has a type, an unique internal key name, a label, and
        some extra options such as tags and display pinning. For example, confidential information is usually tagged, which
        makes it easier to avoid them in views. You can also "pin" the main identifier, which means it stays visible when
        scrolling wide views.
      </p>
    </div>
  </div>

  <div class="row">
    <div class="col-md-12">
      <ul ui-sortable="attributeSortableOptions" ng-model="schema.attributes" id="attributeSortable" class="admin-list-box">
        <li ng-repeat="attribute in schema.attributes" ng-class="{'list-selected' : attribute == selectedAttribute}" ng-click="selectAttribute(attribute)">{{attribute.label}} <span ng-repeat="tag in attribute.options.tags" class="label label-default">{{tag}}</span></li>
      </ul>
    </div>
  </div>

  <div class="row">
    <div class="col-md-12">
      <form class="form-horizontal" role="form" name="attributeForm">
        <fieldset>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-type">Data type:</label>
            <div class="col-md-4">
              <select id="attribute-type" name="type" selectize options="attributeTypes" model="selectedAttribute.type" ng-disabled="! selectedAttribute"></select>
              <span class="error" ng-show="selectedAttribute &amp;&amp; ! selectedAttribute.type">This field is required</span>
            </div>

            <label class="col-md-2 control-label" for="attribute-name">Key:</label>
            <div class="col-md-4">
              <input id="attribute-name" name="attribute-name" type="text" placeholder="Key" class="form-control input-md" ng-model="selectedAttribute.name" ng-disabled="! selectedAttribute">
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-label">Label:</label>
            <div class="col-md-10">
              <input id="attribute-label" name="attribute-label" type="text" placeholder="Label" class="form-control input-md" ng-model="selectedAttribute.label" ng-disabled="! selectedAttribute">
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-calculation">Calculation:</label>
            <div class="col-md-10">
              <input id="attribute-calculation" name="attribute-calculation" type="text" placeholder="Calculation" class="form-control input-md" ng-model="selectedAttribute.options.calculated" ng-disabled="! selectedAttribute">
            </div>
          </div>

          <div class="form-group" ng-show="selectedAttribute &amp;&amp; selectedAttribute.type == 'option'">
            <label class="col-md-2 control-label" for="attribute-values">Option values:</label>
            <div class="col-md-10">
              <select id="attribute-values" selectize-list model="selectedAttribute.options.values" ng-disabled="! selectedAttribute"></select>
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-tags">Tags:</label>
            <div class="col-md-4">
              <select id="attribute-tags" selectize-tags options="attributeTags" model="selectedAttribute.options.tags" ng-disabled="! selectedAttribute" ></select>
            </div>
          </div>

          <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
            <button class="btn btn-default" ng-click="newAttribute()">New attribute</button>
            <button class="btn" ng-class="selectedAttribute ? &apos;btn-warn&apos; : &apos;btn-default&apos;" ng-disabled="! selectedAttribute" ng-click="deleteAttribute(selectedAttribute)">Delete attribute</button>
            </div>
          </div>
        </fieldset>
      </form>
    </div>
  </div>

</div>
<commit_msg>Added key validation, so we can't get in a mess with key names.<commit_after><div ng-controller="StudyAttributeEditorController">

  <div class="row">
    <div class="col-md-12">
      <p class="text-muted">
        This creates all the available study attributes. Each attribute has a type, an unique internal key name, a label, and
        some extra options such as tags and display pinning. For example, confidential information is usually tagged, which
        makes it easier to avoid them in views. You can also "pin" the main identifier, which means it stays visible when
        scrolling wide views.
      </p>
    </div>
  </div>

  <div class="row">
    <div class="col-md-12">
      <ul ui-sortable="attributeSortableOptions" ng-model="schema.attributes" id="attributeSortable" class="admin-list-box">
        <li ng-repeat="attribute in schema.attributes" ng-class="{'list-selected' : attribute == selectedAttribute}" ng-click="selectAttribute(attribute)">{{attribute.label}} <span ng-repeat="tag in attribute.options.tags" class="label label-default">{{tag}}</span></li>
      </ul>
    </div>
  </div>

  <div class="row">
    <div class="col-md-12">
      <form class="form-horizontal" role="form" name="attributeForm">
        <fieldset>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-type">Data type:</label>
            <div class="col-md-4">
              <select id="attribute-type" name="type" selectize options="attributeTypes" model="selectedAttribute.type" ng-disabled="! selectedAttribute"></select>
              <span class="error text-danger" ng-show="selectedAttribute &amp;&amp; ! selectedAttribute.type">A type is required</span>
            </div>

            <label class="col-md-2 control-label" for="attributeName">Key:</label>
            <div class="col-md-4">
              <input id="attributeName" name="attributeName" type="text" placeholder="Key" class="form-control input-md"
                     ng-model="selectedAttribute.name" ng-disabled="! selectedAttribute"
                     pattern="^[A-Za-z0-9_-]+$">
              <span class="error text-danger" ng-show="attributeForm.attributeName.$error.required">A key is required</span>
              <span class="error text-danger" ng-show="attributeForm.attributeName.$error.pattern">Must consist only of alphanumerics, underscores and hyphens</span>
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-label">Label:</label>
            <div class="col-md-10">
              <input id="attribute-label" name="attribute-label" type="text" placeholder="Label" class="form-control input-md" ng-model="selectedAttribute.label" ng-disabled="! selectedAttribute">
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-calculation">Calculation:</label>
            <div class="col-md-10">
              <input id="attribute-calculation" name="attribute-calculation" type="text" placeholder="Calculation" class="form-control input-md" ng-model="selectedAttribute.options.calculated" ng-disabled="! selectedAttribute">
            </div>
          </div>

          <div class="form-group" ng-show="selectedAttribute &amp;&amp; selectedAttribute.type == 'option'">
            <label class="col-md-2 control-label" for="attribute-values">Option values:</label>
            <div class="col-md-10">
              <select id="attribute-values" selectize-list model="selectedAttribute.options.values" ng-disabled="! selectedAttribute"></select>
            </div>
          </div>

          <div class="form-group">
            <label class="col-md-2 control-label" for="attribute-tags">Tags:</label>
            <div class="col-md-4">
              <select id="attribute-tags" selectize-tags options="attributeTags" model="selectedAttribute.options.tags" ng-disabled="! selectedAttribute" ></select>
            </div>
          </div>

          <div class="form-group">
            <div class="col-md-2"></div>
            <div class="col-md-10">
            <button class="btn btn-default" ng-click="newAttribute()">New attribute</button>
            <button class="btn" ng-class="selectedAttribute ? &apos;btn-warn&apos; : &apos;btn-default&apos;" ng-disabled="! selectedAttribute" ng-click="deleteAttribute(selectedAttribute)">Delete attribute</button>
            </div>
          </div>
        </fieldset>
      </form>
    </div>
  </div>

</div>

{'fraction_non_alphanumeric': 0.15529303819245327, 'fraction_numerical': 0.005734602592040372, 'mean_word_length': 2.9138240574506282, 'pattern_counts': {'":': 0, '<': 169, '<?xml version=': 0, '>': 169, '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': '3219908', 'n_tokens_mistral': 2449, 'n_tokens_neox': 2387, 'n_words': 546}