FEATURE: adds possibility to have create_pm as action

FEATURE: adds possibility to have create_pm as action

diff --git a/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6 b/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
index d81e8c0..de76ff9 100644
--- a/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
+++ b/javascripts/discourse/initializers/init-discourse-reply-template-component.js.es6
@@ -69,6 +69,26 @@ function localDateFormat(date) {
   return `[${parts.join(" ")}]`;
 }
 
+function _create(dataset, post, controllerOptions) {
+  return Object.assign(controllerOptions, {
+    action: Composer.CREATE_TOPIC
+  });
+}
+
+function _createPm(dataset, post, controllerOptions) {
+  return Object.assign(controllerOptions, {
+    action: Composer.PRIVATE_MESSAGE,
+    topic: post.topic
+  });
+}
+
+function _reply(dataset, post, controllerOptions) {
+  return Object.assign(controllerOptions, {
+    action: Composer.REPLY,
+    topic: post.topic
+  });
+}
+
 function openComposerWithTemplateAndAction(controller, post, wrap) {
   const dataset = wrap.dataset;
 
@@ -140,7 +160,7 @@ function openComposerWithTemplateAndAction(controller, post, wrap) {
         topicBody += `\n\n${tags.join(", ")}`;
       }
 
-      const controllerOptions = {
+      let controllerOptions = {
         topicBody,
         draftKey: controller.topicModel.draft_key,
         draftSequence: controller.topicModel.draftSequence,
@@ -148,26 +168,21 @@ function openComposerWithTemplateAndAction(controller, post, wrap) {
         categoryId: dataset.categoryId || null
       };
 
-      if (dataset.action && dataset.action === "create") {
-        controller.open(
-          Object.assign(
-            {
-              action: Composer.CREATE_TOPIC
-            },
-            controllerOptions
-          )
-        );
-      } else {
-        controller.open(
-          Object.assign(
-            {
-              action: Composer.REPLY,
-              topic: post.topic
-            },
-            controllerOptions
-          )
-        );
+      switch (dataset.action) {
+        case "create":
+          controllerOptions = _create(dataset, post, controllerOptions);
+          break;
+        case "create_pm":
+          controllerOptions = _createPm(dataset, post, controllerOptions);
+          break;
+        case "reply":
+        case null:
+        case undefined:
+          controllerOptions = _reply(dataset, post, controllerOptions);
+          break;
       }
+
+      controller.open(controllerOptions);
     }
   });
 }
diff --git a/locales/en.yml b/locales/en.yml
index 582e6bc..27fd60f 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -2,4 +2,5 @@ en:
   discourse_reply_template_component:
     use_template_reply: "Use template as reply"
     use_template_create: "Use template as new topic"
+    use_template_create_pm: "Use template as new PM"
     needs_key: 'Each template needs a key attribute. eg: [wrap=template key="weekly_status"][/wrap]'

GitHub sha: 840257c3