From e02a37b0d7e03000471f3b40abc6a5804bafe79a Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 19 Nov 2024 23:14:10 +0100 Subject: [PATCH] DEV: converts jump-to-post modal to gjs (#29830) * DEV: converts jump-to-post modal to gjs * Update app/assets/javascripts/discourse/app/components/modal/jump-to-post.gjs --------- Co-authored-by: Jarek Radosz --- .../app/components/modal/jump-to-post.gjs | 95 +++++++++++++++++++ .../app/components/modal/jump-to-post.hbs | 51 ---------- .../app/components/modal/jump-to-post.js | 32 ------- 3 files changed, 95 insertions(+), 83 deletions(-) create mode 100644 app/assets/javascripts/discourse/app/components/modal/jump-to-post.gjs delete mode 100644 app/assets/javascripts/discourse/app/components/modal/jump-to-post.hbs delete mode 100644 app/assets/javascripts/discourse/app/components/modal/jump-to-post.js diff --git a/app/assets/javascripts/discourse/app/components/modal/jump-to-post.gjs b/app/assets/javascripts/discourse/app/components/modal/jump-to-post.gjs new file mode 100644 index 00000000000..8d88167da42 --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/modal/jump-to-post.gjs @@ -0,0 +1,95 @@ +import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; +import { Input } from "@ember/component"; +import { action } from "@ember/object"; +import DButton from "discourse/components/d-button"; +import DModal from "discourse/components/d-modal"; +import DModalCancel from "discourse/components/d-modal-cancel"; +import DatePicker from "discourse/components/date-picker"; +import { i18n } from "discourse-i18n"; + +export default class JumpToPost extends Component { + @tracked postNumber; + @tracked postDate; + + get filteredPostsCount() { + return this.args.model.topic.postStream.filteredPostsCount; + } + + _jumpToIndex(postsCounts, postNumber) { + const where = Math.min(postsCounts, Math.max(1, parseInt(postNumber, 10))); + this.args.model.jumpToIndex(where); + this.args.closeModal(); + } + + _jumpToDate(date) { + this.args.model.jumpToDate(date); + this.args.closeModal(); + } + + @action + jump() { + if (this.postNumber) { + this._jumpToIndex(this.filteredPostsCount, this.postNumber); + } else if (this.postDate) { + this._jumpToDate(this.postDate); + } + } + + +} diff --git a/app/assets/javascripts/discourse/app/components/modal/jump-to-post.hbs b/app/assets/javascripts/discourse/app/components/modal/jump-to-post.hbs deleted file mode 100644 index 99eda3b5d6c..00000000000 --- a/app/assets/javascripts/discourse/app/components/modal/jump-to-post.hbs +++ /dev/null @@ -1,51 +0,0 @@ - - <:body> -
-
- # - - - {{i18n "topic.progress.jump_prompt_of" count=this.filteredPostsCount}} - -
- -
- - {{i18n "topic.progress.jump_prompt_or"}} - -
-
- -
- - -
-
- - - <:footer> - - - -
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/modal/jump-to-post.js b/app/assets/javascripts/discourse/app/components/modal/jump-to-post.js deleted file mode 100644 index f71a0cb5c52..00000000000 --- a/app/assets/javascripts/discourse/app/components/modal/jump-to-post.js +++ /dev/null @@ -1,32 +0,0 @@ -import Component from "@glimmer/component"; -import { tracked } from "@glimmer/tracking"; -import { action } from "@ember/object"; - -export default class JumpToPost extends Component { - @tracked postNumber; - @tracked postDate; - - get filteredPostsCount() { - return this.args.model.topic.postStream.filteredPostsCount; - } - - _jumpToIndex(postsCounts, postNumber) { - const where = Math.min(postsCounts, Math.max(1, parseInt(postNumber, 10))); - this.args.model.jumpToIndex(where); - this.args.closeModal(); - } - - _jumpToDate(date) { - this.args.model.jumpToDate(date); - this.args.closeModal(); - } - - @action - jump() { - if (this.postNumber) { - this._jumpToIndex(this.filteredPostsCount, this.postNumber); - } else if (this.postDate) { - this._jumpToDate(this.postDate); - } - } -}