Fixed poll required users and motion state extension selector

This commit is contained in:
Finn Stutzenstein 2020-08-11 13:20:08 +02:00
parent ccc3e38427
commit d682d0d134
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
5 changed files with 39 additions and 38 deletions

View File

@ -669,7 +669,6 @@ export class DataStoreService {
public print(): void { public print(): void {
console.log('Max change id', this.maxChangeId); console.log('Max change id', this.maxChangeId);
console.log('json storage');
console.log(JSON.stringify(this.jsonStore)); console.log(JSON.stringify(this.jsonStore));
console.log(this.modelStore); console.log(this.modelStore);
} }

View File

@ -38,7 +38,7 @@
(keydown)="keyDownFunction($event)" (keydown)="keyDownFunction($event)"
/> />
</mat-form-field> </mat-form-field>
<mat-form-field *ngIf="searchList"> <mat-form-field *ngIf="searchList" [formGroup]="extensionFieldForm">
<os-search-value-selector <os-search-value-selector
formControlName="list" formControlName="list"
[inputListValues]="searchList" [inputListValues]="searchList"

View File

@ -153,22 +153,20 @@ export class ExtensionFieldComponent implements OnInit, OnDestroy {
list: [[]] list: [[]]
}); });
this.searchValueSubscription = this.extensionFieldForm this.searchValueSubscription = this.extensionFieldForm.get('list').valueChanges.subscribe((value: any) => {
.get('list') if (value && typeof value === 'number') {
.valueChanges.subscribe((value: number) => { if (this.listSubmitOnChange) {
if (value) { this.listChange.emit(value);
if (this.listSubmitOnChange) {
this.listChange.emit(value);
}
if (this.appendValueToInput) {
if (!this.inputControl) {
this.inputControl = '';
}
this.inputControl += `[${this.listValuePrefix}${value}${this.listValueSuffix}]`;
}
this.extensionFieldForm.reset();
} }
}); if (this.appendValueToInput) {
if (!this.inputControl) {
this.inputControl = '';
}
this.inputControl += `[${this.listValuePrefix}${value}${this.listValueSuffix}]`;
}
this.extensionFieldForm.reset();
}
});
} }
} }

View File

@ -55,7 +55,11 @@ class AssignmentsAppConfig(AppConfig):
) )
required_user.add_collection_string( required_user.add_collection_string(
self.get_model("AssignmentPoll").get_collection_string(), self.get_model("AssignmentPoll").get_collection_string(),
required_users_options, required_users_assignment_polls,
)
required_user.add_collection_string(
self.get_model("AssignmentOption").get_collection_string(),
required_users_assignment_options,
) )
def get_config_variables(self): def get_config_variables(self):
@ -82,28 +86,23 @@ async def required_users_assignments(element: Dict[str, Any]) -> Set[int]:
Returns all user ids that are displayed as candidates (including poll Returns all user ids that are displayed as candidates (including poll
options) in the assignment element. options) in the assignment element.
""" """
from openslides.assignments.models import AssignmentOption, AssignmentPoll
from openslides.utils.cache import element_cache
candidates = set( return set(
related_user["user_id"] for related_user in element["assignment_related_users"] related_user["user_id"] for related_user in element["assignment_related_users"]
) )
for poll_id in element["polls_id"]:
poll = await element_cache.get_element_data(
AssignmentPoll.get_collection_string(), poll_id
)
if poll:
for option_id in poll["options_id"]:
option = await element_cache.get_element_data(
AssignmentOption.get_collection_string(), option_id
)
if option:
candidates.add(option["user_id"])
return candidates
async def required_users_options(element: Dict[str, Any]) -> Set[int]: async def required_users_assignment_polls(element: Dict[str, Any]) -> Set[int]:
""" """
Returns all user ids that have voted on an option and are therefore required for the single votes table. Returns all user ids that have voted on an option and are therefore required for the single votes table.
""" """
return element["voted_id"] from openslides.poll.models import BasePoll
if element["state"] == BasePoll.STATE_PUBLISHED:
return element["voted_id"]
else:
return set()
async def required_users_assignment_options(element: Dict[str, Any]) -> Set[int]:
return set([element["user_id"]])

View File

@ -84,7 +84,7 @@ class MotionsAppConfig(AppConfig):
required_user.add_collection_string( required_user.add_collection_string(
self.get_model("MotionPoll").get_collection_string(), self.get_model("MotionPoll").get_collection_string(),
required_users_options, required_users_motion_polls,
) )
def get_config_variables(self): def get_config_variables(self):
@ -126,8 +126,13 @@ async def required_users_motions(element: Dict[str, Any]) -> Set[int]:
return submitters_supporters return submitters_supporters
async def required_users_options(element: Dict[str, Any]) -> Set[int]: async def required_users_motion_polls(element: Dict[str, Any]) -> Set[int]:
""" """
Returns all user ids that have voted on an option and are therefore required for the single votes table. Returns all user ids that have voted on an option and are therefore required for the single votes table.
""" """
return element["voted_id"] from openslides.poll.models import BasePoll
if element["state"] == BasePoll.STATE_PUBLISHED:
return element["voted_id"]
else:
return set()