Component modals

This commit is contained in:
Mo Bitar
2017-12-24 14:46:00 -06:00
parent 5df39b1c2f
commit f4352253c3
4 changed files with 25 additions and 14 deletions

View File

@@ -6,16 +6,11 @@ class Mfa extends Item {
mapContentToLocalProperties(content) { mapContentToLocalProperties(content) {
super.mapContentToLocalProperties(content) super.mapContentToLocalProperties(content)
this.name = content.name; this.serverContent = content;
} }
structureParams() { structureParams() {
var params = { return _.merge(this.serverContent, super.structureParams());
name: this.name,
};
_.merge(params, super.structureParams());
return params;
} }
toJSON() { toJSON() {
@@ -23,7 +18,7 @@ class Mfa extends Item {
} }
get content_type() { get content_type() {
return "SN|MFA"; return "SF|MFA";
} }
doNotEncrypt() { doNotEncrypt() {

View File

@@ -654,7 +654,7 @@ class ComponentManager {
setSize(iframe, data); setSize(iframe, data);
} else { } else {
var container = document.getElementById("room-" + component.uuid); var container = document.getElementById("component-" + component.uuid);
setSize(container, data); setSize(container, data);
} }
} }

View File

@@ -10,17 +10,18 @@ class ComponentModal {
}; };
} }
link($scope, el, attrs, componentManager) { link($scope, el, attrs) {
$scope.el = el; $scope.el = el;
} }
controller($scope, componentManager) { controller($scope, $timeout, componentManager) {
'ngInject'; 'ngInject';
let identifier = "modal-" + $scope.component.uuid; let identifier = "modal-" + $scope.component.uuid;
$scope.dismiss = function() { $scope.dismiss = function() {
componentManager.deregisterHandler(identifier); componentManager.deregisterHandler(identifier);
componentManager.deactivateComponent($scope.component);
$scope.el.remove(); $scope.el.remove();
} }
@@ -28,12 +29,27 @@ class ComponentModal {
return componentManager.urlForComponent($scope.component); return componentManager.urlForComponent($scope.component);
} }
componentManager.registerHandler({identifier: identifier, areas: ["modal"], componentManager.registerHandler({identifier: identifier, areas: ["modal"], activationHandler: (component) => {
actionHandler: function(component, action, data){ if(component.active) {
$timeout(function(){
var iframe = componentManager.iframeForComponent(component);
console.log("iframe", iframe, component);
if(iframe) {
iframe.onload = function() {
componentManager.registerComponentWindow(component, iframe.contentWindow);
}.bind(this);
}
}.bind(this));
}
},
actionHandler: function(component, action, data) {
if(action == "set-size") { if(action == "set-size") {
console.log("componentModalReceivedAction SetSize", component);
componentManager.handleSetSizeEvent(component, data); componentManager.handleSetSizeEvent(component, data);
} }
}.bind(this)}); }.bind(this)});
componentManager.activateComponent($scope.component);
} }
} }

View File

@@ -1,4 +1,4 @@
.room-item{"ng-repeat" => "room in rooms", "ng-click" => "selectRoom(room)"} .room-item{"ng-repeat" => "room in rooms", "ng-click" => "selectRoom(room)"}
%span {{room.name}} %span {{room.name}}
.room-container.panel-right{"ng-if" => "room.show && room.active", "ng-attr-id" => "room-{{room.uuid}}"} .room-container.panel-right{"ng-if" => "room.show && room.active", "ng-attr-id" => "component-{{room.uuid}}"}
%iframe.room-iframe{"ng-src" => "{{componentManager.urlForComponent(room) | trusted}}", "frameBorder" => "0", "sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-modals", "data-component-id" => "{{room.uuid}}"} %iframe.room-iframe{"ng-src" => "{{componentManager.urlForComponent(room) | trusted}}", "frameBorder" => "0", "sandbox" => "allow-scripts allow-top-navigation-by-user-activation allow-popups allow-popups-to-escape-sandbox allow-modals", "data-component-id" => "{{room.uuid}}"}