Skip to content

Commit

Permalink
Merge pull request #141 from zepheira/feature/support_dialogs
Browse files Browse the repository at this point in the history
Fix support dialogs
  • Loading branch information
ptrourke committed Oct 22, 2014
2 parents 7332d92 + 6034ed0 commit 76bd0ed
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define(['jquery', 'observer'], function ($, Observer) {
var xhr = $.ajax({
type: 'POST',
url: '/support/issue/augmentation/',
data: JSON.stringify(this.toJSON())
data: this.toJSON()
})
.done(this.postAugmentationIssueSuccess.bind(this))
.fail(this.postAugmentationIssueError.bind(this));
Expand Down Expand Up @@ -73,7 +73,7 @@ define(['jquery', 'observer'], function ($, Observer) {
jsonified.comments = this.comments;
jsonified.label = this.label;
jsonified.type = this.type;
jsonified.composite = this.composite;
jsonified.composite = this.composite.join(",");
return jsonified;
}
});
Expand Down
15 changes: 7 additions & 8 deletions viewshare/apps/support/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ def get(self, request, *args, **kwargs):
return render(request, self.create_template, {'form': form})

def post(self, request, *args, **kwargs):
try:
json_post = json.loads(request.body,
parse_float=Decimal)
except ValueError:
return HttpResponseBadRequest('Not a JSON document')
form = self.form_class(json_post)
form = self.form_class(request.POST)
if form.is_valid():
return self.create_issue(request, form, *args, **kwargs)
return render(request, self.create_template, {'form': form})
Expand Down Expand Up @@ -143,6 +138,7 @@ def generate_context(self, request, form, *args, **kwargs):
new_slug = str(uuid.uuid4())
exhibit.pk = None
exhibit.id = None
exhibit.parent = None
exhibit.owner = support
exhibit.slug = new_slug
exhibit.save()
Expand All @@ -167,8 +163,11 @@ def generate_context(self, request, form, *args, **kwargs):
class DataLoadIssueView(SupportFormView):

def generate_context(self, request, form, *args, **kwargs):
source_id = kwargs["source_id"]
source = get_object_or_404(DataSource, uuid=source_id)
owner = kwargs["owner"]
slug = kwargs["slug"]
source = get_object_or_404(DataSource,
exhibit__owner__username=owner,
exhibit__slug=slug)

c = super(DataLoadIssueView, self).generate_context(request, form)
return dict(c, **{"source": source})
Expand Down
74 changes: 0 additions & 74 deletions viewshare/static/support/js/augment.js

This file was deleted.

53 changes: 24 additions & 29 deletions viewshare/static/support/js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,65 @@
function resetForm() {
var dialog = $("div#support");
var form = $("form", dialog);
form.uniform();

var contact_visibility = function() {
if ($("#id_contact_type").val() == "email") {
$("#div_id_contact_phone").hide();
$("#div_id_contact_email").show().effect("highlight");
} else if ($("#id_contact_type").val() == "phone") {
$("#div_id_contact_email").hide();
$("#div_id_contact_phone").show().effect("highlight");
if (dialog.find("#id_contact_type").val() == "email") {
dialog.find("#div_id_contact_phone").hide();
dialog.find("#div_id_contact_email").show();
} else if (dialog.find("#id_contact_type").val() == "phone") {
dialog.find("#div_id_contact_email").hide();
dialog.find("#div_id_contact_phone").show();
}
};

var reason_visibility = function() {
if ($("#id_issue_reason").val() == "other") {
$("#div_id_issue_reason_text").show().effect("highlight");
if (dialog.find("#id_issue_reason").val() == "other") {
dialog.find("#div_id_issue_reason_text").show();
} else {
$("#div_id_issue_reason_text").hide();
$("#id_issue_reason_text").val("");
dialog.find("#div_id_issue_reason_text").hide();
dialog.find("#id_issue_reason_text").val("");
}
};

var format_visibility = function() {
if ($("#id_file_format").val() == "other") {
$("#div_id_file_format_text").show().effect("highlight");
if (dialog.find("#id_file_format").val() == "other") {
dialog.find("#div_id_file_format_text").show();
} else {
$("#div_id_file_format_text").hide();
$("#id_file_format_text").val("");
dialog.find("#div_id_file_format_text").hide();
dialog.find("#id_file_format_text").val("");
}

};

$("#id_contact_type").change(function() {
dialog.find("#id_contact_type").change(function() {
contact_visibility();
});

$("#id_issue_reason").change(function() {
dialog.find("#id_issue_reason").change(function() {
reason_visibility();
});

$("#id_file_format").change(function() {
dialog.find("#id_file_format").change(function() {
format_visibility();
});

form.ajaxForm({
success: function(responseText, statusText, xhr, $form) {
dialog.empty().append($(responseText).find("#issue_create_content"));
dialog.find("#issue_create_content").remove();
dialog.append($(responseText).find("#issue_create_content"));
resetForm();
$("#support-spinner").hide();
$("#support").show();
dialog.find(".support-spinner").hide();
form.show();
},
beforeSubmit: function(formData, jqForm, options) {
$("#support").hide();
$("#support-spinner").show();
form.hide();
dialog.find(".support-spinner").show();
},
error: function() {
var error = $("<div>").load("/support/issue/create_error", function() {
$(".messages>li.error", $(this)).addClass("ui-corner-all").addClass("ui-state-error");
$(".messages>li", $(this)).prepend("<a href='#' class='ui-icon ui-icon-closethick close-message'>&#160;</a> ");
$("#support-spinner").hide();
dialog.find(".support-spinner").hide();
dialog.find(".messages").remove().end().prepend(this);

$("#load-error").show();
Expand Down Expand Up @@ -96,11 +96,6 @@

});

$("div#support .cancel-button").on('click', function() {
root.hide();
$("#load-error").fadeIn();
});

$("div#support .ticket-created").on('click', function() {
root.hide();
$("#load-error").fadeIn();
Expand Down
27 changes: 0 additions & 27 deletions viewshare/templates/support/create_augmentation_issue.html

This file was deleted.

10 changes: 8 additions & 2 deletions viewshare/templates/support/issue_response.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

{% block body %}
<div id="issue_create_content">
<h1>{% trans "Ticket Created" %}</h1>
<div class="modal-header">
<h3>{% trans "Ticket Created" %}</h3>
</div>
<div class="modal-body">
<p>{% blocktrans %}Thank you. A support ticket has been generated and sent to the {{SITE_NAME}} support team.{% endblocktrans %}</p>
<input type="button" class="ticket-created" value="{% trans "OK" %}"/>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>

{% endblock %}
Expand Down
29 changes: 21 additions & 8 deletions viewshare/templates/support/upload_issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@
{% load crispy_forms_tags %}

{% block body %}
<div id="issue_create_content">
<h1>{% trans "Report a Data Loading Problem" %}</h1>
<form action="{{request.path}}" method="post" class="uniForm">
<div id="issue_create_content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>{% trans "Report a Data Loading Problem" %}</h3>
</div>
<form action="{{ request.path }}" method="post" class="uniForm">

<div class="modal-body">
<fieldset class="inlineLabels">
{%csrf_token%}
{{ form|crispy }}
{% csrf_token %}
{{ form|crispy }}
</fieldset>
<input type="submit" value="Send Report"/>
<input type="button" class="cancel-button negative-button" value="{% trans "Cancel" %}"/>
</div>
<div class="modal-footer">
<button class="btn btn-primary">{% trans "Send Report" %}</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</form>
</div>

<div class="support-spinner progress progress-striped active hide">
<div class="bar" style="width: 100%;"></div>
<p>{% blocktrans %}Requesting ticket, please be patient.{% endblocktrans %}</p>
</div>
</div>
{% endblock %}


27 changes: 10 additions & 17 deletions viewshare/templates/upload/datasource_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div class="errorMsg-specific">
{% block format_error %}{% endblock %}
</div>
<div class="errorMsg-followup">{% trans "If you have a file that you think should work after troubleshooting please <strong><a href='' class='support-link'>Click here to create a support ticket</a></strong>." %}</div>
<div class="errorMsg-followup">{% trans "If you have a file that you think should work after troubleshooting please <strong><a href='#support' data-toggle='modal' class='support-link'>Click here to create a support ticket</a></strong>." %}</div>
</li>
</ul>
</div>
Expand All @@ -54,35 +54,28 @@
<fieldset class="upload-form form-well">

<div class="row-fluid">
<div class="span12 well">

<form action="{{ form_url }}" method="post" class="uniForm form form-horizontal" {% block uploadform_enctype %}{% endblock %}>
<div class="span12 well">
<form action="{{ form_url }}" method="post" class="uniForm form form-horizontal" {% block uploadform_enctype %}{% endblock %}>
{%csrf_token %}

{{ form|crispy }}

<div class="load-actions buttons control-group">
<div class="controls">
<input type="submit" value="{% trans "Upload" %}" class="submit btn btn-primary" />
<a href="{% url 'upload_dataset' %}"><input type="button" value="{% trans "Cancel" %}" class="load-form-cancel negative-button btn btn-danger" /></a>
</div>
<div class="controls">
<input type="submit" value="{% trans "Upload" %}" class="submit btn btn-primary" />
<a href="{% url 'upload_dataset' %}"><input type="button" value="{% trans "Cancel" %}" class="load-form-cancel negative-button btn btn-danger" /></a>
</div>
</div>

</form>

</div>
</form>
</div>
</div>

</fieldset>

</div> <!-- end upload_form_type -->

{% if show_error %}
<div id="support" class="hide"></div>
<div class="support-spinner progress progress-striped active hide">
<div class="bar" style="width: 100%;"></div>
<p>{% blocktrans %}Requesting ticket, please be patient.{% endblocktrans %}</p>
</div>
<div id="support" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="supported-file-types-label"></div>
{% endif %}

{% endblock %}

0 comments on commit 76bd0ed

Please sign in to comment.