2016-07-20 12:25:51 +02:00
|
|
|
/**
|
2016-11-02 18:32:24 +01:00
|
|
|
* File: widget-container.js
|
2016-07-20 12:25:51 +02:00
|
|
|
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
|
|
|
* Date: 05.07.2016
|
|
|
|
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
|
|
|
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
|
|
|
**********************************************************************************/
|
|
|
|
|
2016-06-28 14:23:49 +02:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2016-07-19 16:13:56 +02:00
|
|
|
tagName: 'div',
|
2016-11-02 18:32:24 +01:00
|
|
|
classNames: [ 'widgets' ],
|
2016-07-19 16:13:56 +02:00
|
|
|
attributeBindings: [ 'style' ],
|
2016-07-17 18:43:08 +02:00
|
|
|
|
2016-11-02 18:32:24 +01:00
|
|
|
widgets: null,
|
2016-07-19 16:45:45 +02:00
|
|
|
editing: false,
|
2017-01-13 17:11:48 +01:00
|
|
|
grid: false,
|
2016-10-12 08:30:15 +02:00
|
|
|
data: null,
|
2016-07-15 12:09:31 +02:00
|
|
|
|
2016-11-02 18:32:24 +01:00
|
|
|
style: Ember.computed('widgets.@each.height', 'widgets.@each.y', function() {
|
2016-07-27 13:43:10 +02:00
|
|
|
var height = this._calculateHeight();
|
|
|
|
if (this.get('editing') === true && height < 400) {
|
|
|
|
height = 400;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ember.String.htmlSafe('height: ' + height + 'px;');
|
2016-10-18 13:01:55 +02:00
|
|
|
}),
|
2016-07-15 12:09:31 +02:00
|
|
|
|
2016-07-19 16:13:56 +02:00
|
|
|
_calculateHeight() {
|
|
|
|
var maxHeight = 0;
|
2016-11-02 18:32:24 +01:00
|
|
|
var widgets = this.get('widgets');
|
2016-07-19 16:13:56 +02:00
|
|
|
|
2016-11-02 18:32:24 +01:00
|
|
|
widgets.forEach(function(widget) {
|
|
|
|
var widgetHeight = widget.get('y') + widget.get('height');
|
|
|
|
if (widgetHeight > maxHeight) {
|
|
|
|
maxHeight = widgetHeight;
|
2016-07-19 16:13:56 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-07-19 16:45:45 +02:00
|
|
|
// add padding to height
|
|
|
|
maxHeight += 40;
|
|
|
|
|
2016-07-19 16:13:56 +02:00
|
|
|
return maxHeight;
|
2016-10-12 11:29:09 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2016-11-02 18:32:24 +01:00
|
|
|
showWidgetDialog(widget) {
|
|
|
|
this.sendAction('showWidgetDialog', widget);
|
2016-10-12 11:29:09 +02:00
|
|
|
}
|
2016-07-19 16:13:56 +02:00
|
|
|
}
|
2016-06-28 14:23:49 +02:00
|
|
|
});
|