Add parsing of markdown when editing event items

This commit is contained in:
Tom Price
2016-01-07 20:55:21 +00:00
parent e645b72492
commit 7e0e6b6b3e
8 changed files with 94 additions and 83 deletions

View File

@@ -9049,7 +9049,7 @@ textarea {
} }
/* line 57, ../scss/screen.scss */ /* line 57, ../scss/screen.scss */
.item-description { .item_row .description {
margin-left: 1em; margin-left: 1em;
} }

View File

@@ -106,7 +106,7 @@ $('body').on('submit', '#item-form', function (e) {
// update the table // update the table
$row = $('#item-' + pk); $row = $('#item-' + pk);
$row.find('.name').html(escapeHtml(fields.name)); $row.find('.name').html(escapeHtml(fields.name));
$row.find('.description').html(nl2br(escapeHtml(fields.description))); $row.find('.description').html(marked(fields.description));
$row.find('.cost').html(parseFloat(fields.cost).toFixed(2)); $row.find('.cost').html(parseFloat(fields.cost).toFixed(2));
$row.find('.quantity').html(fields.quantity); $row.find('.quantity').html(fields.quantity);

6
RIGS/static/js/marked.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -54,7 +54,7 @@ textarea {
max-width: 2em; max-width: 2em;
} }
.item-description { .item_row .description {
margin-left: 1em; margin-left: 1em;
} }

View File

@@ -1,26 +1,28 @@
{% load markdown_tags %} {% load markdown_tags %}
<tr id="item-{{item.pk}}" data-pk="{{item.pk}}" class="item_row"> <tr id="item-{{ item.pk }}" data-pk="{{ item.pk }}" class="item_row">
<td> <td>
<span class="name">{{ item.name }}</span> <span class="name">{{ item.name }}</span>
<div class="item-description">
<em class="description">{{item.description|markdown}}</em> <div class="description">
{{ item.description|markdown }}
</div> </div>
</td> </td>
<td>£&nbsp;<span class="cost">{{item.cost|floatformat:2}}</span></td> <td>£&nbsp;<span class="cost">{{ item.cost|floatformat:2 }}</span></td>
<td class="quantity">{{item.quantity}}</td> <td class="quantity">{{ item.quantity }}</td>
<td>£&nbsp;<span class="sub-total" data-subtotal="{{item.total_cost}}">{{item.total_cost|floatformat:2}}</span></td> <td>£&nbsp;<span class="sub-total" data-subtotal="{{ item.total_cost }}">{{ item.total_cost|floatformat:2 }}</span>
{% if edit %} </td>
<td class="vert-align text-right"> {% if edit %}
<button type="button" class="item-edit btn btn-xs btn-default" <td class="vert-align text-right">
data-pk="{{item.pk}}" <button type="button" class="item-edit btn btn-xs btn-default"
data-toggle="modal" data-target="#itemModal"> data-pk="{{ item.pk }}"
<span class="glyphicon glyphicon-edit"></span> data-toggle="modal" data-target="#itemModal">
</button> <span class="glyphicon glyphicon-edit"></span>
<button type="button" class="item-delete btn btn-xs btn-danger" </button>
data-pk="{{item.pk}}"> <button type="button" class="item-delete btn btn-xs btn-danger"
<span class="glyphicon glyphicon-remove"></span> data-pk="{{ item.pk }}">
</button> <span class="glyphicon glyphicon-remove"></span>
</td> </button>
{% endif %} </td>
{% endif %}
</tr> </tr>

View File

@@ -1,71 +1,73 @@
<div class="panel table-responsive"> <div class="panel table-responsive">
<table class="table table-hover" id="item-table" {% if edit %}data-orderurl="{#% url 'item_order' %#}"{% endif %}> <table class="table table-hover" id="item-table" {% if edit %}data-orderurl="{#% url 'item_order' %#}"{% endif %}>
<thead> <thead>
<tr> <tr>
<td>Item</td> <td>Item</td>
<td>Price</td> <td>Price</td>
<td>Quantity</td> <td>Quantity</td>
<td>Sub-total</td> <td>Sub-total</td>
{% if edit %} {% if edit %}
<td class="text-right"> <td class="text-right">
<button type="button" class="btn btn-default btn-xs item-add" <button type="button" class="btn btn-default btn-xs item-add"
data-url="{#% url eventitem_add object.pk %#}" data-toggle="modal" data-url="{#% url eventitem_add object.pk %#}" data-toggle="modal"
data-target="#itemModal"> data-target="#itemModal">
<span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-plus"></span>
</button> </button>
</td> </td>
{% endif %} {% endif %}
</tr> </tr>
</thead> </thead>
<tbody id="item-table-body"> <tbody id="item-table-body">
{% for item in object.items.all %} {% for item in object.items.all %}
{% include 'RIGS/item_row.html' %} {% include 'RIGS/item_row.html' %}
{% endfor %} {% endfor %}
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td rowspan="3" colspan="2"></td> <td rowspan="3" colspan="2"></td>
<td>Total (ex. VAT)</td> <td>Total (ex. VAT)</td>
<td colspan="2">£ <span id="sumtotal">{{object.sum_total|default:0|floatformat:2}}</span></td> <td colspan="2">£ <span id="sumtotal">{{ object.sum_total|default:0|floatformat:2 }}</span></td>
</tr> </tr>
<tr> <tr>
{% if not object.pk %} {% if not object.pk %}
<td id="vat-rate" data-rate="{{currentVAT.rate}}">VAT @ <td id="vat-rate" data-rate="{{ currentVAT.rate }}">VAT @
{{currentVAT.as_percent|floatformat}}% (TBC)</td> {{ currentVAT.as_percent|floatformat }}% (TBC)
{% else %} </td>
<td id="vat-rate" data-rate="{{object.vat_rate.rate}}">VAT @ {% else %}
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td> <td id="vat-rate" data-rate="{{ object.vat_rate.rate }}">VAT @
{% endif %} {{ object.vat_rate.as_percent|floatformat|default:"TBD" }}%
<td colspan="2">£ <span id="vat">{{object.vat|default:0|floatformat:2}}</span></td> </td>
</tr> {% endif %}
<tr> <td colspan="2">£ <span id="vat">{{ object.vat|default:0|floatformat:2 }}</span></td>
<td>Total</td> </tr>
<td colspan="2">£ <span id="total">{{object.total|default:0|floatformat:2}}</span></td> <tr>
</tr> <td>Total</td>
</tfoot> <td colspan="2">£ <span id="total">{{ object.total|default:0|floatformat:2 }}</span></td>
</table> </tr>
</tfoot>
</table>
</div> </div>
<table class="hidden invisible"> <table class="hidden invisible">
<tr id="new-item-row" class="item_row"> <tr id="new-item-row" class="item_row">
<td> <td>
<span class="name"></span> <span class="name"></span>
<div class="item-description">
<em class="description"></em> <div class="description">
</div> </div>
</td> </td>
<td>£&nbsp;<span class="cost"></span></td> <td>£&nbsp;<span class="cost"></span></td>
<td class="quantity"></td> <td class="quantity"></td>
<td>£&nbsp;<span class="sub-total"></span></td> <td>£&nbsp;<span class="sub-total"></span></td>
{% if edit %} {% if edit %}
<td class="vert-align text-right"> <td class="vert-align text-right">
<button type="button" class="item-edit btn btn-xs btn-default" <button type="button" class="item-edit btn btn-xs btn-default"
data-toggle="modal" data-target="#itemModal"> data-toggle="modal" data-target="#itemModal">
<span class="glyphicon glyphicon-edit"></span> <span class="glyphicon glyphicon-edit"></span>
</button> </button>
<button type="button" class="item-delete btn btn-xs btn-danger"> <button type="button" class="item-delete btn btn-xs btn-danger">
<span class="glyphicon glyphicon-remove"></span> <span class="glyphicon glyphicon-remove"></span>
</button> </button>
</td> </td>
{% endif %} {% endif %}
</tr> </tr>
</table> </table>

Binary file not shown.

View File

@@ -176,6 +176,7 @@
<script src="{% static "js/dropdown.js" %}"></script> <script src="{% static "js/dropdown.js" %}"></script>
<script src="{% static "js/modal.js" %}"></script> <script src="{% static "js/modal.js" %}"></script>
<script src="{% static "js/konami.js" %}"></script> <script src="{% static "js/konami.js" %}"></script>
<script src="{% static "js/marked.min.js" %}"></script>
<script> <script>
jQuery(document).ready(function () { jQuery(document).ready(function () {
jQuery(document).on('click', '.modal-href', function (e) { jQuery(document).on('click', '.modal-href', function (e) {