- Creating draft in Google Drive...
+
Title
+ {{#if this.formErrors.title}}
+
+ {{this.formErrors.title}}
+
+ {{/if}}
+
+
+ {{! Summary }}
+
+
+ Summary
+ {{#if this.summaryIsLong}}
+
+ Limit this to 1 or 2 sentences if possible.
+
+ {{/if}}
-
This usually takes
- 10-20 seconds.
+
-{{else}}
-
-{{/if}}
+ {{! Contributors }}
+
+
+
+
+
+ Contributors
+
+
+
+
diff --git a/web/app/components/new/doc-form.ts b/web/app/components/new/doc-form.ts
index aa3c498f8..a543ed672 100644
--- a/web/app/components/new/doc-form.ts
+++ b/web/app/components/new/doc-form.ts
@@ -14,22 +14,14 @@ import FlashService from "ember-cli-flash/services/flash-messages";
import { assert } from "@ember/debug";
import cleanString from "hermes/utils/clean-string";
import { ProductArea } from "hermes/services/product-areas";
+import { next } from "@ember/runloop";
interface DocFormErrors {
title: string | null;
- summary: string | null;
productAbbreviation: string | null;
- contributors: string | null;
}
-const FORM_ERRORS: DocFormErrors = {
- title: null,
- summary: null,
- productAbbreviation: null,
- contributors: null,
-};
-
-const AWAIT_DOC_DELAY = Ember.testing ? 0 : 1000;
+const AWAIT_DOC_DELAY = Ember.testing ? 0 : 2000;
const AWAIT_DOC_CREATED_MODAL_DELAY = Ember.testing ? 0 : 1500;
interface NewDocFormComponentSignature {
@@ -54,14 +46,12 @@ export default class NewDocFormComponent extends Component
a != null;
- return Object.values(this.formErrors).filter(defined).length > 0;
+ return Object.values(this.formErrors).some((error) => error !== null);
+ }
+
+ protected get buttonIsActive() {
+ return !!this.title && !!this.productAbbreviation;
}
/**
- * Sets `formRequirementsMet` and conditionally validates the form.
+ * Validates the form if `validateEagerly` is true.
*/
private maybeValidate() {
- if (this.title && this.productArea) {
- this.formRequirementsMet = true;
- } else {
- this.formRequirementsMet = false;
- }
if (this.validateEagerly) {
this.validate();
}
@@ -118,7 +103,12 @@ export default class NewDocFormComponent extends Component 200) {
this.summaryIsLong = true;
} else {
this.summaryIsLong = false;
}
+ if ("productArea" in formObject) {
+ this.productArea = formObject["productArea"] as string;
+ }
+
+ if (e.key === "Enter") {
+ e.preventDefault();
+ this.submit();
+ return;
+ }
+
+ if (this.formErrors.title || this.formErrors.productAbbreviation) {
+ // Validate once the input values are captured
+ next("afterRender", () => {
+ this.validate();
+ });
+ }
+
this.maybeValidate();
}
@@ -179,11 +181,11 @@ export default class NewDocFormComponent extends Component
Choose a template
- {{! PENDING }}
{{!
-
- or
-
-
+
+ or
+
+
}}
diff --git a/web/app/components/new/form.hbs b/web/app/components/new/form.hbs
new file mode 100644
index 000000000..63eb9edf5
--- /dev/null
+++ b/web/app/components/new/form.hbs
@@ -0,0 +1,36 @@
+