Merge pull request #1499 from ostcar/autoupdate_delete

Autoupdate for delete views.
This commit is contained in:
Norman Jäckel 2015-03-01 16:52:37 +01:00
commit 681d1115c9
7 changed files with 21 additions and 15 deletions

View File

@ -41,7 +41,7 @@ angular.module('OpenSlidesApp.agenda', [])
}) })
.controller('ItemListCtrl', function($scope, Agenda, i18n) { .controller('ItemListCtrl', function($scope, Agenda, i18n) {
Agenda.bindAll($scope, 'items'); Agenda.bindAll({}, $scope, 'items');
$scope.test_plural = i18n.ngettext('test', 'tests', 2); $scope.test_plural = i18n.ngettext('test', 'tests', 2);
$scope.test_singular = i18n.ngettext('test', 'tests', 1); $scope.test_singular = i18n.ngettext('test', 'tests', 1);
}) })

View File

@ -109,10 +109,10 @@ class AssignmentFullSerializer(ModelSerializer):
model = Assignment model = Assignment
fields = ( fields = (
'id', 'id',
'name', 'title',
'description', 'description',
'posts', 'open_posts',
'status', 'phase',
'related_users', 'related_users',
'poll_description_default', 'poll_description_default',
'polls', 'polls',
@ -130,10 +130,10 @@ class AssignmentShortSerializer(AssignmentFullSerializer):
model = Assignment model = Assignment
fields = ( fields = (
'id', 'id',
'name', 'title',
'description', 'description',
'posts', 'open_posts',
'status', 'phase',
'related_users', 'related_users',
'poll_description_default', 'poll_description_default',
'polls', 'polls',

View File

@ -42,17 +42,17 @@ angular.module('OpenSlidesApp.assignments', [])
}) })
.controller('AssignmentListCtrl', function($scope, Assignment) { .controller('AssignmentListCtrl', function($scope, Assignment) {
Assignment.bindAll($scope, 'assignments'); Assignment.bindAll({}, $scope, 'assignments');
}) })
.controller('AssignmentDetailCtrl', function($scope, Assignment, assignment) { .controller('AssignmentDetailCtrl', function($scope, Assignment, assignment) {
Assignment.bindOne($scope, 'assignment', assignment.id) Assignment.bindOne(assignment.id, $scope, 'assignment')
}) })
.controller('AssignmentCreateCtrl', function($scope, Assignment) { .controller('AssignmentCreateCtrl', function($scope, Assignment) {
$scope.assignment = {}; $scope.assignment = {};
$scope.save = function(assignment) { $scope.save = function(assignment) {
assignment.posts = 1; assignment.open_posts = 1;
assignment.tags = []; // TODO: the rest_api should do this assignment.tags = []; // TODO: the rest_api should do this
Assignment.create(assignment); Assignment.create(assignment);
// TODO: redirect to list-view // TODO: redirect to list-view

View File

@ -1,2 +1,2 @@
<h1>{{ assignment.name }}</h1> <h1>{{ assignment.title }}</h1>
{{ assignment.description }} {{ assignment.description }}

View File

@ -1,8 +1,8 @@
<h1 ng-if="assignment.id">{{ assignment.name }}</h1> <h1 ng-if="assignment.id">{{ assignment.title }}</h1>
<h1 ng-if="!assignment.id">Neue Assignment</h1> <h1 ng-if="!assignment.id">Neue Assignment</h1>
<form> <form>
Titel: <input type="text" ng-model="assignment.name"><br> Titel: <input type="text" ng-model="assignment.title"><br>
Beschreibung:<br> <textarea ng-model="assignment.description"></textarea><br> Beschreibung:<br> <textarea ng-model="assignment.description"></textarea><br>
<input type="submit" ng-click="save(assignment)" value="Save" /> <input type="submit" ng-click="save(assignment)" value="Save" />
</form> </form>

View File

@ -1,6 +1,6 @@
<ul> <ul>
<li ng-repeat="assignment in assignments"> <li ng-repeat="assignment in assignments">
<a ui-sref="assignments.assignment.detail({id: assignment.id })">{{ assignment.name }}</a> <a ui-sref="assignments.assignment.detail({id: assignment.id })">{{ assignment.title }}</a>
<a ui-sref="assignments.assignment.detail.update({id: assignment.id })">Bearbeiten</a> <a ui-sref="assignments.assignment.detail.update({id: assignment.id })">Bearbeiten</a>
</li> </li>
</ul> </ul>

View File

@ -102,8 +102,14 @@ angular.module('OpenSlidesApp.core', [])
autoupdate.on_message(function(data) { autoupdate.on_message(function(data) {
// TODO: when MODEL.find() is called after this // TODO: when MODEL.find() is called after this
// a new request is fired. This could be a bug in DS // a new request is fired. This could be a bug in DS
// TODO: Do not send the status code to the client, but make the decission
// on the server side. It is an implementation detail, that tornado
// sends request to wsgi, which should not concern the client.
if (data.status_code == 200) { if (data.status_code == 200) {
DS.inject(data.collection, data.data) DS.inject(data.collection, data.data);
} else if (data.status_code == 404) {
DS.eject(data.collection, data.id);
} }
// TODO: handle other statuscodes // TODO: handle other statuscodes
}); });