Personal note: client rework
This commit is contained in:
parent
91d365e386
commit
c80b0abc82
@ -805,12 +805,13 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
'MotionPartialContentProvider',
|
'MotionPartialContentProvider',
|
||||||
'PdfCreate',
|
'PdfCreate',
|
||||||
'PDFLayout',
|
'PDFLayout',
|
||||||
|
'PersonalNoteManager',
|
||||||
'Messaging',
|
'Messaging',
|
||||||
'FileSaver',
|
'FileSaver',
|
||||||
function ($http, $q, operator, Config, gettextCatalog, MotionChangeRecommendation, HTMLValidizer,
|
function ($http, $q, operator, Config, gettextCatalog, MotionChangeRecommendation, HTMLValidizer,
|
||||||
PdfMakeConverter, MotionContentProvider, MotionCatalogContentProvider, PdfMakeDocumentProvider,
|
PdfMakeConverter, MotionContentProvider, MotionCatalogContentProvider, PdfMakeDocumentProvider,
|
||||||
PollContentProvider, PdfMakeBallotPaperProvider, MotionPartialContentProvider, PdfCreate,
|
PollContentProvider, PdfMakeBallotPaperProvider, MotionPartialContentProvider, PdfCreate,
|
||||||
PDFLayout, Messaging, FileSaver) {
|
PDFLayout, PersonalNoteManager, Messaging, FileSaver) {
|
||||||
return {
|
return {
|
||||||
getDocumentProvider: function (motions, params, singleMotion) {
|
getDocumentProvider: function (motions, params, singleMotion) {
|
||||||
params = _.clone(params || {}); // Clone this to avoid sideeffects.
|
params = _.clone(params || {}); // Clone this to avoid sideeffects.
|
||||||
@ -941,9 +942,7 @@ angular.module('OpenSlidesApp.motions.pdf', ['OpenSlidesApp.core.pdf'])
|
|||||||
PdfCreate.download(documentProvider.getDocument(), filename);
|
PdfCreate.download(documentProvider.getDocument(), filename);
|
||||||
},
|
},
|
||||||
exportPersonalNote: function (motion, filename) {
|
exportPersonalNote: function (motion, filename) {
|
||||||
var personalNote = _.find(motion.personal_notes, function (note) {
|
var personalNote = PersonalNoteManager.getNote(motion);
|
||||||
return note.user_id === operator.user.id;
|
|
||||||
});
|
|
||||||
var content = [{
|
var content = [{
|
||||||
heading: gettextCatalog.getString('Personal note'),
|
heading: gettextCatalog.getString('Personal note'),
|
||||||
text: personalNote ? personalNote.note : '',
|
text: personalNote ? personalNote.note : '',
|
||||||
|
@ -873,9 +873,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
'osTableSort',
|
'osTableSort',
|
||||||
'MotionExportForm',
|
'MotionExportForm',
|
||||||
'MotionPdfExport',
|
'MotionPdfExport',
|
||||||
|
'PersonalNoteManager',
|
||||||
function($scope, $state, $http, gettext, gettextCatalog, operator, ngDialog, MotionForm, Motion,
|
function($scope, $state, $http, gettext, gettextCatalog, operator, ngDialog, MotionForm, Motion,
|
||||||
MotionComment, Category, Config, Tag, Workflow, User, Agenda, MotionBlock, Projector,
|
MotionComment, Category, Config, Tag, Workflow, User, Agenda, MotionBlock, Projector,
|
||||||
ProjectionDefault, osTableFilter, osTableSort, MotionExportForm, MotionPdfExport) {
|
ProjectionDefault, osTableFilter, osTableSort, MotionExportForm, MotionPdfExport,
|
||||||
|
PersonalNoteManager) {
|
||||||
Category.bindAll({}, $scope, 'categories');
|
Category.bindAll({}, $scope, 'categories');
|
||||||
MotionBlock.bindAll({}, $scope, 'motionBlocks');
|
MotionBlock.bindAll({}, $scope, 'motionBlocks');
|
||||||
Tag.bindAll({}, $scope, 'tags');
|
Tag.bindAll({}, $scope, 'tags');
|
||||||
@ -895,9 +897,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
}, function () {
|
}, function () {
|
||||||
$scope.motions = Motion.getAll();
|
$scope.motions = Motion.getAll();
|
||||||
_.forEach($scope.motions, function (motion) {
|
_.forEach($scope.motions, function (motion) {
|
||||||
motion.personalNote = _.find(motion.personal_notes, function (note) {
|
motion.personalNote = PersonalNoteManager.getNote(motion);
|
||||||
return note.user_id === operator.user.id;
|
|
||||||
});
|
|
||||||
// For filtering, we cannot filter for .personalNote.star
|
// For filtering, we cannot filter for .personalNote.star
|
||||||
motion.star = motion.personalNote ? motion.personalNote.star : false;
|
motion.star = motion.personalNote ? motion.personalNote.star : false;
|
||||||
});
|
});
|
||||||
@ -1089,9 +1089,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
} else {
|
} else {
|
||||||
motion.personalNote = {star: true};
|
motion.personalNote = {star: true};
|
||||||
}
|
}
|
||||||
$http.put('/rest/motions/motion/' + motion.id + '/set_personal_note/',
|
PersonalNoteManager.saveNote(motion, motion.personalNote);
|
||||||
motion.personalNote
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// open new/edit dialog
|
// open new/edit dialog
|
||||||
@ -1191,12 +1189,13 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
'ProjectionDefault',
|
'ProjectionDefault',
|
||||||
'MotionBlock',
|
'MotionBlock',
|
||||||
'MotionPdfExport',
|
'MotionPdfExport',
|
||||||
|
'PersonalNoteManager',
|
||||||
'EditingWarning',
|
'EditingWarning',
|
||||||
function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm,
|
function($scope, $http, $timeout, operator, ngDialog, gettextCatalog, MotionForm,
|
||||||
ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation,
|
ChangeRecommmendationCreate, ChangeRecommmendationView, MotionChangeRecommendation,
|
||||||
Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing,
|
Motion, MotionComment, Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing,
|
||||||
MotionCommentsInlineEditing, Projector, ProjectionDefault, MotionBlock, MotionPdfExport,
|
MotionCommentsInlineEditing, Projector, ProjectionDefault, MotionBlock, MotionPdfExport,
|
||||||
EditingWarning) {
|
PersonalNoteManager, EditingWarning) {
|
||||||
var motion = Motion.get(motionId);
|
var motion = Motion.get(motionId);
|
||||||
Category.bindAll({}, $scope, 'categories');
|
Category.bindAll({}, $scope, 'categories');
|
||||||
Mediafile.bindAll({}, $scope, 'mediafiles');
|
Mediafile.bindAll({}, $scope, 'mediafiles');
|
||||||
@ -1231,9 +1230,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
}, function () {
|
}, function () {
|
||||||
$scope.motion = Motion.get(motionId);
|
$scope.motion = Motion.get(motionId);
|
||||||
MotionComment.populateFields($scope.motion);
|
MotionComment.populateFields($scope.motion);
|
||||||
$scope.motion.personalNote = _.find($scope.motion.personal_notes, function (note) {
|
$scope.motion.personalNote = PersonalNoteManager.getNote($scope.motion);
|
||||||
return note.user_id === operator.user.id;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
$scope.projectionModes = [
|
$scope.projectionModes = [
|
||||||
{mode: 'original',
|
{mode: 'original',
|
||||||
@ -1462,21 +1459,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
} else {
|
} else {
|
||||||
$scope.motion.personalNote = {star: true};
|
$scope.motion.personalNote = {star: true};
|
||||||
}
|
}
|
||||||
$http.put('/rest/motions/motion/' + $scope.motion.id + '/set_personal_note/',
|
PersonalNoteManager.saveNote($scope.motion, $scope.motion.personalNote);
|
||||||
$scope.motion.personalNote
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
// personal note
|
|
||||||
$scope.toggleStar = function () {
|
|
||||||
if ($scope.motion.personalNote) {
|
|
||||||
$scope.motion.personalNote.star = !$scope.motion.personalNote.star;
|
|
||||||
} else {
|
|
||||||
$scope.motion.personalNote = {star: true};
|
|
||||||
}
|
|
||||||
$http.put('/rest/motions/motion/' + $scope.motion.id + '/set_personal_note/',
|
|
||||||
$scope.motion.personalNote
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Inline editing functions
|
// Inline editing functions
|
||||||
@ -1516,9 +1499,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
} else {
|
} else {
|
||||||
motion.personalNote = {note: obj.editor.getData()};
|
motion.personalNote = {note: obj.editor.getData()};
|
||||||
}
|
}
|
||||||
$http.put('/rest/motions/motion/' + $scope.motion.id + '/set_personal_note/',
|
PersonalNoteManager.saveNote(motion, motion.personalNote);
|
||||||
motion.personalNote
|
|
||||||
);
|
|
||||||
obj.revert();
|
obj.revert();
|
||||||
obj.disable();
|
obj.disable();
|
||||||
return true; // Do not update the motion via patch request.
|
return true; // Do not update the motion via patch request.
|
||||||
|
@ -131,9 +131,10 @@ angular.module('OpenSlidesApp.users', [])
|
|||||||
'$http',
|
'$http',
|
||||||
'DS',
|
'DS',
|
||||||
function($http, DS) {
|
function($http, DS) {
|
||||||
|
var name = 'users/group';
|
||||||
var permissions;
|
var permissions;
|
||||||
return DS.defineResource({
|
return DS.defineResource({
|
||||||
name: 'users/group',
|
name: name,
|
||||||
permissions: permissions,
|
permissions: permissions,
|
||||||
// TODO (Issue 2862): Do not query the permissions from server. They should be included
|
// TODO (Issue 2862): Do not query the permissions from server. They should be included
|
||||||
// in the startup data. Then remove 'permission' injection from group list controller.
|
// in the startup data. Then remove 'permission' injection from group list controller.
|
||||||
@ -150,13 +151,31 @@ angular.module('OpenSlidesApp.users', [])
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
.factory('PersonalNote', [
|
||||||
|
'DS',
|
||||||
|
function (DS) {
|
||||||
|
var name = 'users/personal-note';
|
||||||
|
return DS.defineResource({
|
||||||
|
name: name,
|
||||||
|
relations: {
|
||||||
|
hasOne: {
|
||||||
|
'users/user': {
|
||||||
|
localField: 'user',
|
||||||
|
localKey: 'user_id',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
.run([
|
.run([
|
||||||
'User',
|
'User',
|
||||||
'Group',
|
'Group',
|
||||||
|
'PersonalNote',
|
||||||
function(User, Group) {}
|
function(User, Group) {}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
// Mark strings for translation in JavaScript.
|
// Mark strings for translation in JavaScript.
|
||||||
.config([
|
.config([
|
||||||
'gettext',
|
'gettext',
|
||||||
|
@ -203,6 +203,53 @@ angular.module('OpenSlidesApp.users.site', [
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
.factory('PersonalNoteManager', [
|
||||||
|
'PersonalNote',
|
||||||
|
'operator',
|
||||||
|
function (PersonalNote, operator) {
|
||||||
|
var _getPersonalNoteObject = function (resourceName) {
|
||||||
|
var personalNote = _.find(PersonalNote.getAll(), function (pn) {
|
||||||
|
return pn.user_id === operator.user.id;
|
||||||
|
});
|
||||||
|
if (!personalNote) {
|
||||||
|
personalNote = {
|
||||||
|
notes: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!personalNote.notes[resourceName]) {
|
||||||
|
personalNote.notes[resourceName] = {};
|
||||||
|
}
|
||||||
|
return personalNote;
|
||||||
|
};
|
||||||
|
var get = function (resourceName, id) {
|
||||||
|
return _getPersonalNoteObject(resourceName).notes[resourceName][id];
|
||||||
|
};
|
||||||
|
var save = function (resourceName, id, note) {
|
||||||
|
var personalNote = _getPersonalNoteObject(resourceName);
|
||||||
|
personalNote.notes[resourceName][id] = note;
|
||||||
|
if (personalNote.id) {
|
||||||
|
return PersonalNote.save(personalNote);
|
||||||
|
} else {
|
||||||
|
return PersonalNote.create(personalNote);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
getNote: function (obj) {
|
||||||
|
if (typeof obj.getResourceName === 'undefined') {
|
||||||
|
throw 'The Object has to be a js data model!';
|
||||||
|
}
|
||||||
|
return get(obj.getResourceName(), obj.id);
|
||||||
|
},
|
||||||
|
saveNote: function (obj, note) {
|
||||||
|
if (typeof obj.getResourceName === 'undefined') {
|
||||||
|
throw 'The Object has to be a js data model!';
|
||||||
|
}
|
||||||
|
return save(obj.getResourceName(), obj.id, note);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
// Service for generic assignment form (create and update)
|
// Service for generic assignment form (create and update)
|
||||||
.factory('UserForm', [
|
.factory('UserForm', [
|
||||||
'$http',
|
'$http',
|
||||||
|
Loading…
Reference in New Issue
Block a user