diff --git a/app/assets/javascripts/admin/addon/components/form-template/form.hbs b/app/assets/javascripts/admin/addon/components/form-template/form.hbs index fe94fdc6bd2..907310123d4 100644 --- a/app/assets/javascripts/admin/addon/components/form-template/form.hbs +++ b/app/assets/javascripts/admin/addon/components/form-template/form.hbs @@ -1,4 +1,4 @@ -
{{i18n "admin.form_templates.list_table.headings.name"}}
diff --git a/app/assets/javascripts/admin/addon/templates/modal/admin-form-template-validation-options.hbs b/app/assets/javascripts/admin/addon/templates/modal/admin-form-template-validation-options.hbs
new file mode 100644
index 00000000000..330dd1cebdc
--- /dev/null
+++ b/app/assets/javascripts/admin/addon/templates/modal/admin-form-template-validation-options.hbs
@@ -0,0 +1,23 @@
+
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/dropdown.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/dropdown.hbs
new file mode 100644
index 00000000000..c4f17167935
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/dropdown.hbs
@@ -0,0 +1,15 @@
+
+ {{#if @attributes.label}}
+
+ {{/if}}
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/input.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/input.hbs
new file mode 100644
index 00000000000..4a08a25960b
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/input.hbs
@@ -0,0 +1,10 @@
+
+ {{#if @attributes.label}}
+
+ {{/if}}
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/multi-select.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/multi-select.hbs
new file mode 100644
index 00000000000..06721b3cd86
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/multi-select.hbs
@@ -0,0 +1,15 @@
+
+ {{#if @attributes.label}}
+
+ {{/if}}
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/textarea.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/textarea.hbs
new file mode 100644
index 00000000000..3029d15a318
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/textarea.hbs
@@ -0,0 +1,9 @@
+
+ {{#if @attributes.label}}
+
+ {{/if}}
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/upload.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/upload.hbs
new file mode 100644
index 00000000000..20ddddde27f
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/upload.hbs
@@ -0,0 +1,11 @@
+
+ {{#if @attributes.label}}
+
+ {{/if}}
+
+
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.hbs b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.hbs
new file mode 100644
index 00000000000..3d69797766e
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.hbs
@@ -0,0 +1,14 @@
+{{#if this.canShowContent}}
+ {{#each this.parsedContent as |content|}}
+ {{component
+ (concat "form-template-field/" content.type)
+ attributes=content.attributes
+ choices=content.choices
+ validations=content.validations
+ }}
+ {{/each}}
+{{else}}
+
+ {{this.error}}
+
+{{/if}}
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.js b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.js
new file mode 100644
index 00000000000..f181dd88c47
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/components/form-template-field/wrapper.js
@@ -0,0 +1,17 @@
+import Component from "@glimmer/component";
+import Yaml from "js-yaml";
+import { tracked } from "@glimmer/tracking";
+
+export default class FormTemplateFieldWrapper extends Component {
+ @tracked error = null;
+
+ get canShowContent() {
+ try {
+ const parsedContent = Yaml.load(this.args.content);
+ this.parsedContent = parsedContent;
+ return true;
+ } catch (e) {
+ this.error = e;
+ }
+ }
+}
diff --git a/app/assets/javascripts/admin/addon/controllers/modals/admin-customize-form-template-view.js b/app/assets/javascripts/discourse/app/controllers/customize-form-template-view.js
similarity index 87%
rename from app/assets/javascripts/admin/addon/controllers/modals/admin-customize-form-template-view.js
rename to app/assets/javascripts/discourse/app/controllers/customize-form-template-view.js
index 817621d485b..302d77f782b 100644
--- a/app/assets/javascripts/admin/addon/controllers/modals/admin-customize-form-template-view.js
+++ b/app/assets/javascripts/discourse/app/controllers/customize-form-template-view.js
@@ -5,12 +5,19 @@ import { inject as service } from "@ember/service";
import I18n from "I18n";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { ajax } from "discourse/lib/ajax";
+import { tracked } from "@glimmer/tracking";
export default class AdminCustomizeFormTemplateView extends Controller.extend(
ModalFunctionality
) {
@service router;
@service dialog;
+ @tracked showPreview = false;
+
+ @action
+ togglePreview() {
+ this.showPreview = !this.showPreview;
+ }
@action
editTemplate() {
diff --git a/app/assets/javascripts/discourse/app/controllers/form-template-form-preview.js b/app/assets/javascripts/discourse/app/controllers/form-template-form-preview.js
new file mode 100644
index 00000000000..15a936ada6b
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/controllers/form-template-form-preview.js
@@ -0,0 +1,6 @@
+import Controller from "@ember/controller";
+import ModalFunctionality from "discourse/mixins/modal-functionality";
+
+export default class AdminFormTemplateValidationOptions extends Controller.extend(
+ ModalFunctionality
+) {}
diff --git a/app/assets/javascripts/admin/addon/templates/modal/admin-customize-form-template-view.hbs b/app/assets/javascripts/discourse/app/templates/modal/customize-form-template-view.hbs
similarity index 53%
rename from app/assets/javascripts/admin/addon/templates/modal/admin-customize-form-template-view.hbs
rename to app/assets/javascripts/discourse/app/templates/modal/customize-form-template-view.hbs
index 771c43bfd65..b27d7740b46 100644
--- a/app/assets/javascripts/admin/addon/templates/modal/admin-customize-form-template-view.hbs
+++ b/app/assets/javascripts/discourse/app/templates/modal/customize-form-template-view.hbs
@@ -1,6 +1,17 @@
+
+ {{#if this.showPreview}}
+ |
---|