-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#47: Port export configuration diff view.
- Loading branch information
1 parent
a0afb05
commit 775bf21
Showing
13 changed files
with
170 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'diff2html/bundles/css/diff2html.min.css'; | ||
import './styles/export.css'; | ||
import $ from 'jquery'; | ||
import 'jquery-ui'; | ||
// import { Diff2Html } from 'diff2html'; | ||
import Diff2HtmlUI from 'diff2html/bundles/js/diff2html-ui.min.js'; | ||
import * as Diff from 'diff'; | ||
|
||
function buildDiffView(text1, text2, label1, label2) { | ||
var changes = Diff.diffLines(text1, text2); | ||
if (changes.length > 1) { | ||
const diff = Diff.createPatch('', text1, text2, label1, label2, { options: { context: 5} }); | ||
const configuration = { | ||
drawFileList: true, | ||
matching: 'lines', | ||
outputFormat: 'side-by-side', | ||
fileListToggle: false, | ||
fileListStartVisible: false, | ||
fileContentToggle: false, | ||
container: document.createElement('div'), | ||
diff2htmlUi:null, | ||
highlight: true | ||
}; | ||
var diff2htmlUi = new Diff2HtmlUI.Diff2HtmlUI($('#diff').get(0), diff, configuration); | ||
diff2htmlUi.draw(); | ||
} else { | ||
$('#diff').append("<div style='border:1px solid gray;padding:10px'><p>No difference in JSON data between these revisions</p></div>"); | ||
} | ||
} | ||
|
||
$(document).ready(function() { | ||
buildDiffView( | ||
$("#rev1").val(), | ||
$("#rev2").val(), | ||
"Revision #" + $("#rev1").data('rev-id') + " (" + $("#rev1").data('rev-date') + ")", | ||
"Revision #" + $("#rev2").data('rev-id') + " (" + $("#rev2").data('rev-date') + ")", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule jsdifflib
deleted from
f728d4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block importmap %} | ||
{# do NOT call parent() #} | ||
{{ importmap(['app', 'export_revision_diff']) }} | ||
{% endblock %} | ||
|
||
{% block body %} | ||
|
||
<div id='diff'></div> | ||
<textarea id="rev1" data-rev-id="{{ rev1.id }}" data-rev-date="{{ rev1.last_saved }}" style="display:none">{{ rev1.json_data }}</textarea> | ||
<textarea id="rev2" data-rev-id="{{ rev2.id }}" data-rev-date="{{ rev2.last_saved }}" style="display:none">{{ rev2.json_data }}</textarea> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block importmap %} | ||
{# do NOT call parent() #} | ||
{{ importmap(['app', 'export_revision_history']) }} | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<h1>Revision history for {{ configLabel }}</h1> | ||
<div class='admin-menu'><a href="{{ url('admin_exports_config', {exportId: configId}) }}">« Back to catalog export configuration</a></div> | ||
|
||
<div class='config-menu'> | ||
<button class="compare-revisions-button" data-url="{{ url('admin_exports_config_revision_diff', {rev1: '-rev1-', rev2: '-rev2-'}) }}">Compare selected revisions</button> | ||
</div> | ||
|
||
{% if revisions | length %} | ||
<table id='revisions-table'> | ||
<tr> | ||
<th>Compare</th> | ||
<th>Date</th> | ||
<th>Author</th> | ||
<th>Note</th> | ||
<th>JSON</th> | ||
<th>Actions</th> | ||
</tr> | ||
{% for revision in revisions %} | ||
<tr> | ||
<td> | ||
<input id='radio{{ revision.id }}' type='radio'/> | ||
<input class='revId' type='hidden' value='{{ revision.id }}' /> | ||
</td> | ||
<td class='timestamp'>{{ revision.last_saved }}</td> | ||
<td>{{ revision.user_disp_name }}</td> | ||
<td width='200'>{{ revision.note }}</td> | ||
<td> | ||
<a class='link-button' href='{{ url('admin_exports_config_revision_json', {revisionId: revision.id}) }}' target="_blank">View JSON</a> | ||
</td> | ||
<td> | ||
<button onclick="revertTo($revision['id'])">Revert to this revision</button> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
{% else %} | ||
No revisions in history for config: {{ configLabel }} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters