Give motions by id in state and recommendation.
This commit is contained in:
parent
7a3d3d99d6
commit
2bdaf85b67
@ -49,6 +49,7 @@ Motions:
|
|||||||
- Improved the multiselect state filter [#3459].
|
- Improved the multiselect state filter [#3459].
|
||||||
- Added karma:watch command [#3466].
|
- Added karma:watch command [#3466].
|
||||||
- Show the number of next speakers in motion list view [#3470].
|
- Show the number of next speakers in motion list view [#3470].
|
||||||
|
- Reference to motions by id in state and recommendation special field [#3498].
|
||||||
|
|
||||||
Elections:
|
Elections:
|
||||||
- Added pagination for list view [#3393].
|
- Added pagination for list view [#3393].
|
||||||
|
@ -189,10 +189,34 @@ angular.module('OpenSlidesApp.motions', [
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
.factory('MotionStateAndRecommendationParser', [
|
||||||
|
'DS',
|
||||||
|
'gettextCatalog',
|
||||||
|
function (DS, gettextCatalog) {
|
||||||
|
return {
|
||||||
|
formatMotion: function (motion) {
|
||||||
|
return '[motion:' + motion.id + ']';
|
||||||
|
},
|
||||||
|
parse: function (recommendation) {
|
||||||
|
return recommendation.replace(/\[motion:(\d+)\]/g, function (match, id) {
|
||||||
|
var motion = DS.get('motions/motion', id);
|
||||||
|
if (motion) {
|
||||||
|
return motion.identifier ? motion.identifier : motion.getTitle();
|
||||||
|
} else {
|
||||||
|
return gettextCatalog.getString("<unknown motion>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
.factory('Motion', [
|
.factory('Motion', [
|
||||||
'DS',
|
'DS',
|
||||||
'$http',
|
'$http',
|
||||||
'MotionPoll',
|
'MotionPoll',
|
||||||
|
'MotionStateAndRecommendationParser',
|
||||||
'MotionChangeRecommendation',
|
'MotionChangeRecommendation',
|
||||||
'MotionComment',
|
'MotionComment',
|
||||||
'jsDataModel',
|
'jsDataModel',
|
||||||
@ -204,7 +228,7 @@ angular.module('OpenSlidesApp.motions', [
|
|||||||
'OpenSlidesSettings',
|
'OpenSlidesSettings',
|
||||||
'Projector',
|
'Projector',
|
||||||
'operator',
|
'operator',
|
||||||
function(DS, $http, MotionPoll, MotionChangeRecommendation, MotionComment, jsDataModel, gettext, gettextCatalog,
|
function(DS, $http, MotionPoll, MotionStateAndRecommendationParser, MotionChangeRecommendation, MotionComment, jsDataModel, gettext, gettextCatalog,
|
||||||
Config, lineNumberingService, diffService, OpenSlidesSettings, Projector, operator) {
|
Config, lineNumberingService, diffService, OpenSlidesSettings, Projector, operator) {
|
||||||
var name = 'motions/motion';
|
var name = 'motions/motion';
|
||||||
return DS.defineResource({
|
return DS.defineResource({
|
||||||
@ -399,35 +423,33 @@ angular.module('OpenSlidesApp.motions', [
|
|||||||
// depended by state and provided by a custom comment field
|
// depended by state and provided by a custom comment field
|
||||||
getStateName: function () {
|
getStateName: function () {
|
||||||
var name = '';
|
var name = '';
|
||||||
var additionalName = '';
|
|
||||||
if (this.state) {
|
if (this.state) {
|
||||||
name = gettextCatalog.getString(this.state.name);
|
name = gettextCatalog.getString(this.state.name);
|
||||||
if (this.state.show_state_extension_field) {
|
if (this.state.show_state_extension_field) {
|
||||||
// check motion comment fields for flag 'forState'
|
// check motion comment fields for flag 'forState'
|
||||||
var commentFieldForStateId = MotionComment.getFieldIdForFlag('forState');
|
var commentFieldForStateId = MotionComment.getFieldIdForFlag('forState');
|
||||||
if (commentFieldForStateId > -1) {
|
if (commentFieldForStateId > -1) {
|
||||||
additionalName = ' ' + this.comments[commentFieldForStateId];
|
name += ' ' + this.comments[commentFieldForStateId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return name + additionalName;
|
return MotionStateAndRecommendationParser.parse(name);
|
||||||
},
|
},
|
||||||
// full recommendation string - optional with custom recommendationextension
|
// full recommendation string - optional with custom recommendationextension
|
||||||
// depended by state and provided by a custom comment field
|
// depended by state and provided by a custom comment field
|
||||||
getRecommendationName: function () {
|
getRecommendationName: function () {
|
||||||
var recommendation = '';
|
var recommendation = '';
|
||||||
var additionalName = '';
|
|
||||||
if (Config.get('motions_recommendations_by').value !== '' && this.recommendation) {
|
if (Config.get('motions_recommendations_by').value !== '' && this.recommendation) {
|
||||||
recommendation = gettextCatalog.getString(this.recommendation.recommendation_label);
|
recommendation = gettextCatalog.getString(this.recommendation.recommendation_label);
|
||||||
if (this.recommendation.show_recommendation_extension_field) {
|
if (this.recommendation.show_recommendation_extension_field) {
|
||||||
// check motion comment fields for flag 'forRecommendation'
|
// check motion comment fields for flag 'forRecommendation'
|
||||||
var commentFieldForRecommendationId = MotionComment.getFieldIdForFlag('forRecommendation');
|
var commentFieldForRecommendationId = MotionComment.getFieldIdForFlag('forRecommendation');
|
||||||
if (commentFieldForRecommendationId > -1) {
|
if (commentFieldForRecommendationId > -1) {
|
||||||
additionalName = ' ' + this.comments[commentFieldForRecommendationId];
|
recommendation += ' ' + this.comments[commentFieldForRecommendationId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return recommendation + additionalName;
|
return MotionStateAndRecommendationParser.parse(recommendation);
|
||||||
},
|
},
|
||||||
// link name which is shown in search result
|
// link name which is shown in search result
|
||||||
getSearchResultName: function () {
|
getSearchResultName: function () {
|
||||||
@ -808,21 +830,6 @@ angular.module('OpenSlidesApp.motions', [
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
.factory('MotionList', [
|
|
||||||
function () {
|
|
||||||
return {
|
|
||||||
getList: function (items){
|
|
||||||
var list = [];
|
|
||||||
_.each(items, function (item) {
|
|
||||||
list.push({ id: item.id,
|
|
||||||
item: item });
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
.factory('MotionChangeRecommendation', [
|
.factory('MotionChangeRecommendation', [
|
||||||
'DS',
|
'DS',
|
||||||
'Config',
|
'Config',
|
||||||
|
@ -185,7 +185,7 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions',
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
.factory('ChangeRecommmendationCreate', [
|
.factory('ChangeRecommendationCreate', [
|
||||||
'ngDialog',
|
'ngDialog',
|
||||||
'ChangeRecommendationForm',
|
'ChangeRecommendationForm',
|
||||||
function(ngDialog, ChangeRecommendationForm) {
|
function(ngDialog, ChangeRecommendationForm) {
|
||||||
@ -366,7 +366,7 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions',
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
.factory('ChangeRecommmendationView', [
|
.factory('ChangeRecommendationView', [
|
||||||
'Motion',
|
'Motion',
|
||||||
'MotionChangeRecommendation',
|
'MotionChangeRecommendation',
|
||||||
'Config',
|
'Config',
|
||||||
|
@ -1230,8 +1230,9 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
'ngDialog',
|
'ngDialog',
|
||||||
'gettextCatalog',
|
'gettextCatalog',
|
||||||
'MotionForm',
|
'MotionForm',
|
||||||
'ChangeRecommmendationCreate',
|
'ChangeRecommendationCreate',
|
||||||
'ChangeRecommmendationView',
|
'ChangeRecommendationView',
|
||||||
|
'MotionStateAndRecommendationParser',
|
||||||
'MotionChangeRecommendation',
|
'MotionChangeRecommendation',
|
||||||
'Motion',
|
'Motion',
|
||||||
'MotionComment',
|
'MotionComment',
|
||||||
@ -1253,11 +1254,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
'WebpageTitle',
|
'WebpageTitle',
|
||||||
'EditingWarning',
|
'EditingWarning',
|
||||||
function($scope, $http, $timeout, $window, $filter, operator, ngDialog, gettextCatalog,
|
function($scope, $http, $timeout, $window, $filter, operator, ngDialog, gettextCatalog,
|
||||||
MotionForm, ChangeRecommmendationCreate, ChangeRecommmendationView,
|
MotionForm, ChangeRecommendationCreate, ChangeRecommendationView,
|
||||||
MotionChangeRecommendation, Motion, MotionComment, Category, Mediafile, Tag, User,
|
MotionStateAndRecommendationParser, MotionChangeRecommendation, Motion, MotionComment,
|
||||||
Workflow, Config, motionId, MotionInlineEditing, MotionCommentsInlineEditing, Editor,
|
Category, Mediafile, Tag, User, Workflow, Config, motionId, MotionInlineEditing,
|
||||||
Projector, ProjectionDefault, MotionBlock, MotionPdfExport, PersonalNoteManager,
|
MotionCommentsInlineEditing, Editor, Projector, ProjectionDefault, MotionBlock,
|
||||||
WebpageTitle, EditingWarning) {
|
MotionPdfExport, PersonalNoteManager, WebpageTitle, 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');
|
||||||
@ -1265,6 +1266,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
User.bindAll({}, $scope, 'users');
|
User.bindAll({}, $scope, 'users');
|
||||||
Workflow.bindAll({}, $scope, 'workflows');
|
Workflow.bindAll({}, $scope, 'workflows');
|
||||||
MotionBlock.bindAll({}, $scope, 'motionBlocks');
|
MotionBlock.bindAll({}, $scope, 'motionBlocks');
|
||||||
|
Motion.bindAll({}, $scope, 'motions');
|
||||||
$scope.$watch(function () {
|
$scope.$watch(function () {
|
||||||
return MotionChangeRecommendation.lastModified();
|
return MotionChangeRecommendation.lastModified();
|
||||||
}, function () {
|
}, function () {
|
||||||
@ -1472,6 +1474,9 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension;
|
motion['comment_' + $scope.commentFieldForRecommendationId] = recommendationExtension;
|
||||||
$scope.save(motion);
|
$scope.save(motion);
|
||||||
};
|
};
|
||||||
|
$scope.addMotionToRecommendationField = function (motion) {
|
||||||
|
$scope.recommendationExtension += MotionStateAndRecommendationParser.formatMotion(motion);
|
||||||
|
};
|
||||||
// update recommendation
|
// update recommendation
|
||||||
$scope.updateRecommendation = function (recommendation_id) {
|
$scope.updateRecommendation = function (recommendation_id) {
|
||||||
$http.put('/rest/motions/motion/' + motion.id + '/set_recommendation/', {'recommendation': recommendation_id});
|
$http.put('/rest/motions/motion/' + motion.id + '/set_recommendation/', {'recommendation': recommendation_id});
|
||||||
@ -1645,11 +1650,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Change recommendation creation functions
|
// Change recommendation creation functions
|
||||||
$scope.createChangeRecommendation = ChangeRecommmendationCreate;
|
$scope.createChangeRecommendation = ChangeRecommendationCreate;
|
||||||
$scope.createChangeRecommendation.init($scope, motion);
|
$scope.createChangeRecommendation.init($scope, motion);
|
||||||
|
|
||||||
// Change recommendation viewing
|
// Change recommendation viewing
|
||||||
$scope.viewChangeRecommendations = ChangeRecommmendationView;
|
$scope.viewChangeRecommendations = ChangeRecommendationView;
|
||||||
$scope.viewChangeRecommendations.init($scope, Config.get('motions_recommendation_text_mode').value);
|
$scope.viewChangeRecommendations.init($scope, Config.get('motions_recommendation_text_mode').value);
|
||||||
|
|
||||||
// PDF creating functions
|
// PDF creating functions
|
||||||
@ -2283,26 +2288,28 @@ angular.module('OpenSlidesApp.motions.site', [
|
|||||||
'$scope',
|
'$scope',
|
||||||
'$stateParams',
|
'$stateParams',
|
||||||
'$http',
|
'$http',
|
||||||
'MotionList',
|
|
||||||
'Category',
|
'Category',
|
||||||
'categoryId',
|
'categoryId',
|
||||||
'Motion',
|
'Motion',
|
||||||
'ErrorMessage',
|
'ErrorMessage',
|
||||||
function($scope, $stateParams, $http, MotionList, Category, categoryId, Motion, ErrorMessage) {
|
function($scope, $stateParams, $http, Category, categoryId, Motion, ErrorMessage) {
|
||||||
Category.bindOne(categoryId, $scope, 'category');
|
Category.bindOne(categoryId, $scope, 'category');
|
||||||
Motion.bindAll({}, $scope, 'motions');
|
Motion.bindAll({}, $scope, 'motions');
|
||||||
$scope.filter = { category_id: categoryId,
|
$scope.filter = { category_id: categoryId,
|
||||||
parent_id: null,
|
parent_id: null,
|
||||||
orderBy: 'identifier' };
|
orderBy: 'identifier' };
|
||||||
|
|
||||||
$scope.$watch(
|
$scope.$watch(function () {
|
||||||
function () {
|
|
||||||
return Motion.lastModified();
|
return Motion.lastModified();
|
||||||
},
|
}, function () {
|
||||||
function () {
|
var motions = Motion.filter($scope.filter);
|
||||||
$scope.items = MotionList.getList(Motion.filter($scope.filter));
|
$scope.items = _.map(motions, function (motion) {
|
||||||
}
|
return {
|
||||||
);
|
id: motion.id,
|
||||||
|
item: motion
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$scope.alert = {};
|
$scope.alert = {};
|
||||||
// Numbers all motions in this category by the given order in $scope.items
|
// Numbers all motions in this category by the given order in $scope.items
|
||||||
|
@ -224,7 +224,7 @@
|
|||||||
<label class="sr-only" for="recommendationExtensionField">
|
<label class="sr-only" for="recommendationExtensionField">
|
||||||
{{ commentsFields[commentFieldForRecommendationId].name }}
|
{{ commentsFields[commentFieldForRecommendationId].name }}
|
||||||
</label>
|
</label>
|
||||||
<input type="text" ng-model="recommendationExtension"
|
<input type="text" ng-model="$parent.$parent.recommendationExtension"
|
||||||
id="recommendationExtensionField" class="form-control input-sm"
|
id="recommendationExtensionField" class="form-control input-sm"
|
||||||
placeholder="{{ commentsFields[commentFieldForRecommendationId].name }}">
|
placeholder="{{ commentsFields[commentFieldForRecommendationId].name }}">
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
@ -232,6 +232,21 @@
|
|||||||
<i class="fa fa-check"></i>
|
<i class="fa fa-check"></i>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<span uib-dropdown>
|
||||||
|
<span id="motion-dropdown" class="drop-down-name btn btn-default btn-sm" uib-dropdown-toggle>
|
||||||
|
<i class="fa fa-plus"></i>
|
||||||
|
<translate>Motion</translate>
|
||||||
|
</span>
|
||||||
|
<ul uib-dropdown-menu class="dropdown-menu" aria-labelledby="motion-dropdown">
|
||||||
|
<li ng-repeat="m in motions">
|
||||||
|
<a href ng-click="addMotionToRecommendationField(m)">
|
||||||
|
{{ m.identifier ? m.identifier + ':' : '' }} {{ m.getTitle() }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
ng-if="motion.recommendation &&
|
ng-if="motion.recommendation &&
|
||||||
|
Loading…
Reference in New Issue
Block a user