Unverified Commit fb640e7b authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : rework total display on main view

parent ad566a71
Pipeline #8843 failed with stage
......@@ -284,7 +284,7 @@
datas: archives,
total: totalResult,
rowMerge: ArchiveFolderList.mergeRow,
rowMaxNumber: 10,
rowMaxNumber: ($('#fullTextSearchForm').find('[name=maxResults]').val() != 'undefined' ? parseInt($('#fullTextSearchForm').find('[name=maxResults]').val(), 10) : 10),
rowTranslation: $('#rows_text').text(),
emptyMessage: '<i class="text-muted"><br\/><span class="fa fa-times">&nbsp;<\/span>' + $('#emptyFolder_text').html() + '<\/i>',
itemsName: [$('#archive_text').text(), $('#archives_text').text()],
......
/* OPTIONS
datas -> json datas to merge,
total -> nombre de résultat total,
rowMerge -> datas merging function,
rowMaxNumber -> default rowNumber,
rowTranslation -> translation for "row"
......@@ -49,17 +48,17 @@ var DataList = {
'<option value="20">20</option>'+
'<option value="30">30</option>'+
'<option value="40">40</option>'+
'</select>'+
'</select>'+
'</div>',
sortingBtn :'<div class="btn-group">'+
'<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'+
'<i class="fa fa-sort-amount-asc"\/>'+
'<\/button>'+
'<\/div>',
'<\/div>',
selectAllHTML :'<h4 class="pull-left" style="width:15px"><i class="selectAll multipleSelection fa fa-square-o" style="cursor:pointer"\/><\/h4>',
selectorHTML :'<h4 class="pull-left" style="width:15px"><i class="multipleSelection fa fa-square-o" style="cursor:pointer"\/><\/h4>',
resultNumberHTML:'<h2 class="itemNumber" style="margin:0px 0px 0px 40px"><small><span class="resultNumber"\/><span class="itemsName"\/><\/small><\/h2>',
totalNumberHTML :'<h2 class="itemNumber" style="margin:-40px 0px 0px 160px"><small>/&nbsp(<span class="totalNumber"\/><span/>&nbsptotal)<\/small><\/h2>',
resultNumberHTMLWithTotal:'<h2 class="itemNumber" style="margin:0px 0px 0px 40px"><small><span class="resultNumber"\/><span class="itemsName"\/>&nbsp;/&nbsp;<span class="total"\/>&nbsp;total<\/small><\/h2>',
init: function(options, element) {
var id = Math.round(new Date().getTime() + (Math.random() * 100));
......@@ -82,7 +81,7 @@ var DataList = {
toolbar : header,
footer : footer
};
// Build header row
header.prepend(this.selectAllHTML)
.prepend(this.filterList);
......@@ -98,30 +97,31 @@ var DataList = {
} else {
footer.append(this.buttonPagination);
}
if(!options.rowTranslation) {
options.rowTranslation = "lines";
}
header.prepend(this.initRowNumberSelect(options.rowTranslation, options.rowMaxNumber))
.removeClass('hide')
.find('.selectAll').on('click', DataList.bind_selectAll).on('click', DataList.bind_selection);
// Set message for empty list
if (options.emptyMessage) {
this.dataList[id].emptyMessage = $(options.emptyMessage);
list.before(this.dataList[id].emptyMessage.addClass('emptyMessage hide'));
}
this.dataList[id].resultNumber = "<h4><span class='resultNumber'\/><\/h4>";
if(!options.itemsName) {
options.itemsName = ["result", "results"];
}
header.append(this.resultNumberHTML);
this.dataList[id].totalNumber = "<h4><span class='totalNumber'\/><\/h4>";
header.append(this.totalNumberHTML);
if (options.total >= options.rowMaxNumber) {
header.append(this.resultNumberHTMLWithTotal);
} else {
header.append(this.resultNumberHTML);
}
if (options.translation) {
$.each(options.translation, function(key, value) {
......@@ -223,8 +223,6 @@ var DataList = {
} else {
this.buildList(id);
}
console.log("in build, result total =");
console.log(this.dataList[id].total);
},
buildPaginationButtons: function(id, filteredDatas) {
......@@ -312,7 +310,7 @@ var DataList = {
buildList: function(id, range, filteredDatas) {
var totalResult = this.dataList[id].total;
var datas = this.dataList[id].datas;
if(filteredDatas != undefined){
datas = filteredDatas;
} else {
......@@ -363,8 +361,10 @@ var DataList = {
// Set the search result displayed (maxResult in conf)
this.dataList[id].toolbar.find('.itemNumber .resultNumber').html(datas.length);
// Set the total result number
this.dataList[id].toolbar.find('.itemNumber .totalNumber').html(totalResult);
if (totalResult >= datas.length) {
this.dataList[id].toolbar.find('.itemNumber .total').html(totalResult);
}
this.dataList[id].element.find('.selectAll').removeClass('fa-check-square-o').addClass('fa-square-o');
this.dataList[id].element.find('.multipleSelection').not('.selectAll').on('click', DataList.bind_selection);
},
......
Supports Markdown
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