From d9343289045d4a733710706421ab528626cc02d4 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Fri, 12 Sep 2014 10:48:06 +0200 Subject: [PATCH] Added edition of room name --- webclient/app.css | 8 ++-- webclient/components/matrix/matrix-service.js | 7 +++ webclient/room/room-controller.js | 47 ++++++++++++++++--- webclient/room/room.html | 11 ++++- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/webclient/app.css b/webclient/app.css index 71af550679..1b918f59e2 100755 --- a/webclient/app.css +++ b/webclient/app.css @@ -296,20 +296,20 @@ a:active { color: #000; } } #roomTopic { - text-align: right; font-size: 13px; + text-align: right; } -.roomTopicInput { +.roomNameInput, .roomTopicInput { width: 100%; } -.roomTopicSection { +.roomNameSection, .roomTopicSection { float: right; width: 100%; } -.roomTopicSetNew { +.roomNameSetNew, .roomTopicSetNew { float: right; } diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 62aff091d4..68ef16800b 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -236,6 +236,13 @@ angular.module('matrixService', []) 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) { var data = { topic: topic diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 9f15b61e10..3cc127140b 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -15,8 +15,8 @@ limitations under the License. */ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) -.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'mPresence', 'matrixPhoneService', 'MatrixCall', - function($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($filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, mPresence, matrixPhoneService, MatrixCall) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; var THUMBNAIL_SIZE = 320; @@ -42,6 +42,44 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) $scope.imageURLToSend = ""; $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 $scope.topic = { isEditing: false, @@ -81,10 +119,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) cancelEdit: function() { $scope.topic.isEditing = false; } - }; - - - + }; var scrollToBottom = function(force) { console.log("Scrolling to bottom"); diff --git a/webclient/room/room.html b/webclient/room/room.html index e8d8c3f46a..72c8a97adb 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -3,9 +3,16 @@
[matrix]
-
- {{ room_id | mRoomName }} + +
+
+ {{ room_id | mRoomName }} +
+
+ +
+