Commit b3dbb2dd authored by Bas Lijnse's avatar Bas Lijnse

Replaced user data handler by service

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1111 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 590278de
Ext.ns("itasks.tui"); Ext.ns("itasks.tui");
itasks.tui.UsernameReader = new Ext.data.JsonReader();
itasks.tui.UsernameReader.readRecords = function(o) {
var UsernameRecord = Ext.data.Record.create(["username"]);
var usernames = [];
for(var i = 0, len = o.users.length; i < len; i++) {
usernames[usernames.length] = new UsernameRecord({username: o.users[i]});
}
return {success: true, records: usernames, totalRecords: usernames.length};
}
itasks.tui.UsernameControl = Ext.extend(Ext.form.ComboBox,{ itasks.tui.UsernameControl = Ext.extend(Ext.form.ComboBox,{
store: new Ext.data.JsonStore({ store: {
url: "/dummy", url: "/services/json/users/names",
root: "users", reader: itasks.tui.UsernameReader
totalProperty: "total", },
fields: ["user"] valueField: "username",
}), displayField: "username",
valueField: "user", tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{username:htmlEncode}</div></tpl>'),
displayField: "user",
tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{user:htmlEncode}</div></tpl>'),
triggerAction: "all", triggerAction: "all",
listeners: { listeners: {
"beforequery": function(e) { "beforequery": function(e) {
e.combo.store.proxy.conn.url = itasks.config.serverUrl + "/data/users";
e.combo.store.baseParams["_session"] = itasks.app.session; e.combo.store.baseParams["_session"] = itasks.app.session;
delete e.combo.lastQuery; delete e.combo.lastQuery;
} }
}, },
initComponent: function() { initComponent: function() {
if(this.staticDisplay){ if(this.staticDisplay){
this.autoCreate = {tag: 'span', html: this.value}; this.autoCreate = {tag: "span", html: this.value};
} }
this.msgTarget = 'side'; this.msgTarget = "side";
this.hideLabel = this.fieldLabel == null; this.hideLabel = this.fieldLabel == null;
this.fieldLabel = itasks.util.fieldLabel(this.optional,this.fieldLabel); this.fieldLabel = itasks.util.fieldLabel(this.optional,this.fieldLabel);
......
...@@ -20,6 +20,13 @@ userService url html path req tst ...@@ -20,6 +20,13 @@ userService url html path req tst
# items = [details \\ RegisteredUser details <- users] # items = [details \\ RegisteredUser details <- users]
# json = JSONObject [("success",JSONBool True),("users",toJSON items)] # json = JSONObject [("success",JSONBool True),("users",toJSON items)]
= (serviceResponse html "users" url params json, tst) = (serviceResponse html "users" url params json, tst)
//List usernames
["names"]
| isJust mbSessionErr
= (serviceResponse html "users names" url params (jsonSessionErr mbSessionErr), tst)
# (users,tst) = getUsers tst
# json = JSONObject [("success",JSONBool True),("users",toJSON [toString u \\ u <- users])]
= (serviceResponse html "users names" url params json, tst)
//Show user details //Show user details
[userId] [userId]
| isJust mbSessionErr | isJust mbSessionErr
......
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