Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

unify components of common module

Behrokh Satarnejad82486a058467
diff --git a/lookbook/previews/open_project/common/datepicker_preview.rb b/lookbook/previews/open_project/common/datepicker_preview.rb
new file mode 100644
index 00000000000..c9bdeaca41e
--- /dev/null
+++ b/lookbook/previews/open_project/common/datepicker_preview.rb
@@ -0,0 +1,56 @@
+module OpenProject
+ module Common
+ # @logical_path OpenProject/Common
+ class DatepickerPreview < Lookbook::Preview
+ ##
+ # **Single date picker**
+ # ---------------------
+ # The basic date picker is a key element in OpenProject and is displayed
+ # any time the user has to input a date.
+ #
+ # Basic date pickers are attached to existing date input fields
+ # and is displayed as a drop-down when that date input field is in focus.
+ # It consists of only the mini-calendar component.
+ #
+ # The basic date picker can also be placed inside modals
+ # like the work package date drop modal and the Baseline drop modal.
+ # All date picker are built on the [Flatpickr javascript library](https://flatpickr.js.org/).
+ #
+ # On mobile devices, the component will automatically degrade to the device's native date picker.
+ #
+ # For more complex implementations involving date pickers (the work package date field or the baseline modal),
+ # please refer to documentation concerning those specific features for notes on mobile-specific rendering.
+ #
+ # The library gives us certain functionality out of the box with a fairly high degree of customisation,
+ # but also introduces limits (which will be mentioned below when relevant).
+ #
+ # Please read the [Flatpickr documentation](https://flatpickr.js.org/instance-methods-properties-elements/)
+ # before using or contributing to date pickers.
+ #
+ # @param value date
+ def single(value: Time.zone.today.iso8601)
+ render_with_template(locals: { value: })
+ end
+
+ ##
+ # **Range date picker**
+ # ---------------------
+ # Range datepicker allow inputing a range (2023-02-09 - 2023-02-14),
+ # and shows the date picker with two months.
+ #
+ # All date picker are built on the [Flatpickr javascript library](https://flatpickr.js.org/).
+ # On mobile devices, the component will automatically degrade to two inputs with the device's native date picker.
+ #
+ # The library gives us certain functionality out of the box with a fairly high degree of customisation,
+ # but also introduces limits (which will be mentioned below when relevant).
+ #
+ # Please read the [Flatpickr documentation](https://flatpickr.js.org/instance-methods-properties-elements/)
+ # before using or contributing to date pickers.
+ #
+ # @param value text
+ def range(value: "#{Time.zone.today.iso8601} - #{Time.zone.today.iso8601}")
+ render_with_template(locals: { value: })
+ end
+ end
+ end
+end
diff --git a/lookbook/previews/open_project/datepicker_preview/range.html.erb b/lookbook/previews/open_project/common/datepicker_preview/range.html.erb
similarity index 100%
rename from lookbook/previews/open_project/datepicker_preview/range.html.erb
rename to lookbook/previews/open_project/common/datepicker_preview/range.html.erb
diff --git a/lookbook/previews/open_project/datepicker_preview/single.html.erb b/lookbook/previews/open_project/common/datepicker_preview/single.html.erb
similarity index 100%
rename from lookbook/previews/open_project/datepicker_preview/single.html.erb
rename to lookbook/previews/open_project/common/datepicker_preview/single.html.erb
diff --git a/lookbook/previews/open_project/common/loading_indicator_preview.rb b/lookbook/previews/open_project/common/loading_indicator_preview.rb
new file mode 100644
index 00000000000..1c6613595c5
--- /dev/null
+++ b/lookbook/previews/open_project/common/loading_indicator_preview.rb
@@ -0,0 +1,8 @@
+module OpenProject
+ module Common
+ # @logical_path OpenProject/Common
+ class LoadingIndicatorPreview < Lookbook::Preview
+ def default; end
+ end
+ end
+end
diff --git a/lookbook/previews/open_project/loading_indicator_preview/default.html.erb b/lookbook/previews/open_project/common/loading_indicator_preview/default.html.erb
similarity index 100%
rename from lookbook/previews/open_project/loading_indicator_preview/default.html.erb
rename to lookbook/previews/open_project/common/loading_indicator_preview/default.html.erb
diff --git a/lookbook/previews/open_project/datepicker_preview.rb b/lookbook/previews/open_project/datepicker_preview.rb
deleted file mode 100644
index 56f859753eb..00000000000
--- a/lookbook/previews/open_project/datepicker_preview.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-module OpenProject
- # @logical_path OpenProject/common
- class DatepickerPreview < Lookbook::Preview
- ##
- # **Single date picker**
- # ---------------------
- # The basic date picker is a key element in OpenProject and is displayed
- # any time the user has to input a date.
- #
- # Basic date pickers are attached to existing date input fields
- # and is displayed as a drop-down when that date input field is in focus.
- # It consists of only the mini-calendar component.
- #
- # The basic date picker can also be placed inside modals
- # like the work package date drop modal and the Baseline drop modal.
- # All date picker are built on the [Flatpickr javascript library](https://flatpickr.js.org/).
- #
- # On mobile devices, the component will automatically degrade to the device's native date picker.
- #
- # For more complex implementations involving date pickers (the work package date field or the baseline modal),
- # please refer to documentation concerning those specific features for notes on mobile-specific rendering.
- #
- # The library gives us certain functionality out of the box with a fairly high degree of customisation,
- # but also introduces limits (which will be mentioned below when relevant).
- #
- # Please read the [Flatpickr documentation](https://flatpickr.js.org/instance-methods-properties-elements/)
- # before using or contributing to date pickers.
- #
- # @param value date
- def single(value: Time.zone.today.iso8601)
- render_with_template(locals: { value: })
- end
-
- ##
- # **Range date picker**
- # ---------------------
- # Range datepicker allow inputing a range (2023-02-09 - 2023-02-14),
- # and shows the date picker with two months.
- #
- # All date picker are built on the [Flatpickr javascript library](https://flatpickr.js.org/).
- # On mobile devices, the component will automatically degrade to two inputs with the device's native date picker.
- #
- # The library gives us certain functionality out of the box with a fairly high degree of customisation,
- # but also introduces limits (which will be mentioned below when relevant).
- #
- # Please read the [Flatpickr documentation](https://flatpickr.js.org/instance-methods-properties-elements/)
- # before using or contributing to date pickers.
- #
- # @param value text
- def range(value: "#{Time.zone.today.iso8601} - #{Time.zone.today.iso8601}")
- render_with_template(locals: { value: })
- end
- end
-end
diff --git a/lookbook/previews/open_project/loading_indicator_preview.rb b/lookbook/previews/open_project/loading_indicator_preview.rb
deleted file mode 100644
index 1a0b76eaae2..00000000000
--- a/lookbook/previews/open_project/loading_indicator_preview.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-module OpenProject
- # @logical_path OpenProject/common
- class LoadingIndicatorPreview < Lookbook::Preview
- def default; end
- end
-end