Skip to content

Commit

Permalink
Merge pull request #17 from kaishuu0123/master
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
kaishuu0123 authored Oct 21, 2019
2 parents 6e06fd4 + 9fc9a4d commit 6a3e2bd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ def update
end
end

def show_with_ticket_number
ticket_number = params[:ticket_number]

if ticket_number.match(/([A-Za-z]+)-([0-9]+)/)
ticket_prefix = Regexp.last_match(1)
ticket_id = Regexp.last_match(2)
project = Project.find_by(ticket_prefix: ticket_prefix)
ticket = Ticket.find_by(project: project, ticket_number: ticket_id)

redirect_to(root_path, alert: t('message.ticket_not_found', ticket_number: ticket_number, default: "Ticket #{ticket_number} not Found")) && return if ticket.blank?

redirect_to_with_ticket(ticket_number, project, ticket)
end

redirect_to(root_path, alert: t('message.ticket_not_found', ticket_number: ticket_number, default: "Ticket #{ticket_number} not Found")) && return if ticket.blank?
end

def destroy
end

Expand Down Expand Up @@ -114,4 +131,22 @@ def project_params
def set_project
@project = Project.find(params[:id])
end

def redirect_to_with_ticket(ticket_number, project, ticket)
case ticket.type
when 'Story'
redirect_to File.join("#{project_path(project)}#", 'stories', ticket.id.to_s)
when 'Task'
story = ticket.story
sprint = story.sprint

if sprint.blank?
path = File.join("#{project_path(project)}#", 'stories', story.id.to_s)
path = "#{path}?message_type=danger&message=#{t('message.task_is_not_in_sprint', ticket_number: ticket_number, default: 'Task is not in Sprint. Currently showing Story.')}"
redirect_to(path) && return
end

redirect_to File.join(project_path(project), 'sprints', sprint.id.to_s, 'kanban#', 'story', story.id.to_s, 'tasks', ticket.id.to_s)
end
end
end
20 changes: 20 additions & 0 deletions app/javascript/components/backlogs/StoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
hide-footer
no-fade>
<div class="container">
<div v-if="message.body" class="row">
<div :class="`w-100 p-2 alert alert-${this.message.type}`">
{{ this.message.body }}
</div>
</div>
<div class="row">
<div class="col-9">
<div class="d-flex mb-2">
Expand Down Expand Up @@ -148,6 +153,10 @@ export default {
projectTicketStatus: null,
projectTicketCategory: null,
assignee: null
},
message: {
type: null,
body: null
}
}
},
Expand Down Expand Up @@ -199,6 +208,13 @@ export default {
methods: {
onShow() {
this.resetData()
if (this.$route.query) {
if (this.$route.query.message_type && this.$route.query.message) {
this.message.type = this.$route.query.message_type
this.message.body = this.$route.query.message
}
}
if (this.$route.params.storyId) {
this.isLoading = true
this.getStory({
Expand All @@ -225,6 +241,10 @@ export default {
projectTicketCategory: null,
assignee: null
}
this.message = {
type: null,
body: null
}
this.isEdit = false
this.SET_SELECTED_STORY(this.story)
this.RESET_TICKET_ATTRIBUTES()
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ja:
settings: 管理
message:
ticket_prefix_description: チケットプレフィックスとは、チケット作成時にチケット番号に付与される特定の文字列です。好きな文字(英字の大文字か小文字)を数文字入力してください
ticket_not_found: チケット %{ticket_number} が見つかりませんでした
task_is_not_in_sprint: タスク %{ticket_number} が Sprint に含まれていません。現在 Story を表示しています。
commons:
sidebar:
opening_sprints: オープン中の Sprint
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Rails.application.routes.draw do
devise_for :users
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

root to: 'projects#index'
get '/:ticket_number', to: 'projects#show_with_ticket_number', ticket_number: /[A-Za-z]+-[0-9]+/

resources :projects do
resources :sprints, constraints: { format: :json }
Expand Down

0 comments on commit 6a3e2bd

Please sign in to comment.