-
Notifications
You must be signed in to change notification settings - Fork 167
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
Changes from 1 commit
d19997d
12e6167
1d6c888
9fb78c1
2ff88ac
520c8bd
a86b075
d64117f
615f5d4
fa17b76
4ecf63c
89eda18
d209ad7
405f17c
6b78028
2b19e0d
68ecbb1
14e987a
8be724e
0977079
c465f32
cbfe255
1daa48a
25276f0
1ec13cc
9335ccc
1e40465
f64b319
e81dc71
9a62434
0541a3e
b091f73
20bf699
a199b20
f30e30d
f32e2ba
185cc00
4e2dbfb
7f2c913
3c735ff
f411710
3227078
6b73cfc
6033f61
e5fe212
42d52aa
43a76af
7e12347
516583f
dd0444c
ed5e0cf
c30ad5f
ca9952d
e61d8cf
588b3a9
32e5899
868945a
ab60b13
8feb1ec
aa4afcc
ba88ccc
e924cc3
21141ef
42b4996
696bb81
868f7c3
ef875a5
dc5c9e4
9b94737
0d19446
c0d07af
59cd3d4
39ead6e
b4567b8
d00b293
c80d546
63075aa
fba3423
f64ec59
5863c8c
c7e8103
2602d09
cbf62b2
fcd9eee
3571d27
3df61ec
782c8aa
21ee83f
1623c63
dd97dde
af4f552
08a2c30
909b53e
af170c0
b95cc17
88a9290
21255b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,66 @@ | ||
|
||
|
||
$(document).ready(function () { | ||
console.log('oooooo'); | ||
|
||
$('.compare-introduction').mergely({ | ||
width: 'auto', | ||
height: 400, | ||
sidebar: false, | ||
cmsettings: { readOnly: false, lineNumbers: true }, | ||
lhs: function(setValue) { | ||
setValue($("#your_introduction").html()); | ||
}, | ||
rhs: function(setValue) { | ||
setValue($("#id_introduction").text()); | ||
} | ||
}); | ||
(function($, undefined) { | ||
"use strict"; | ||
|
||
$('.compare-conclusion').mergely({ | ||
width: 'auto', | ||
height: 400, | ||
sidebar: false, | ||
cmsettings: { readOnly: false, lineNumbers: true }, | ||
lhs: function(setValue) { | ||
setValue($("#your_conclusion").html()); | ||
}, | ||
rhs: function(setValue) { | ||
setValue($("#id_conclusion").text()); | ||
$(document).ready(function () { | ||
|
||
/** | ||
* Sets up the merge interface (using mergely). | ||
*/ | ||
function mergelySetUp(div, left, right) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. peux-tu mettre un There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pourquoi pas changer le nom. Après local et remote c'est une convention pour nous (car le code actuel écrase), par sur que ça soit clair nom plus... Je vais détailler les commentaires avant pour expliquer les paramètres. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Effectivement les variables jQuery doivent être préfixées par var $lala = $('.foo').find('.bar').get(1);
var baz = $lala.val(); Je sais pas comment nommer idéalement |
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L’accolade doit être sur la même ligne que |
||
div.mergely({ | ||
width: "auto", | ||
height: 400, | ||
sidebar: false, | ||
cmsettings: { readOnly: false, lineNumbers: true, lineWrapping: true }, | ||
lhs: function(setValue) { | ||
setValue(left.html()); | ||
}, | ||
rhs: function(setValue) { | ||
setValue(right.text()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. peux-tu mettre un commentaire dans le code pour expliquer pourquoi on a "html" d'un côté et "text" de l'autre stp? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bien vu, j'ai uniformisé car il n'y avait pas de raison en particulier. |
||
} | ||
}); | ||
} | ||
}); | ||
|
||
// TODO a voir comment on peut factoriser ce code. | ||
|
||
$("#compare-editor-lhs").append('Votre Version'); | ||
$("#compare-editor-rhs").append('La version courante'); | ||
|
||
|
||
|
||
/** | ||
* Merge introduction | ||
*/ | ||
$(".merge-btn").on("click", function(e){ | ||
console.log('click'); | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
// var $form = $(this).parents("form:first"); | ||
var button = $(this); | ||
|
||
console.log(button); | ||
|
||
var classList = button.attr('class').split(/\s+/); | ||
console.log(classList); | ||
for (var i = 0; i < classList.length; i++) { | ||
if (classList[i].indexOf('need-to-merge-') >= 0) { | ||
|
||
// Cut the string to get the ending part | ||
console.log(classList[i]) | ||
var substring = classList[i].substring(14) | ||
|
||
// TODO : problème des retours à la ligne qui s'en vont (ou normal car markdown ?) ? | ||
$intro = $("#id_" + substring); | ||
$to_merge = $(".compare-" + substring).mergely('get','rhs'); | ||
$intro.val($to_merge); | ||
|
||
console.log($intro.val()); | ||
// TODO : un bon petit alert des familles | ||
var msg = '<div class="alert-box alert"> \ | ||
<span>Le merge a bien été effectué</span> \ | ||
<a href="#close-alert-box" class="close-alert-box ico-after cross white">{% trans "Masquer l\'alerte" %}</a> \ | ||
</div>'; | ||
|
||
$(".compare-" + substring).append(msg) | ||
|
||
alert('Contenu bien mergé'); | ||
} | ||
} | ||
}); | ||
mergelySetUp($(".compare-introduction"),$("#your_introduction"),$("#id_introduction")); | ||
mergelySetUp($(".compare-conclusion"),$("#your_conclusion"),$("#id_conclusion")); | ||
|
||
$("#compare-editor-lhs").append("Votre Version"); | ||
$("#compare-editor-rhs").append("La version courante"); | ||
|
||
|
||
/** | ||
* Merge content | ||
*/ | ||
$(".merge-btn").on("click", function(e){ | ||
|
||
e.stopPropagation(); | ||
e.preventDefault(); | ||
|
||
var button = $(this); | ||
var classList = button.attr("class").split(/\s+/); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hum pas sûr que ça soit la méthode la plus facile d'autant qu'il existe déjà l'attribut classList ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. De mémoire .classList à un support limité (voir inexistant) avec < IE9, d'où le choix de .attr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on ne supporte que IE 11 et supérieur, chrome last, firefox last, safari last. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ca marche alors ;) |
||
|
||
for (var i = 0; i < classList.length; i++) { | ||
if (classList[i].indexOf("need-to-merge-") >= 0) { | ||
|
||
// Cut the string to get the ending part | ||
var substring = classList[i].substring(14); | ||
|
||
var $intro = $("#id_" + substring); | ||
var $toMerge = $(".compare-" + substring).mergely("get","rhs"); | ||
$intro.val($toMerge); | ||
|
||
|
||
}); | ||
// Display confirmation message | ||
var msg = "<div class='alert-box success'>" + | ||
"<span>Le merge a bien été effectué</span>" + | ||
"<a href='#close-alert-box' class='close-alert-box ico-after cross white'>Masquer l'alerte</a>" + | ||
"</div>"; | ||
|
||
button.before(msg); | ||
} | ||
} | ||
}); | ||
|
||
}); | ||
})(jQuery); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,27 +237,25 @@ def __init__(self, *args, **kwargs): | |
|
||
if kwargs.get('data') is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pourquoi la condition apparaît-elle deux fois? |
||
old_intro = kwargs.get('data').get('introduction') | ||
# TODO retirer le br et passer en style | ||
|
||
self.helper.layout.append(Layout(Field('introduction', css_class='hidden'))) | ||
self.helper.layout.append(Layout(HTML('<div id="your_introduction" class="hidden" >'+old_intro+'</div>'))) | ||
self.helper.layout.append(Layout(HTML('<br><br><div id="compare" class="compare-introduction"></div><br><br>'))) | ||
self.helper.layout.append(Layout(HTML('<div id="compare" class="compare-introduction"></div>'))) | ||
|
||
self.helper.layout.append(Layout( | ||
ButtonHolder(StrictButton(_(u'Merger'), type='merge', name='merge', css_class='btn btn-submit merge-btn need-to-merge-introduction')))) | ||
|
||
else : | ||
self.helper.layout.append(Layout(Field('introduction', css_class='md-editor'))) | ||
|
||
if kwargs.get('data') is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. il te manque un |
||
old_conclusion = kwargs.get('data').get('conclusion') | ||
# TODO retirer le br et passer en style | ||
|
||
self.helper.layout.append(Layout(Field('conclusion', css_class='hidden'))) | ||
self.helper.layout.append(Layout(HTML('<div id="your_conclusion" class="hidden" >'+old_conclusion+'</div>'))) | ||
self.helper.layout.append(Layout(HTML('<br><br><div id="compare" class="compare-conclusion"></div><br><br>'))) | ||
self.helper.layout.append(Layout(HTML('<div id="compare" class="compare-conclusion"></div>'))) | ||
|
||
self.helper.layout.append(Layout( | ||
ButtonHolder(StrictButton(_(u'Merger'), type='merge', name='merge', css_class='btn btn-submit merge-btn need-to-merge-conclusion')))) | ||
|
||
else : | ||
self.helper.layout.append(Layout(Field('conclusion', css_class='md-editor'))) | ||
|
||
|
There was a problem hiding this comment.
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.