mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
using filter/sort endpoint parameters
This commit is contained in:
parent
890c97e7cb
commit
8b08505116
4 changed files with 23 additions and 8 deletions
|
@ -61,11 +61,11 @@ Column {
|
||||||
listModelName: actions;
|
listModelName: actions;
|
||||||
listView: scroll;
|
listView: scroll;
|
||||||
searchFilter: filter.toUpperCase().split(/\s+/).filter(identity).join(' ');
|
searchFilter: filter.toUpperCase().split(/\s+/).filter(identity).join(' ');
|
||||||
searchItemTest: function (text, item) {
|
/* FIXME searchItemTest: function (text, item) {
|
||||||
return searchFilter.split().every(function (word) {
|
return searchFilter.split().every(function (word) {
|
||||||
return item.searchText.indexOf(word) >= 0;
|
return item.searchText.indexOf(word) >= 0;
|
||||||
});
|
});
|
||||||
}; //HRS FIXME remove when endpoint works.
|
};*/ //HRS FIXME remove when endpoint works.
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveUrl(url) {
|
function resolveUrl(url) {
|
||||||
|
|
|
@ -50,9 +50,18 @@ Rectangle {
|
||||||
id: connectionsUserModel;
|
id: connectionsUserModel;
|
||||||
http: http;
|
http: http;
|
||||||
endpoint: "/api/v1/users?filter=connections";
|
endpoint: "/api/v1/users?filter=connections";
|
||||||
localSort: true;
|
//FIXME localSort: true;
|
||||||
property var sortColumn: connectionsTable.getColumn(connectionsTable.sortIndicatorColumn);
|
property var sortColumn: connectionsTable.getColumn(connectionsTable.sortIndicatorColumn);
|
||||||
sortProperty: sortColumn ? sortColumn.role : "userName";
|
sortProperty: switch (sortColumn && sortColumn.role) {
|
||||||
|
case 'placeName':
|
||||||
|
'location';
|
||||||
|
break;
|
||||||
|
case 'connection':
|
||||||
|
'is_friend';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
'username';
|
||||||
|
}
|
||||||
sortAscending: connectionsTable.sortIndicatorOrder === Qt.AscendingOrder;
|
sortAscending: connectionsTable.sortIndicatorOrder === Qt.AscendingOrder;
|
||||||
itemsPerPage: 9;
|
itemsPerPage: 9;
|
||||||
listView: connectionsTable;
|
listView: connectionsTable;
|
||||||
|
|
|
@ -404,9 +404,9 @@ Item {
|
||||||
return data.users;
|
return data.users;
|
||||||
};
|
};
|
||||||
searchFilter: filterBar.text;
|
searchFilter: filterBar.text;
|
||||||
searchItemTest: function (text, item) {
|
/* FIXME searchItemTest: function (text, item) {
|
||||||
return item.username.toLowerCase().indexOf(text.toLowerCase()) !== -1;
|
return item.username.toLowerCase().indexOf(text.toLowerCase()) !== -1;
|
||||||
}; //HRS FIXME remove when endpoint works.
|
};*/ //HRS FIXME remove when endpoint works.
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
@ -27,7 +27,7 @@ Item {
|
||||||
property string endpoint;
|
property string endpoint;
|
||||||
property string sortProperty; // Currently only handles sorting on one column, which fits with current needs and tables.
|
property string sortProperty; // Currently only handles sorting on one column, which fits with current needs and tables.
|
||||||
property bool sortAscending;
|
property bool sortAscending;
|
||||||
property string sortKey: !sortProperty ? '' : (sortProperty + "," + (sortAscending ? "asc" : "desc"));
|
property string sortKey: !sortProperty ? '' : (sortProperty + "," + (sortAscending ? "ASC" : "DESC"));
|
||||||
property string searchFilter: "";
|
property string searchFilter: "";
|
||||||
property string tagsFilter;
|
property string tagsFilter;
|
||||||
|
|
||||||
|
@ -144,10 +144,16 @@ Item {
|
||||||
// If it is a path starting with slash, add the metaverseServer domain.
|
// If it is a path starting with slash, add the metaverseServer domain.
|
||||||
var url = /^\//.test(endpoint) ? (Account.metaverseServerURL + endpoint) : endpoint;
|
var url = /^\//.test(endpoint) ? (Account.metaverseServerURL + endpoint) : endpoint;
|
||||||
var parameters = [
|
var parameters = [
|
||||||
// FIXME: handle sort, search, tag parameters
|
// FIXME: handle sort, tag parameters
|
||||||
'per_page=' + itemsPerPage,
|
'per_page=' + itemsPerPage,
|
||||||
'page=' + currentPageToRetrieve
|
'page=' + currentPageToRetrieve
|
||||||
];
|
];
|
||||||
|
if (!searchItemTest && searchFilter) {
|
||||||
|
parameters.splice(parameters.length, 0, 'search=' + searchFilter);
|
||||||
|
}
|
||||||
|
if (!localSort && sortKey) {
|
||||||
|
parameters.splice(parameters.length, 0, 'sort=' + sortKey);
|
||||||
|
}
|
||||||
var parametersSeparator = /\?/.test(url) ? '&' : '?';
|
var parametersSeparator = /\?/.test(url) ? '&' : '?';
|
||||||
url = url + parametersSeparator + parameters.join('&');
|
url = url + parametersSeparator + parameters.join('&');
|
||||||
console.debug('getPage', listModelName, currentPageToRetrieve);
|
console.debug('getPage', listModelName, currentPageToRetrieve);
|
||||||
|
|
Loading…
Reference in a new issue