Commit 5b628816 by tasawernawaz Committed by Tasawer Nawaz

diff implemented

parent 0d557a56
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"js-cookie": "2.1.2", "js-cookie": "2.1.2",
"moment": "~2.13.0", "moment": "~2.13.0",
"pikaday": "https://github.com/owenmead/Pikaday.git#1.4.0", "pikaday": "https://github.com/owenmead/Pikaday.git#1.4.0",
"underscore": "~1.8.3" "underscore": "~1.8.3",
"google-diff-match-patch": "0.1.0"
} }
} }
$(document).on('click', '.btn-show-changes', function (e) {
if ($(this).text() === 'Show changes') {
$('.field-container').each(function () {
showDiff($(this).find('span.object'), $(this).find('span.history-object'), $(this).find('span.show-diff'));
});
$(this).text('Hide changes');
} else {
$('.object').show();
$('.show-diff').hide();
$(this).text('Show changes');
}
});
var dmp =new diff_match_patch();
function showDiff($object, $historyObject, $outputDiv) {
var d = dmp.diff_main($object.text(), $historyObject.text());
$outputDiv.html(dmp.diff_prettyHtml(d));
$object.hide();
}
...@@ -930,6 +930,10 @@ select { ...@@ -930,6 +930,10 @@ select {
font-weight: 600; font-weight: 600;
} }
.history-object {
display: none;
}
span { span {
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n %} {% load i18n %}
{% load staticfiles %}
{% block title %} {% block title %}
{% trans "Revision History" %} {% trans "Revision History" %}
{% endblock title %} {% endblock title %}
{% block content %} {% block content %}
<div class="parent-course-history"> <div class="parent-course-history" xmlns="http://www.w3.org/1999/html">
<div class="title">{% trans "Revision History" %}</div> <div class="title">{% trans "Revision History" %}</div>
<div> <div>
...@@ -25,55 +26,84 @@ ...@@ -25,55 +26,84 @@
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Course Title" %}</div> <div class="field-title">{% trans "Course Title" %}</div>
<span>{{ history_object.title }}</span> <span class="object">{{ history_object.title }}</span>
<span class="history-object">{{ object.title }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Course Number" %}</div> <div class="field-title">{% trans "Course Number" %}</div>
<span>{{ history_object.number }}</span> <span class="object">{{ history_object.number }}</span>
<span class="history-object">{{ object.number }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Brief Description" %}</div> <div class="field-title">{% trans "Brief Description" %}</div>
<span>{{ history_object.short_description }}</span> <span class="object">{{ history_object.short_description }}</span>
<span class="history-object">{{ object.short_description }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Full Description" %}</div> <div class="field-title">{% trans "Full Description" %}</div>
<span>{{ history_object.full_description }}</span> <span class="object">{{ history_object.full_description }}</span>
<span class="history-object">{{ object.full_description }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Expected Learnings" %}</div> <div class="field-title">{% trans "Expected Learnings" %}</div>
<span>{{ history_object.expected_learnings }}</span> <span class="object">{{ history_object.expected_learnings }}</span>
<span class="history-object">{{ object.expected_learnings }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Primary Subject" %}</div> <div class="field-title">{% trans "Primary Subject" %}</div>
<span>{{ history_object.primary_subject }}</span> <span class="object">{{ history_object.primary_subject }}</span>
<span class="history-object">{{ object.primary_subject }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Secondary Subject" %}</div> <div class="field-title">{% trans "Secondary Subject" %}</div>
<span>{{ history_object.secondary_subject }}</span> <span class="object">{{ history_object.secondary_subject }}</span>
<span class="history-object">{{ object.secondary_subject }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Tertiary Subject" %}</div> <div class="field-title">{% trans "Tertiary Subject" %}</div>
<span>{{ history_object.tertiary_subject }}</span> <span class="object">{{ history_object.tertiary_subject }}</span>
<span class="history-object">{{ object.tertiary_subject }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Prerequisites" %}</div> <div class="field-title">{% trans "Prerequisites" %}</div>
<span>{{ history_object.prerequisites }}</span> <span class="object">{{ history_object.prerequisites }}</span>
<span class="history-object">{{ object.prerequisites }}</span>
<span class="show-diff"></span>
</div> </div>
<div class="field-container"> <div class="field-container">
<div class="field-title">{% trans "Course Level" %}</div> <div class="field-title">{% trans "Course Level" %}</div>
<span>{{ history_object.level_type }}</span> <span class="object">{{ history_object.level_type }}</span>
<span class="history-object">{{ object.level_type }}</span>
<span class="show-diff"></span>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block js %}
{% compress js %}
<script src="{% static 'bower_components/jquery/dist/jquery.js' %}"></script>
<script src="{% static 'bower_components/google-diff-match-patch/diff_match_patch.js' %}"></script>
<script src="{% static 'js/publisher/comparing-objects.js' %}"></script>
{% endcompress %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment