Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-02-15 17:19:23 +0300
committerRémy Coutable <remy@rymai.me>2016-02-15 17:40:24 +0300
commit54613b6af56008588a3cc8a9e9f2ee642ca59a36 (patch)
tree1e5c08d6ce26d4fb839302eac3911ba59f227cd9 /app/helpers/issuables_helper.rb
parentc29517aaf420b0d83f21d468b371260f4887cf00 (diff)
Fix the "x of y" displayed at the top of Issuables' sidebar
1. We now display the index of the current issuable among all its project's issuables, of the same type and with the same state. 2. Also, refactored a bit the Issuable helpers into a new IssuablesHelper module. 3. Added acceptance specs for the sidebar counter.
Diffstat (limited to 'app/helpers/issuables_helper.rb')
-rw-r--r--app/helpers/issuables_helper.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
new file mode 100644
index 00000000000..ccbd93967a2
--- /dev/null
+++ b/app/helpers/issuables_helper.rb
@@ -0,0 +1,41 @@
+module IssuablesHelper
+
+ def sidebar_gutter_toggle_icon
+ sidebar_gutter_collapsed? ? icon('angle-double-left') : icon('angle-double-right')
+ end
+
+ def sidebar_gutter_collapsed_class
+ "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
+ end
+
+ def issuable_index(issuable)
+ base_issuable_scope(issuable).where('id < ?', issuable.id).size + 1
+ end
+
+ def issuables_count(issuable)
+ base_issuable_scope(issuable).size
+ end
+
+ def next_issuable_for(issuable)
+ base_issuable_scope(issuable).where('id > ?', issuable.id).last
+ end
+
+ def prev_issuable_for(issuable)
+ base_issuable_scope(issuable).where('id < ?', issuable.id).first
+ end
+
+ private
+
+ def sidebar_gutter_collapsed?
+ cookies[:collapsed_gutter] == 'true'
+ end
+
+ def base_issuable_scope(issuable)
+ issuable.project.send(issuable.to_scope_name).send(issuable_state_scope(issuable))
+ end
+
+ def issuable_state_scope(issuable)
+ issuable.open? ? :opened : :closed
+ end
+
+end