diff --git a/app/assets/javascripts/select-kit/addon/components/timezone-input.js b/app/assets/javascripts/select-kit/addon/components/timezone-input.js index 4590c703a7b..28a0c25e6d9 100644 --- a/app/assets/javascripts/select-kit/addon/components/timezone-input.js +++ b/app/assets/javascripts/select-kit/addon/components/timezone-input.js @@ -1,25 +1,29 @@ import ComboBoxComponent from "select-kit/components/combo-box"; -import { computed } from "@ember/object"; export default ComboBoxComponent.extend({ pluginApiIdentifiers: ["timezone-input"], classNames: ["timezone-input"], - nameProperty: null, - valueProperty: null, selectKitOptions: { filterable: true, allowAny: false, }, - content: computed(function () { - if ( - moment.locale() !== "en" && - typeof moment.tz.localizedNames === "function" - ) { - return moment.tz.localizedNames().mapBy("value"); - } else { - return moment.tz.names(); - } - }), + get nameProperty() { + return this.isLocalized ? "name" : null; + }, + + get valueProperty() { + return this.isLocalized ? "value" : null; + }, + + get content() { + return this.isLocalized ? moment.tz.localizedNames() : moment.tz.names(); + }, + + get isLocalized() { + return ( + moment.locale() !== "en" && typeof moment.tz.localizedNames === "function" + ); + }, }); diff --git a/package.json b/package.json index ddb9c608515..6a7bfc5edee 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "license": "GPL-2.0-only", "dependencies": { "@discourse/itsatrap": "^2.0.10", + "@discourse/moment-timezone-names-translations": "^1.0.0", "@fortawesome/fontawesome-free": "5.11.2", "@highlightjs/cdn-assets": "^10.7.0", "@json-editor/json-editor": "^2.6.1", @@ -30,7 +31,6 @@ "markdown-it": "10.0.0", "moment": "2.29.1", "moment-timezone": "0.5.31", - "moment-timezone-names-translations": "https://github.com/discourse/moment-timezone-names-translations", "pikaday": "1.8.0", "workbox-cacheable-response": "^4.3.1", "workbox-core": "^4.3.1", diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js index 46dee48eee6..c2a2f5f6a4e 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js @@ -205,7 +205,7 @@ export default Component.extend({ @computed("currentUserTimezone") formatedCurrentUserTimezone(timezone) { - return timezone.replace("_", " ").replace("Etc/", "").split("/"); + return timezone.replace("_", " ").replace("Etc/", "").replace("/", ", "); }, @computed("formats") @@ -398,8 +398,10 @@ export default Component.extend({ return new Promise((resolve) => { loadScript("/javascripts/pikaday.js").then(() => { const options = { - field: this.$(`.fake-input`)[0], - container: this.$(`#picker-container-${this.elementId}`)[0], + field: this.element.querySelector(".fake-input"), + container: this.element.querySelector( + `#picker-container-${this.elementId}` + ), bound: false, format: "YYYY-MM-DD", reposition: false, diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/templates/components/discourse-local-dates-create-form.hbs b/plugins/discourse-local-dates/assets/javascripts/discourse/templates/components/discourse-local-dates-create-form.hbs index 196fb791c96..847a3b31cdf 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/templates/components/discourse-local-dates-create-form.hbs +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/templates/components/discourse-local-dates-create-form.hbs @@ -7,7 +7,8 @@ {{#if isValid}} {{#if timezoneIsDifferentFromUserTimezone}}