Commit 49bb60ba authored by Maxym Borodenko's avatar Maxym Borodenko

Contributor entry as <textarea line

parent 0bac30a4
......@@ -123,7 +123,7 @@
<div class="row">
<div class="large-12 columns">
<label>Edit the contributors list:
<textarea id="contributorsText" placeholder="Contributor 1, Contributor 2, ..."></textarea>
<textarea id="contributorsText" placeholder="Contributor 1 \nContributor 2 \n..." rows="3"></textarea>
</label>
</div>
</div>
......
......@@ -117,7 +117,7 @@ export function editContributors(contributors) {
if (contributors.length === 1 && !contributors[0]) {
tree_root['contributors'] = undefined;
} else {
tree_root['contributors'] = contributors.map(c => c.trim());
tree_root['contributors'] = contributors.filter(c => !!c).map(c => c.trim());
}
}
}
......
......@@ -184,7 +184,7 @@ $('document').ready(function() {
$('#EditContributorsModal .errorMessage')[0].innerHTML = '';
const text = $('#EditContributorsModal #contributorsText')[0].value;
editContributors(text.split(','));
editContributors(text.split('\n'));
$('#EditContributorsModal').foundation('close');
});
......@@ -209,16 +209,34 @@ $('document').ready(function() {
});
$('#editContributorsBtn').on('click', () => {
const contributorsText = $('#contributorsText');
contributorsText.attr('placeholder', contributorsText.prop('placeholder').replace(/\\n/g, '\n'));
const tree = getTree();
if (tree.contributors) {
$('#EditContributorsModal #contributorsText')[0].value = tree.contributors.join(', ');
contributorsText.val(tree.contributors.join('\n'));
const lines = tree.contributors.length;
if (lines <= 25) {
contributorsText.attr('rows', lines);
} else {
contributorsText.attr('rows', 25);
}
} else {
contributorsText.val('');
contributorsText.attr('rows', 3);
console.log('The list of contributors isn\'t found.');
}
$('#EditContributorsModal').foundation('open');
$('#EditContributorsModal').focus();
});
$('#EditContributorsModal #contributorsText').on('input propertychange', () => {
const element = $('#contributorsText');
const lines = element.val().split(/\r*\n/).length;
if (lines >= 3 && lines < 25) {
element.attr('rows', lines);
}
});
const resetTree = () => {
let newTree = {
name: 'Entire genepool',
......
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