mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-18 14:02:15 +00:00
101 lines
3.9 KiB
HTML
101 lines
3.9 KiB
HTML
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
|
|
{% load widget_tweaks %}
|
|
{% load static %}
|
|
|
|
|
|
{% block title %}An event checklist{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="col-sm-12">
|
|
<h2>"{{object.schema.schema_type.name}}" for "<a href="{% url 'event_detail' object.event.pk %}">N{{object.event.pk|stringformat:"05d"}} | {{object.event.name}}</a>"</h2>
|
|
|
|
<a href="{% url 'form_list' object.event.pk %}" class="btn btn-default" title="Rig Forms"><span class="glyphicon glyphicon-chevron-left"></span> <span class="hidden-xs">Other forms for N{{object.event.pk|stringformat:"05d"}}</span></a>
|
|
|
|
<hr/>
|
|
|
|
</div>
|
|
{% include 'form_errors.html' %}
|
|
|
|
<div ng-controller="FormController" class="col-sm-12">
|
|
|
|
<form name="theForm" ng-submit="onSubmit(theForm)">
|
|
|
|
<div sf-schema="schema" sf-form="form" sf-model="model"
|
|
sf-options=" { formDefaults: { startEmpty: true,
|
|
{% if not edit %}
|
|
readonly: true,
|
|
{% endif %}
|
|
} }"></div>
|
|
|
|
{% if edit %}
|
|
<input class="btn btn-primary" type="submit" value="Save">
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
{% if request.is_ajax %}
|
|
{% block footer %}
|
|
An AJAX request footer
|
|
{% endblock %}
|
|
{% endif %}
|
|
|
|
|
|
{% block js %}
|
|
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/angular.min.js"%}"></script>
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/angular-sanitize.js"%}"></script>
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/tv4.min.js"%}"></script>
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/ObjectPath.js"%}"></script>
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/schema-form.min.js"%}"></script>
|
|
<script type="text/javascript" src="{% static "js/angular-schema-form/bootstrap-decorator.min.js"%}"></script>
|
|
<link rel="stylesheet" type="text/css" href="{% static "js/angular-schema-form/bootstrap.vertical-tabs.min.css"%}"/>
|
|
|
|
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
angular.module('myModule', ['schemaForm']).controller('FormController', function($scope) {
|
|
{% autoescape off %} {# otherwise quotes get replaced with HTML entities #}
|
|
$scope.schema = {{ object.schema.schema }};
|
|
|
|
$scope.form = {{ object.schema.layout }};
|
|
|
|
{% comment %}
|
|
//This is useful for development, allowing the schema & layout to reside in the file system (you need to make the relevant files in the templates directory). Commented out for production
|
|
$scope.schema = {% include "rigForms/schema.js" %};
|
|
|
|
$scope.form = {% include "rigForms/layout.js" %};
|
|
{% endcomment %}
|
|
|
|
$scope.model = {{ object.data }};
|
|
{% endautoescape %}
|
|
|
|
$scope.onSubmit = function(form) {
|
|
// First we broadcast an event so all fields validate themselves
|
|
$scope.$broadcast('schemaFormValidate');
|
|
|
|
// Then we check if the form is valid
|
|
if (form.$valid) {
|
|
|
|
//Submit the data in JSON form
|
|
var form = $('<form action="" method="post">' + "{% csrf_token %}" +
|
|
'<input style="display:none" type="text" name="data" value="" />' +
|
|
'</form>');
|
|
|
|
$('input[name="data"]', form).val(JSON.stringify($scope.model));
|
|
|
|
$('body').append(form);
|
|
|
|
form.submit();
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
angular.bootstrap(document, ['myModule']);
|
|
});
|
|
</script>
|
|
|
|
{% endblock %} |