Improved forms in ng-dialogs.
- users: use form field in grid layout and add more option to reduce scrolling of long dialog. - agenda/motions/assignment: show parent agenda item field for create dialog only (to prevent corrupt agenda by action 'set my child item as my new parent item') - refactor ng dialog and formly code.
This commit is contained in:
parent
fb646df1fd
commit
e865cfe105
@ -152,8 +152,8 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
};
|
||||
},
|
||||
// angular-formly fields for assignment form
|
||||
getFormFields: function () {
|
||||
return [
|
||||
getFormFields: function (isCreateForm) {
|
||||
var formFields = [
|
||||
{
|
||||
key: 'title',
|
||||
type: 'input',
|
||||
@ -193,8 +193,11 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
description: gettextCatalog.getString('If deactivated the election appears as internal item on agenda.')
|
||||
},
|
||||
hide: !operator.hasPerms('assignments.can_manage')
|
||||
},
|
||||
{
|
||||
}];
|
||||
|
||||
// parent item
|
||||
if (isCreateForm) {
|
||||
formFields.push({
|
||||
key: 'agenda_parent_item_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -204,7 +207,11 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
placeholder: gettextCatalog.getString('Select a parent item ...')
|
||||
},
|
||||
hide: !operator.hasPerms('agenda.can_manage')
|
||||
},
|
||||
});
|
||||
}
|
||||
// more (with tags field)
|
||||
if (Tag.getAll().length > 0) {
|
||||
formFields.push(
|
||||
{
|
||||
key: 'more',
|
||||
type: 'checkbox',
|
||||
@ -213,6 +220,10 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
},
|
||||
hide: !operator.hasPerms('assignments.can_manage')
|
||||
},
|
||||
{
|
||||
template: '<hr class="smallhr">',
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
key: 'tags_id',
|
||||
type: 'select-multiple',
|
||||
@ -223,7 +234,11 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a tag ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
}];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return formFields;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -588,7 +603,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
// set default value for open posts form field
|
||||
$scope.model.open_posts = 1;
|
||||
// get all form fields
|
||||
$scope.formFields = AssignmentForm.getFormFields();
|
||||
$scope.formFields = AssignmentForm.getFormFields(true);
|
||||
// save assignment
|
||||
$scope.save = function(assignment) {
|
||||
Assignment.create(assignment).then(
|
||||
|
@ -1196,6 +1196,16 @@ img {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.no-padding {
|
||||
padding: 0 !important;
|
||||
}
|
||||
.no-padding-left {
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
.no-padding-right {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
/* user details */
|
||||
.user_details fieldset {
|
||||
margin-bottom: 10px;
|
||||
@ -1292,16 +1302,42 @@ img {
|
||||
}
|
||||
|
||||
.ngdialog.ngdialog-theme-default.wide-form .ngdialog-content {
|
||||
width: 650px;
|
||||
width: 750px;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
.ngdialog h2 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.ngdialog .row:after, .ngdialog .row:before {
|
||||
display: table-cell !important;
|
||||
}
|
||||
|
||||
.help-block {
|
||||
font-size: 85%;
|
||||
margin-top: 2px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
/* angular-chosen: override default width of select fields in quickmode */
|
||||
.chosen-container {
|
||||
width: 100% !important;
|
||||
font-size: 14px;
|
||||
}
|
||||
.chosen-container .chosen-choices {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.chosen-container-active .chosen-choices {
|
||||
border-color: rgba(82,168,236,.8);
|
||||
box-shadow: 0 0 8px rgba(82,168,236,.6);
|
||||
}
|
||||
.chosen-container .chosen-choices li.search-choice {
|
||||
margin: 6px 5px 0 0 !important;
|
||||
}
|
||||
.chosen-container input {
|
||||
margin: 4px 0 !important;
|
||||
}
|
||||
|
||||
/* angular-ui-tree style */
|
||||
|
@ -412,7 +412,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
};
|
||||
},
|
||||
// angular-formly fields for motion form
|
||||
getFormFields: function () {
|
||||
getFormFields: function (isCreateForm) {
|
||||
var workflows = Workflow.getAll();
|
||||
var images = Mediafile.getAllImages();
|
||||
var formFields = [
|
||||
@ -481,8 +481,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
description: gettextCatalog.getString('If deactivated the motion appears as internal item on agenda.')
|
||||
},
|
||||
hide: !operator.hasPerms('motions.can_manage')
|
||||
},
|
||||
{
|
||||
}];
|
||||
|
||||
// parent item
|
||||
if (isCreateForm) {
|
||||
formFields.push({
|
||||
key: 'agenda_parent_item_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -492,9 +495,14 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select a parent item ...')
|
||||
},
|
||||
hide: !operator.hasPerms('agenda.can_manage')
|
||||
}]
|
||||
.concat(MotionComment.getFormFields())
|
||||
.concat([
|
||||
});
|
||||
}
|
||||
|
||||
// motion comments
|
||||
formFields = formFields.concat(MotionComment.getFormFields());
|
||||
|
||||
// more
|
||||
formFields.push(
|
||||
{
|
||||
key: 'more',
|
||||
type: 'checkbox',
|
||||
@ -504,6 +512,13 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
hide: !operator.hasPerms('motions.can_manage')
|
||||
},
|
||||
{
|
||||
template: '<hr class="smallhr">',
|
||||
hideExpression: '!model.more'
|
||||
}
|
||||
);
|
||||
// attachments
|
||||
if (Mediafile.getAll().length > 0) {
|
||||
formFields.push({
|
||||
key: 'attachments_id',
|
||||
type: 'select-multiple',
|
||||
templateOptions: {
|
||||
@ -513,8 +528,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search an attachment ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
// category
|
||||
if (Category.getAll().length > 0) {
|
||||
formFields.push({
|
||||
key: 'category_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -524,8 +542,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a category ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
// motion block
|
||||
if (MotionBlock.getAll().length > 0) {
|
||||
formFields.push({
|
||||
key: 'motion_block_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -535,16 +556,20 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a motion block ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
// origin
|
||||
formFields.push({
|
||||
key: 'origin',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Origin'),
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
});
|
||||
// tags
|
||||
if (Tag.getAll().length > 0) {
|
||||
formFields.push({
|
||||
key: 'tags_id',
|
||||
type: 'select-multiple',
|
||||
templateOptions: {
|
||||
@ -554,8 +579,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a tag ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
// supporters
|
||||
if (Config.get('motions_min_supporters') > 0) {
|
||||
formFields.push({
|
||||
key: 'supporters_id',
|
||||
type: 'select-multiple',
|
||||
templateOptions: {
|
||||
@ -565,11 +593,11 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a supporter ...')
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
}]);
|
||||
|
||||
});
|
||||
}
|
||||
// workflows
|
||||
if (workflows.length > 1) {
|
||||
formFields = formFields.concat([
|
||||
{
|
||||
formFields.push({
|
||||
key: 'workflow_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -580,8 +608,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
placeholder: gettextCatalog.getString('Select or search a workflow ...')
|
||||
},
|
||||
hideExpression: '!model.more',
|
||||
}
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
return formFields;
|
||||
@ -1323,7 +1350,7 @@ angular.module('OpenSlidesApp.motions.site', [
|
||||
// ... preselect default workflow
|
||||
$scope.model.workflow_id = Config.get('motions_workflow').value;
|
||||
// get all form fields
|
||||
$scope.formFields = MotionForm.getFormFields();
|
||||
$scope.formFields = MotionForm.getFormFields(true);
|
||||
|
||||
// save motion
|
||||
$scope.save = function (motion) {
|
||||
|
@ -96,9 +96,9 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics'])
|
||||
resolve: (resolve) ? resolve : null
|
||||
};
|
||||
},
|
||||
getFormFields: function () {
|
||||
getFormFields: function (isCreateForm) {
|
||||
var images = Mediafile.getAllImages();
|
||||
return [
|
||||
var formFields = [
|
||||
{
|
||||
key: 'title',
|
||||
type: 'input',
|
||||
@ -116,8 +116,10 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics'])
|
||||
data: {
|
||||
tinymceOption: Editor.getOptions(images)
|
||||
}
|
||||
},
|
||||
{
|
||||
}];
|
||||
// attachments
|
||||
if (Mediafile.getAll().length > 0) {
|
||||
formFields.push({
|
||||
key: 'attachments_id',
|
||||
type: 'select-multiple',
|
||||
templateOptions: {
|
||||
@ -126,16 +128,21 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics'])
|
||||
ngOptions: 'option.id as option.title_or_filename for option in to.options',
|
||||
placeholder: gettextCatalog.getString('Select or search an attachment ...')
|
||||
}
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
// show as agenda item
|
||||
formFields.push({
|
||||
key: 'showAsAgendaItem',
|
||||
type: 'checkbox',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Show as agenda item'),
|
||||
description: gettextCatalog.getString('If deactivated it appears as internal item on agenda.')
|
||||
}
|
||||
},
|
||||
{
|
||||
});
|
||||
|
||||
// parent item
|
||||
if (isCreateForm) {
|
||||
formFields.push({
|
||||
key: 'agenda_parent_item_id',
|
||||
type: 'select-single',
|
||||
templateOptions: {
|
||||
@ -144,7 +151,10 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics'])
|
||||
ngOptions: 'item.id as item.getListViewTitle() for item in to.options | notself : model.agenda_item_id',
|
||||
placeholder: gettextCatalog.getString('Select a parent item ...')
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
return formFields;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -187,7 +197,7 @@ angular.module('OpenSlidesApp.topics.site', ['OpenSlidesApp.topics'])
|
||||
$scope.model = {};
|
||||
$scope.model.showAsAgendaItem = true;
|
||||
// get all form fields
|
||||
$scope.formFields = TopicForm.getFormFields();
|
||||
$scope.formFields = TopicForm.getFormFields(true);
|
||||
// save form
|
||||
$scope.save = function (topic) {
|
||||
Topic.create(topic).then(
|
||||
|
@ -293,24 +293,20 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
var images = Mediafile.getAllImages();
|
||||
return [
|
||||
{
|
||||
key: 'username',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Username')
|
||||
},
|
||||
hide: hideOnCreateForm
|
||||
},
|
||||
className: "row",
|
||||
fieldGroup: [
|
||||
{
|
||||
key: 'title',
|
||||
type: 'input',
|
||||
className: "col-xs-2 no-padding-left",
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Title'),
|
||||
description: gettextCatalog.getString('Will be shown before the name.')
|
||||
label: gettextCatalog.getString('Title')
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'first_name',
|
||||
type: 'input',
|
||||
className: "col-xs-5 no-padding",
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('First name')
|
||||
}
|
||||
@ -318,23 +314,40 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
{
|
||||
key: 'last_name',
|
||||
type: 'input',
|
||||
className: "col-xs-5 no-padding-right",
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Last name')
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
className: "row",
|
||||
fieldGroup: [
|
||||
{
|
||||
key: 'structure_level',
|
||||
type: 'input',
|
||||
className: "col-xs-9 no-padding-left",
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Structure level'),
|
||||
description: gettextCatalog.getString('Will be shown after the name.')
|
||||
}
|
||||
},
|
||||
{ key: 'number',
|
||||
type: 'input',
|
||||
className: "col-xs-3 no-padding-left no-padding-right",
|
||||
templateOptions: {
|
||||
label:gettextCatalog.getString('Participant number')
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'username',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Username')
|
||||
},
|
||||
hide: hideOnCreateForm
|
||||
},
|
||||
{
|
||||
key: 'groups_id',
|
||||
@ -368,19 +381,20 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('Comment'),
|
||||
description: gettextCatalog.getString('Only for notes.')
|
||||
description: gettextCatalog.getString('Only for internal notes.')
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'about_me',
|
||||
type: 'editor',
|
||||
key: 'more',
|
||||
type: 'checkbox',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('About me'),
|
||||
},
|
||||
data: {
|
||||
tinymceOption: Editor.getOptions(images)
|
||||
label: gettextCatalog.getString('Show extended fields')
|
||||
}
|
||||
},
|
||||
{
|
||||
template: '<hr class="smallhr">',
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
key: 'is_present',
|
||||
type: 'checkbox',
|
||||
@ -388,7 +402,8 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
label: gettextCatalog.getString('Is present'),
|
||||
description: gettextCatalog.getString('Designates whether this user is in the room or not.')
|
||||
},
|
||||
defaultValue: true
|
||||
defaultValue: true,
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
key: 'is_active',
|
||||
@ -399,7 +414,8 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
'Designates whether this user should be treated as ' +
|
||||
'active. Unselect this instead of deleting the account.')
|
||||
},
|
||||
defaultValue: true
|
||||
defaultValue: true,
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
key: 'is_committee',
|
||||
@ -409,8 +425,21 @@ angular.module('OpenSlidesApp.users.site', [
|
||||
description: gettextCatalog.getString(
|
||||
'Designates whether this user should be treated as a committee.')
|
||||
},
|
||||
defaultValue: false
|
||||
}];
|
||||
defaultValue: false,
|
||||
hideExpression: '!model.more'
|
||||
},
|
||||
{
|
||||
key: 'about_me',
|
||||
type: 'editor',
|
||||
templateOptions: {
|
||||
label: gettextCatalog.getString('About me'),
|
||||
},
|
||||
data: {
|
||||
tinymceOption: Editor.getOptions(images)
|
||||
},
|
||||
hideExpression: '!model.more'
|
||||
}
|
||||
];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user