WIP: switching to another assignment on the modal
This commit is contained in:
parent
eab180291d
commit
b9c27bc7fd
|
@ -1,6 +1,7 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import EmberObject from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import I18n from "I18n";
|
||||
|
||||
|
@ -11,31 +12,31 @@ export default class EditTopicAssignments extends Component {
|
|||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
const topicAssignment = {
|
||||
type: "Topic",
|
||||
username: this.topic.assigned_to_user?.username,
|
||||
group_name: this.topic.assigned_to_group?.name,
|
||||
status: this.topic.assignment_status,
|
||||
note: this.topic.assignment_note
|
||||
};
|
||||
const topicAssignment = new Assignment(
|
||||
this.topic.assigned_to_user?.username,
|
||||
this.topic.assigned_to_group?.name,
|
||||
this.topic.assignment_status,
|
||||
this.topic.assignment_note,
|
||||
"Topic"
|
||||
);
|
||||
this.assignments.push(topicAssignment);
|
||||
|
||||
this.topic.assignedPosts().forEach((a) => {
|
||||
this.assignments.push({
|
||||
type: "Post",
|
||||
post_number: a.post_number,
|
||||
username: a.username,
|
||||
group_name: a.name,
|
||||
status: a.assignment_status,
|
||||
note: a.assignment_note,
|
||||
});
|
||||
this.assignments.push(
|
||||
new Assignment(
|
||||
a.assigned_to.username,
|
||||
a.assigned_to.name,
|
||||
a.assignment_status,
|
||||
a.assignment_note,
|
||||
"Post",
|
||||
a.post_number
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
get title() {
|
||||
const title = this.topic.isAssigned()
|
||||
? "reassign_title"
|
||||
: "title";
|
||||
const title = this.topic.isAssigned() ? "reassign_title" : "title";
|
||||
return I18n.t(`discourse_assign.assign_modal.${title}`);
|
||||
}
|
||||
|
||||
|
@ -45,9 +46,27 @@ export default class EditTopicAssignments extends Component {
|
|||
|
||||
@action
|
||||
async submit() {
|
||||
console.log("", this.assignments);
|
||||
throw "Not implemented"; // fixme andrei
|
||||
// this.args.closeModal();
|
||||
// await this.taskActions.assign(this.model);
|
||||
}
|
||||
}
|
||||
|
||||
class Assignment extends EmberObject {
|
||||
@tracked username;
|
||||
@tracked group_name; // fixme andrei fix case
|
||||
@tracked status;
|
||||
@tracked note;
|
||||
type;
|
||||
postNumber;
|
||||
|
||||
constructor(username, groupName, status, note, type, postNumber) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.group_name = groupName;
|
||||
this.status = status;
|
||||
this.note = note;
|
||||
this.type = type;
|
||||
this.postNumber = postNumber;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,17 @@ export default class TopicAssignments extends Component {
|
|||
@action
|
||||
synchronizeAssignment(selectedAssignmentId) {
|
||||
this.selectedAssignmentId = selectedAssignmentId;
|
||||
// fixme andrei:
|
||||
if (selectedAssignmentId === this.TOPIC_ID) {
|
||||
this.selectedAssignment = this.args.assignments.find(
|
||||
(a) => a.id === selectedAssignmentId
|
||||
); // fixme andrei
|
||||
(a) => a.type === "Topic"
|
||||
);
|
||||
} else {
|
||||
this.selectedAssignment = this.args.assignments.find(
|
||||
(a) => a.postNumber === selectedAssignmentId
|
||||
);
|
||||
}
|
||||
console.log("this.selectedAssignment", this.selectedAssignment);
|
||||
}
|
||||
|
||||
#toComboBoxOption(assignment) {
|
||||
|
@ -30,7 +38,7 @@ export default class TopicAssignments extends Component {
|
|||
} else {
|
||||
return {
|
||||
id: assignment.post_number,
|
||||
name: `Post #${assignment.post_number}`, // fixme andrei string
|
||||
name: `Post #${assignment.postNumber}`, // fixme andrei string
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue