Skip to content

Commit 6c195d0

Browse files
committed
[enh] ES: allow to search in private messages - fix #647
1 parent 71fbd20 commit 6c195d0

File tree

11 files changed

+305
-60
lines changed

11 files changed

+305
-60
lines changed

www/plugins/es/i18n/locale-en-GB.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@
134134
"LIST": {
135135
"INBOX": "Inbox",
136136
"OUTBOX": "Outbox",
137+
"LAST_INBOX": "New messages",
138+
"LAST_OUTBOX": "Sent messages",
139+
"BTN_LAST_MESSAGES": "Recent messages",
137140
"TITLE": "Private messages",
141+
"SEARCH_HELP": "Search in messages",
138142
"POPOVER_ACTIONS": {
139143
"TITLE": "Options",
140144
"DELETE_ALL": "Delete all messages"

www/plugins/es/i18n/locale-en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@
134134
"LIST": {
135135
"INBOX": "Inbox",
136136
"OUTBOX": "Outbox",
137+
"LAST_INBOX": "New messages",
138+
"LAST_OUTBOX": "Sent messages",
139+
"BTN_LAST_MESSAGES": "Recent messages",
137140
"TITLE": "Private messages",
141+
"SEARCH_HELP": "Search in messages",
138142
"POPOVER_ACTIONS": {
139143
"TITLE": "Options",
140144
"DELETE_ALL": "Delete all messages"

www/plugins/es/i18n/locale-es-ES.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@
134134
"LIST": {
135135
"INBOX": "Bandeja de entrada",
136136
"OUTBOX": "Mensajes mandados",
137+
"LAST_INBOX": "Nuevos mensajes",
138+
"LAST_OUTBOX": "Mensajes enviados",
139+
"BTN_LAST_MESSAGES": "Mensajes recientes",
137140
"TITLE": "Mensajes",
141+
"SEARCH_HELP": "Buscar en mensajes",
138142
"POPOVER_ACTIONS": {
139143
"TITLE": "Opciónes",
140144
"DELETE_ALL": "Suprimir todos los mensajes"
@@ -156,7 +160,8 @@
156160
"TITLE": "Mensaje",
157161
"SENDER": "Mandado por",
158162
"RECIPIENT": "Mandado a",
159-
"NO_CONTENT": "Mensaje vacío"
163+
"NO_CONTENT": "Mensaje vacío",
164+
"DELETE": "Eliminar el mensaje"
160165
},
161166
"CONFIRM": {
162167
"REMOVE": "Está usted segura/o querer <b>suprimir este mensaje</b> ?<br/><br/>Esta operación es ireversible.",
@@ -279,14 +284,16 @@
279284
"BTN_ADVANCED_SEARCH": "búsqueda avanzada",
280285
"BTN_OPTIONS": "Búsqueda avanzada",
281286
"TYPE": "Tipo de página",
282-
"LOCATION": "Localización",
283287
"LOCATION_HELP": "Ciudad",
284288
"RESULTS": "Resultados",
285289
"RESULT_COUNT_LOCATION": "{{count}} Resultado{{count>0?'s':''}}, cerca de {{location}}",
286290
"RESULT_COUNT": "{{count}} resultado{{count>0?'s':''}}",
287291
"LAST_RECORDS": "Páginas recientes",
288292
"LAST_RECORD_COUNT_LOCATION": "{{count}} página{{count>0?'s':''}} reciente{{count>0?'s':''}}, cerca de {{location}}",
289-
"LAST_RECORD_COUNT": "{{count}} página{{count>0?'s':''}} reciente{{count>0?'s':''}}"
293+
"LAST_RECORD_COUNT": "{{count}} página{{count>0?'s':''}} reciente{{count>0?'s':''}}",
294+
"POPOVER_FILTERS": {
295+
"BTN_ADVANCED_SEARCH": "Opciones avanzadas?"
296+
}
290297
},
291298
"VIEW": {
292299
"TITLE": "Anuario",
@@ -346,6 +353,8 @@
346353
"NO_PROFILE_DEFINED": "Ningún perfil Cesium+",
347354
"BTN_ADD": "Ingresar mi perfil",
348355
"BTN_EDIT": "Editar mi perfil",
356+
"BTN_DELETE": "Eliminar mi perfil",
357+
"BTN_REORDER": "Reordenar",
349358
"UID": "Seudónimo",
350359
"TITLE": "Nombre, Apellido",
351360
"TITLE_HELP": "Nombre, Apellido",
@@ -362,13 +371,18 @@
362371
"RESIZE_HELP": "<b>Encuadra la imagen</b>, si es necesario. Un clic mantenido sobre la imagen permite desplazarla. Hace un clic sobre la zona abajo a la izquierda para hacer zoom.",
363372
"RESULT_HELP": "<b>Aquí está el resultado</b> tal como está visible sobre su perfil :"
364373
},
374+
"CONFIRM": {
375+
"DELETE": "¿Estás seguro de que quieres <b>eliminar tu perfil Cesium+?</b><br/><br/>Esta operación es irreversible."
376+
},
365377
"ERROR": {
378+
"REMOVE_PROFILE_FAILED": "Error de eliminación de perfil",
366379
"LOAD_PROFILE_FAILED": "Fracaso en la carga del perfil usuario.",
367380
"SAVE_PROFILE_FAILED": "Fracaso durante el respaldo",
368381
"INVALID_SOCIAL_NETWORK_FORMAT": "Formato no tomado en cuenta : por favor, indica una dirección válida.<br/><br/>Ejemplos :<ul><li>- Una página Facebook (https://www.facebook.com/user)</li><li>- Una página web (http://www.misitio.es)</li><li>- Una dirección email ([email protected])</li></ul>",
369382
"IMAGE_RESIZE_FAILED": "Fracaso durante el redimensionamiento de la imagen"
370383
},
371384
"INFO": {
385+
"PROFILE_REMOVED": "Perfil eliminado",
372386
"PROFILE_SAVED": "Perfil respaldado"
373387
},
374388
"HELP": {
@@ -490,6 +504,9 @@
490504
"UPDATE_REPLY_COMMENT": "<span ng-class=\"{'gray': !notification.uid, 'positive':notification.uid }\"><i class=\"icon\" ng-class=\"{'ion-person': notification.uid, 'ion-key': !notification.uid}\"></i>&thinsp;{{name||uid||params[1]}}</span> ha modificado la repuesta a su comentario sobre el referencia : <b>{{params[2]}}</b>"
491505
}
492506
},
507+
"CONFIRM": {
508+
"ES_USE_FALLBACK_NODE": "Nodo de datos <b> {{old}} </ b> dirección inalcanzable o no válida.<br/><br/>¿Desea utilizar temporalmente el nodo de datos <b>{{new}}</b>?"
509+
},
493510
"ERROR": {
494511
"ES_CONNECTION_ERROR": "Nodo de datos <b>{{server}}</b> dirección inalcanzable o no válida.<br/><br/>Cesium continuará funcionando, <b>sin la extensión Cesium+</b> (perfiles de usuario, mensajes privados), mapas y gráficos).<br/><br/>Verifique su conexión a Internet, o cambie el nodo de datos en <a class=\"positive\" ng-click=\"doQuickFix('settings')\"> configuración de extensión </a>.",
495512
"ES_MAX_UPLOAD_BODY_SIZE": "El volumen de datos a enviar excede el límite establecido por el servidor.<br/><br/>Por favor, inténtelo de nuevo después, por ejemplo, borrando fotos."

www/plugins/es/i18n/locale-fr-FR.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@
134134
"LIST": {
135135
"INBOX": "Boite de réception",
136136
"OUTBOX": "Messages envoyés",
137+
"LAST_INBOX": "Nouveaux messages",
138+
"LAST_OUTBOX": "Messages envoyés",
139+
"BTN_LAST_MESSAGES": "Messages récents",
137140
"TITLE": "Messages",
141+
"SEARCH_HELP": "Recherche dans les messages",
138142
"POPOVER_ACTIONS": {
139143
"TITLE": "Options",
140144
"DELETE_ALL": "Supprimer tous les messages"

www/plugins/es/js/controllers/message-controllers.js

Lines changed: 97 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,23 @@ angular.module('cesium.es.message.controllers', ['cesium.es.services'])
117117

118118
;
119119

120-
function ESMessageAbstractListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout,
120+
function ESMessageAbstractListController($scope, $state, $translate, $ionicHistory, $ionicPopover, $timeout, $filter,
121121
csWallet, esModals, UIUtils, esMessage) {
122122
'ngInject';
123123

124-
$scope.loading = true;
125-
$scope.messages = [];
124+
var defaultSearchLimit = 40;
125+
126+
$scope.search = {
127+
loading: true,
128+
results: [],
129+
hasMore : false,
130+
loadingMore : false,
131+
limit: defaultSearchLimit,
132+
type: 'last',
133+
text: null,
134+
options: {
135+
}
136+
};
126137

127138
$scope.fabButtonNewMessageId = undefined;
128139

@@ -154,28 +165,39 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
154165
return $scope.load(undefined, undefined, silent);
155166
};
156167

157-
$scope.load = function(size, offset, silent) {
158-
var options = {};
159-
options.from = offset || 0;
160-
options.size = size || 20;
168+
$scope.load = function(from, size, silent) {
169+
170+
var options = angular.copy($scope.search.options);
171+
options.from = options.from || from || 0;
172+
options.size = options.size || size || defaultSearchLimit;
161173
options.type = $scope.type;
174+
options.summary = false;
175+
options.filter = ($scope.search.type == 'text' && $scope.search.text && $scope.search.text.trim().length > 0) ?
176+
$scope.search.text : undefined;
162177

163-
$scope.loading = !silent;
178+
$scope.search.loading = !silent;
164179
return esMessage.load(options)
165-
.then(function(messages) {
166-
$scope.messages = messages;
180+
.then(function(res) {
167181

168-
UIUtils.loading.hide();
169-
$scope.loading = false;
170-
171-
if (messages.length > 0) {
172-
$scope.motion.show({selector: '.view-messages .list .item'});
182+
if (!options.from) {
183+
$scope.search.results = res || [];
184+
}
185+
else if (res){
186+
$scope.search.results = $scope.search.results.concat(res);
173187
}
188+
189+
UIUtils.loading.hide();
190+
$scope.search.loading = false;
191+
$scope.search.hasMore = ($scope.search.results && $scope.search.results.length >= $scope.search.limit);
192+
$scope.updateView();
174193
})
175194
.catch(function(err) {
195+
$scope.search.loading = false;
196+
if (!options.from) {
197+
$scope.search.results = [];
198+
}
199+
$scope.search.hasMore = false;
176200
UIUtils.onError('MESSAGE.ERROR.LOAD_MESSAGES_FAILED')(err);
177-
$scope.messages = [];
178-
$scope.loading = false;
179201
});
180202
};
181203

@@ -184,16 +206,39 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
184206
$scope.load();
185207
};
186208

209+
$scope.updateView = function() {
210+
if ($scope.motion && $scope.motion.ionListClass && $scope.search.results.length) {
211+
$scope.motion.show({selector: '.view-messages .list .item'});
212+
}
213+
};
214+
215+
$scope.showMore = function() {
216+
$scope.search.limit = $scope.search.limit || defaultSearchLimit;
217+
$scope.search.limit += defaultSearchLimit;
218+
if ($scope.search.limit < defaultSearchLimit) {
219+
$scope.search.limit = defaultSearchLimit;
220+
}
221+
$scope.search.loadingMore = true;
222+
$scope.load(
223+
$scope.search.results.length, // from
224+
$scope.search.limit,
225+
true /*silent*/)
226+
.then(function() {
227+
$scope.search.loadingMore = false;
228+
$scope.$broadcast('scroll.infiniteScrollComplete');
229+
});
230+
};
231+
187232
$scope.markAllAsRead = function() {
188233
$scope.hideActionsPopover();
189-
if (!$scope.messages || !$scope.messages.length) return;
234+
if (!$scope.search.results || !$scope.search.results.length) return;
190235

191236
UIUtils.alert.confirm('MESSAGE.CONFIRM.MARK_ALL_AS_READ')
192237
.then(function(confirm) {
193238
if (confirm) {
194239
esMessage.markAllAsRead()
195240
.then(function () {
196-
_.forEach($scope.messages, function(msg){
241+
_.forEach($scope.search.results, function(msg){
197242
msg.read = true;
198243
});
199244
})
@@ -203,15 +248,15 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
203248
};
204249

205250
$scope.delete = function(index) {
206-
var message = $scope.messages[index];
251+
var message = $scope.search.results[index];
207252
if (!message) return;
208253

209254
UIUtils.alert.confirm('MESSAGE.CONFIRM.REMOVE')
210255
.then(function(confirm) {
211256
if (confirm) {
212257
esMessage.remove(message.id, $scope.type)
213258
.then(function () {
214-
$scope.messages.splice(index,1); // remove from messages array
259+
$scope.search.results.splice(index,1); // remove from messages array
215260
UIUtils.toast.show('MESSAGE.INFO.MESSAGE_REMOVED');
216261
})
217262
.catch(UIUtils.onError('MESSAGE.ERROR.REMOVE_MESSAGE_FAILED'));
@@ -221,21 +266,41 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
221266

222267
$scope.deleteAll = function() {
223268
$scope.hideActionsPopover();
224-
if (!$scope.messages || !$scope.messages.length) return;
269+
if (!$scope.search.results || !$scope.search.results.length) return;
225270

226271
UIUtils.alert.confirm('MESSAGE.CONFIRM.REMOVE_ALL')
227272
.then(function(confirm) {
228273
if (confirm) {
229274
esMessage.removeAll($scope.type)
230275
.then(function () {
231-
$scope.messages.splice(0,$scope.messages.length); // reset array
276+
$scope.search.results.splice(0,$scope.search.results.length); // reset array
232277
UIUtils.toast.show('MESSAGE.INFO.All_MESSAGE_REMOVED');
233278
})
234279
.catch(UIUtils.onError('MESSAGE.ERROR.REMOVE_All_MESSAGES_FAILED'));
235280
}
236281
});
237282
};
238283

284+
$scope.doSearchLast = function() {
285+
$scope.search.type='last';
286+
$scope.search.loadingMore=false;
287+
$scope.search.limit = defaultSearchLimit;
288+
return $scope.load();
289+
};
290+
291+
$scope.doSearch = function() {
292+
if (!$scope.search.text || $scope.search.text.length < 3) {
293+
return;
294+
}
295+
$scope.search.type='text';
296+
$scope.search.loadingMore=false;
297+
$scope.search.results = [];
298+
$scope.search.limit = defaultSearchLimit;
299+
300+
console.debug('[message] [{0}] Searching for: {1}'.format($scope.type, $scope.search.text));
301+
return $scope.load();
302+
};
303+
239304
/* -- Modals -- */
240305

241306
$scope.showNewMessageModal = function(parameters) {
@@ -250,7 +315,7 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
250315
};
251316

252317
$scope.showReplyModal = function(index) {
253-
var message = $scope.messages[index];
318+
var message = $scope.search.results[index];
254319
if (!message) return;
255320

256321
$translate('MESSAGE.REPLY_TITLE_PREFIX')
@@ -301,11 +366,11 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
301366

302367
// Message deletion
303368
$scope.onMessageDelete = function(id) {
304-
var index = _.findIndex($scope.messages, function(msg) {
369+
var index = _.findIndex($scope.search.results, function(msg) {
305370
return msg.id == id;
306371
});
307372
if (index) {
308-
$scope.messages.splice(index,1); // remove from messages array
373+
$scope.search.results.splice(index,1); // remove from messages array
309374
}
310375
};
311376
esMessage.api.data.on.delete($scope, $scope.onMessageDelete);
@@ -320,7 +385,7 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
320385
return esMessage.get(id, {type: $scope.type, summary: true});
321386
}, 500 /*waiting ES propagation*/)
322387
.then(function(msg) {
323-
$scope.messages.splice(0,0,msg);
388+
$scope.search.results.splice(0,0,msg);
324389
$scope.loading = false;
325390
$scope.motion.show({selector: '.view-messages .list .item'});
326391
})
@@ -338,21 +403,21 @@ function ESMessageAbstractListController($scope, $state, $translate, $ionicHisto
338403
// Load the the message
339404
return esMessage.get(notification.id, {type: $scope.type, summary: true})
340405
.then(function(msg) {
341-
$scope.messages.splice(0,0,msg);
342-
$scope.loading = false;
406+
$scope.search.results.splice(0,0,msg);
407+
$scope.search.loading = false;
343408
$scope.motion.show({selector: '.view-messages .list .item'});
344409
})
345410
.catch(function() {
346-
$scope.loading = false;
411+
$scope.search.loading = false;
347412
});
348413
};
349414
esMessage.api.data.on.new($scope, $scope.onNewInboxMessage);
350415

351416
// Watch unauth
352417
$scope.onUnauth = function() {
353418
// Reset all data
354-
$scope.messages = undefined;
355-
$scope.loading = false;
419+
$scope.search.results = undefined;
420+
$scope.search.loading = false;
356421
$scope.entered = false;
357422
};
358423
csWallet.api.data.on.unauth($scope, $scope.onUnauth);

www/plugins/es/js/controllers/notification-controllers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function NotificationsController($scope, $rootScope, $ionicPopover, $state, $tim
7777
$scope.search.loading = !silent;
7878
return esNotification.load(csWallet.data.pubkey, options)
7979
.then(function(res) {
80-
if (!from) {
80+
if (!options.from) {
8181
$scope.search.results = res || [];
8282
}
8383
else if (res){
@@ -89,7 +89,7 @@ function NotificationsController($scope, $rootScope, $ionicPopover, $state, $tim
8989
})
9090
.catch(function(err) {
9191
$scope.search.loading = false;
92-
if (!from) {
92+
if (!options.from) {
9393
$scope.search.results = [];
9494
}
9595
$scope.search.hasMore = false;

0 commit comments

Comments
 (0)