<commit_before>{% extends "conversation/edit.html" %}
{% load url from future %}

{% block content_extraclass %}campaigns dialogue{% endblock %}

{% block content_actions_left %}
    <button class="btn btn-primary" data-action='new-state'>
        Create new message
    </button>
{% endblock %}

{% block content_actions_right %}
  <div class="pull-left">

    <input type="checkbox" name="multiple_surveys" id="multiple_surveys">
    Enable users to submit multiple surveys
  </div>

  <div class="pull-right">
    <a href="{% url 'conversations:index' %}">Cancel</a>
    <button class="btn btn-primary" data-action="save">Save</button>
  </div>
{% endblock %}

{% block content_main %}
<div id="diagram"></div>
{% endblock %}

{% block ondomready %}
  {{ block.super }}
  var dialogue = go.campaign.dialogue;

  var diagram = new dialogue.diagram.DialogueDiagramView({
    el: '.dialogue #diagram',
    model: new dialogue.models.DialogueModel({{ model_data|safe }})
  });

  $('.actions [data-action="new-state"]').click(function(e) {
      e.preventDefault();
      diagram.newState();
  });

  $('.actions button[data-action="save"]').click(function(e) {
      e.preventDefault();

      // TODO, we've got to inject the value of the multiple-survey
      // button.

      // TODO uncomment once the screen is hooked up to the api
      //diagram.model.save();

      // send user to conversation show page
      window.location.href = "/conversations/{{ conversation_key }}/";
  });


  dialogue.style.initialize();
  diagram.render();
{% endblock %}
<commit_msg>Hook up diagram saving (possibly incorrectly).<commit_after>{% extends "conversation/edit.html" %}
{% load url from future %}

{% block content_extraclass %}campaigns dialogue{% endblock %}

{% block content_actions_left %}
    <button class="btn btn-primary" data-action='new-state'>
        Create new message
    </button>
{% endblock %}

{% block content_actions_right %}
  <div class="pull-left">

    <input type="checkbox" name="multiple_surveys" id="multiple_surveys">
    Enable users to submit multiple surveys
  </div>

  <div class="pull-right">
    <a href="{% url 'conversations:index' %}">Cancel</a>
    <button class="btn btn-primary" data-action="save">Save</button>
  </div>
{% endblock %}

{% block content_main %}
<div id="diagram"></div>
{% endblock %}

{% block ondomready %}
  {{ block.super }}
  var dialogue = go.campaign.dialogue;

  var diagram = new dialogue.diagram.DialogueDiagramView({
    el: '.dialogue #diagram',
    model: new dialogue.models.DialogueModel({{ model_data|safe }})
  });

  $('.actions [data-action="new-state"]').click(function(e) {
      e.preventDefault();
      diagram.newState();
  });

  $('.actions button[data-action="save"]').click(function(e) {
      e.preventDefault();

      // TODO, we've got to inject the value of the multiple-survey
      // button.

      diagram.model.save({}, {
        sessionId: "{{ session_id|safe }}",
        error: function() {
          bootbox.alert("Something bad happened, changes couldn't be saved.");
        }
      });

      // send user to conversation show page
      window.location.href = "/conversations/{{ conversation_key }}/";
  });


  dialogue.style.initialize();
  diagram.render();
{% endblock %}

{'fraction_non_alphanumeric': 0.1672250989948218, 'fraction_numerical': 0.0, 'mean_word_length': 3.4863387978142075, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '5207797', 'n_tokens_mistral': 1063, 'n_tokens_neox': 993, 'n_words': 235}