This commit is contained in:
Andrei Prigorshnev 2024-04-02 00:57:46 +04:00
parent 572a9a4223
commit 1343702a27
No known key found for this signature in database
GPG Key ID: 185E0A5F45783902
4 changed files with 25 additions and 12 deletions

View File

@ -3,4 +3,4 @@
@note={{@model.note}}
@status={{@model.status}}
@onSubmit={{this.assign}}
@showAssigneeError={{this.assigneeError}}/>
@showValidationErrors={{this.showValidationErrors}}/>

View File

@ -9,16 +9,22 @@ export default class AssignUserForm extends Component {
@service capabilities;
@tracked assigneeError = false;
@tracked showValidationErrors = false;
constructor() {
super(...arguments);
this.args.formApi.submit = this.assign;
}
get assigneeIsEmpty() {
return !this.args.model.username && !this.args.model.group_name;
}
@action
async assign() {
if (!(this.args.model.username || this.args.model.group_name)) {
this.assigneeError = true;
if (this.assigneeIsEmpty) {
this.showValidationErrors = true;
return;
}

View File

@ -1,4 +1,4 @@
<div class="control-group {{if @showAssigneeError 'assignee-error'}}">
<div class="control-group {{if this.showAssigneeIeEmptyError 'assignee-error'}}">
<label>{{i18n "discourse_assign.assign_modal.assignee_label"}}</label>
<AssigneeChooser
autocomplete="off"
@ -21,7 +21,7 @@
}}
/>
{{#if @showAssigneeError}}
{{#if this.showAssigneeIeEmptyError}}
<span class="error-label">
{{d-icon "exclamation-triangle"}}
{{i18n "discourse_assign.assign_modal.choose_assignee"}}

View File

@ -14,11 +14,23 @@ export default class Assignment extends Component {
}
get status() {
return this.args.status || this.#assignStatuses[0];
return this.args.status || this.assignStatuses[0];
}
get assignStatuses() {
return this.siteSettings.assign_statuses.split("|");
}
get assignStatusOptions() {
return this.#assignStatuses.map((status) => ({ id: status, name: status }));
return this.assignStatuses.map((status) => ({ id: status, name: status }));
}
get assigneeIsEmpty() {
return !this.args.model.username && !this.args.model.group_name;
}
get showAssigneeIeEmptyError() {
return this.assigneeIsEmpty && this.args.showValidationErrors;
}
@action
@ -31,7 +43,6 @@ export default class Assignment extends Component {
@action
setAssignee([newAssignee]) {
this.assignee = newAssignee;
// this.args.showAssigneeError = false;
if (this.taskActions.allowedGroupsForAssignment.includes(newAssignee)) {
this.args.model.username = null;
@ -41,8 +52,4 @@ export default class Assignment extends Component {
this.args.model.group_name = null;
}
}
get #assignStatuses() {
return this.siteSettings.assign_statuses.split("|");
}
}