Agenda item list: new multiselect delete mode

Remove action column.
This commit is contained in:
Emanuel Schuetze 2015-09-05 16:30:55 +02:00
parent e5008c1f53
commit 7f9c8b6a38
6 changed files with 467 additions and 348 deletions

View File

@ -14,6 +14,7 @@
"angular-loading-bar": "~0.7.1", "angular-loading-bar": "~0.7.1",
"angular-ui-router": "~0.2.13", "angular-ui-router": "~0.2.13",
"angular-ui-select": "~0.12", "angular-ui-select": "~0.12",
"angular-ui-switch": "~0.1.0",
"angular-ui-tree": "~2.2.0", "angular-ui-tree": "~2.2.0",
"angular-gettext": "~2.0.2", "angular-gettext": "~2.0.2",
"angular-sanitize": "~1.3.15", "angular-sanitize": "~1.3.15",

View File

@ -2,7 +2,9 @@
angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users']) angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
.factory('Speaker', ['DS', function(DS) { .factory('Speaker', [
'DS',
function(DS) {
return DS.defineResource({ return DS.defineResource({
name: 'agenda/speaker', name: 'agenda/speaker',
relations: { relations: {
@ -14,9 +16,14 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
} }
} }
}); });
}]) }
])
.factory('Agenda', ['DS', 'Speaker', 'jsDataModel', function(DS, Speaker, jsDataModel) { .factory('Agenda', [
'DS',
'Speaker',
'jsDataModel',
function(DS, Speaker, jsDataModel) {
var name = 'agenda/item' var name = 'agenda/item'
return DS.defineResource({ return DS.defineResource({
name: name, name: name,
@ -39,7 +46,8 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
} }
} }
}); });
}]) }
])
// Make sure that the Agenda resource is loaded. // Make sure that the Agenda resource is loaded.
.run(['Agenda', function(Agenda) {}]); .run(['Agenda', function(Agenda) {}]);
@ -60,7 +68,9 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
} }
]) ])
.config(function($stateProvider) { .config([
'$stateProvider',
function($stateProvider) {
$stateProvider $stateProvider
.state('agenda', { .state('agenda', {
url: '/agenda', url: '/agenda',
@ -126,13 +136,14 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
url: '/import', url: '/import',
controller: 'AgendaImportCtrl', controller: 'AgendaImportCtrl',
}); });
}) }
])
.factory('AgendaTree', [ .factory('AgendaTree', [
function () { function () {
return { return {
getTree: function (items) { getTree: function (items) {
// sortieren nach weight??? // TODO: sortieren nach weight???
// Build a dict with all children (dict-value) to a specific // Build a dict with all children (dict-value) to a specific
// item id (dict-key). // item id (dict-key).
@ -190,7 +201,14 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
} }
]) ])
.controller('ItemListCtrl', function($scope, $http, Agenda, Projector, AgendaTree) { .controller('ItemListCtrl', [
'$scope',
'$http',
'$state',
'Agenda',
'AgendaTree',
'Projector',
function($scope, $http, $state, Agenda, AgendaTree, Projector) {
// Bind agenda tree to the scope // Bind agenda tree to the scope
$scope.$watch(function () { $scope.$watch(function () {
return Agenda.lastModified(); return Agenda.lastModified();
@ -198,14 +216,43 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.items = AgendaTree.getFlatTree(Agenda.getAll()); $scope.items = AgendaTree.getFlatTree(Agenda.getAll());
}); });
// open detail view link
$scope.openDetail = function (id) {
$state.go('agenda.item.detail', {id: id});
}
// save changed item // save changed item
$scope.save = function (item) { $scope.save = function (item) {
Agenda.save(item); Agenda.save(item);
}; };
// delete selected item
$scope.delete = function (id) { // *** delete mode functions ***
Agenda.destroy(id); $scope.isDeleteMode = false;
// check all checkboxes
$scope.checkAll = function () {
angular.forEach($scope.items, function (item) {
item.selected = $scope.selectedAll;
});
}; };
// uncheck all checkboxes if isDeleteMode is closed
$scope.uncheckAll = function () {
if (!$scope.isDeleteMode) {
$scope.selectedAll = false;
angular.forEach($scope.items, function (item) {
item.selected = false;
});
}
};
// delete selected item
$scope.delete = function () {
angular.forEach($scope.items, function (item) {
if (item.selected)
Agenda.destroy(item.id);
});
$scope.isDeleteMode = false;
$scope.uncheckAll();
};
// project agenda // project agenda
$scope.projectAgenda = function () { $scope.projectAgenda = function () {
$http.post('/rest/core/projector/1/prune_elements/', $http.post('/rest/core/projector/1/prune_elements/',
@ -223,9 +270,16 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
}) > -1; }) > -1;
}; };
}) }
])
.controller('ItemDetailCtrl', function($scope, $http, Agenda, User, item) { .controller('ItemDetailCtrl', [
'$scope',
'$http',
'Agenda',
'User',
'item',
function ($scope, $http, Agenda, User, item) {
Agenda.bindOne(item.id, $scope, 'item'); Agenda.bindOne(item.id, $scope, 'item');
User.bindAll({}, $scope, 'users'); User.bindAll({}, $scope, 'users');
$scope.speaker = {}; $scope.speaker = {};
@ -279,9 +333,16 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$http.post('/rest/core/projector/1/prune_elements/', $http.post('/rest/core/projector/1/prune_elements/',
[{name: 'agenda/item', id: item.id, list_of_speakers: true}]); [{name: 'agenda/item', id: item.id, list_of_speakers: true}]);
}; };
}) }
])
.controller('ItemCreateCtrl', function($scope, $state, Agenda, Tag, types) { .controller('ItemCreateCtrl', [
'$scope',
'$state',
'Agenda',
'Tag',
'types',
function($scope, $state, Agenda, Tag, types) {
$scope.types = types.data.actions.POST.type.choices; // get all item types $scope.types = types.data.actions.POST.type.choices; // get all item types
Tag.bindAll({}, $scope, 'tags'); Tag.bindAll({}, $scope, 'tags');
$scope.save = function (item) { $scope.save = function (item) {
@ -293,9 +354,17 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
} }
); );
}; };
}) }
])
.controller('ItemUpdateCtrl', function($scope, $state, Agenda, Tag, types, item) { .controller('ItemUpdateCtrl', [
'$scope',
'$state',
'Agenda',
'Tag',
'types',
'item',
function($scope, $state, Agenda, Tag, types, item) {
$scope.types = types.data.actions.POST.type.choices; // get all item types $scope.types = types.data.actions.POST.type.choices; // get all item types
Tag.bindAll({}, $scope, 'tags'); Tag.bindAll({}, $scope, 'tags');
$scope.item = item; $scope.item = item;
@ -306,9 +375,15 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
} }
); );
}; };
}) }
])
.controller('AgendaSortCtrl', function($scope, $http, Agenda, AgendaTree) { .controller('AgendaSortCtrl', [
'$scope',
'$http',
'Agenda',
'AgendaTree',
function($scope, $http, Agenda, AgendaTree) {
// Bind agenda tree to the scope // Bind agenda tree to the scope
$scope.$watch(function () { $scope.$watch(function () {
return Agenda.lastModified(); return Agenda.lastModified();
@ -319,12 +394,17 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
// set changed agenda tree // set changed agenda tree
$scope.treeOptions = { $scope.treeOptions = {
dropped: function() { dropped: function() {
$http.put('/rest/agenda/item/tree/', {tree: $scope.items}); $http.put('/rest/agenda/item/tree/', {tree: $scope.tree});
} }
}; };
}) }
])
.controller('AgendaImportCtrl', function($scope, $state, Agenda) { .controller('AgendaImportCtrl', [
'$scope',
'$state',
'Agenda',
function($scope, $state, Agenda) {
// import from textarea // import from textarea
$scope.importByLine = function () { $scope.importByLine = function () {
$scope.items = $scope.itemlist[0].split("\n"); $scope.items = $scope.itemlist[0].split("\n");
@ -365,24 +445,26 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
} }
$scope.csvimported = true; $scope.csvimported = true;
} }
$scope.clear = function () { $scope.clear = function () {
$scope.csv.result = null; $scope.csv.result = null;
}; };
}
}); ]);
angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda']) angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda'])
.config(function(slidesProvider) { .config([
'slidesProvider',
function(slidesProvider) {
slidesProvider.registerSlide('agenda/item', { slidesProvider.registerSlide('agenda/item', {
template: 'static/templates/agenda/slide-item-detail.html', template: 'static/templates/agenda/slide-item-detail.html',
}); });
slidesProvider.registerSlide('agenda/item-list', { slidesProvider.registerSlide('agenda/item-list', {
template: 'static/templates/agenda/slide-item-list.html', template: 'static/templates/agenda/slide-item-list.html',
}); });
}) }
])
.controller('SlideItemDetailCtrl', [ .controller('SlideItemDetailCtrl', [
'$scope', '$scope',
@ -401,18 +483,21 @@ angular.module('OpenSlidesApp.agenda.projector', ['OpenSlidesApp.agenda'])
} }
]) ])
.controller('SlideItemListCtrl', function($scope, $http, Agenda) { .controller('SlideItemListCtrl', [
'$scope',
'$http',
'Agenda',
'AgendaTree',
function($scope, $http, Agenda, AgendaTree) {
// Attention! Each object that is used here has to be dealt on server side. // Attention! Each object that is used here has to be dealt on server side.
// Add it to the coresponding get_requirements method of the ProjectorElement // Add it to the coresponding get_requirements method of the ProjectorElement
// class. // class.
Agenda.findAll();
Agenda.bindAll({}, $scope, 'items'); // Bind agenda tree to the scope
$scope.ids = []; $scope.$watch(function () {
var tree = $http.get('/rest/agenda/item/tree/').success(function(data) { return Agenda.lastModified();
var ids = []; }, function () {
angular.forEach(data,function(element) { $scope.items = AgendaTree.getFlatTree(Agenda.getAll());
ids.push(element.id)
}); });
$scope.ids = ids; }
}) ]);
});

View File

@ -23,74 +23,93 @@
</a> </a>
</div> </div>
<div class="row form-group">
<div class="row">
<div class="col-sm-8"> <div class="col-sm-8">
<!-- project agenda --> <form class="form-inline">
<a os-perms="core.can_manage_projector" class="btn btn-default btn-sm" <!-- delete mode -->
<div os-perms-lite="agenda.can_manage" class="form-group">
<label for="deleteSwitcher" translate>Delete mode</label>
<switch id="deleteSwitcher" ng-model="isDeleteMode" ng-change="uncheckAll()"
on="{{'On'|translate}}" off="{{'Off'|translate}}"
class="green wide form-control">
</switch>
</div>
<div class="form-group">
<!-- project agenda button -->
<a ng-show="!isDeleteMode" os-perms="core.can_manage_projector"
class="btn btn-default btn-sm form-control"
ng-click="projectAgenda()" ng-click="projectAgenda()"
ng-class="{ 'btn-primary': isAgendaProjected() }"> ng-class="{ 'btn-primary': isAgendaProjected() }">
<i class="fa fa-video-camera"></i> <i class="fa fa-video-camera"></i>
<translate>Project agenda</translate> <translate>Project agenda</translate>
</a> </a>
<!-- delete button -->
<a ng-show="isDeleteMode && (items|filter:{selected:true}).length > 0"
os-perms="agenda.can_manage" ng-click="delete()"
class="btn btn-primary btn-sm form-control">
<i class="fa fa-trash fa-lg"></i>
<translate>Delete selected items</translate>
</a>
</div>
</form>
</div> </div>
<div class="col-sm-4"> <div class="col-sm-4">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-filter"></i></div>
<input type="text" os-focus-me ng-model="filter.search" class="form-control" <input type="text" os-focus-me ng-model="filter.search" class="form-control"
placeholder="{{ 'Filter' | translate}}"> placeholder="{{ 'Filter' | translate}}">
</div> </div>
</div>
</div> </div>
<i>{{ items.length }} {{ "items" | translate }}</i> <i>
{{ items.length }} {{ "items" | translate }}<span ng-if="(items|filter:{selected:true}).length > 0">,
{{(items|filter:{selected:true}).length}} {{ "selected" | translate }}</span>
</i>
<table class="table table-striped table-bordered table-hover"> <table class="table table-striped table-bordered table-hover">
<thead> <thead>
<tr> <tr>
<th class="minimum"> <!-- projector column -->
<translate>Closed</translate> <th ng-show="!isDeleteMode" os-perms="core.can_manage_projector" class="firstColumn">
<!-- delete selection column -->
<th ng-show="isDeleteMode" os-perms-lite="agenda.can_manage" class="firstColumn deleteColumn"
ng-click="$event.stopPropagation();">
<input type="checkbox" ng-model="selectedAll" ng-change="checkAll()">
<!-- agenda item column -->
<th> <th>
<translate>Agenda item</translate> <translate>Agenda item</translate>
<th os-perms="agenda.can_manage"> <th os-perms="agenda.can_manage">
<translate>Duration</translate> <translate>Duration</translate>
<th os-perms="agenda.can_manage core.can_manage_projector" class="minimum"> <th class="minimum">
<translate>Actions</translate> <translate>Done</translate>
<tbody> <tbody>
<tr ng-repeat="item in items" <tr ng-repeat="item in items | filter: filter.search"
ng-class="{ 'activeline': item.isProjected() }"> ng-click="openDetail(item.id)"
<td> ng-class="{ 'activeline': item.isProjected() }"
<!-- Please do not use ng-click, but ng-change --> class="pointer">
<input type="checkbox" ng-model="item.closed" ng-click="save(item.id)"> <!-- projector column -->
<td ng-show="!isDeleteMode" os-perms="core.can_manage_projector">
<a class="btn btn-default btn-sm"
ng-class="{ 'btn-primary': item.isProjected() }"
ng-click="item.project(); $event.stopPropagation();"
title="{{ 'Project item' | translate }}">
<i class="fa fa-video-camera"></i>
</a>
<!-- delete selection column -->
<td ng-show="isDeleteMode" os-perms="agenda.can_manage" class="deleteColumn"
ng-click="$event.stopPropagation();">
<input type="checkbox" ng-model="item.selected">
<!-- agenda item column -->
<td> <td>
<span ng-repeat="n in [].constructor(item.parentCount) track by $index">&ndash;</span> <span ng-repeat="n in [].constructor(item.parentCount) track by $index">&ndash;</span>
<a ui-sref="agenda.item.detail({id: item.id})"> {{ item.item_number }} {{ item.title }}
{{ item.item_number }}
{{ item.title }}
</a>
<div ng-if="item.comment"> <div ng-if="item.comment">
<small><i class="fa fa-info-circle"></i> {{ item.comment }}</small> <small><i class="fa fa-info-circle"></i> {{ item.comment }}</small>
</div> </div>
<td os-perms="agenda.can_manage" class="optional"> <td os-perms="agenda.can_manage" class="optional">
<a href="#" editable-number="item.duration" e-min="1" onaftersave="save(item.id)">
{{ item.duration }} {{ item.duration }}
</a> <span ng-if="item.duration" translate>h</span>
<span ng-if="item.duration" translate>min</span> <td ng-click="$event.stopPropagation();">
<td os-perms="agenda.can_manage core.can_manage_projector" class="nobr"> <input type="checkbox" ng-model="item.closed" ng-change="save(item.id);">
<!-- project -->
<a os-perms="core.can_manage_projector" class="btn btn-default btn-sm"
ng-class="{ 'btn-primary': item.isProjected() }"
ng-click="item.project()"
title="{{ 'Project item' | translate }}">
<i class="fa fa-video-camera"></i>
</a>
<!-- edit -->
<a ui-sref="agenda.item.detail.update({id: item.id })" os-perms="agenda.can_manage"
class="btn btn-default btn-sm"
title="{{ 'Edit' | translate }}">
<i class="fa fa-pencil"></i>
</a>
<!-- delete -->
<a os-perms="agenda.can_manage" class="btn btn-danger btn-sm"
ng-bootbox-confirm="Are you sure you want to delete
<b>{{ item.title }}</b>?"
ng-bootbox-confirm-action="delete(item.id)"
title="{{ 'Delete' | translate }}">
<i class="fa fa-trash-o"></i>
</a>
</table> </table>

View File

@ -2,10 +2,10 @@
<h1 translate>Agenda</h1> <h1 translate>Agenda</h1>
<table class="tablelist"> <table class="tablelist">
<tr ng-repeat="id in ids"> <tr ng-repeat="item in items">
<td class="leftcolumn nobr" ng-class="{ 'closed': (items | filter: {id: id})[0].closed }"> <td class="leftcolumn nobr" ng-class="{ 'closed': item.closed }">
{{ (items | filter: {id: id})[0].item_number }} {{ item.item_number }}
<td class="rightcolumn" ng-class="{ 'closed': (items | filter: {id: id})[0].closed }"> <td class="rightcolumn" ng-class="{ 'closed': item.closed }">
{{ (items | filter: {id: id})[0].title }} {{ item.title }}
</table> </table>
</div> </div>

View File

@ -184,7 +184,7 @@ a:hover {
} }
/* List tables */ /* List tables */
th.sortable:hover { th.sortable:hover, tr.pointer:hover {
cursor: pointer; cursor: pointer;
} }
@ -246,7 +246,7 @@ tr.offline td, li.offline {
background-color: #EAEAEA !important; background-color: #EAEAEA !important;
} }
tr.activeline td, li.activeline { tr.activeline td, li.activeline {
background-color: #bed4de !important; background-color: #bed4de;
} }
.nopadding { .nopadding {
padding: 0; padding: 0;
@ -266,6 +266,19 @@ tr.total td {
.indentation { .indentation {
margin-left: 12px; margin-left: 12px;
} }
.firstColumn {
width: 55px;
}
.deleteColumn {
text-align: center;
background-color: #ff9999 !important;
}
.switch.checked {
background-color: #ff9999 !important;
border-color: #ff9999;
}
.minimum, .mini_width { .minimum, .mini_width {
width: 1px; width: 1px;
} }

View File

@ -8,6 +8,7 @@ angular.module('OpenSlidesApp.core', [
'ngAnimate', 'ngAnimate',
'ui.bootstrap', 'ui.bootstrap',
'ui.tree', 'ui.tree',
'uiSwitch',
]) ])
.config(['DSProvider', 'DSHttpAdapterProvider', function(DSProvider, DSHttpAdapterProvider) { .config(['DSProvider', 'DSHttpAdapterProvider', function(DSProvider, DSHttpAdapterProvider) {