Explorar o código

UserMsgs - reply test - added ajax fetch user options

Piotr Labudda %!s(int64=10) %!d(string=hai) anos
pai
achega
430cdfc3c8
Modificáronse 2 ficheiros con 27 adicións e 12 borrados
  1. 27 12
      SE/se-lib/Route/UserMsgs.php
  2. 0 0
      SE/stuff/bundle.se_route_user_msgs.js

+ 27 - 12
SE/se-lib/Route/UserMsgs.php

@@ -752,18 +752,33 @@ function frmTestSubmit(frm) {
 				//complete: true
 				//complete: true
 			});
 			});
 		},
 		},
-		fetchOptionsForUser: function(input, callback) {
-			var options = [];
-			for (var i = 1; i <= 100; i++) {
-				options.push({value: 'user' + i, label: 'User [' + i + ']'});
-			}
-			callback(null, {
-				options: options,
-				// CAREFUL! Only set this to true when there are no more options,
-				// or more specific queries will not be sent to the server.
-				//complete: true
-			});
-		}
+		fetchOptionsForUser: (function() {
+			var _userXhr = null;
+			return function(input, callback) {
+				if (_userXhr && _userXhr.state() === 'pending') {
+					_userXhr.abort();
+					_userXhr = null;
+				}
+				_userXhr = $.ajax({
+					url: 'index.php?_route=UserMsgs&_task=typeSpecialUserLogin&q=' + input,
+					dataType: 'json'
+				});
+				_userXhr.done(function(data, textStatus, jqXHR) {
+					if (data && data.length > 0) {
+						var options = [];
+						data.forEach(function(item) {
+							options.push({value: item.id, label: item.name});
+						});
+						callback(null, {options: options});
+					} else {
+						callback("Error no data!");
+					}
+				});
+				_userXhr.always(function() {
+					_userXhr = null;
+				});
+			};
+		})()
 	});
 	});
 //	jQuery("#widget-msg-tree").on('change', function(e, data) {
 //	jQuery("#widget-msg-tree").on('change', function(e, data) {
 //		console.log('#widget-msg-tree/MsgTree::onChange: data:', data);
 //		console.log('#widget-msg-tree/MsgTree::onChange: data:', data);

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
SE/stuff/bundle.se_route_user_msgs.js


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio