summary refs log tree commit diff
path: root/webclient
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-10-29 15:02:30 +0000
committerKegan Dougal <kegan@matrix.org>2014-10-29 15:02:30 +0000
commit70137409ed13da80fe1722f1bd0638936a14bff1 (patch)
treea32642eb8c49b650f39f0786ece5bd3b0b7cb122 /webclient
parentImplement SYWEB-58: Clicking a notification now takes you to that room. (diff)
downloadsynapse-70137409ed13da80fe1722f1bd0638936a14bff1.tar.xz
SYWEB-98: Add a 'Redact' button to the event info modal dialog.
I think this is better than overriding the right-click contextual menu.
Currently clicking this button does nothing.
Diffstat (limited to '')
-rw-r--r--webclient/room/room-controller.js21
-rw-r--r--webclient/room/room.html13
2 files changed, 31 insertions, 3 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 31aed71d7f..c4014b2fe0 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -985,10 +985,25 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
     };
 
     $scope.openJson = function(content) {
-        console.log("Displaying modal dialog for " + JSON.stringify(content));
+        $scope.event_selected = content;
+        // scope this so the template can check power levels and enable/disable
+        // buttons
+        $scope.pow = matrixService.getUserPowerLevel;
+
         var modalInstance = $modal.open({
-            template: "<pre>" + angular.toJson(content, true) + "</pre>"
+            templateUrl: 'eventInfoTemplate.html',
+            controller: 'EventInfoController',
+            scope: $scope
         });
     };
 
-}]);
+}])
+.controller('EventInfoController', function($scope, $modalInstance) {
+    console.log("Displaying modal dialog for >>>> " + JSON.stringify($scope.event_selected));
+    $scope.redact = function() {
+        console.log("User level = "+$scope.pow($scope.room_id, $scope.state.user_id)+
+                    " Redact level = "+$scope.events.rooms[$scope.room_id]["m.room.ops_levels"].content.redact_level);
+        console.log("Redact event >> " + JSON.stringify($scope.event_selected));
+        $modalInstance.dismiss();
+    };
+});
diff --git a/webclient/room/room.html b/webclient/room/room.html
index e753b037fe..5293a579d3 100644
--- a/webclient/room/room.html
+++ b/webclient/room/room.html
@@ -1,5 +1,18 @@
 <div ng-controller="RoomController" data-ng-init="onInit()" class="room" style="height: 100%;">
 
+    <script type="text/ng-template" id="eventInfoTemplate.html">
+        <div class="modal-body">
+            <pre> {{event_selected | json}} </pre>
+        </div>
+        <div class="modal-footer">
+            <button ng-click="redact()" type="button" class="btn btn-danger" 
+             ng-disabled="pow(room_id, state.user_id) < events.rooms[room_id]['m.room.ops_levels'].content.redact_level"
+             title="Delete this event on all home servers. This cannot be undone.">
+                Redact
+            </button>        
+        </div>
+    </script>
+
     <div id="roomHeader">
         <a href ng-click="goToPage('/')"><img src="img/logo-small.png" width="100" height="43" alt="[matrix]"/></a>
         <div class="roomHeaderInfo">