Added edition of room name

This commit is contained in:
Emmanuel ROHEE 2014-09-12 10:48:06 +02:00
parent 6ea20f3503
commit d934328904
4 changed files with 61 additions and 12 deletions

View File

@ -296,20 +296,20 @@ a:active { color: #000; }
} }
#roomTopic { #roomTopic {
text-align: right;
font-size: 13px; font-size: 13px;
text-align: right;
} }
.roomTopicInput { .roomNameInput, .roomTopicInput {
width: 100%; width: 100%;
} }
.roomTopicSection { .roomNameSection, .roomTopicSection {
float: right; float: right;
width: 100%; width: 100%;
} }
.roomTopicSetNew { .roomNameSetNew, .roomTopicSetNew {
float: right; float: right;
} }

View File

@ -236,6 +236,13 @@ angular.module('matrixService', [])
return doRequest("GET", path, undefined, {}); return doRequest("GET", path, undefined, {});
}, },
setName: function(room_id, name) {
var data = {
name: name
};
return this.sendStateEvent(room_id, "m.room.name", data);
},
setTopic: function(room_id, topic) { setTopic: function(room_id, topic) {
var data = { var data = {
topic: topic topic: topic

View File

@ -15,8 +15,8 @@ limitations under the License.
*/ */
angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'mPresence', 'matrixPhoneService', 'MatrixCall', .controller('RoomController', ['$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'mPresence', 'matrixPhoneService', 'MatrixCall',
function($scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, mPresence, matrixPhoneService, MatrixCall) { function($filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, mPresence, matrixPhoneService, MatrixCall) {
'use strict'; 'use strict';
var MESSAGES_PER_PAGINATION = 30; var MESSAGES_PER_PAGINATION = 30;
var THUMBNAIL_SIZE = 320; var THUMBNAIL_SIZE = 320;
@ -42,6 +42,44 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
$scope.imageURLToSend = ""; $scope.imageURLToSend = "";
$scope.userIDToInvite = ""; $scope.userIDToInvite = "";
// vars and functions for updating the name
$scope.name = {
isEditing: false,
newNameText: "",
editName: function() {
if ($scope.name.isEditing) {
console.log("Warning: Already editing name.");
return;
};
// Use the filter applied in html to set the input value
$scope.name.newNameText = $filter('mRoomName')($scope.room_id);
// Force focus to the input
$timeout(function() {
angular.element('.roomNameInput').focus();
}, 0);
$scope.name.isEditing = true;
},
updateName: function() {
console.log("Updating name to "+$scope.name.newNameText);
matrixService.setName($scope.room_id, $scope.name.newNameText).then(
function() {
},
function(error) {
$scope.feedback = "Request failed: " + error.data.error;
}
);
$scope.name.isEditing = false;
},
cancelEdit: function() {
$scope.name.isEditing = false;
}
};
// vars and functions for updating the topic // vars and functions for updating the topic
$scope.topic = { $scope.topic = {
isEditing: false, isEditing: false,
@ -83,9 +121,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
} }
}; };
var scrollToBottom = function(force) { var scrollToBottom = function(force) {
console.log("Scrolling to bottom"); console.log("Scrolling to bottom");

View File

@ -3,9 +3,16 @@
<div id="roomHeader"> <div id="roomHeader">
<a href ng-click="goToPage('/')"><img src="img/logo-small.png" width="100" height="43" alt="[matrix]"/></a> <a href ng-click="goToPage('/')"><img src="img/logo-small.png" width="100" height="43" alt="[matrix]"/></a>
<div class="roomHeaderInfo"> <div class="roomHeaderInfo">
<div id="roomName">
{{ room_id | mRoomName }} <div class="roomNameSection">
<div ng-hide="name.isEditing" ng-dblclick="name.editName()" id="roomName">
{{ room_id | mRoomName }}
</div>
<form ng-submit="name.updateName()" ng-show="name.isEditing" class="roomNameForm">
<input ng-model="name.newNameText" ng-blur="name.cancelEdit()" class="roomNameInput" />
</form>
</div> </div>
<div class="roomTopicSection"> <div class="roomTopicSection">
<button ng-hide="events.rooms[room_id]['m.room.topic'].content.topic || topic.isEditing" <button ng-hide="events.rooms[room_id]['m.room.topic'].content.topic || topic.isEditing"
ng-click="topic.editTopic()" class="roomTopicSetNew"> ng-click="topic.editTopic()" class="roomTopicSetNew">