diff --git a/css/groups.css b/css/groups.css index 3bf7590..2e4326c 100644 --- a/css/groups.css +++ b/css/groups.css @@ -28,3 +28,18 @@ clear: both; } +#groups .group +{ + margin-bottom: 4em; +} + +#groups .group > h4 +{ + margin-top: 0; + float: left; +} + +#groups .group > .groupActions +{ + float: right; +} diff --git a/messages.json b/messages.json index 56bdee9..8e619ee 100644 --- a/messages.json +++ b/messages.json @@ -81,7 +81,9 @@ "yourGroups": "Your groups", "newGroupName": "New group name", "addGroup": "Add group", + "renameGroup": "Rename group", "deleteGroup": "Delete group", + "enterGroupName": "What do you want to rename \"{group}\" to?", "confirmDeleteGroup": "Are you sure you want to delete the group \"{group}\"?" }, "messagePreview": { @@ -347,7 +349,9 @@ "yourGroups": "あなたのグループ", "newGroupName": "新しいグループ名", "addGroup": "グループを追加", + "renameGroup": "グループの名前を変更する", "deleteGroup": "グループを削除", + "enterGroupName": "「{group}」の名前を何に変更しますか?", "confirmDeleteGroup": "「{group}」という名前のグループを削除してもよろしいですか?" }, "messagePreview": { diff --git a/ui/groups.js b/ui/groups.js index 46bfd12..2ba099c 100644 --- a/ui/groups.js +++ b/ui/groups.js @@ -10,8 +10,14 @@ module.exports = function (componentsState) {

{{ $t('groups.yourGroups') }}

  -
-

{{ group.name }} X

+
+
+

{{ group.name }}

+
+ + +
+
  • @@ -83,6 +89,22 @@ module.exports = function (componentsState) { }) }, + renameGroup: function(group) { + var self = this + const newName = prompt(this.$root.$t('groups.enterGroupName', { group: group.name }), group.name) + if (newName && newName.trim() != '' && newName != group.name) { + group.name = newName + userGroups.updateGroup(group.id, group, (err, success) => { + if (err) + alert(err) + else { + self.groups = [] + self.loadGroups() + } + }) + } + }, + deleteGroup: function(group) { var self = this if (confirm(this.$root.$t('groups.confirmDeleteGroup', { group: group.name }))) { diff --git a/usergroups.js b/usergroups.js index c48ffd0..0aa1711 100644 --- a/usergroups.js +++ b/usergroups.js @@ -47,7 +47,26 @@ exports.addGroup = function(groupInfo, cb) { } exports.updateGroup = function(groupId, groupInfo, cb) { - cb("Not supported yet") + var groups = getFullLocalGroupInfo() + var updated = false + for (g in groups) { + if (groups[g].id == groupId) { + if (groupInfo.name && groupInfo.name.trim() != '') { + groups[g].name = groupInfo.name + updated = true + } + if (groupInfo.description) { + groups[g].description = groupInfo.description + updated = true + } + } + } + if (!updated) + cb("Group not found") + else { + setFullLocalGroupInfo(groups) + cb(null, true) + } } exports.deleteGroup = function(groupId, cb) {