Convert event forms to be partially embery.

This commit is contained in:
Tom Price
2016-08-09 18:26:16 +01:00
parent bccd82c6aa
commit 60cf5dbb71
20 changed files with 619 additions and 343 deletions

View File

@@ -1,9 +1,30 @@
// Return a helper with preserved width of cells
var fixHelper = function (e, ui) {
ui.children().each(function () {
$(this).width($(this).width());
});
return ui;
};
function setupItemTable(items_json) {
objectitems = JSON.parse(items_json)
objectitems = JSON.parse(items_json);
$.each(objectitems, function (key, val) {
objectitems[key] = JSON.parse(val);
})
});
newitem = -1;
$("#item-table tbody").sortable({
helper: fixHelper,
update: function (e, ui) {
info = $(this).sortable("toArray");
itemorder = [];
$.each(info, function (key, value) {
pk = $('#' + value).data('pk');
objectitems[pk].fields.order = key;
});
}
});
}
function nl2br (str, is_xhtml) {
@@ -33,7 +54,7 @@ function updatePrices() {
}
$('#item-table').on('click', '.item-delete', function () {
delete objectitems[$(this).data('pk')]
delete objectitems[$(this).data('pk')];
$('#item-' + $(this).data('pk')).remove();
updatePrices();
});
@@ -73,8 +94,8 @@ $('body').on('submit', '#item-form', function (e) {
var fields;
if (pk == newitem--) {
// Create the new data structure and add it on.
fields = new Object();
fields['name'] = $('#item_name').val()
fields = {};
fields['name'] = $('#item_name').val();
fields['description'] = $('#item_description').val();
fields['cost'] = $('#item_cost').val();
fields['quantity'] = $('#item_quantity').val();
@@ -86,7 +107,7 @@ $('body').on('submit', '#item-form', function (e) {
fields['order'] = order;
objectitems[pk] = new Object();
objectitems[pk] = {};
objectitems[pk]['fields'] = fields;
// Add the new table
@@ -96,7 +117,7 @@ $('body').on('submit', '#item-form', function (e) {
// Existing item
// update data structure
fields = objectitems[pk].fields;
fields.name = $('#item_name').val()
fields.name = $('#item_name').val();
fields.description = $('#item_description').val();
fields.cost = $('#item_cost').val();
fields.quantity = $('#item_quantity').val();
@@ -116,24 +137,3 @@ $('body').on('submit', '#item-form', function (e) {
$('body').on('submit', '.itemised_form', function (e) {
$('#id_items_json').val(JSON.stringify(objectitems));
});
// Return a helper with preserved width of cells
var fixHelper = function (e, ui) {
ui.children().each(function () {
$(this).width($(this).width());
});
return ui;
};
$("#item-table tbody").sortable({
helper: fixHelper,
update: function (e, ui) {
info = $(this).sortable("toArray");
itemorder = new Array();
$.each(info, function (key, value) {
pk = $('#' + value).data('pk');
objectitems[pk].fields.order = key;
});
}
});

View File

@@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'base_ember.html' %}
{% load widget_tweaks %}
{% load static %}
{% load multiply from filters %}
@@ -11,22 +11,6 @@
<script src="{% static "js/autocompleter.js" %}"></script>
<script>
function setTime23Hours() {
$('#{{ form.end_time.id_for_label }}').val('23:00');
}
function setTime02Hours() {
var id_start = "{{ form.start_date.id_for_label }}";
var id_end_date = "{{ form.end_date.id_for_label }}";
var id_end_time = "{{ form.end_time.id_for_label }}";
if ($('#'+id_start).val() == $('#'+id_end_date).val()) {
var end_date = new Date($('#'+id_end_date).val());
end_date.setDate(end_date.getDate() + 1);
$('#'+id_end_date).val(end_date.getISOString());
}
$('#'+id_end_time).val('02:00');
}
$(document).ready(function () {
{% if not object.pk and not form.errors %}
@@ -61,33 +45,34 @@
function supportsDate() {
//return false; //for development
var input = document.createElement('input');
input.setAttribute('type','date');
input.setAttribute('type', 'date');
var notADateValue = 'not-a-date';
input.setAttribute('value', notADateValue);
return !(input.value === notADateValue);
}
if(supportsDate()){
if (supportsDate()) {
//Good, we'll use the browser implementation
}else{
} else {
//Rubbish browser - do JQuery backup
$('<link>')
.appendTo('head')
.attr({type : 'text/css', rel : 'stylesheet'})
.attr('href', '{% static "css/bootstrap-datetimepicker.min.css" %}');
.appendTo('head')
.attr({type: 'text/css', rel: 'stylesheet'})
.attr('href', '{% static "css/bootstrap-datetimepicker.min.css" %}');
$.when(
$.getScript( "{% static "js/moment.min.js" %}" ),
$.getScript( "{% static "js/bootstrap-datetimepicker.min.js" %}" ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function(){
$('input[type=date]').attr('type','text').datetimepicker({
$.getScript("{% static "js/moment.min.js" %}"),
$.getScript("{% static "js/bootstrap-datetimepicker.min.js" %}"),
$.Deferred(function (deferred) {
$(deferred.resolve);
})
).done(function () {
$('input[type=date]').attr('type', 'text').datetimepicker({
format: 'YYYY-MM-DD',
});
$('input[type=time]').attr('type','text').datetimepicker({
$('input[type=time]').attr('type', 'text').datetimepicker({
format: 'HH:mm',
});
$('input[type=datetime-local]').attr('type','text').datetimepicker({
$('input[type=datetime-local]').attr('type', 'text').datetimepicker({
format: 'YYYY-MM-DD[T]HH:mm',
sideBySide: true,
});
@@ -97,339 +82,397 @@
});
$(document).ready(function () {
setupItemTable($("#{{ form.items_json.id_for_label }}").val());
setupItemTable(JSON.stringify({{ form.items_json.value|safe }}));
});
$(function () {
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="tooltip"]').tooltip();
})
</script>
{% endblock %}
{% block content %}
<form class="form-horizontal itemised_form" role="form" method="POST">{% csrf_token %}
<div class="row">
<div class="col-sm-12">
<div class="col-sm-8">
<h2>
{% if duplicate %}
Duplicate of Event N{{ object.pk|stringformat:"05d" }}
{% elif object.pk %}
Event N{{ object.pk|stringformat:"05d" }}
{% else %}
New Event
{% endif %}
</h2>
</div>
<div class="col-sm-4 text-right">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span></button>
<script type="text/x-handlebars" data-template-name="event/-form">
<form class="form-horizontal itemised_form" role="form" method="POST">{% csrf_token %}
<div class="row">
<div class="col-sm-12">
<div class="col-sm-8">
<h2>
{% if duplicate %}
Duplicate of Event N{{ object.pk|stringformat:"05d" }}
{% elif object.pk %}
Event N{{ object.pk|stringformat:"05d" }}
{% else %}
New Event
{% endif %}
</h2>
</div>
<div class="col-sm-4 text-right">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span></button>
</div>
</div>
</div>
</div>
</div>
</div>
{% include 'form_errors.html' %}
{% render_field form.is_rig style="display: none" %}
<input type="hidden" name="{{ form.items_json.name }}" id="{{ form.items_json.id_for_label }}"
value="{{ form.items_json.value }}"/>
{% include 'form_errors.html' %}
{% render_field form.is_rig style="display: none" %}
<input type="hidden" name="{{ form.items_json.name }}" id="{{ form.items_json.id_for_label }}"
value="{{ form.items_json.value }}"/>
{# New rig buttons #}
{% if not object.pk %}
<div class="col-md-12 well">
<div class="form-group" id="is_rig-selector">
<div class="col-sm-12">
{# New rig buttons #}
{% if not object.pk %}
<div class="col-md-12 well">
<div class="form-group" id="is_rig-selector">
<div class="col-sm-12">
<span class="col-sm-6" data-toggle="tooltip"
title="Anything that involves TEC kit, crew, or otherwise us providing a service to anyone.">
<button type="button" class="btn btn-primary col-xs-12" data-is_rig="1">Rig</button>
</span>
<span class="col-sm-6" data-toggle="tooltip"
title="Things that aren't service-based, like training, meetings and site visits.">
<span class="col-sm-6" data-toggle="tooltip"
title="Things that aren't service-based, like training, meetings and site visits.">
<button type="button" class="btn btn-info col-xs-12" data-is_rig="0">Non-Rig</button>
</span>
</div>
</div>
</div>
{% endif %}
{# Contact details #}
<div class="col-sm-12 col-md-6">
<div class="panel panel-default form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="panel-heading">Contact Details</div>
<div class="panel-body">
<div class="form-group" data-toggle="tooltip" title="The main contact for the event, can be left blank if purely an organisation">
<label for="{{ form.person.id_for_label }}"
class="col-sm-4 control-label">{{ form.person.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='person' %}">
{% if person %}
<option value="{{form.person.value}}" selected="selected" data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'person_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.person.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="{% if form.person.value %}{% url 'person_update' form.person.value %}{% endif %}" class="btn btn-default modal-href" id="{{ form.person.id_for_label }}-update" data-target="#{{ form.person.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</div>
</div>
</div>
</div>
</div>
<div class="form-group" data-toggle="tooltip" title="The client organisation, leave blank if client is an individual">
<label for="{{ form.organisation.id_for_label }}"
class="col-sm-4 control-label">{{ form.organisation.label }}</label>
{% endif %}
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.organisation.id_for_label }}" name="{{ form.organisation.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='organisation' %}" >
{% if organisation %}
<option value="{{form.organisation.value}}" selected="selected" data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'organisation_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.organisation.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="{% if form.organisation.value %}{% url 'organisation_update' form.organisation.value %}{% endif %}" class="btn btn-default modal-href" id="{{ form.organisation.id_for_label }}-update" data-target="#{{ form.organisation.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
{# Contact details #}
<div class="col-sm-12 col-md-6">
<div class="panel panel-default form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="panel-heading">Contact Details</div>
<div class="panel-body">
<div class="form-group" data-toggle="tooltip"
title="The main contact for the event, can be left blank if purely an organisation">
<label for="{{ form.person.id_for_label }}"
class="col-sm-4 control-label">{{ form.person.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.person.id_for_label }}" name="{{ form.person.name }}"
class="form-control selectpicker" data-live-search="true"
data-sourceurl="{% url 'api_secure' model='person' %}">
{% if person %}
<option value="{{ form.person.value }}" selected="selected"
data-update_url="{% url 'person_update' form.person.value %}">{{ person }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'person_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.person.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="
{% if form.person.value %}{% url 'person_update' form.person.value %}{% endif %}"
class="btn btn-default modal-href"
id="{{ form.person.id_for_label }}-update"
data-target="#{{ form.person.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default form-hws form-non_rig">
<div class="panel-heading">Event Description</div>
<div class="panel-body">
<div class="form-group" data-toggle="tooltip" title="A short description of the event, shown on rigboard and on paperwork">
<label for="{{ form.description.id_for_label }}"
class="col-sm-4 control-label">{{ form.description.label }}</label>
<div class="form-group" data-toggle="tooltip"
title="The client organisation, leave blank if client is an individual">
<label for="{{ form.organisation.id_for_label }}"
class="col-sm-4 control-label">{{ form.organisation.label }}</label>
<div class="col-sm-8">
{% render_field form.description class+="form-control" %}
</div>
</div>
</div>
</div>
</div>
<!-- /.col-sm-12 .col-md-6 -->
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.organisation.id_for_label }}"
name="{{ form.organisation.name }}" class="form-control selectpicker"
data-live-search="true"
data-sourceurl="{% url 'api_secure' model='organisation' %}">
{% if organisation %}
<option value="{{ form.organisation.value }}" selected="selected"
data-update_url="{% url 'organisation_update' form.organisation.value %}">{{ organisation }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'organisation_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.organisation.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="
{# Event details #}
<div class="col-sm-12 col-md-6">
<div class="panel panel-default form-hws form-non_rig">
<div class="panel-heading">Event Details</div>
<div class="panel-body">
<div id="form-hws">
<div class="form-group" data-toggle="tooltip" title="Name of the event, displays on rigboard and on paperwork">
<label for="{{ form.name.id_for_label }}"
class="col-sm-4 control-label">{{ form.name.label }}</label>
<div class="col-sm-8">
{% render_field form.name class+="form-control" %}
</div>
</div>
<div class="form-group" data-toggle="tooltip" title="The venue for the rig, leave blank if unknown (e.g. for a dry hire)">
<label for="{{ form.venue.id_for_label }}"
class="col-sm-4 control-label">{{ form.venue.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='venue' %}">
{% if venue %}
<option value="{{form.venue.value}}" selected="selected" data-update_url="{% url 'venue_update' form.venue.value %}">{{ venue }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'venue_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.venue.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="{% if object.venue %}{% url 'venue_update' object.venue.pk %}{% endif %}" class="btn btn-default modal-href" id="{{ form.venue.id_for_label }}-update" data-target="#{{ form.venue.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
{% if form.organisation.value %}{% url 'organisation_update' form.organisation.value %}{% endif %}"
class="btn btn-default modal-href"
id="{{ form.organisation.id_for_label }}-update"
data-target="#{{ form.organisation.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="{{ form.start_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.start_date.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="Start date for event, required">
{% render_field form.start_date type="date" class+="form-control" %}
</div>
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="Start time of event, can be left blank">
{% render_field form.start_time type="time" class+="form-control" %}
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="{{ form.end_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.end_date.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7" data-toggle="tooltip" title="End date of event, leave blank if unknown or same as start date">
{% render_field form.end_date type="date" class+="form-control" %}
</div>
<div class="col-sm-12 col-md-5" data-toggle="tooltip" title="End time of event, leave blank if unknown">
{% render_field form.end_time type="time" class+="form-control" %}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-offset-7 col-md-5">
<div class="btn-group btn-group-justified">
<btn class="btn btn-default btn-xs" onclick="setTime23Hours()">23:00</btn>
<btn class="btn btn-default btn-xs" onclick="setTime02Hours()">02:00</btn>
</div>
</div>
</div>
</div>
</div>
{# Rig only information #}
<div class="form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="form-group" data-toggle="tooltip" title="The date/time at which TEC have access to the venue">
<label for="{{ form.access_at.id_for_label }}"
class="col-sm-4 control-label">{{ form.access_at.label }}</label>
</div>
<div class="panel panel-default form-hws form-non_rig">
<div class="panel-heading">Event Description</div>
<div class="panel-body">
<div class="form-group" data-toggle="tooltip"
title="A short description of the event, shown on rigboard and on paperwork">
<label for="{{ form.description.id_for_label }}"
class="col-sm-4 control-label">{{ form.description.label }}</label>
<div class="col-sm-8">
{% render_field form.access_at type="datetime-local" class+="form-control" %}
</div>
</div>
<div class="form-group" data-toggle="tooltip" title="The date/time at which crew should meet for this event">
<label for="{{ form.meet_at.id_for_label }}"
class="col-sm-4 control-label">{{ form.meet_at.label }}</label>
<div class="col-sm-8">
{% render_field form.meet_at type="datetime-local" class+="form-control" %}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label data-toggle="tooltip" title="Mark this event as a dry-hire, so it needs to be checked in at the end">
{% render_field form.dry_hire %}{{ form.dry_hire.label }}
</label>
</div>
{% render_field form.description class+="form-control" %}
</div>
</div>
</div>
</div>
</div>
<!-- /.col-sm-12 .col-md-6 -->
{# Status is needed on all events types and it looks good here in the form #}
<div class="form-group" data-toggle="tooltip" title="The current status of the event. Only mark as booked once paperwork is received">
<label for="{{ form.status.id_for_label }}"
class="col-sm-4 control-label">{{ form.status.label }}</label>
<div class="col-sm-8">
{% render_field form.status class+="form-control" %}
</div>
</div>
<div class="form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="form-group" data-toggle="tooltip" title="The Member in Charge of this event">
<label for="{{ form.mic.id_for_label }}"
class="col-sm-4 control-label">{{ form.mic.label }}</label>
<div class="col-sm-8">
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
{% if mic %}
<option value="{{form.mic.value}}" selected="selected" >{{ mic.name }}</option>
{% endif %}
</select>
</div>
</div>
{% if object.dry_hire %}
<div class="form-group" data-toggle="tooltip" title="The person who checked-in this dry hire">
<label for="{{ form.checked_in_by.id_for_label }}"
class="col-sm-4 control-label">{{ form.checked_in_by.label }}</label>
{# Event details #}
<div class="col-sm-12 col-md-6">
<div class="panel panel-default form-hws form-non_rig">
<div class="panel-heading">Event Details</div>
<div class="panel-body">
<div id="form-hws">
<div class="form-group" data-toggle="tooltip"
title="Name of the event, displays on rigboard and on paperwork">
<label for="{{ form.name.id_for_label }}"
class="col-sm-4 control-label">{{ form.name.label }}</label>
<div class="col-sm-8">
<select id="{{ form.checked_in_by.id_for_label }}" name="{{ form.checked_in_by.name }}" class="form-control selectpicker" data-live-search="true" data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
{% if checked_in_by %}
<option value="{{form.checked_in_by.value}}" selected="selected" >{{ checked_in_by.name }}</option>
{% endif %}
</select>
{% render_field form.name class+="form-control" %}
</div>
</div>
{% endif %}
<div class="form-group" data-toggle="tooltip"
title="The venue for the rig, leave blank if unknown (e.g. for a dry hire)">
<label for="{{ form.venue.id_for_label }}"
class="col-sm-4 control-label">{{ form.venue.label }}</label>
<div class="form-group" data-toggle="tooltip" title="The student ID of the client who collected the dry-hire">
<label for="{{ form.collector.id_for_label }}"
class="col-sm-4 control-label">{{ form.collector.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-9 col-md-7 col-lg-8">
<select id="{{ form.venue.id_for_label }}" name="{{ form.venue.name }}"
class="form-control selectpicker" data-live-search="true"
data-sourceurl="{% url 'api_secure' model='venue' %}">
{% if venue %}
<option value="{{ form.venue.value }}" selected="selected"
data-update_url="{% url 'venue_update' form.venue.value %}">{{ venue }}</option>
{% endif %}
</select>
</div>
<div class="col-sm-3 col-md-5 col-lg-4 align-right">
<div class="btn-group">
<a href="{% url 'venue_create' %}" class="btn btn-default modal-href"
data-target="#{{ form.venue.id_for_label }}">
<span class="glyphicon glyphicon-plus"></span>
</a>
<a href="
<div class="col-sm-8">
{% render_field form.collector class+="form-control" %}
{% if object.venue %}{% url 'venue_update' object.venue.pk %}{% endif %}"
class="btn btn-default modal-href"
id="{{ form.venue.id_for_label }}-update"
data-target="#{{ form.venue.id_for_label }}">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group" data-toggle="tooltip" title="The purchase order number (for external clients)">
<label for="{{ form.purchase_order.id_for_label }}"
class="col-sm-4 control-label">{{ form.purchase_order.label }}</label>
<div class="form-group">
<label for="{{ form.start_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.start_date.label }}</label>
<div class="col-sm-8">
{% render_field form.purchase_order class+="form-control" %}
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7" data-toggle="tooltip"
title="Start date for event, required">
{% render_field form.start_date type="date" class+="form-control" %}
</div>
<div class="col-sm-12 col-md-5" data-toggle="tooltip"
title="Start time of event, can be left blank">
{% render_field form.start_time type="time" class+="form-control" %}
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="{{ form.end_date.id_for_label }}"
class="col-sm-4 control-label">{{ form.end_date.label }}</label>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12 col-md-7" data-toggle="tooltip"
title="End date of event, leave blank if unknown or same as start date">
{% render_field form.end_date type="date" class+="form-control" %}
</div>
<div class="col-sm-12 col-md-5" data-toggle="tooltip"
title="End time of event, leave blank if unknown">
{% render_field form.end_time type="time" class+="form-control" %}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-offset-7 col-md-5">
<div class="btn-group btn-group-justified">
{% verbatim %}
<btn class="btn btn-default btn-xs" {{ action
'setTime23Hours' }}>23:00
</btn>
<btn class="btn btn-default btn-xs" {{ action
'setTime02Hours' }}>02:00
</btn>
{% endverbatim %}
</div>
</div>
</div>
</div>
</div>
{# Rig only information #}
<div class="form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="form-group" data-toggle="tooltip"
title="The date/time at which TEC have access to the venue">
<label for="{{ form.access_at.id_for_label }}"
class="col-sm-4 control-label">{{ form.access_at.label }}</label>
<div class="col-sm-8">
{% render_field form.access_at type="datetime-local" class+="form-control" %}
</div>
</div>
<div class="form-group" data-toggle="tooltip"
title="The date/time at which crew should meet for this event">
<label for="{{ form.meet_at.id_for_label }}"
class="col-sm-4 control-label">{{ form.meet_at.label }}</label>
<div class="col-sm-8">
{% render_field form.meet_at type="datetime-local" class+="form-control" %}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label data-toggle="tooltip"
title="Mark this event as a dry-hire, so it needs to be checked in at the end">
{% render_field form.dry_hire %}{{ form.dry_hire.label }}
</label>
</div>
</div>
</div>
</div>
{# Status is needed on all events types and it looks good here in the form #}
<div class="form-group" data-toggle="tooltip"
title="The current status of the event. Only mark as booked once paperwork is received">
<label for="{{ form.status.id_for_label }}"
class="col-sm-4 control-label">{{ form.status.label }}</label>
<div class="col-sm-8">
{% render_field form.status class+="form-control" %}
</div>
</div>
<div class="form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="form-group" data-toggle="tooltip"
title="The Member in Charge of this event">
<label for="{{ form.mic.id_for_label }}"
class="col-sm-4 control-label">{{ form.mic.label }}</label>
<div class="col-sm-8">
<select id="{{ form.mic.id_for_label }}" name="{{ form.mic.name }}"
class="form-control selectpicker" data-live-search="true"
data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
{% if mic %}
<option value="{{ form.mic.value }}"
selected="selected">{{ mic.name }}</option>
{% endif %}
</select>
</div>
</div>
{% if object.dry_hire %}
<div class="form-group" data-toggle="tooltip"
title="The person who checked-in this dry hire">
<label for="{{ form.checked_in_by.id_for_label }}"
class="col-sm-4 control-label">{{ form.checked_in_by.label }}</label>
<div class="col-sm-8">
<select id="{{ form.checked_in_by.id_for_label }}"
name="{{ form.checked_in_by.name }}"
class="form-control selectpicker" data-live-search="true"
data-sourceurl="{% url 'api_secure' model='profile' %}?fields=first_name,last_name,initials">
{% if checked_in_by %}
<option value="{{ form.checked_in_by.value }}"
selected="selected">{{ checked_in_by.name }}</option>
{% endif %}
</select>
</div>
</div>
{% endif %}
<div class="form-group" data-toggle="tooltip"
title="The student ID of the client who collected the dry-hire">
<label for="{{ form.collector.id_for_label }}"
class="col-sm-4 control-label">{{ form.collector.label }}</label>
<div class="col-sm-8">
{% render_field form.collector class+="form-control" %}
</div>
</div>
<div class="form-group" data-toggle="tooltip"
title="The purchase order number (for external clients)">
<label for="{{ form.purchase_order.id_for_label }}"
class="col-sm-4 control-label">{{ form.purchase_order.label }}</label>
<div class="col-sm-8">
{% render_field form.purchase_order class+="form-control" %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.col-sm-12 .col-md-6 -->
<div class="col-sm-12 text-right">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span>
</button>
</div>
</div>
<!-- /.col-sm-12 .col-md-6 -->
<div class="col-sm-12 text-right">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span>
</button>
</div>
</div>
{# Notes and item shit #}
<div class="col-sm-12">
<div class="panel panel-default form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="panel-body">
<div class="col-sm-12">
<div class="form-group" data-toggle="tooltip" title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork">
<label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label>
{% render_field form.notes class+="form-control" %}
{# Notes and item shit #}
<div class="col-sm-12">
<div class="panel panel-default form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="panel-body">
<div class="col-sm-12">
<div class="form-group" data-toggle="tooltip"
title="Notes on the event. This is only visible to keyholders, and is not displayed on the paperwork">
<label for="{{ form.notes.id_for_label }}">{{ form.notes.label }}</label>
{% render_field form.notes class+="form-control" %}
</div>
</div>
{% include "RIGS/item_table.html" %}
</div>
</div>
{% include "RIGS/item_table.html" %}
</div>
</div>
</div>
<div class="col-sm-12 text-right form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span>
</button>
</div>
</div>
</form>
<div class="col-sm-12 text-right form-hws form-is_rig {% if object.pk and not object.is_rig %}hidden{% endif %}">
<div class="btn-group btn-page">
<button type="submit" class="btn btn-default" title="Save"><span
class="glyphicon glyphicon-floppy-disk"></span>
</button>
</div>
</div>
</form>
{% include 'RIGS/item_modal.html' %}
{% include 'RIGS/item_modal.html' %}
</script>
{% endblock %}

View File

@@ -0,0 +1,4 @@
import Ember from "ember";
import SetTimeMixin from "pyrigs/mixins/set-time-mixin";
export default Ember.Controller.extend(SetTimeMixin, {});

View File

@@ -0,0 +1,4 @@
import Ember from "ember";
import SetTimeMixin from "pyrigs/mixins/set-time-mixin";
export default Ember.Controller.extend(SetTimeMixin, {});

View File

@@ -0,0 +1,23 @@
import Ember from "ember";
export default Ember.Mixin.create({
actions: {
setTime23Hours() {
Ember.$('#id_end_time').val('23:00');
},
setTime02Hours() {
var start = Ember.$('#id_start_date');
var end_date = Ember.$('#id_end_date');
var end_time = Ember.$('#id_end_time');
if (start.val() != '' && start.val() == end_date.val()) {
var new_date = new Date(end_date.val());
new_date.setDate(new_date.getDate() + 1);
end_date.val(new_date.getISOString());
}
end_time.val('02:00');
},
}
});

View File

@@ -1,5 +1,5 @@
import Ember from 'ember';
import config from './config/environment';
import Ember from "ember";
import config from "./config/environment";
const Router = Ember.Router.extend({
location: config.locationType,
@@ -7,6 +7,20 @@ const Router = Ember.Router.extend({
});
Router.map(function () {
this.route('event', function () {
this.route('create');
this.route('show', {
path: ':id'
});
this.route('duplicate', {
path: ':id/duplicate'
});
this.route('edit', {
path: ':id/edit'
});
});
this.route('legacy', {path: '/*wildcard'});
});
export default Router;

View File

@@ -0,0 +1,3 @@
import Ember from "ember";
export default Ember.Route.extend({});

3
app/routes/event/edit.js Normal file
View File

@@ -0,0 +1,3 @@
import Ember from "ember";
export default Ember.Route.extend({});

View File

@@ -0,0 +1 @@
{{ partial "event/form" }}

View File

@@ -0,0 +1 @@
{{ partial "event/form" }}

View File

@@ -0,0 +1 @@
{{partial "event/form"}}

View File

@@ -7,6 +7,7 @@
"js-cookie": "^2.1.2",
"bootstrap-sass": "^3.3.7",
"bootstrap-select": "^1.10.0",
"ajax-bootstrap-select": "^1.3.1"
"ajax-bootstrap-select": "^1.3.1",
"jQuery UI Sortable": "jquery-ui-sortable#*"
}
}

Binary file not shown.

View File

@@ -27,8 +27,12 @@ module.exports = function (defaults) {
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
app.import('bower_components/ember/ember-template-compiler.js');
app.import('bower_components/bootstrap-select/dist/js/bootstrap-select.js');
app.import('bower_components/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js');
app.import('bower_components/jQuery UI Sortable/jquery-ui-sortable.js');
return app.toTree();
};

117
templates/base_ember.html Normal file
View File

@@ -0,0 +1,117 @@
{% load static from staticfiles %}
{% load raven %}
<!DOCTYPE html>
<html
dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}"
xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
lang="{% firstof LANGUAGE_CODE 'en' %}">
<head>
<title>{% block title %}{% endblock %} | Rig Information Gathering System</title>
<meta name="viewport" content="initial-scale=1">
<link rel="icon" type="image/png" href="{% static "imgs/pyrigs-avatar.png" %}">
<link rel="apple-touch-icon" href="{% static "imgs/pyrigs-avatar.png" %}">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400italic,700,300,400' rel='stylesheet'
type='text/css'>
<link rel="stylesheet" type="text/css" href="{% static "assets/vendor.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "assets/pyrigs.css" %}">
{% block css %}
{% endblock %}
{% block preload_js %}
{% endblock %}
{% block extra-head %}{% endblock %}
</head>
<body>
{% include "analytics.html" %}
<script type="text/x-handlebars" data-template-name="application">
{% include "navbar.html" %}
<div class="container">
<div id="content" class="row">
{% block content-header %}
{% if error %}
<div class="error">{{ error }}</div>{% endif %}
{% if info %}
<div class="info">{{ info }}</div>{% endif %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.level_tag }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endblock %}
{% verbatim %}{{ outlet }}{% endverbatim %}
</div>
<div id="sidebar" class="column">
{% block sidebar %}
{% endblock %}
</div>
</div>
</script>
{% block content %}{% endblock %}
<div class="modal fade" id="modal" role="dialog" tabindex=-1></div>
<script src="{% static "assets/vendor.js" %}"></script>
<script src="{% static "assets/pyrigs.js" %}"></script>
<script src="https://cdn.ravenjs.com/1.3.0/jquery,native/raven.min.js"></script>
<script>Raven.config('{% sentry_public_dsn %}').install()</script>
<script>
Date.prototype.getISOString = function () {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth() + 1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + '-' + (mm[1] ? mm : "0" + mm[0]) + '-' + (dd[1] ? dd : "0" + dd[0]); // padding
};
</script>
<script>
$('.navbar-collapse').addClass('collapse')
</script>
<script src="{% static "js/konami.js" %}"></script>
<script>
jQuery(document).ready(function () {
jQuery(document).on('click', '.modal-href', function (e) {
$link = jQuery(this);
// Anti modal inception
if ($link.parents('#modal').length == 0) {
e.preventDefault();
modaltarget = $link.data('target');
modalobject = "";
jQuery('#modal').load($link.attr('href'), function (e) {
jQuery('#modal').modal();
});
}
});
var easter_egg = new Konami();
easter_egg.code = function () {
var s = document.createElement('script');
s.type = 'text/javascript';
document.body.appendChild(s);
s.src = '{% static "js/asteroids.min.js"%}';
ga('send', 'event', 'easter_egg', 'activated');
};
easter_egg.load();
});
</script>
{% block js %}
{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,12 @@
import {moduleFor, test} from "ember-qunit";
moduleFor('controller:event/create', 'Unit | Controller | event/create', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
// Replace this with your real tests.
test('it exists', function (assert) {
let controller = this.subject();
assert.ok(controller);
});

View File

@@ -0,0 +1,12 @@
import Ember from "ember";
import SetTimeMixinMixin from "pyrigs/mixins/set-time-mixin";
import {module, test} from "qunit";
module('Unit | Mixin | set time mixin');
// Replace this with your real tests.
test('it works', function (assert) {
let SetTimeMixinObject = Ember.Object.extend(SetTimeMixinMixin);
let subject = SetTimeMixinObject.create();
assert.ok(subject);
});

View File

@@ -0,0 +1,11 @@
import {moduleFor, test} from "ember-qunit";
moduleFor('route:event/create', 'Unit | Route | event/create', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function (assert) {
let route = this.subject();
assert.ok(route);
});

View File

@@ -0,0 +1,11 @@
import {moduleFor, test} from "ember-qunit";
moduleFor('route:event/duplicate', 'Unit | Route | event/duplicate', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function (assert) {
let route = this.subject();
assert.ok(route);
});

View File

@@ -0,0 +1,11 @@
import {moduleFor, test} from "ember-qunit";
moduleFor('route:event/edit', 'Unit | Route | event/edit', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function (assert) {
let route = this.subject();
assert.ok(route);
});