SYWEB-12: Add ability to add new state events.

This commit is contained in:
Kegan Dougal 2014-10-30 17:01:17 +00:00
parent 0985bfb775
commit f618f99ece
2 changed files with 21 additions and 2 deletions

View File

@ -1018,13 +1018,20 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
}; };
$scope.openRoomInfo = function() { $scope.openRoomInfo = function() {
$scope.roomInfo = {};
$scope.roomInfo.newEvent = {
content: {},
type: "",
state_key: ""
};
var stateFilter = $filter("stateEventsFilter"); var stateFilter = $filter("stateEventsFilter");
var stateEvents = stateFilter($scope.events.rooms[$scope.room_id]); var stateEvents = stateFilter($scope.events.rooms[$scope.room_id]);
// The modal dialog will 2-way bind this field, so we MUST make a deep // The modal dialog will 2-way bind this field, so we MUST make a deep
// copy of the state events else we will be *actually adjusing our view // copy of the state events else we will be *actually adjusing our view
// of the world* when fiddling with the JSON!! Apparently parse/stringify // of the world* when fiddling with the JSON!! Apparently parse/stringify
// is faster than jQuery's extend when doing deep copies. // is faster than jQuery's extend when doing deep copies.
$scope.roomInfoStateEvents = JSON.parse(JSON.stringify(stateEvents)); $scope.roomInfo.stateEvents = JSON.parse(JSON.stringify(stateEvents));
var modalInstance = $modal.open({ var modalInstance = $modal.open({
templateUrl: 'roomInfoTemplate.html', templateUrl: 'roomInfoTemplate.html',
controller: 'RoomInfoController', controller: 'RoomInfoController',

View File

@ -16,7 +16,7 @@
<script type="text/ng-template" id="roomInfoTemplate.html"> <script type="text/ng-template" id="roomInfoTemplate.html">
<div class="modal-body"> <div class="modal-body">
<table class="room-info"> <table class="room-info">
<tr ng-repeat="(key, event) in roomInfoStateEvents" class="room-info-event"> <tr ng-repeat="(key, event) in roomInfo.stateEvents" class="room-info-event">
<td class="room-info-event-meta" width="30%"> <td class="room-info-event-meta" width="30%">
<span class="monospace">{{ key }}</span> <span class="monospace">{{ key }}</span>
<br/> <br/>
@ -32,6 +32,18 @@
<textarea class="room-info-textarea-content" msd-elastic ng-model="event.content" asjson></textarea> <textarea class="room-info-textarea-content" msd-elastic ng-model="event.content" asjson></textarea>
</td> </td>
</tr> </tr>
<tr>
<td class="room-info-event-meta" width="30%">
<input ng-model="roomInfo.newEvent.type" placeholder="your.event.type" />
<br/>
<button ng-click="submit(roomInfo.newEvent)" type="button" class="btn btn-success" ng-disabled="!roomInfo.newEvent.content">
Submit
</button>
</td>
<td class="room-info-event-content" width="70%">
<textarea class="room-info-textarea-content" msd-elastic ng-model="roomInfo.newEvent.content" asjson></textarea>
</td>
</tr>
</table> </table>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">