Merge pull request #1835 from emanuelschuetze/templateFixes3

A lot of template fixes
This commit is contained in:
Emanuel Schütze 2016-01-13 10:24:47 +01:00
commit bc17baa2b9
30 changed files with 320 additions and 217 deletions

View File

@ -101,7 +101,7 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
// detail view of related item (content object)
$scope.open = function (item) {
$state.go(item.content_object.collection.replace('/','.')+'.detail',
{id: item.content_object.id});
{id: item.content_object.id});
};
// save changed item
$scope.save = function (item) {
@ -183,10 +183,11 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
'$scope',
'$filter',
'$http',
'$state',
'Agenda',
'User',
'item',
function ($scope, $filter, $http, Agenda, User, item) {
function ($scope, $filter, $http, $state, Agenda, User, item) {
Agenda.bindOne(item.id, $scope, 'item');
User.bindAll({}, $scope, 'users');
$scope.speakerSelectBox = {};
@ -198,6 +199,13 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.speakers = $filter('orderBy')(item.speakers, 'weight');
});
// go to detail view of related item (content object)
$scope.open = function (item) {
$state.go(item.content_object.collection.replace('/','.')+'.detail',
{id: item.content_object.id});
};
// close/open list of speakers of current item
$scope.closeList = function (listClosed) {
item.speaker_list_closed = listClosed;

View File

@ -3,7 +3,11 @@
<div class="submenu">
<a ui-sref="agenda.item.list" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to agenda</translate>
<translate>Agenda</translate>
</a>
<a href="" ng-click="open(item)" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
{{item.getContentResource().verboseName}}
</a>
<!-- project list of speakers -->
<a os-perms="core.can_manage_projector" class="btn btn-default btn-sm"

View File

@ -146,10 +146,10 @@
<a ui-sref="agenda.item.detail({id: item.id})" translate>List of speakers</a> |
<a href="" ng-click="item.quickEdit=true" translate>QuickEdit</a> |
<a href="" ng-click="editDialog(item)" translate>Edit</a>
<!-- TODO: translate confirm message -->
<span ng-if="item.content_object.collection == 'core/customslide'"> |
<a href="" class="text-danger"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ item.getTitle() }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ item.getTitle() }}</b>"
ng-bootbox-confirm-action="deleteRelatedItem(item)" translate>Delete</a>
</span>
</div>
@ -159,7 +159,7 @@
<td ng-if="!item.quickEdit">
<input type="checkbox" ng-model="item.closed" ng-change="save(item.id);">
<!-- quickEdit columns -->
<td ng-if="$parent.item.quickEdit" os-perms="agenda.can_manage" colspan="3">
<td ng-show="item.quickEdit" os-perms="agenda.can_manage" colspan="3">
<form ng-submit="save(item)">
<h4>{{ item.getTitle() }} <span class="text-muted">&ndash; QuickEdit</span></h4>
<alert ng-show="alert.show" type="{{ alert.type }}" ng-click="alert={}" close="alert={}">

View File

@ -79,7 +79,8 @@ angular.module('OpenSlidesApp.assignments', [])
return DS.defineResource({
name: name,
useClass: jsDataModel,
agendaSupplement: gettext('Election'),
verboseName: gettext('Election'),
agendaSupplement: this.verboseName,
phases: phases,
getPhases: function () {
if (!this.phases) {

View File

@ -50,24 +50,54 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
}
}
})
// redirects to assignment detail and opens assignment edit form dialog, uses edit url,
// used by ui-sref links from agenda only
// (from assignment controller use AssignmentForm factory instead to open dialog in front
// of current view without redirect)
.state('assignments.assignment.detail.update', {
onEnter: ['$stateParams', 'ngDialog', 'Assignment', function($stateParams, ngDialog, Assignment) {
ngDialog.open({
template: 'static/templates/assignments/assignment-form.html',
controller: 'AssignmentUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: { assignment: function() {
return Assignment.find($stateParams.id) }}
});
}]
onEnter: ['$stateParams', '$state', 'ngDialog', 'Assignment',
function($stateParams, $state, ngDialog, Assignment) {
ngDialog.open({
template: 'static/templates/assignments/assignment-form.html',
controller: 'AssignmentUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: {
assignment: function() {return Assignment.find($stateParams.id)}
},
preCloseCallback: function() {
$state.go('assignments.assignment.detail', {assignment: $stateParams.id});
return true;
}
});
}
]
});
})
// Provide generic assignment form fields for create and update view
.factory('AssignmentFormFieldFactory', [
// Service for generic assignment form (create and update)
.factory('AssignmentForm', [
'gettextCatalog',
function (gettextCatalog) {
return {
// ngDialog for assignment form
getDialog: function (assignment) {
if (assignment) {
var resolve = {
assignment: function(Assignment) {return Assignment.find(assignment.id);}
};
}
return {
template: 'static/templates/assignments/assignment-form.html',
controller: (assignment) ? 'AssignmentUpdateCtrl' : 'AssignmentCreateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: (resolve) ? resolve : null
}
},
// angular-formly fields for assignment form
getFormFields: function () {
return [
{
@ -143,9 +173,10 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
.controller('AssignmentListCtrl', [
'$scope',
'ngDialog',
'AssignmentForm',
'Assignment',
'phases',
function($scope, ngDialog, Assignment, phases) {
function($scope, ngDialog, AssignmentForm, Assignment, phases) {
Assignment.bindAll({}, $scope, 'assignments');
// get all item types via OPTIONS request
$scope.phases = phases.data.actions.POST.phase.choices;
@ -163,26 +194,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
$scope.sortColumn = column;
};
// open new dialog
$scope.newDialog = function () {
ngDialog.open({
template: 'static/templates/assignments/assignment-form.html',
controller: 'AssignmentCreateCtrl',
className: 'ngdialog-theme-default wide-form'
});
};
// open edit dialog
$scope.editDialog = function (assignment) {
ngDialog.open({
template: 'static/templates/assignments/assignment-form.html',
controller: 'AssignmentUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
assignment: function(Assignment) {
return Assignment.find(assignment.id);
}
}
});
// open new/edit dialog
$scope.openDialog = function (assignment) {
ngDialog.open(AssignmentForm.getDialog(assignment));
};
// save changed assignment
$scope.save = function (assignment) {
@ -237,16 +251,22 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'$http',
'gettext',
'ngDialog',
'AssignmentForm',
'operator',
'Assignment',
'User',
'assignment',
function($scope, $http, gettext, ngDialog, operator, Assignment, User, assignment) {
function($scope, $http, gettext, ngDialog, AssignmentForm, operator, Assignment, User, assignment) {
User.bindAll({}, $scope, 'users');
Assignment.bindOne(assignment.id, $scope, 'assignment');
Assignment.loadRelations(assignment, 'agenda_item');
$scope.candidateSelectBox = {};
$scope.alert = {};
// open edit dialog
$scope.openDialog = function (assignment) {
ngDialog.open(AssignmentForm.getDialog(assignment));
};
// add (nominate) candidate
$scope.addCandidate = function (userId) {
$http.post('/rest/assignments/assignment/' + assignment.id + '/candidature_other/', {'user': userId})
@ -369,13 +389,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'$scope',
'$state',
'Assignment',
'AssignmentFormFieldFactory',
function($scope, $state, Assignment, AssignmentFormFieldFactory) {
'AssignmentForm',
function($scope, $state, Assignment, AssignmentForm) {
$scope.model = {};
// set default value for open posts form field
$scope.model.open_posts = 1;
// get all form fields
$scope.formFields = AssignmentFormFieldFactory.getFormFields();
$scope.formFields = AssignmentForm.getFormFields();
// save assignment
$scope.save = function(assignment) {
@ -392,13 +412,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'$scope',
'$state',
'Assignment',
'AssignmentFormFieldFactory',
'AssignmentForm',
'assignment',
function($scope, $state, Assignment, AssignmentFormFieldFactory, assignment) {
function($scope, $state, Assignment, AssignmentForm, assignment) {
// set initial values for form model
$scope.model = assignment;
// get all form fields
$scope.formFields = AssignmentFormFieldFactory.getFormFields();
$scope.formFields = AssignmentForm.getFormFields();
// save assignment
$scope.save = function (assignment) {

View File

@ -3,7 +3,7 @@
<div class="submenu">
<a ui-sref="assignments.assignment.list" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to overview</translate>
<translate>All elections</translate>
</a>
<a ui-sref="assignments_single_pdf({pk: assignment.id})" target="_blank" class="btn btn-default btn-sm">
<i class="fa fa-file-pdf-o fa-lg"></i>
@ -22,7 +22,7 @@
<i class="fa fa-video-camera"></i>
</a>
<!-- edit -->
<a ui-sref="assignments.assignment.detail.update({id: assignment.id })" os-perms="assignments.can_manage"
<a os-perms="assignments.can_manage" ng-click="openDialog(assignment)"
class="btn btn-default btn-sm"
title="{{ 'Edit' | translate}}">
<i class="fa fa-pencil"></i>
@ -30,8 +30,11 @@
</div>
<h1>{{ assignment.title }}</h1>
<h2>
<translate>Election</translate> &ndash;
<translate>Agenda</translate>: {{ assignment.agenda_item.item_number }}
<translate>Election</translate>
<span ng-if="assignment.agenda_item.item_number">
&ndash;
<translate>Agenda</translate>: {{ assignment.agenda_item.item_number }}
</span>
</h2>
</div>
</div>

View File

@ -4,7 +4,7 @@
<form name="assignmentForm" ng-submit="save(model)">
<formly-form model="model" fields="formFields">
<button type="submit" ng-disabled="assignmentForm.$invalid" class="btn btn-primary" translate>
Submit
Save
</button>
<button ng-click="closeThisDialog()" class="btn btn-default" translate>
Cancel

View File

@ -1,7 +1,7 @@
<div class="header">
<div class="title">
<div class="submenu">
<a ng-click="newDialog()" os-perms="assignments.can_manage" class="btn btn-primary btn-sm">
<a ng-click="openDialog()" os-perms="assignments.can_manage" class="btn btn-primary btn-sm">
<i class="fa fa-plus fa-lg"></i>
<translate>New</translate>
</a>
@ -115,11 +115,11 @@
<td ng-if="!assignment.quickEdit" ng-mouseover="assignment.hover=true" ng-mouseleave="assignment.hover=false">
<strong><a ui-sref="assignments.assignment.detail({id: assignment.id})">{{ assignment.title }}</a></strong>
<div os-perms="assignments.can_manage" class="hoverActions" ng-class="{'hiddenDiv': !assignment.hover}">
<a href="" ng-click="editDialog(assignment)" translate>Edit</a> |
<a href="" ng-click="openDialog(assignment)" translate>Edit</a> |
<a href="" ng-click="assignment.quickEdit=true" translate>QuickEdit</a> |
<!-- TODO: translate confirm message -->
<a href="" class="text-danger"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ assignment.title }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ assignment.title }}</b>"
ng-bootbox-confirm-action="delete(assignment)" translate>Delete</a>
</div>
<td ng-if="!assignment.quickEdit" class="optional">
@ -164,7 +164,7 @@
<button ng-click="save(assignment)" class="btn btn-primary" translate>
Update
</button>
<a href="" ng-click="editDialog(assignment)"
<a href="" ng-click="openDialog(assignment)"
class="pull-right" translate>Edit election ...</a>
</div>
</table>

View File

@ -3,7 +3,7 @@
<form name="assignmentpollForm" ng-submit="save(model)">
<formly-form model="model" fields="formFields">
<button type="submit" ng-disabled="assignmentForm.$invalid" class="btn btn-primary" translate>
Submit
Save
</button>
<button ng-click="closeThisDialog()" class="btn btn-default" translate>
Cancel

View File

@ -167,11 +167,13 @@ angular.module('OpenSlidesApp.core', [
.factory('Customslide', [
'DS',
'jsDataModel',
function(DS, jsDataModel) {
'gettext',
function(DS, jsDataModel, gettext) {
var name = 'core/customslide';
return DS.defineResource({
name: name,
useClass: jsDataModel,
verboseName: gettext('Agenda item'),
methods: {
getResourceName: function () {
return name;

View File

@ -258,6 +258,13 @@ angular.module('OpenSlidesApp.core.site', [
}
})
.state('core.tag.create', {})
.state('core.tag.detail', {
resolve: {
tag: function(Tag, $stateParams) {
return Tag.find($stateParams.id);
}
}
})
.state('core.tag.detail.update', {
views: {
'@core.tag': {}
@ -747,7 +754,6 @@ angular.module('OpenSlidesApp.core.site', [
Tag.save(tag);
};
$scope.delete = function (tag) {
//TODO: add confirm message
Tag.destroy(tag.id).then(
function(success) {
//TODO: success message
@ -756,6 +762,10 @@ angular.module('OpenSlidesApp.core.site', [
};
})
.controller('TagDetailCtrl', function($scope, Tag, tag) {
Tag.bindOne(tag.id, $scope, 'tag');
})
.controller('TagCreateCtrl', function($scope, $state, Tag) {
$scope.tag = {};
$scope.save = function (tag) {

View File

@ -4,7 +4,7 @@
<form name="customslideForm" ng-submit="save(model)">
<formly-form model="model" fields="formFields">
<button type="submit" ng-disabled="customslideForm.$invalid" class="btn btn-primary" translate>
Submit
Save
</button>
<button ng-click="closeThisDialog()" class="btn btn-default" translate>
Cancel

View File

@ -0,0 +1,14 @@
<div class="header">
<div class="title">
<div class="submenu">
<a ui-sref="core.tag.list" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to overview</translate>
</a>
</div>
<h1>{{ tag.name }}</h1>
<h2 translate>Tag</h2>
</div>
</div>
<div class="details"></div>

View File

@ -34,9 +34,9 @@
<strong>{{ tag.name }}</strong>
<div class="hoverActions" ng-class="{'hiddenDiv': !tag.hover}">
<a ui-sref="core.tag.detail.update({id: tag.id })" translate>Edit</a> |
<!-- TODO: translate confirm message -->
<a href="" class="text-danger"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ tag.name }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ tag.name }}</b>"
ng-bootbox-confirm-action="delete(tag)" translate>Delete</a>
</div>
</table>

View File

@ -109,7 +109,6 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
]);
function uploadFile($timeout, $scope, $state, operator, Upload, mediafile) {
console.log(operator.user);
return function(file) {
file.upload = Upload.upload({
url: '/rest/mediafiles/mediafile/' + (mediafile ? mediafile.id : ''),

View File

@ -168,7 +168,8 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users'])
return DS.defineResource({
name: name,
useClass: jsDataModel,
agendaSupplement: gettext('Motion'),
verboseName: gettext('Motion'),
agendaSupplement: this.verboseName,
methods: {
getResourceName: function () {
return name;

View File

@ -64,16 +64,29 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
}
}
})
// redirects to motion detail and opens motion edit form dialog, uses edit url,
// used by ui-sref links from agenda only
// (from motion controller use MotionForm factory instead to open dialog in front of
// current view without redirect)
.state('motions.motion.detail.update', {
onEnter: ['$stateParams', 'ngDialog', 'Motion', function($stateParams, ngDialog, Motion) {
ngDialog.open({
template: 'static/templates/motions/motion-form.html',
controller: 'MotionUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: { motion: function() {
return Motion.find($stateParams.id) }}
});
}]
onEnter: ['$stateParams', '$state', 'ngDialog', 'Motion',
function($stateParams, $state, ngDialog, Motion) {
ngDialog.open({
template: 'static/templates/motions/motion-form.html',
controller: 'MotionUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: {
motion: function() {return Motion.find($stateParams.id)}
},
preCloseCallback: function() {
$state.go('motions.motion.detail', {motion: $stateParams.id});
return true;
}
});
}
]
})
.state('motions.motion.import', {
url: '/import',
@ -118,8 +131,8 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
});
})
// Provide generic motion form fields for create and update view
.factory('MotionFormFieldFactory', [
// Service for generic motion form (create and update)
.factory('MotionForm', [
'gettextCatalog',
'operator',
'Category',
@ -130,6 +143,23 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'Workflow',
function (gettextCatalog, operator, Category, Config, Mediafile, Tag, User, Workflow) {
return {
// ngDialog for motion form
getDialog: function (motion) {
if (motion) {
var resolve = {
motion: function(Motion) { return Motion.find(motion.id); }
};
}
return {
template: 'static/templates/motions/motion-form.html',
controller: (motion) ? 'MotionUpdateCtrl' : 'MotionCreateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: (resolve) ? resolve : null
}
},
// angular-formly fields for motion form
getFormFields: function () {
return [
{
@ -266,12 +296,13 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'$scope',
'$state',
'ngDialog',
'MotionForm',
'Motion',
'Category',
'Tag',
'Workflow',
'User',
function($scope, $state, ngDialog, Motion, Category, Tag, Workflow, User) {
function($scope, $state, ngDialog, MotionForm, Motion, Category, Tag, Workflow, User) {
Motion.bindAll({}, $scope, 'motions');
Category.bindAll({}, $scope, 'categories');
Tag.bindAll({}, $scope, 'tags');
@ -318,26 +349,9 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
});
});
// open new dialog
$scope.newDialog = function () {
ngDialog.open({
template: 'static/templates/motions/motion-form.html',
controller: 'MotionCreateCtrl',
className: 'ngdialog-theme-default wide-form'
});
};
// open edit dialog
$scope.editDialog = function (motion) {
ngDialog.open({
template: 'static/templates/motions/motion-form.html',
controller: 'MotionUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
motion: function(Motion) {
return Motion.find(motion.id);
}
}
});
// open new/edit dialog
$scope.openDialog = function (motion) {
ngDialog.open(MotionForm.getDialog(motion));
};
// save changed motion
$scope.save = function (motion) {
@ -396,6 +410,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'$scope',
'$http',
'ngDialog',
'MotionForm',
'Motion',
'Category',
'Mediafile',
@ -403,7 +418,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'User',
'Workflow',
'motion',
function($scope, $http, ngDialog, Motion, Category, Mediafile, Tag, User, Workflow, motion) {
function($scope, $http, ngDialog, MotionForm, Motion, Category, Mediafile, Tag, User, Workflow, motion) {
Motion.bindOne(motion.id, $scope, 'motion');
Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles');
@ -411,24 +426,13 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
User.bindAll({}, $scope, 'users');
Workflow.bindAll({}, $scope, 'workflows');
Motion.loadRelations(motion, 'agenda_item');
// TODO: make 'motion.attachments' useable and itteratable in template
// Motion.loadRelations(motion, 'attachments');
$scope.alert = {};
$scope.isCollapsed = true;
// open edit dialog
$scope.editDialog = function (motion) {
ngDialog.open({
template: 'static/templates/motions/motion-form.html',
controller: 'MotionUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
motion: function(Motion) {
return Motion.find(motion.id);
}
}
});
$scope.openDialog = function (motion) {
ngDialog.open(MotionForm.getDialog(motion));
};
$scope.support = function () {
@ -437,8 +441,8 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.unsupport = function () {
$http.delete('/rest/motions/motion/' + motion.id + '/support/');
}
$scope.update_state = function (state) {
$http.put('/rest/motions/motion/' + motion.id + '/set_state/', {'state': state.id});
$scope.updateState = function (state_id) {
$http.put('/rest/motions/motion/' + motion.id + '/set_state/', {'state': state_id});
}
$scope.reset_state = function (state_id) {
$http.put('/rest/motions/motion/' + motion.id + '/set_state/', {});
@ -483,14 +487,14 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'$state',
'gettext',
'Motion',
'MotionFormFieldFactory',
'MotionForm',
'Category',
'Config',
'Mediafile',
'Tag',
'User',
'Workflow',
function($scope, $state, gettext, Motion, MotionFormFieldFactory, Category, Config, Mediafile, Tag, User, Workflow) {
function($scope, $state, gettext, Motion, MotionForm, Category, Config, Mediafile, Tag, User, Workflow) {
Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles');
Tag.bindAll({}, $scope, 'tags');
@ -504,7 +508,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
// ... preselect default workflow
$scope.model.workflow_id = Config.get('motions_workflow').value;
// get all form fields
$scope.formFields = MotionFormFieldFactory.getFormFields();
$scope.formFields = MotionForm.getFormFields();
for (var i = 0; i < $scope.formFields.length; i++) {
if ($scope.formFields[i].key == "identifier") {
$scope.formFields[i].hide = true;
@ -528,12 +532,12 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
'Category',
'Config',
'Mediafile',
'MotionFormFieldFactory',
'MotionForm',
'Tag',
'User',
'Workflow',
'motion',
function($scope, $state, Motion, Category, Config, Mediafile, MotionFormFieldFactory, Tag, User, Workflow, motion) {
function($scope, $state, Motion, Category, Config, Mediafile, MotionForm, Tag, User, Workflow, motion) {
Category.bindAll({}, $scope, 'categories');
Mediafile.bindAll({}, $scope, 'mediafiles');
Tag.bindAll({}, $scope, 'tags');
@ -544,7 +548,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
$scope.model = motion;
$scope.model.more = false;
// get all form fields
$scope.formFields = MotionFormFieldFactory.getFormFields();
$scope.formFields = MotionForm.getFormFields();
// override default values for update form
for (var i = 0; i < $scope.formFields.length; i++) {
if ($scope.formFields[i].key == "identifier") {
@ -567,7 +571,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
// get saved workflow id from state
$scope.formFields[i].defaultValue = motion.state.workflow_id;
}
}
}
// save motion
$scope.save = function (motion) {
@ -755,6 +759,17 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
.controller('CategoryListCtrl', function($scope, Category) {
Category.bindAll({}, $scope, 'categories');
// setup table sorting
$scope.sortColumn = 'name';
$scope.reverse = false;
// function to sort by clicked column
$scope.toggleSort = function ( column ) {
if ( $scope.sortColumn === column ) {
$scope.reverse = !$scope.reverse;
}
$scope.sortColumn = column;
};
// delete selected category
$scope.delete = function (category) {
Category.destroy(category.id);

View File

@ -7,6 +7,7 @@
</a>
</div>
<h1>{{ category.name }}</h1>
<h2 translate>Category</h2>
</div>
</div>

View File

@ -25,32 +25,29 @@
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th ng-click="sortby='prefix';reverse=!reverse">
<translate>Prefix</translate>
<i class="fa" ng-show="sortby == 'prefix'"
ng-class="reverse ? 'fa-caret-down' : 'fa-caret-up'"></i>
<th ng-click="sortby='name';reverse=!reverse">
<th ng-click="toggleSort('name')" class="sortable">
<translate>Name</translate>
<i class="fa" ng-show="sortby == 'name'"
ng-class="reverse ? 'fa-caret-down' : 'fa-caret-up'"></i>
<th os-perms="motions.can_manage core.can_manage_projector" class="mini_width" translate>Actions</th>
<i class="pull-right fa" ng-show="sortColumn === 'name' && header.sortable != false"
ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
</i>
<th ng-click="toggleSort('prefix')" class="sortable">
<translate>Prefix</translate>
<i class="pull-right fa" ng-show="sortColumn === 'prefix' && header.sortable != false"
ng-class="reverse ? 'fa-sort-desc' : 'fa-sort-asc'">
</i>
<tbody>
<tr ng-repeat="category in categories | filter: filter.search | orderBy:sortby:reverse">
<tr ng-repeat="category in categories | filter: filter.search | orderBy: sortColumn:reverse">
<td ng-mouseover="category.hover=true" ng-mouseleave="category.hover=false">
<strong>{{ category.name }}</strong>
<div class="hoverActions" ng-class="{'hiddenDiv': !category.hover}">
<!-- edit -->
<a ui-sref="motions.category.detail.update({id: category.id })" translate>Edit</a> |
<!-- delete -->
<a href="" class="text-danger"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ category.name }}</b>"
ng-bootbox-confirm-action="delete(category)" translate>Delete</a>
</div>
<td>{{ category.prefix }}
<td><a ui-sref="motions.category.detail({id: category.id})">{{ category.name }}</a>
<td os-perms="motions.can_manage" class="nobr minimum">
<!-- edit -->
<a ui-sref="motions.category.detail.update({id: category.id})" os-perms="motions.can_manage"
class="btn btn-default btn-sm"
title="{{ 'Edit' | translate }}">
<i class="fa fa-pencil"></i>
</a>
<!-- delete -->
<a os-perms="motions.can_manage" class="btn btn-danger btn-sm"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ category.name }}</b>?"
ng-bootbox-confirm-action="delete(category)"
title="{{ 'Delete' | translate }}">
<i class="fa fa-trash-o"></i>
</a>
</table>
</div>

View File

@ -1,10 +1,9 @@
<div class="header">
<div class="title">
<!-- TODO: show list of speakers controls for { motion.agenda_item } -->
<div class="submenu">
<a ui-sref="motions.motion.list" class="btn btn-sm btn-default">
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to overview</translate>
<translate>All motions</translate>
</a>
<a ui-sref="motions_single_pdf({pk: motion.id})" target="_blank" class="btn btn-default btn-sm">
<i class="fa fa-file-pdf-o fa-lg"></i>
@ -23,7 +22,7 @@
<i class="fa fa-video-camera"></i>
</a>
<!-- edit -->
<a ng-if="motion.isAllowed('update')" ui-sref="motions.motion.detail.update({id: motion.id })"
<a ng-if="motion.isAllowed('update')" ng-click="openDialog(motion)"
class="btn btn-default btn-sm"
title="{{ 'Edit' | translate}}">
<i class="fa fa-pencil"></i>
@ -33,8 +32,10 @@
<h2>
<translate>Motion</translate> {{ motion.identifier }}
<span ng-if="motion.versions.length > 1" >| Version {{ motion.active_version }}</span>
&ndash;
<translate>Agenda</translate>: {{ motion.agenda_item.item_number }}
<span ng-if="motion.agenda_item.item_number">
&ndash;
<translate>Agenda</translate>: {{ motion.agenda_item.item_number }}
</span>
</h2>
</div>
</div>
@ -86,24 +87,22 @@
{{ motion.state.name | translate }}
</span>
<div ng-if="motion.isAllowed('change_state')" class="spacer">
<div class="btn-group-vertical spacer" role="group">
<button ng-repeat="state in motion.state.getNextStates()" ng-click="update_state(state)"
class="btn btn-default btn-sm">
{{state.action_word}}
</button>
<button ng-if="motion.isAllowed('reset_state')" ng-click="reset_state()"
class="btn btn-danger btn-xs">
<i class="fa fa-exclamation-triangle"></i>
<translate>Reset state</translate>
</button>
</div>
<select ng-if="motion.state.getNextStates().length > 0" ng-model="stateSelect" class="form-control" ng-change="updateState(stateSelect)">
<option value="" translate>--- Set next state ---</option>
<option ng-repeat="state in motion.state.getNextStates()" value="{{ state.id }}">{{ state.action_word }}</option>
</select>
<button ng-if="motion.isAllowed('reset_state')" ng-click="reset_state()"
class="btn btn-danger btn-xs spacer">
<i class="fa fa-exclamation-triangle"></i>
<translate>Reset state</translate>
</button>
</div>
</div>
<div class="col-sm-3">
<h3 ng-if="motion.polls.length > 0" translate>Voting result</h3>
<ol class="slimlist">
<li ng-repeat="poll in motion.polls" class="spacer">
<translate>Vote</translate>
<translate translate-context="ballot">Vote</translate>
<button os-perms="motions.can_manage" ng-click="$parent.poll.isEditMode=true;"
class="btn btn-default btn-xs">
<i class="fa fa-pencil"></i>

View File

@ -4,7 +4,7 @@
<form name="motionForm" ng-submit="save(model)">
<formly-form model="model" fields="formFields">
<button type="submit" ng-disabled="motionForm.$invalid" class="btn btn-primary" translate>
Submit
Save
</button>
<button ng-click="closeThisDialog()" class="btn btn-default" translate>
Cancel

View File

@ -1,7 +1,7 @@
<div class="header">
<div class="title">
<div class="submenu">
<a ng-click="newDialog()" os-perms="motions.can_create" class="btn btn-primary btn-sm">
<a ng-click="openDialog()" os-perms="motions.can_create" class="btn btn-primary btn-sm">
<i class="fa fa-plus fa-lg"></i>
<translate>New</translate>
</a>
@ -131,17 +131,20 @@
<td ng-if="!motion.quickEdit">{{ motion.identifier }}
<td ng-if="!motion.quickEdit" ng-mouseover="motion.hover=true" ng-mouseleave="motion.hover=false">
<strong><a ui-sref="motions.motion.detail({id: motion.id})">{{ motion.getTitle() }}</a></strong>
<span ng-repeat="tag in motion.tags" class="label label-default">
{{ tag.name }}{{$last ? '' : ', '}}
</span>
<div ng-if="motion.isAllowed('update')" class="hoverActions" ng-class="{'hiddenDiv': !motion.hover}">
<span ng-if="motion.isAllowed('update')">
<a href="" ng-click="editDialog(motion)" translate>Edit</a>
<a href="" ng-click="openDialog(motion)" translate>Edit</a>
</span>
<span ng-if="motion.isAllowed('quickedit')">
| <a href="" ng-click="motion.quickEdit=true" translate>QuickEdit</a> |
</span>
<span ng-if="motion.isAllowed('delete')">
<!-- TODO: translate confirm message -->
<a href="" class="text-danger"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ motion.getTitle() }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ motion.getTitle() }}</b>"
ng-bootbox-confirm-action="delete(motion)" translate>Delete</a>
</span>
</div>

View File

@ -1,4 +1,12 @@
<div ng-controller="SlideMotionCtrl" class="content scrollcontent">
<h1>{{ motion.getTitle() }}</h1>
<div class="white-space-pre-line">{{ motion.getText() }}</div>
<div ng-bind-html="motion.getText()"></div>
<h2 ng-if="motion.getReason()" translate>Reason</h2>
<div ng-bind-html="motion.getReason()"></div>
<h2 ng-if="motion.submitters" translate>Submitters</h2>
<div ng-repeat="submitter in motion.submitters">
{{ submitter.get_full_name() }}<br>
</div>
</div>

View File

@ -53,16 +53,6 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
}
}
})
.state('users.user.detail.update', {
views: {
'@users.user': {}
},
resolve: {
groups: function(Group) {
return Group.findAll();
}
}
})
.state('users.user.detail.profile', {
views: {
'@users.user': {},
@ -275,13 +265,30 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
}
])
// Provide generic user form fields for create and update view
.factory('UserFormFieldFactory', [
// Service for generic assignment form (create and update)
.factory('UserForm', [
'$http',
'gettextCatalog',
'Group',
function ($http, gettextCatalog, Group) {
return {
// ngDialog for user form
getDialog: function (user) {
if (user) {
var resolve = {
user: function(User) {return User.find(user.id);}
};
}
return {
template: 'static/templates/users/user-form.html',
controller: (user) ? 'UserUpdateCtrl' : 'UserCreateCtrl',
className: 'ngdialog-theme-default wide-form',
closeByEscape: false,
closeByDocument: false,
resolve: (resolve) ? resolve : null
}
},
// angular-formly fields for user form
getFormFields: function () {
return [
{
@ -336,7 +343,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
label: gettextCatalog.getString('Default password'),
addonRight: { text: 'Reset', class: 'fa fa-undo', onClick:
function (options, scope) {
$http.post('/rest/users/user/' + scope.model.id + '/reset_password/', {})
$http.post(
'/rest/users/user/' + scope.model.id + '/reset_password/',
{'password': scope.model.default_password})
}
}
}
@ -385,9 +394,10 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
'$scope',
'$state',
'ngDialog',
'UserForm',
'User',
'Group',
function($scope, $state, ngDialog, User, Group) {
function($scope, $state, ngDialog, UserForm, User, Group) {
User.bindAll({}, $scope, 'users');
Group.bindAll({}, $scope, 'groups');
$scope.alert = {};
@ -404,26 +414,9 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
$scope.sortColumn = column;
};
// open new dialog
$scope.newDialog = function () {
ngDialog.open({
template: 'static/templates/users/user-form.html',
controller: 'UserCreateCtrl',
className: 'ngdialog-theme-default wide-form'
});
};
// open edit dialog
$scope.editDialog = function (user) {
ngDialog.open({
template: 'static/templates/users/user-form.html',
controller: 'UserUpdateCtrl',
className: 'ngdialog-theme-default wide-form',
resolve: {
user: function(User) {
return User.find(user.id);
}
}
});
// open new/edit dialog
$scope.openDialog = function (user) {
ngDialog.open(UserForm.getDialog(user));
};
// save changed user
$scope.save = function (user) {
@ -475,12 +468,19 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
.controller('UserDetailCtrl', [
'$scope',
'ngDialog',
'UserForm',
'User',
'user',
'Group',
function($scope, User, user, Group) {
function($scope, ngDialog, UserForm, User, user, Group) {
User.bindOne(user.id, $scope, 'user');
Group.bindAll({}, $scope, 'groups');
// open edit dialog
$scope.openDialog = function (user) {
ngDialog.open(UserForm.getDialog(user));
};
}
])
@ -488,12 +488,12 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
'$scope',
'$state',
'User',
'UserFormFieldFactory',
'UserForm',
'Group',
function($scope, $state, User, UserFormFieldFactory, Group) {
function($scope, $state, User, UserForm, Group) {
Group.bindAll({where: {id: {'>': 2}}}, $scope, 'groups');
// get all form fields
$scope.formFields = UserFormFieldFactory.getFormFields();
$scope.formFields = UserForm.getFormFields();
// save user
$scope.save = function (user) {
@ -514,15 +514,15 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
'$state',
'$http',
'User',
'UserFormFieldFactory',
'UserForm',
'Group',
'user',
function($scope, $state, $http, User, UserFormFieldFactory, Group, user) {
function($scope, $state, $http, User, UserForm, Group, user) {
Group.bindAll({where: {id: {'>': 2}}}, $scope, 'groups');
// set initial values for form model
$scope.model = user;
// get all form fields
$scope.formFields = UserFormFieldFactory.getFormFields();
$scope.formFields = UserForm.getFormFields();
// save user
$scope.save = function (user) {

View File

@ -52,7 +52,8 @@
</a>
<!-- delete -->
<a os-perms="users.can_manage" class="btn btn-danger btn-sm"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ group.name }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ group.name }}</b>"
ng-bootbox-confirm-action="delete(group)"
title="{{ 'Delete' | translate }}">
<i class="fa fa-trash-o"></i>

View File

@ -13,7 +13,7 @@
<i class="fa fa-video-camera"></i>
</a>
<!-- edit -->
<a ui-sref="users.user.detail.update({id: user.id })" os-perms="users.can_manage"
<a os-perms="users.can_manage" ng-click="openDialog(user)"
class="btn btn-default btn-sm"
title="{{ 'Edit' | translate}}">
<i class="fa fa-pencil"></i>

View File

@ -4,7 +4,7 @@
<form name="userForm" ng-submit="save(model)">
<formly-form model="model" fields="formFields">
<button type="submit" ng-disabled="userForm.$invalid" class="btn btn-primary" translate>
Submit
Save
</button>
<button ng-click="closeThisDialog()" class="btn btn-default" translate>
Cancel

View File

@ -1,7 +1,7 @@
<div class="header">
<div class="title">
<div class="submenu">
<a ng-click="newDialog()" os-perms="users.can_manage" class="btn btn-primary btn-sm">
<a ng-click="openDialog()" os-perms="users.can_manage" class="btn btn-primary btn-sm">
<i class="fa fa-user-plus fa-lg"></i>
<translate>New</translate>
</a>
@ -137,10 +137,10 @@
<small><i class="fa fa-info-circle"></i> {{ user.comment }}</small>
</div>
<div os-perms="users.can_manage" class="hoverActions" ng-class="{'hiddenDiv': !user.hover}">
<a href="" ng-click="editDialog(user)" translate>Edit</a> |
<!-- TODO: translate confirm message -->
<a href="" ng-click="openDialog(user)" translate>Edit</a> |
<a href="" class="text-danger"
ng-bootbox-confirm="Are you sure you want to delete <b>{{ user.get_short_name() }}</b>?"
ng-bootbox-confirm="{{ 'Are you sure you want to delete this entry?' | translate }}<br>
<b>{{ user.get_short_name() }}</b>"
ng-bootbox-confirm-action="delete(user)" translate>Delete</a>
</div>
<td class="optional">{{ user.structure_level }}

View File

@ -153,9 +153,11 @@ class UserViewSet(ModelViewSet):
@detail_route(methods=['post'])
def reset_password(self, request, pk=None):
"""
View to reset the password (using the default password).
View to reset the password using the requested password.
"""
user = self.get_object()
if request.data.get('password'):
user.default_password = request.data['password']
user.set_password(user.default_password)
user.save()
return Response({'detail': _('Password successfully reset.')})

View File

@ -165,9 +165,24 @@ class UserResetPassword(TestCase):
user = User.objects.create(username='Test name ooMoa4ou4mohn2eo1ree')
user.default_password = 'new_password_Yuuh8OoQueePahngohy3'
user.save()
response = admin_client.post(reverse('user-reset-password', args=[user.pk]))
response = admin_client.post(
reverse('user-reset-password', args=[user.pk]),
{'password': 'new_password_Yuuh8OoQueePahngohy3_new'})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertTrue(User.objects.get(pk=user.pk).check_password('new_password_Yuuh8OoQueePahngohy3'))
self.assertTrue(User.objects.get(pk=user.pk).check_password(
'new_password_Yuuh8OoQueePahngohy3_new'))
def test_reset_to_default(self):
admin_client = APIClient()
admin_client.login(username='admin', password='admin')
user = User.objects.create(username='Test name ooMoa4ou4mohn2eo1ree')
user.default_password = 'new_password_Yuuh8OoQueePahngohy3'
user.save()
response = admin_client.post(
reverse('user-reset-password', args=[user.pk]), {})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertTrue(User.objects.get(pk=user.pk).check_password(
'new_password_Yuuh8OoQueePahngohy3'))
class GroupReceive(TestCase):