A new modal for editing topic assignments
This commit is contained in:
		
							parent
							
								
									47245339e7
								
							
						
					
					
						commit
						70a7585777
					
				|  | @ -0,0 +1,24 @@ | |||
| <DModal class="assign" @title={{this.title}} @closeModal={{@closeModal}}> | ||||
|   <:body> | ||||
|     <p>Edit topic assignments form</p> | ||||
| <!--    <AssignUserForm--> | ||||
| <!--      @model={{this.model}}--> | ||||
| <!--      @onSubmit={{this.onSubmit}}--> | ||||
| <!--      @formApi={{this.formApi}}--> | ||||
| <!--    />--> | ||||
|   </:body> | ||||
| 
 | ||||
|   <:footer> | ||||
|     <DButton | ||||
|       class="btn-primary" | ||||
|       @action={{this.formApi.submit}} | ||||
|       @label={{if | ||||
|         this.model.reassign | ||||
|         "discourse_assign.reassign.title" | ||||
|         "discourse_assign.assign_modal.assign" | ||||
|       }} | ||||
|     /> | ||||
| 
 | ||||
|     <DModalCancel @close={{@closeModal}} /> | ||||
|   </:footer> | ||||
| </DModal> | ||||
|  | @ -0,0 +1,27 @@ | |||
| import Component from "@glimmer/component"; | ||||
| import { action } from "@ember/object"; | ||||
| import { inject as service } from "@ember/service"; | ||||
| import { TrackedObject } from "@ember-compat/tracked-built-ins"; | ||||
| import I18n from "I18n"; | ||||
| 
 | ||||
| export default class EditTopicAssignments extends Component { | ||||
|   @service taskActions; | ||||
| 
 | ||||
|   model = new TrackedObject(this.args.model); | ||||
| 
 | ||||
|   // `submit` property will be mutated by the `AssignUserForm` component
 | ||||
|   formApi = { | ||||
|     submit() {}, | ||||
|   }; | ||||
| 
 | ||||
|   get title() { | ||||
|     const title = this.model.topic.isAssigned() ? "reassign_title" : "title"; | ||||
|     return I18n.t(`discourse_assign.assign_modal.${title}`); | ||||
|   } | ||||
| 
 | ||||
|   @action | ||||
|   async onSubmit() { | ||||
|     this.args.closeModal(); | ||||
|     await this.taskActions.assign(this.model); | ||||
|   } | ||||
| } | ||||
|  | @ -3,6 +3,7 @@ import { htmlSafe } from "@ember/template"; | |||
| import { renderAvatar } from "discourse/helpers/user-avatar"; | ||||
| import { iconHTML } from "discourse-common/lib/icon-library"; | ||||
| import I18n from "I18n"; | ||||
| import EditTopicAssignments from "../components/modal/edit-topic-assignments"; | ||||
| 
 | ||||
| const DEPENDENT_KEYS = [ | ||||
|   "topic.assigned_to_user", | ||||
|  | @ -22,6 +23,7 @@ export default { | |||
|     } | ||||
| 
 | ||||
|     const taskActions = getOwner(this).lookup("service:task-actions"); | ||||
|     const modal = getOwner(this).lookup("service:modal"); | ||||
|     const firstPostId = this.topic.postStream.firstPostId; | ||||
| 
 | ||||
|     switch (id) { | ||||
|  | @ -42,9 +44,10 @@ export default { | |||
|         break; | ||||
|       } | ||||
|       case "reassign": { | ||||
|         await taskActions.showAssignModal(this.topic, { | ||||
|           targetType: "Topic", | ||||
|           isAssigned: this.topic.isAssigned(), | ||||
|         await modal.show(EditTopicAssignments, { | ||||
|           model: { | ||||
|             topic: this.topic, | ||||
|           }, | ||||
|           onSuccess: () => | ||||
|             this.appEvents.trigger("post-stream:refresh", { id: firstPostId }), | ||||
|         }); | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ import I18n from "I18n"; | |||
| import BulkAssign from "../components/bulk-actions/assign-user"; | ||||
| import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user"; | ||||
| import TopicLevelAssignMenu from "../components/topic-level-assign-menu"; | ||||
| import EditTopicAssignments from "../components/modal/edit-topic-assignments"; | ||||
| 
 | ||||
| const PLUGIN_ID = "discourse-assign"; | ||||
| 
 | ||||
|  | @ -110,6 +111,7 @@ function registerTopicFooterButtons(api) { | |||
|       } | ||||
| 
 | ||||
|       const taskActions = getOwner(this).lookup("service:task-actions"); | ||||
|       const modal = getOwner(this).lookup("service:modal"); | ||||
| 
 | ||||
|       if (this.topic.isAssigned()) { | ||||
|         this.set("topic.assigned_to_user", null); | ||||
|  | @ -121,7 +123,10 @@ function registerTopicFooterButtons(api) { | |||
|           id: this.topic.postStream.firstPostId, | ||||
|         }); | ||||
|       } else { | ||||
|         await taskActions.showAssignModal(this.topic, { | ||||
|         await modal.show(EditTopicAssignments, { | ||||
|           model: { | ||||
|             topic: this.topic, | ||||
|           }, | ||||
|           onSuccess: () => | ||||
|             this.appEvents.trigger("post-stream:refresh", { | ||||
|               id: this.topic.postStream.firstPostId, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue