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 );
onCreate : this.$onCreate,
onResize : this.$onResize
{
if ( !this.$Elm ) {
return;
}
var self = this;
this.Loader.show();
this.getBricksFromProject(this.$ProjectSelect.getValue(), 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',
events : {
onChange : this.refresh
}
});
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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
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();
},
/**
*
*/
$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;
}
*/
$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)
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
project : self.$ProjectSelect.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 {Function} callback - callback function
*/
Ajax.get('package_quiqqer_bricks_ajax_project_getBricks', callback, {
'package' : 'quiqqer/bricks',
project : JSON.encode({
name : project
})
});
*
* @param {String} project
* @param {Object} data
* @param {Function} callback
*/
Ajax.post('package_quiqqer_bricks_ajax_project_createBrick', callback, {
'package' : 'quiqqer/bricks',
project : JSON.encode({
name : project
}),
data : JSON.encode( data )
});
* @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 )