UX: uses new date-time-range-input

UX: uses new date-time-range-input

diff --git a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6 b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
index daa31c5..d935eb5 100644
--- a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
+++ b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js.es6
@@ -28,13 +28,17 @@ export default Controller.extend(ModalFunctionality, {
 
   startsAt: computed("model.eventModel.starts_at", {
     get() {
-      return this.model.eventModel.starts_at;
+      return this.model.eventModel.starts_at
+        ? moment(this.model.eventModel.starts_at)
+        : moment();
     }
   }),
 
   endsAt: computed("model.eventModel.ends_at", {
     get() {
-      return this.model.eventModel.ends_at;
+      return (
+        this.model.eventModel.ends_at && moment(this.model.eventModel.ends_at)
+      );
     }
   }),
 
@@ -45,14 +49,8 @@ export default Controller.extend(ModalFunctionality, {
   @action
   onChangeDates(changes) {
     this.model.eventModel.setProperties({
-      starts_at: moment(changes.from)
-        .utc()
-        .toISOString(),
+      starts_at: changes.from,
       ends_at: changes.to
-        ? moment(changes.to)
-            .utc()
-            .toISOString()
-        : null
     });
   },
 
@@ -135,9 +133,13 @@ export default Controller.extend(ModalFunctionality, {
   },
 
   _buildEventParams() {
-    const eventParams = {
-      start: this.startsAt
-    };
+    const eventParams = {};
+
+    if (this.startsAt) {
+      eventParams.start = moment(this.startsAt).format("YYYY-MM-DDTHH:mm");
+    } else {
+      eventParams.start = moment().format("YYYY-MM-DDTHH:mm");
+    }
 
     if (this.model.eventModel.status) {
       eventParams.status = this.model.eventModel.status;
@@ -150,7 +152,7 @@ export default Controller.extend(ModalFunctionality, {
     }
 
     if (this.endsAt) {
-      eventParams.end = this.endsAt;
+      eventParams.end = moment(this.endsAt).format("YYYY-MM-DDTHH:mm");
     }
 
     if (this.model.eventModel.status === "private") {
@@ -178,9 +180,12 @@ export default Controller.extend(ModalFunctionality, {
     if (eventMatches && eventMatches[1]) {
       const markdownParams = [];
       const eventParams = this._buildEventParams();
-      Object.keys(eventParams).forEach(eventParam =>
-        markdownParams.push(`${eventParam}="${eventParams[eventParam]}"`)
-      );
+      Object.keys(eventParams).forEach(eventParam => {
+        const value = eventParams[eventParam];
+        if (value && value.length) {
+          markdownParams.push(`${eventParam}="${eventParams[eventParam]}"`);
+        }
+      });
 
       return raw.replace(
         eventRegex,
diff --git a/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs b/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
index 2c34192..668fdd4 100644
--- a/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
+++ b/assets/javascripts/discourse/templates/modal/discourse-post-event-builder.hbs
@@ -3,70 +3,71 @@
   class="discourse-post-event-builder"
 }}
   {{#conditional-loading-section isLoading=model.eventModel.isSaving}}
-  <form>
-    {{#event-field class="name" label="discourse_post_event.builder_modal.name.label"}}
-      {{input
-        value=(readonly model.eventModel.name)
-        placeholderKey="discourse_post_event.builder_modal.name.placeholder"
-        input=(action (mut model.eventModel.name) value="target.value")
+    <form>
+      {{date-time-input-range
+        from=startsAt
+        to=endsAt
+        toTimeFirst=true
+        clearable=true
+        onChange=(action "onChangeDates")
       }}
-    {{/event-field}}
+      {{#event-field class="name" label="discourse_post_event.builder_modal.name.label"}}
+        {{input
+          value=(readonly model.eventModel.name)
+          placeholderKey="discourse_post_event.builder_modal.name.placeholder"
+          input=(action (mut model.eventModel.name) value="target.value")
+        }}
+      {{/event-field}}
 
-    {{date-time-input-range
-      from=startsAt
-      to=endsAt
-      onChange=(action "onChangeDates")
-    }}
+      {{#event-field label="discourse_post_event.builder_modal.status.label"}}
+        <label class="radio-label">
+          {{radio-button
+            name="status"
+            value="public"
+            selection=model.eventModel.status
+            onChange=(action (mut model.eventModel.status))
+          }}
+          <span class="message">
+            <span class="title">{{i18n "discourse_post_event.models.event.status.public.title"}}</span>
+            <span class="description">{{i18n "discourse_post_event.models.event.status.public.description"}}</span>
+          </span>
+        </label>
+        <label class="radio-label">
+          {{radio-button
+            name="status"
+            value="private"
+            selection=model.eventModel.status
+            onChange=(action (mut model.eventModel.status))
+          }}
+          <span class="message">
+            <span class="title">{{i18n "discourse_post_event.models.event.status.private.title"}}</span>
+            <span class="description">{{i18n "discourse_post_event.models.event.status.private.description"}}</span>
+          </span>
+        </label>
+        <label class="radio-label">
+          {{radio-button
+            name="status"
+            value="standalone"
+            selection=model.eventModel.status
+            onChange=(action (mut model.eventModel.status))
+          }}
+          <span class="message">
+            <span class="title">{{i18n "discourse_post_event.models.event.status.standalone.title"}}</span>
+            <span class="description">{{i18n "discourse_post_event.models.event.status.standalone.description"}}</span>
+          </span>
+        </label>
+      {{/event-field}}
 
-    {{#event-field label="discourse_post_event.builder_modal.status.label"}}
-      <label class="radio-label">
-        {{radio-button
-          name="status"
-          value="public"
-          selection=model.eventModel.status
-          onChange=(action (mut model.eventModel.status))
-        }}
-        <span class="message">
-          <span class="title">{{i18n "discourse_post_event.models.event.status.public.title"}}</span>
-          <span class="description">{{i18n "discourse_post_event.models.event.status.public.description"}}</span>
-        </span>
-      </label>
-      <label class="radio-label">
-        {{radio-button
-          name="status"
-          value="private"
-          selection=model.eventModel.status
-          onChange=(action (mut model.eventModel.status))
+      {{#event-field enabled=allowsInvitees label="discourse_post_event.builder_modal.invitees.label"}}
+        {{group-selector
+          fullWidthWrap=true
+          groupFinder=groupFinder
+          groupNames=model.eventModel.raw_invitees
+          onChangeCallback=(action "setRawInvitees")
+          placeholderKey="topic.invite_private.group_name"
         }}
-        <span class="message">
-          <span class="title">{{i18n "discourse_post_event.models.event.status.private.title"}}</span>
-          <span class="description">{{i18n "discourse_post_event.models.event.status.private.description"}}</span>
-        </span>
-      </label>
-      <label class="radio-label">
-        {{radio-button
-          name="status"
-          value="standalone"
-          selection=model.eventModel.status
-          onChange=(action (mut model.eventModel.status))
-        }}
-        <span class="message">
-          <span class="title">{{i18n "discourse_post_event.models.event.status.standalone.title"}}</span>
-          <span class="description">{{i18n "discourse_post_event.models.event.status.standalone.description"}}</span>
-        </span>
-      </label>
-    {{/event-field}}
-

[... diff too long, it was truncated ...]

GitHub sha: 7b71cccc