Component modals wip

This commit is contained in:
Mo Bitar
2017-12-23 17:43:52 -06:00
parent 08c13ce478
commit 5df39b1c2f
10 changed files with 110 additions and 31 deletions

View File

@@ -210,6 +210,7 @@ class ComponentManager {
save-context-client-data
get-context-client-data
install-local-component
open-component
*/
if(message.action === "stream-items") {
@@ -291,6 +292,12 @@ class ComponentManager {
})
}
else if(message.action === "open-component") {
let openComponent = this.modelManager.findItem(message.data.uuid);
console.log("Received open-component event", openComponent);
this.openModalComponent(openComponent);
}
for(let handler of this.handlers) {
if(handler.areas.includes(component.area)) {
this.timeout(function(){
@@ -449,6 +456,13 @@ class ComponentManager {
}
}
openModalComponent(component) {
var scope = this.$rootScope.$new(true);
scope.component = component;
var el = this.$compile( "<component-modal component='component' class='component-modal'></component-modal>" )(scope);
angular.element(document.body).append(el);
}
replyToMessage(component, originalMessage, replyData) {
var reply = {
action: "reply",
@@ -511,6 +525,11 @@ class ComponentManager {
this.handlers.push(handler);
}
deregisterHandler(identifier) {
var handler = _.find(this.handlers, {identifier: identifier});
this.handlers.splice(this.handlers.indexOf(handler), 1);
}
// Called by other views when the iframe is ready
registerComponentWindow(component, componentWindow) {
if(component.window === componentWindow) {
@@ -619,6 +638,27 @@ class ComponentManager {
}
}
handleSetSizeEvent(component, data) {
var setSize = function(element, size) {
var widthString = typeof size.width === 'string' ? size.width : `${data.width}px`;
var heightString = typeof size.height === 'string' ? size.height : `${data.height}px`;
element.setAttribute("style", `width:${widthString}; height:${heightString}; `);
}
if(data.type === "content") {
var iframe = this.iframeForComponent(component);
var width = data.width;
var height = data.height;
iframe.width = width;
iframe.height = height;
setSize(iframe, data);
} else {
var container = document.getElementById("room-" + component.uuid);
setSize(container, data);
}
}
}