From 20397091f10f4c00db7cfab7b8598b9a6b7fdec1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 19 Aug 2013 22:12:59 +0300 Subject: [PATCH] Show iid in event feed and uatocomplete as default id for issues, mr --- app/assets/javascripts/gfm_auto_complete.js.coffee | 2 +- app/models/event.rb | 4 ++++ app/views/events/event/_common.html.haml | 2 +- config/routes.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee index e22761e57a4..77091da8f61 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.coffee +++ b/app/assets/javascripts/gfm_auto_complete.js.coffee @@ -44,7 +44,7 @@ GitLab.GfmAutoComplete = tpl: @Issues.template callbacks: before_save: (issues) -> - $.map issues, (i) -> id: i.id, title: sanitize(i.title), search: "#{i.id} #{i.title}" + $.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}" input.one "focus", => $.getJSON(@dataSource).done (data) -> diff --git a/app/models/event.rb b/app/models/event.rb index 759e84bb55a..5839a834e78 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -256,6 +256,10 @@ class Event < ActiveRecord::Base target.commit_id end + def target_iid + target.respond_to?(:iid) ? target.iid : target_id + end + def note_short_commit_id note_commit_id[0..8] end diff --git a/app/views/events/event/_common.html.haml b/app/views/events/event/_common.html.haml index 6989f862f47..a9d3adf41df 100644 --- a/app/views/events/event/_common.html.haml +++ b/app/views/events/event/_common.html.haml @@ -2,7 +2,7 @@ %span.author_name= link_to_author event %span.event_label{class: event.action_name}= event_action_name(event) - if event.target - %strong= link_to "##{event.target_id}", [event.project, event.target] + %strong= link_to "##{event.target_iid}", [event.project, event.target] - else %strong= gfm event.target_title at diff --git a/config/routes.rb b/config/routes.rb index ff84bc15270..5cf47f9ac5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -281,7 +281,7 @@ Gitlab::Application.routes.draw do end end - resources :issues, except: [:destroy] do + resources :issues, constraints: {id: /\d+/}, except: [:destroy] do collection do post :bulk_update end