|
1
|
|
|
Ext.namespace('Zarafa.common.ui'); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @class Zarafa.common.ui.ContextMainPanelToolbar |
|
5
|
|
|
* @extends Ext.Toolbar |
|
6
|
|
|
* @xtype zarafa.contextmainpaneltoolbar |
|
7
|
|
|
* |
|
8
|
|
|
* Main toolbar for all the contexts which contains paging toolbar, foldertitle |
|
9
|
|
|
* and some context related menu buttons e.g. copy/move, delete |
|
10
|
|
|
*/ |
|
11
|
|
|
Zarafa.common.ui.ContextMainPanelToolbar = Ext.extend(Ext.Toolbar, { |
|
12
|
|
|
/** |
|
13
|
|
|
* @cfg {Zarafa.core.Context} context The context to which this toolbar belongs |
|
14
|
|
|
*/ |
|
15
|
|
|
context: undefined, |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The {@link Zarafa.core.ContextModel} which is obtained from the {@link #context}. |
|
19
|
|
|
* @property |
|
20
|
|
|
* @type Zarafa.mail.MailContextModel |
|
21
|
|
|
*/ |
|
22
|
|
|
model: undefined, |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @cfg {Array} paging Configuration objects of pagination toolbars which should |
|
26
|
|
|
* be added. This can be used if the default pagination toolbar is not sufficient, |
|
27
|
|
|
* and in some situations should be swapped with a different paging toolbar. |
|
28
|
|
|
*/ |
|
29
|
|
|
paging: undefined, |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @cfg {String} defaultTitle The title for the {@link Ext.Panel} Panel |
|
33
|
|
|
*/ |
|
34
|
|
|
defaultTitle: _('grommunio Web'), |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @constructor |
|
38
|
|
|
* @param {Object} config Configuration object |
|
39
|
|
|
*/ |
|
40
|
|
|
constructor: function(config) |
|
41
|
|
|
{ |
|
42
|
|
|
config = config || {}; |
|
43
|
|
|
|
|
44
|
|
|
if (!Ext.isDefined(config.model) && Ext.isDefined(config.context)) { |
|
45
|
|
|
config.model = config.context.getModel(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
// Built up the items array |
|
49
|
|
|
var items = []; |
|
50
|
|
|
|
|
51
|
|
|
items = items.concat({ |
|
52
|
|
|
xtype: 'zarafa.searchfieldcontainer', |
|
53
|
|
|
boxMinWidth: 100, |
|
54
|
|
|
ref: 'searchFieldContainer', |
|
55
|
|
|
model: config.model |
|
56
|
|
|
}); |
|
57
|
|
|
|
|
58
|
|
|
if (!Ext.isEmpty(config.paging)) { |
|
59
|
|
|
items = items.concat(config.paging); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// We add the default buttons |
|
63
|
|
|
items = items.concat([ |
|
64
|
|
|
'->', |
|
65
|
|
|
container.populateInsertionPoint('context.mainpaneltoolbar.item', config.context), |
|
66
|
|
|
{ |
|
67
|
|
|
xtype: 'zarafa.toolbarbutton', |
|
68
|
|
|
overflowText: _('Copy/Move'), |
|
69
|
|
|
tooltip: _('Copy/Move') + ' (Ctrl + M)', |
|
70
|
|
|
iconCls: 'icon_copy', |
|
71
|
|
|
ref: 'copyButton', |
|
72
|
|
|
nonEmptySelectOnly: true, |
|
73
|
|
|
handler: this.onCopyMove, |
|
74
|
|
|
model: config.model, |
|
75
|
|
|
scope: this |
|
76
|
|
|
},{ |
|
77
|
|
|
xtype: 'zarafa.toolbarbutton', |
|
78
|
|
|
overflowText: _('Delete'), |
|
79
|
|
|
tooltip: _('Delete'), |
|
80
|
|
|
ref: 'deleteButton', |
|
81
|
|
|
iconCls: 'icon_delete', |
|
82
|
|
|
nonEmptySelectOnly: true, |
|
83
|
|
|
handler: this.onDelete, |
|
84
|
|
|
model: config.model, |
|
85
|
|
|
scope: this |
|
86
|
|
|
}]); |
|
87
|
|
|
|
|
88
|
|
|
// Add the extra items |
|
89
|
|
|
if (!Ext.isEmpty(config.items)) { |
|
90
|
|
|
items = items.concat(config.items); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
// Delete config.items as we will override it |
|
94
|
|
|
// during Ext.applyIf. |
|
95
|
|
|
delete config.items; |
|
96
|
|
|
|
|
97
|
|
|
// Update configuration |
|
98
|
|
|
Ext.applyIf(config, { |
|
99
|
|
|
xtype: 'zarafa.contextmainpaneltoolbar', |
|
100
|
|
|
ref: 'contextMainPanelToolbar', |
|
101
|
|
|
items: items, |
|
102
|
|
|
enableOverflow: true |
|
103
|
|
|
}); |
|
104
|
|
|
|
|
105
|
|
|
Zarafa.common.ui.ContextMainPanelToolbar.superclass.constructor.call(this, config); |
|
106
|
|
|
this.initEvent(); |
|
107
|
|
|
}, |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Initialize Events |
|
111
|
|
|
*/ |
|
112
|
|
|
initEvent: function() |
|
113
|
|
|
{ |
|
114
|
|
|
this.on('afterlayout', this.resizeSearchField, this, {delay: 2, single: true}); |
|
115
|
|
|
}, |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Open the {@link Zarafa.common.dialogs.CopyMoveContentPanel CopyMoveContentPanel} for copying |
|
119
|
|
|
* or moving the currently selected folders. |
|
120
|
|
|
* @private |
|
121
|
|
|
*/ |
|
122
|
|
|
onCopyMove: function() |
|
123
|
|
|
{ |
|
124
|
|
|
Zarafa.common.Actions.openCopyMoveContent(this.model.getSelectedRecords()); |
|
125
|
|
|
}, |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Delete the currently selected messages. If any of the records is a recurring item, |
|
129
|
|
|
* then the {@link #Zarafa.common.dialogs.MessageBox.select MessageBox} will be used |
|
130
|
|
|
* to select between the recurring and single appointment. |
|
131
|
|
|
* @private |
|
132
|
|
|
*/ |
|
133
|
|
|
onDelete: function() |
|
134
|
|
|
{ |
|
135
|
|
|
Zarafa.common.Actions.deleteRecords(this.model.getSelectedRecords()); |
|
136
|
|
|
}, |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Open the Print dialog |
|
140
|
|
|
* @private |
|
141
|
|
|
*/ |
|
142
|
|
|
onPrint: function() |
|
143
|
|
|
{ |
|
144
|
|
|
Zarafa.common.Actions.openPrintDialog(this.model.getSelectedRecords()); |
|
145
|
|
|
}, |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Called when the grid is being resized. This will calculate the new width for the internal |
|
149
|
|
|
* {@link #searchTextField}. |
|
150
|
|
|
* @param {Number} adjWidth The box-adjusted width that was set |
|
151
|
|
|
* @param {Number} adjHeight The box-adjusted height that was set |
|
152
|
|
|
* @param {Number} rawWidth The width that was originally specified |
|
153
|
|
|
* @param {Number} rawHeight The height that was originally specified |
|
154
|
|
|
* @private |
|
155
|
|
|
**/ |
|
156
|
|
|
onResize: function(adjWidth, adjHeight, rawWidth, rawHeight) |
|
157
|
|
|
{ |
|
158
|
|
|
Zarafa.common.ui.ContextMainPanelToolbar.superclass.onResize.apply(this, arguments); |
|
159
|
|
|
|
|
160
|
|
|
// Only resize the searchTextField when the width |
|
161
|
|
|
// of this component has been changed. |
|
162
|
|
|
var allowResize = this.searchFieldContainer.rendered && this.copyButton.rendered && this.deleteButton.rendered; |
|
163
|
|
|
if (Ext.isDefined(adjWidth) && allowResize) { |
|
164
|
|
|
this.resizeSearchField(); |
|
165
|
|
|
} |
|
166
|
|
|
}, |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Function is used to resize the {@link #searchTextField}. also it will show the |
|
170
|
|
|
* hidden tool bar items if tool bar container has enough size to show. |
|
171
|
|
|
*/ |
|
172
|
|
|
resizeSearchField: function() |
|
173
|
|
|
{ |
|
174
|
|
|
// Get the width of the container without the padding |
|
175
|
|
|
var containerWidth = this.el.getStyleSize().width; |
|
176
|
|
|
var copyButtonWidth = 0; |
|
177
|
|
|
var deleteButtonWidth = 0; |
|
178
|
|
|
var filterButtonWidth = 0; |
|
179
|
|
|
|
|
180
|
|
|
if(Ext.isDefined(this.filterBtn)) { |
|
181
|
|
|
if(this.filterBtn.xtbHidden) { |
|
182
|
|
|
filterButtonWidth = this.filterBtn.xtbWidth; |
|
183
|
|
|
if (containerWidth > this.searchFieldContainer.getWidth() + filterButtonWidth) { |
|
184
|
|
|
this.layout.unhideItem(this.filterBtn); |
|
185
|
|
|
// Update the selection of filter split button. |
|
186
|
|
|
if (!Ext.isEmpty(this.model)) { |
|
187
|
|
|
if (this.model.getStore().hasFilterApplied) { |
|
188
|
|
|
this.filterBtn.btnEl.addClass('k-selection'); |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
this.doLayout(); |
|
192
|
|
|
} |
|
193
|
|
|
} else { |
|
194
|
|
|
filterButtonWidth = this.filterBtn.getWidth(); |
|
195
|
|
|
} |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/* |
|
199
|
|
|
* Check if copyButton is visible then get width of the same, |
|
200
|
|
|
* but if not then get the xtbWidth of copyButton item. show the |
|
201
|
|
|
* tool bar item if container has enough space available. |
|
202
|
|
|
*/ |
|
203
|
|
|
if(this.copyButton.xtbHidden) { |
|
204
|
|
|
copyButtonWidth = this.copyButton.xtbWidth; |
|
205
|
|
|
if (containerWidth > this.searchFieldContainer.getWidth() + copyButtonWidth) { |
|
206
|
|
|
this.layout.unhideItem(this.copyButton); |
|
207
|
|
|
this.doLayout(); |
|
208
|
|
|
} |
|
209
|
|
|
} else { |
|
210
|
|
|
copyButtonWidth = this.copyButton.getWidth(); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/* |
|
214
|
|
|
* Check if deleteButton is visible then get width of the same, |
|
215
|
|
|
* but if not then get the xtbWidth of deleteButton item. show the |
|
216
|
|
|
* tool bar item if container has enough space available. |
|
217
|
|
|
*/ |
|
218
|
|
|
if(this.deleteButton.xtbHidden) { |
|
219
|
|
|
deleteButtonWidth = this.deleteButton.xtbWidth; |
|
220
|
|
|
if (containerWidth > this.searchFieldContainer.getWidth() + copyButtonWidth + deleteButtonWidth) { |
|
221
|
|
|
this.layout.unhideItem(this.deleteButton); |
|
222
|
|
|
this.doLayout(); |
|
223
|
|
|
} |
|
224
|
|
|
} else { |
|
225
|
|
|
deleteButtonWidth = this.deleteButton.getWidth(); |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
var extraMargin = 0; |
|
229
|
|
|
var adjWidth = containerWidth - copyButtonWidth - deleteButtonWidth - extraMargin - filterButtonWidth; |
|
230
|
|
|
|
|
231
|
|
|
var searchFieldContainer = this.searchFieldContainer; |
|
232
|
|
|
var searchField = searchFieldContainer.searchTextField; |
|
233
|
|
|
var searchFolderCombo = searchFieldContainer.searchFolderCombo; |
|
234
|
|
|
var searchFolderComboWidth = searchFolderCombo?.getWidth(); |
|
235
|
|
|
var searchFolderComboTriggeredWidth = searchFolderCombo.getTriggerWidth(); |
|
236
|
|
|
var searchBtnWidth = searchFieldContainer.searchBtn.getWidth(); |
|
237
|
|
|
|
|
238
|
|
|
searchField.setWidth(adjWidth-(searchFolderComboWidth + searchBtnWidth + searchFolderComboTriggeredWidth)); |
|
239
|
|
|
} |
|
240
|
|
|
}); |
|
241
|
|
|
|
|
242
|
|
|
Ext.reg('zarafa.contextmainpaneltoolbar', Zarafa.common.ui.ContextMainPanelToolbar); |
|
243
|
|
|
|