Commit e39758cf authored by buttle's avatar buttle

Added 'Edition mode' to entries list

parent 8a5f8adc
......@@ -31,7 +31,7 @@ babel = Babel(app)
csrf = CSRFProtect()
csrf.init_app(app)
app.config['APP_VERSION'] = 25
app.config['APP_VERSION'] = 26
app.config['SCHEMA_VERSION'] = 12
app.config['RESERVED_SLUGS'] = ['static', 'admin', 'admins', 'user', 'users', 'form', 'forms', 'site', 'sites', 'update']
......
......@@ -62,8 +62,11 @@ hr { margin-top: 5px }
}
/* ######### Entries table ######### */
.delete-row {
font-weight: bold !important;
.delete-row-icon {
font-size: 1.15em !important;
color: grey;
}
.delete-row-icon.enabled {
color: #d9534f;
cursor: pointer;
}
......@@ -77,7 +80,7 @@ hr { margin-top: 5px }
text-decoration: line-through;
cursor: auto;
}
#entriesTable td:not(.deleted-row):not(:nth-child(-n+2)):not(.cellEditionMode):hover {
.entryCellHighlighter td:not(.deleted-row):not(:nth-child(-n+2)):not(.cellEditionMode):hover {
background-color: #ffffcc;
cursor: pointer;
}
......
......@@ -42,23 +42,18 @@
<table class="table table-striped table-condensed">
<tr>
<td>{%trans%}Author{%endtrans%}</td>
{% if g.isAdmin %}
<td><a href="/admin/users/{{ form.user._id }}">{{ form.user.username }}</a></td>
{% else %}
<td>{{ form.user.username }}</td>
{% endif %}
</tr>
<tr>
<td>{%trans%}Created{%endtrans%}</td>
<td>{{ form.created }}</td>
<td>{%trans%}Entries{%endtrans%}</td>
<td>
{% if form.editors[g.current_user._id|string] is defined %}
<input class="btn-primary btn btn-xs" type="button" value="{%trans%}View{%endtrans%} {{form.totalEntries}} {%trans%}entries{%endtrans%}" onClick="location.href='/forms/entries/{{form._id}}'" >
{% else %}
{{form.totalEntries}}
{% endif %}
{% if form.totalEntries %}
{%trans%}Last{%endtrans%}: {{ form.lastEntryDate }}
{% endif %}
</td>
</tr>
{% if g.isRootUser %}
<tr>
<td>{%trans%}Hostname{%endtrans%}</td>
<td>{{ form.hostname }}</td>
</tr>
{% endif %}
<tr>
<td>{%trans%}Published{%endtrans%}</td>
<td>
......@@ -109,19 +104,6 @@
{% endif %}
</td>
</tr>
<tr>
<td>{%trans%}Entries{%endtrans%}</td>
<td>
{% if form.editors[g.current_user._id|string] is defined %}
<input class="btn-primary btn btn-xs" type="button" value="{%trans%}View{%endtrans%} {{form.totalEntries}} {%trans%}entries{%endtrans%}" onClick="location.href='/forms/entries/{{form._id}}'" >
{% else %}
{{form.totalEntries}}
{% endif %}
{% if form.totalEntries %}
{%trans%}Last{%endtrans%}: {{ form.lastEntryDate }}
{% endif %}
</td>
</tr>
<tr>
<td>{%trans%}Shared{%endtrans%}</td>
<td>
......@@ -165,6 +147,24 @@
</td>
</tr>
{% endif %}
<tr>
<td>{%trans%}Author{%endtrans%}</td>
{% if g.isAdmin %}
<td><a href="/admin/users/{{ form.user._id }}">{{ form.user.username }}</a></td>
{% else %}
<td>{{ form.user.username }}</td>
{% endif %}
</tr>
<tr>
<td>{%trans%}Created{%endtrans%}</td>
<td>{{ form.created }}</td>
</tr>
{% if g.isRootUser %}
<tr>
<td>{%trans%}Hostname{%endtrans%}</td>
<td>{{ form.hostname }}</td>
</tr>
{% endif %}
</table>
{% if form.editors[g.current_user._id|string] is defined %}
......
......@@ -13,14 +13,15 @@
</style>
<div class="container">
<div class="row col-md-9" style="font-size:1.5em">
<div class="row col-md-8" style="font-size:1.5em">
<input class="btn-primary btn btn-sm" type="button" value="{%trans%}Form details{%endtrans%}" onClick="location.href='/forms/view/{{ form._id }}'">
{{ form.slug }}
</div>
<div class="row col-md-3" style="text-align:right">
<div class="row col-md-4" style="text-align:right">
<input id="editModeButton" class="btn-primary btn btn-sm" type="button" value="{%trans%}Enable edition{%endtrans%}" onClick="js:setEditMode();">
<input class="btn-primary btn btn-sm" type="button" value="{%trans%}Download CSV{%endtrans%}" onClick="location.href='/forms/csv/{{ form._id }}'">
<input class="btn-danger btn btn-sm" type="button" value="{%trans%}Delete all entries{%endtrans%}" onClick="location.href='/forms/delete-entries/{{ form._id }}'" {% if not form.totalEntries %}disabled{%endif%} >
<input class="btn-danger btn btn-sm" type="button" value="{%trans%}Delete all{%endtrans%}" onClick="location.href='/forms/delete-entries/{{ form._id }}'" {% if not form.totalEntries %}disabled{%endif%} >
</div>
</div>
......@@ -51,7 +52,7 @@
{% for entry in form.entries %}
<tr>
<td style="border-right: 1px solid #ccc; border-left: 1px solid #ccc;">
<i class="fa fa-minus-circle delete-row" aria-hidden="true"></i>
<i class="fa fa-minus-circle delete-row-icon" aria-hidden="true"></i>
</td>
{% for field in fieldIndex %}
<td style="border-right: 1px solid #ccc;">{{ entry[field['name']] }}</td>
......@@ -65,7 +66,16 @@
<script>
var csrftoken = "{{ csrf_token() }}";
var fieldIndex={{fieldIndex|tojson}};
var editMode = false;
function setEditMode(){
editMode = true;
$('#editModeButton').removeClass('btn-primary');
$('#editModeButton').addClass('btn-success');
$('#editModeButton').val('{%trans%}Edition enabled{%endtrans%}');
$('.delete-row-icon').addClass('enabled');
$('#entriesTable tbody').addClass('entryCellHighlighter');
}
function getFieldValueInRow(fieldName, $row){
var arrayLength = fieldIndex.length;
for (var loop = 0; loop < arrayLength; loop++) {
......@@ -96,16 +106,19 @@ $(document).ready(function() {
{ "orderable": false, "targets": 0 }
]
});
$('.delete-row').attr('title', "{%trans%}Delete entry{%endtrans%}");
$('.delete-row-icon').attr('title', "{%trans%}Delete entry{%endtrans%}");
});
// Edit cell
$('#entriesTable tbody').on('click', "td:not(.deleted-row):not(:nth-child(1)):not(:nth-child(2)):not(.cellEditionMode)", function () {
$('#entriesTable tbody').on('click', "td:not(.deleted-row):not(:nth-child(-n+2)):not(.cellEditionMode)", function () {
if(editMode == false){
return;
}
$(this).addClass('cellEditionMode');
var cellValue = $(this).html();
var $editor = $("<div style='white-space:nowrap;' initial_value=\""+ cellValue +"\"></div>");
$editor.append("<input style='width:70%' type='text' value=\""+ cellValue +"\" />");
$editor.append('<i class="fa fa-check-circle saveCellEdition" aria-hidden="true"></i>');
$editor.append('<i class="fa fa-times-circle cancelCellEdition" aria-hidden="true"></i>');
$editor.append('<i class="fa fa-check-circle saveCellEdition" aria-hidden="true" title="{%trans%}Save{%endtrans%}"></i>');
$editor.append('<i class="fa fa-times-circle cancelCellEdition" aria-hidden="true" title="{%trans%}Cancel{%endtrans%}"></i>');
$(this).html($editor);
});
// Cancel edition
......@@ -141,7 +154,11 @@ $('#entriesTable tbody').on('click', '.saveCellEdition', function () {
}
});
});
$('#entriesTable tbody').on('click', '.delete-row', function () {
$('#entriesTable tbody').on('click', '.delete-row-icon', function () {
if(editMode == false){
console.log(editMode)
return;
}
var $row=$(this).parents('tr');
if ($row.find(".cellEditionMode").length == 1){
return
......@@ -183,7 +200,7 @@ $('#entriesTable tbody').on('click', '.undo-delete-row', function () {
{
if (data.undone == true) {
$row.children(':not(:first-child)').removeClass('deleted-row');
$row.children('td').eq(0).html('<i class="fa fa-minus-circle delete-row" aria-hidden="true"></i>');
$row.children('td').eq(0).html('<i class="fa fa-minus-circle delete-row-icon enabled" aria-hidden="true"></i>');
}
}
});
......
......@@ -18,23 +18,18 @@
<div class="container">
<hr />
<table id="formEntries" class="table table-striped table-condensed">
<table id="formEntries" style="display:none" class="table table-striped table-condensed">
<thead>
<tr>
<th>#</th>
{% for field in fieldIndex %}
<th>{{ field['label'] }}</th>
{% endfor %}
</tr>
</thead>
{% for entry in form.entries %}
<tr>
<td style="border-right: 1px solid #ccc;">{{ loop.index }}</td>
{% for field in fieldIndex %}
<td class="{{ fieldName }}" style="border-right: 1px solid #ccc;">{{ entry[field['name']] }}</td>
{% endfor %}
</tr>
{% endfor %}
......@@ -46,7 +41,11 @@ $(document).ready(function() {
$('#formEntries').DataTable({
"language": {
"url": "/static/dataTables-languages/{{language}}.js"
}
},
"initComplete": function(settings, json) {
$("#formEntries").show();
},
"order": [[0, 'desc']],
});
});
</script>
......
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