Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Ajout d'une interface de merge pour les contenus #4151

Closed
wants to merge 97 commits into from
Closed
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
d19997d
First commit
Anto59290 Nov 28, 2016
12e6167
ajout de routes, netoyage, test
Anto59290 Dec 5, 2016
1d6c888
Remove useless routes, add tests, add permissions, typos, styling
Anto59290 Dec 15, 2016
9fb78c1
Ajout de test, retrait de todo
Anto59290 Dec 19, 2016
2ff88ac
Testing
Anto59290 Dec 23, 2016
520c8bd
Tests
Anto59290 Dec 24, 2016
a86b075
Add validator, test
Anto59290 Dec 29, 2016
d64117f
Fixing tests, adding tests
Anto59290 Jan 2, 2017
615f5d4
tests
Anto59290 Jan 3, 2017
fa17b76
fixing test
Anto59290 Jan 4, 2017
4ecf63c
testing'
Anto59290 Jan 5, 2017
89eda18
Remove useless code, update todo list, style
Anto59290 Jan 5, 2017
d209ad7
Update settings.py
Anto59290 Jan 5, 2017
405f17c
First POC
Anto59290 Jan 10, 2017
6b78028
clean, remove useless file
Anto59290 Jan 10, 2017
2b19e0d
Clean, industrialisation du processus, divers bugs réglés
Anto59290 Jan 10, 2017
68ecbb1
ajout de la conclusion
Anto59290 Jan 11, 2017
14e987a
change alert to msg
Anto59290 Jan 12, 2017
8be724e
Nettoyage et style, diverses améliorations visuelles
Anto59290 Jan 12, 2017
0977079
style
Anto59290 Jan 12, 2017
c465f32
style
Anto59290 Jan 12, 2017
cbfe255
ajout du package, simplifie le formulaire
Anto59290 Jan 12, 2017
1daa48a
js plus logique
Anto59290 Jan 12, 2017
25276f0
Documentation JS, Refacto JS, ajout d'un TODO
Anto59290 Jan 13, 2017
1ec13cc
Style
Anto59290 Jan 13, 2017
9335ccc
better UX, remove todo
Anto59290 Jan 17, 2017
1e40465
ajout de l'interface de merge aux autres formulaires
Anto59290 Jan 23, 2017
f64b319
Update forms.py
Anto59290 Jan 23, 2017
e81dc71
ajout aux autres forms
Anto59290 Jan 24, 2017
9a62434
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Jan 26, 2017
0541a3e
Update forms.py
Anto59290 Jan 26, 2017
b091f73
merge
Anto59290 Jan 26, 2017
20bf699
fix style
Anto59290 Jan 26, 2017
a199b20
fix style
Anto59290 Jan 26, 2017
f30e30d
merge
Anto59290 Jan 26, 2017
f32e2ba
Update forms.py
Anto59290 Feb 2, 2017
185cc00
Update settings.py
Anto59290 Feb 21, 2017
4e2dbfb
Update auto-merge.js
Anto59290 Feb 21, 2017
7f2c913
Update forms.py
Anto59290 Feb 28, 2017
3c735ff
Remove mege info
Anto59290 Apr 15, 2017
f411710
Merging
Anto59290 Apr 15, 2017
3227078
Merging
Anto59290 Apr 15, 2017
6b73cfc
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Apr 20, 2017
6033f61
Update forms.py
Anto59290 Apr 20, 2017
e5fe212
Update forms.py
Anto59290 Apr 20, 2017
42d52aa
Update forms.py
Anto59290 Apr 22, 2017
43a76af
Update main.scss
Anto59290 Apr 22, 2017
7e12347
Merge branch 'dev' into 3251_git_diff_2
Anto59290 May 7, 2017
516583f
Merge branch 'dev' of https://github.com/zestedesavoir/zds-site into …
Anto59290 May 9, 2017
dd0444c
Fix styles, add sccs files
Anto59290 May 9, 2017
ed5e0cf
merge
Anto59290 May 9, 2017
c30ad5f
Update models.py
Anto59290 May 10, 2017
ca9952d
Update models.py
Anto59290 May 10, 2017
e61d8cf
Update models.py
Anto59290 May 10, 2017
588b3a9
Update models.py
Anto59290 May 10, 2017
32e5899
Update forms.py
Anto59290 May 10, 2017
868945a
Update forms.py
Anto59290 May 10, 2017
ab60b13
Remove files
Anto59290 May 10, 2017
8feb1ec
Merge branch '3251_git_diff_2' of https://github.com/Anto59290/zds-si…
Anto59290 May 10, 2017
aa4afcc
Fix rebase
Anto59290 May 10, 2017
ba88ccc
Update tests_models.py
Anto59290 May 10, 2017
e924cc3
Update permissions.py
Anto59290 May 10, 2017
21141ef
Update forms.py
Anto59290 May 10, 2017
42b4996
Update tests.py
Anto59290 May 10, 2017
696bb81
Update views.py
Anto59290 May 10, 2017
868f7c3
Update
Anto59290 May 10, 2017
ef875a5
Update urls.py
Anto59290 May 11, 2017
dc5c9e4
Update permissions.py
Anto59290 May 11, 2017
9b94737
Update forms.py
Anto59290 May 11, 2017
0d19446
Update models.py
Anto59290 May 11, 2017
c0d07af
Update urls.py
Anto59290 May 13, 2017
59cd3d4
Merge branch 'dev' into 3251_git_diff_2
Anto59290 May 31, 2017
39ead6e
Remove old code
Anto59290 May 31, 2017
b4567b8
Peping
Anto59290 Jun 1, 2017
d00b293
Style
Anto59290 Jun 1, 2017
c80d546
fix tests
Anto59290 Jun 2, 2017
63075aa
Just PEPing
Anto59290 Jun 3, 2017
fba3423
Just PEPing so more forms
Anto59290 Jun 3, 2017
f64ec59
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Aug 15, 2017
5863c8c
Refacto
Anto59290 Aug 22, 2017
c7e8103
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Aug 26, 2017
2602d09
I hate Js
Anto59290 Aug 27, 2017
cbf62b2
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Aug 27, 2017
fcd9eee
Working example
Anto59290 Sep 18, 2017
3571d27
Merge branch '3251_git_diff_2' of https://github.com/Anto59290/zds-si…
Anto59290 Sep 23, 2017
3df61ec
Code style
Anto59290 Oct 28, 2017
782c8aa
Try to rebase
Anto59290 Nov 2, 2017
21ee83f
Fixing merge
Anto59290 Nov 2, 2017
1623c63
Update settings.py
Anto59290 Nov 2, 2017
dd97dde
Refactoring
Anto59290 Nov 5, 2017
af4f552
Merge branch '3251_git_diff_2' of https://github.com/Anto59290/zds-si…
Anto59290 Nov 5, 2017
08a2c30
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Nov 5, 2017
909b53e
Linting
Anto59290 Nov 5, 2017
af170c0
Linting and remove py2 u
Anto59290 Nov 5, 2017
b95cc17
Update auto-merge.js
Anto59290 Nov 5, 2017
88a9290
Update auto-merge.js
Anto59290 Nov 6, 2017
21255b0
Merge branch 'dev' into 3251_git_diff_2
Anto59290 Jan 1, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gulpfile.js
Expand Up @@ -48,6 +48,8 @@ gulp.task('js', () =>
gulp.src([
require.resolve('jquery'),
require.resolve('cookies-eu-banner'),
require.resolve('codemirror'),
require.resolve('codemirror/addon/merge/merge'),
// Used by other scripts, must be first
'assets/js/modal.js',
'assets/js/tooltips.js',
Expand All @@ -56,6 +58,7 @@ gulp.task('js', () =>
'assets/js/accordeon.js',
'assets/js/ajax-actions.js',
'assets/js/autocompletion.js',
'assets/js/auto-merge.js',
'assets/js/close-alert-box.js',
'assets/js/compare-commits.js',
'assets/js/dropdown-menu.js',
Expand Down
65 changes: 65 additions & 0 deletions assets/js/auto-merge.js
@@ -0,0 +1,65 @@
(function($, undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faudrait réindenter ce fichier comme le reste, avec des espaces et non des tabulations.

"use strict";

$(document).ready(function () {

/**
* Sets up the merge interface (using codemirror) in the $div Object.
* Data is generally retrieved from a form field or an aditionnal
* div exposing the old data,also generated in the form.
* @param {Object} $div - The base object used to set up the interface. Generally created in forms files.
* @param {Object} $left - The object from which we will pick the content to put in the left hand side (lhs) of the editor.
* @param {Object} $right - The object from which we will pick the content to put in the right hand side (rhs) of the editor.
*/
function mergeUISetUp(selector, $left, $right){
var target = document.getElementsByClassName(selector)[0]; // TODO remplacer par ID ou objet
if (target) {
target.innerHTML = "";
var merge = CodeMirror.MergeView(target, {
value: $left.html(),
orig: $right.html(),
lineNumbers: true,
highlightDifferences: true,
connect: "align",
collapseIdentical: true
});
return merge;
}
}

var mergeInterfaceList = {};
mergeInterfaceList.introduction = mergeUISetUp("compare-introduction",$("#your_introduction"),$("#id_introduction"));
mergeInterfaceList.conclusion = mergeUISetUp("compare-conclusion",$("#your_conclusion"),$("#id_conclusion"));
mergeInterfaceList.text = mergeUISetUp("compare-text",$("#your_text"),$("#id_text"));

$(".CodeMirror-merge-editor").append("Votre Version");
$(".CodeMirror-merge-right").append("La version courante");

/**
* Merge content
*/
$(".merge-btn").on("click", function(e){
e.stopPropagation();
e.preventDefault();
var button = $(this);

Array.from(this.classList).forEach(function(element){
if (element.indexOf("need-to-merge-") >= 0) {
var substring = element.substring(14);
var toMerge = mergeInterfaceList[substring].editor().getValue();
$("#id_" + substring).text(toMerge);

// Confirmation message
var msg = "<div class='alert-box success alert-merge'>" +
"<span>Le contenu a bien été validé.</span>" +
"<a href='#close-alert-box' class='close-alert-box ico-after cross white'>Masquer l'alerte</a>" +
"</div>";
button.before(msg);
setTimeout(function() {
$(".alert-merge").fadeOut("fast");
}, 2000);
}
});
});
});
})(jQuery);
3 changes: 3 additions & 0 deletions assets/scss/components/_auto-merge.scss
@@ -0,0 +1,3 @@
#compare-lhs-margin, #compare-rhs-margin {
display: none;
}