|
26 |
* /usr/share/common-licenses/AGPL-3; if not, see |
26 |
* /usr/share/common-licenses/AGPL-3; if not, see |
27 |
* <http://www.gnu.org/licenses/>. |
27 |
* <http://www.gnu.org/licenses/>. |
28 |
*/ |
28 |
*/ |
29 |
/*global define, window*/ |
29 |
/*global define*/ |
30 |
|
30 |
|
31 |
define([ |
31 |
define([ |
32 |
"dojo/_base/declare", |
32 |
"dojo/_base/declare", |
33 |
"dojo/_base/array", |
33 |
"dojo/_base/array", |
34 |
"dojo/_base/lang", |
34 |
"dojo/_base/lang", |
|
|
35 |
"dojo/io-query", |
35 |
"dojo/on", |
36 |
"dojo/on", |
36 |
"put-selector/put", |
37 |
"put-selector/put", |
37 |
], function(declare, array, lang, on, put) { |
38 |
], function(declare, array, lang, ioQuery, on, put) { |
38 |
|
39 |
|
39 |
return declare("umc.module.udm.TileView", [], { |
40 |
return declare("umc.module.udm.TileView", [], { |
40 |
|
41 |
|
|
43 |
necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"], |
44 |
necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"], |
44 |
|
45 |
|
45 |
_queryTimer: null, |
46 |
_queryTimer: null, |
|
|
47 |
moduleFlavor: null, |
46 |
|
48 |
|
47 |
_queryCache: null, |
49 |
_queryCache: null, |
48 |
|
50 |
|
|
50 |
|
52 |
|
51 |
grid: null, |
53 |
grid: null, |
52 |
|
54 |
|
53 |
setPicture: function(item) { |
|
|
54 |
if (this._queryTimer) { |
55 |
this.grid.moduleStore.get(item.$dn$); |
56 |
} else { |
57 |
this._queryCache = this.grid.moduleStore.transaction(); |
58 |
this._queryTimer = window.setTimeout(lang.hitch(this, "_setPictures"), 100); |
59 |
this.grid.moduleStore.get(item.$dn$); |
60 |
} |
61 |
}, |
62 |
|
63 |
_setPictures: function() { |
64 |
this._queryTimer = null; |
65 |
this._queryCache.commit().then(lang.hitch(this, function(data) { |
66 |
array.forEach(data, function(item){ |
67 |
if (item.jpegPhoto) { |
68 |
//put(this._userImageNodes[item.$dn$], "+img.umcGridTileIcon[src=data:image/jpeg;base64," + item.jpegPhoto + "]"); |
69 |
put(this._userImageNodes[item.$dn$], "+div.umcGridTileIcon[style=background-image: url(data:image/jpeg;base64," + item.jpegPhoto + ")]"); |
70 |
} |
71 |
}, this); |
72 |
})); |
73 |
}, |
74 |
|
75 |
_getInitials: function(item) { |
55 |
_getInitials: function(item) { |
76 |
var initials = ""; |
56 |
var initials = ""; |
77 |
// FIXME: item.firstname[0] is not unicode save! |
57 |
// FIXME: item.firstname[0] is not unicode save! |
|
115 |
} |
95 |
} |
116 |
this._userImageNodes[item.$dn$] = put(div, "div.umcGridTileIcon", this._getInitials(item)); |
96 |
this._userImageNodes[item.$dn$] = put(div, "div.umcGridTileIcon", this._getInitials(item)); |
117 |
var nameNode = put(div, 'div.umcGridTileName', item.name); |
97 |
var nameNode = put(div, 'div.umcGridTileName', item.name); |
118 |
this.setPicture(item); |
98 |
var idProperty = this.grid.moduleStore.idProperty; |
|
|
99 |
put(put(div, '+div.umcGridTileIcon'), 'img[src=/univention/management/command/udm/' + encodeURIComponent(this.moduleFlavor) + '/' + encodeURIComponent(idProperty) + '/image'); |
119 |
put(div, this._getDescription(item)); |
100 |
put(div, this._getDescription(item)); |
120 |
var defaultAction = this.grid._getDefaultActionForItem(item); |
101 |
var defaultAction = this.grid._getDefaultActionForItem(item); |
121 |
var idProperty = this.grid.moduleStore.idProperty; |
|
|
122 |
on(nameNode, 'click', lang.hitch(this, function() { |
102 |
on(nameNode, 'click', lang.hitch(this, function() { |
123 |
defaultAction.callback([item[idProperty]], [item]); |
103 |
defaultAction.callback([item[idProperty]], [item]); |
124 |
})); |
104 |
})); |