Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Basic conversation-management works (#33):
Browse files Browse the repository at this point in the history
* editing/deleting messages
* updating the conversation status (New, Ongoing, Complete)
  • Loading branch information
ja-fra committed Sep 6, 2017
1 parent 117762d commit 1b1d8ba
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
13 changes: 12 additions & 1 deletion frontend/src/app/scripts/controllers/conversationEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ angular.module('smartiApp')
$ctrl.backToList = backToList;
$ctrl.saveMessage = saveMessage;
$ctrl.deleteMessage = deleteMessage;
$ctrl.setConversationStatus = setConversationStatus;

function backToList() {
$location.path('client/' + client.data.id + '/conversations');
Expand Down Expand Up @@ -62,7 +63,17 @@ angular.module('smartiApp')
return response;
},
handleError
)
);
}

function setConversationStatus(newStatus) {
return ConversationService.setConversationStatus(conversation.id, newStatus).then(
function (response) {
conversation.meta.status = response.meta.status;
return response;
},
handleError
);
}

});
12 changes: 11 additions & 1 deletion frontend/src/app/scripts/services/conversation.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ angular.module('smartiApp')
this.saveMessage = saveMessage;
this.deleteMessage = deleteMessage;

this.setConversationStatus = setConversationStatus;

function getForClient(clientId, page, pageSize) {
return $http.get(ENV.serviceBaseUrl + 'admin/conversation', {
params: {
clientId: clientId,
owner: clientId,
page: page,
pageSize: pageSize
}
Expand Down Expand Up @@ -66,4 +68,12 @@ angular.module('smartiApp')
});
}

function setConversationStatus(conversationId, newStatus) {
return $http.put(ENV.serviceBaseUrl + 'admin/conversation/' + conversationId + '/status/' + newStatus, undefined)
.then(function (response) {
return response.data;
});

}

});
18 changes: 15 additions & 3 deletions frontend/src/app/views/conversationEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@
</div>
<h2>Edit conversation <span ng-bind="$resolve.conversation.id"></span></h2>
</div>
<div>
<h3>Settings</h3>
<form class="form-inline">
<div class="form-group">
<strong>Status</strong>
<select class="form-control"
ng-model="$resolve.conversation.meta.status"
ng-options="s for s in ['New', 'Ongoing', 'Complete']"
ng-change="$ctrl.setConversationStatus($resolve.conversation.meta.status)"></select>
</div>
</form>
</div>
<div>
<h3>Messages</h3>
<div class="panel panel-info panel-sm"
ng-repeat="m in $resolve.conversation.messages"
id="#{{$index}}">
id="#{{$index+1}}">
<div class="panel-heading">
#{{$index}}
#{{$index+1}}
<span ng-bind="m.user.displayName"></span>
<span class="pull-right" style="display: inline-block">
<button ng-if="m.editing" class="btn btn-default btn-xs" ng-click="$ctrl.saveMessage(m)"><i class="glyphicon glyphicon-floppy-disk"></i></button>
<button ng-if="!m.editing" class="btn btn-default btn-xs" ng-click="m.editing = true"><i class="glyphicon glyphicon-pencil"></i></button>
<button ng-if="!m.editing" class="btn btn-default btn-xs" ng-click="$ctrl.deleteMessage(m.id)"><i class="glyphicon glyphicon-remove"></i></button>
<button ng-if="!m.editing" class="btn btn-default btn-xs" ng-click="$ctrl.deleteMessage(m)"><i class="glyphicon glyphicon-remove"></i></button>
</span>
</div>
<div class="panel-body">
Expand Down

0 comments on commit 1b1d8ba

Please sign in to comment.