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 */
.item-description {
.item_row .description {
margin-left: 1em;
}

View File

@@ -106,7 +106,7 @@ $('body').on('submit', '#item-form', function (e) {
// update the table
$row = $('#item-' + pk);
$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('.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;
}
.item-description {
.item_row .description {
margin-left: 1em;
}

View File

@@ -3,13 +3,15 @@
<tr id="item-{{ item.pk }}" data-pk="{{ item.pk }}" class="item_row">
<td>
<span class="name">{{ item.name }}</span>
<div class="item-description">
<em class="description">{{item.description|markdown}}</em>
<div class="description">
{{ item.description|markdown }}
</div>
</td>
<td>£&nbsp;<span class="cost">{{ item.cost|floatformat:2 }}</span></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>
</td>
{% if edit %}
<td class="vert-align text-right">
<button type="button" class="item-edit btn btn-xs btn-default"

View File

@@ -31,10 +31,12 @@
<tr>
{% if not object.pk %}
<td id="vat-rate" data-rate="{{ currentVAT.rate }}">VAT @
{{currentVAT.as_percent|floatformat}}% (TBC)</td>
{{ currentVAT.as_percent|floatformat }}% (TBC)
</td>
{% else %}
<td id="vat-rate" data-rate="{{ object.vat_rate.rate }}">VAT @
{{object.vat_rate.as_percent|floatformat|default:"TBD"}}%</td>
{{ object.vat_rate.as_percent|floatformat|default:"TBD" }}%
</td>
{% endif %}
<td colspan="2">£ <span id="vat">{{ object.vat|default:0|floatformat:2 }}</span></td>
</tr>
@@ -49,8 +51,8 @@
<tr id="new-item-row" class="item_row">
<td>
<span class="name"></span>
<div class="item-description">
<em class="description"></em>
<div class="description">
</div>
</td>
<td>£&nbsp;<span class="cost"></span></td>

Binary file not shown.

View File

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