Newer
Older
* @author www.pcsg.de (Henning Leutz)
*/
'qui/QUI',
'qui/controls/desktop/Panel',
'qui/controls/buttons/Select',
'qui/controls/buttons/Button',
'qui/controls/buttons/Seperator',
'controls/grid/Grid',
'Locale',
'Projects',
], function(QUI, QUIPanel, QUISelect, QUIButton, QUISeperator, QUIConfirm, Grid, QUILocale, Projects, Ajax)
return new Class({
Extends : QUIPanel,
},
initialize : function(options)
{
this.parent( options );
this.$Grid = false;
this.$ProjectSelect = false;
this.$ProjectLangs = false;
onCreate : this.$onCreate,
onResize : this.$onResize
var self = this,
project = this.$ProjectSelect.getValue(),
lang = this.$ProjectLangs.getValue();
this.getBricksFromProject( project, lang, function(result)
/**
* Refresh the buttons status
*/
refreshButtons : function()
{
var selected = this.$Grid.getSelectedData(),
AddButton = this.getButtons('brick-add'),
DelButton = this.getButtons('brick-delete');
if ( !selected.length )
{
AddButton.enable();
DelButton.disable();
return;
}
AddButton.enable();
DelButton.enable();
if ( selected.length > 1 ) {
AddButton.disable();
}
},
/**
* event : on create
*/
$onCreate : function()
{
var self = this;
// Buttons
this.$ProjectSelect = new QUISelect({
name : 'projects-name',
events : {
onChange : this.$refreshProjectLanguages
}
});
this.$ProjectLangs = new QUISelect({
name : 'projects-langs',
}
});
this.addButton( this.$ProjectSelect );
this.addButton( new QUISeperator() );
this.addButton(
new QUIButton({
this.addButton(
new QUIButton({
text : 'Markierte Blöcke löschen',
disabled : true,
events : {
onClick : this.$openDeleteDialog
}
})
);
// Grid
var Container = new Element('div').inject(
this.getContent()
);
this.$Grid = new Grid( Container, {
columnModel : [{
header : QUILocale.get( 'quiqqer/system', 'id' ),
dataIndex : 'id',
dataType : 'integer',
width : 40
}, {
header : QUILocale.get( 'quiqqer/system', 'title' ),
dataIndex : 'title',
dataType : 'string',
width : 140
}, {
header : QUILocale.get( 'quiqqer/system', 'description' ),
dataIndex : 'description',
dataType : 'string',
width : 300
}, {
dataIndex : 'type',
dataType : 'string',
width : 200
onDblClick : this.$onDblClick,
onClick : this.$onClick
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
this.Loader.show();
Projects.getList(function(projects)
{
for ( var project in projects )
{
if ( !projects.hasOwnProperty( project ) ) {
continue;
}
self.$ProjectSelect.appendChild(
project, project, 'icon-home'
);
}
self.$ProjectSelect.setValue(
self.$ProjectSelect.firstChild().getAttribute( 'value' )
);
});
},
/**
* event : on resize
*/
$onResize : function()
{
if ( !this.$Grid ) {
return;
}
var Body = this.getContent();
if ( !Body ) {
return;
}
var size = Body.getSize();
this.$Grid.setHeight( size.y - 40 );
this.$Grid.setWidth( size.x - 40 );
},
/**
* event : dbl click
*/
$onDblClick : function()
{
/**
* event : click
*/
$onClick : function()
{
this.refreshButtons();
},
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/**
* Refresh the project language dropdown
*/
$refreshProjectLanguages : function()
{
var self = this,
activeProject = this.$ProjectSelect.getValue();
Projects.getList(function(projects)
{
for ( var project in projects )
{
if ( !projects.hasOwnProperty( project ) ) {
continue;
}
if ( activeProject != project ) {
continue;
}
var langs = projects[ project ].langs;
langs = langs.split( ',' );
self.$ProjectLangs.clear();
for ( var i = 0, len = langs.length; i < len; i++ )
{
self.$ProjectLangs.appendChild(
langs[ i ], langs[ i ], 'icon-home'
);
}
self.$ProjectLangs.setValue(
self.$ProjectLangs.firstChild().getAttribute( 'value' )
);
}
});
},
*/
$openCreateDialog : function()
{
var self = this;
new QUIConfirm({
icon : 'icon-th',
maxHeight : 300,
maxWidth : 400,
autoclose : false,
events :
{
onOpen : function(Win)
{
var Body = Win.getContent();
Win.Loader.show();
' Title' +
' </span>' +
' <input type="text" name="title" />' +
'</label>' +
'<label>' +
' <span class="quiqqer-bricks-create-label-text">' +
' Brick Typ' +
' </span>' +
' <select name="type"></select>' +
'</label>'
);
var i, len, group, title, val;
var Select = Body.getElement( 'select'),
Title = Body.getElement( '[name="title"]');
if ( 'group' in title )
{
group = title.group;
val = title.var;
} else
{
group = title[ 0 ];
val = title[ 1 ];
}
html : QUILocale.get( group, val )
}).inject( Select );
}
Title.focus.delay( 500, Title );
Win.Loader.hide();
});
},
onSubmit : function(Win)
{
Win.Loader.show();
var Body = Win.getContent(),
Title = Body.getElement( '[name="title"]' ),
Type = Body.getElement( '[name="type"]' );
if ( Title.value === '' ) {
return;
}
var project = self.$ProjectSelect.getValue(),
lang = self.$ProjectLangs.getValue();
self.createBrick(project, lang, {
*/
$openDeleteDialog : function()
{
var self = this,
brickIds = this.$Grid.getSelectedData().map(function(brick) {
return brick.id;
});
new QUIConfirm({
maxHeight : 300,
maxWidth : 600,
autoclose : false,
events :
{
onOpen : function(Win)
{
var Content = Win.getContent(),
lists = '<ul>';
self.$Grid.getSelectedData().each(function(brick) {
lists = lists +'<li>'+ brick.id +' - '+ brick.title +'</li>';
});
lists = lists +'</ul>';
Content.set(
'html',
'<h1>Möchten Sie folgende Brick-IDs wirklich löschen</h1>' +
lists
);
},
onSubmit : function(Win)
{
Win.Loader.show();
{
Win.close();
self.refresh();
});
}
}
}).open();
},
/**
require(['package/quiqqer/bricks/bin/BrickEdit'], function(BrickEdit)
id : brickId,
projectName : self.$ProjectSelect.getValue(),
projectLang : self.$ProjectLangs.getValue(),
events :
{
onLoaded : function() {
self.Loader.hide();
}
}
}).inject( Sheet.getContent() );
});
Sheet.getContent().setStyle( 'overflow', 'auto' );
}
});
Sheet.addButton({
textimage : 'icon-save',
text : 'Speichern',
styles : {
width : 200
},
events :
{
onClick : function()
{
self.Loader.show();
{
self.Loader.hide();
Sheet.hide();
});
}
}
});
Sheet.show();
},
/**
* Methods / Model
*/
/**
Ajax.get('package_quiqqer_bricks_ajax_getAvailableBricks', callback, {
'package' : 'quiqqer/bricks'
*
* @param {String} project - name of the project
* @param {String} lang - Language of the project
* @param {Function} callback - callback function
*/
getBricksFromProject : function(project, lang, callback)
Ajax.get('package_quiqqer_bricks_ajax_project_getBricks', callback, {
'package' : 'quiqqer/bricks',
createBrick : function(project, lang, data, callback)
Ajax.post('package_quiqqer_bricks_ajax_project_createBrick', callback, {
'package' : 'quiqqer/bricks',
* @param {array} brickIds - Brick IDs which should be deleted
Ajax.post('package_quiqqer_bricks_ajax_brick_delete', callback, {
'package' : 'quiqqer/bricks',
brickIds : JSON.encode( brickIds )