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