Skip to content

Commit

Permalink
Merge pull request #54 from kaishuu0123/master
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
kaishuu0123 authored Dec 17, 2019
2 parents c1e6b71 + 430fa38 commit 15be751
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 34 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,6 @@ gem 'omniauth-github', '~> 1.3'
gem 'omniauth-google-oauth2', '~> 0.8'

gem 'config'

gem 'kaminari', '~> 1.1'

13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ GEM
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jwt (2.2.1)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
kaminari-activerecord (= 1.1.1)
kaminari-core (= 1.1.1)
kaminari-actionview (1.1.1)
actionview
kaminari-core (= 1.1.1)
kaminari-activerecord (1.1.1)
activerecord
kaminari-core (= 1.1.1)
kaminari-core (1.1.1)
kramdown (1.17.0)
launchy (2.4.3)
addressable (~> 2.3)
Expand Down Expand Up @@ -368,6 +380,7 @@ DEPENDENCIES
identicon
initial_avatar
jbuilder (~> 2.7)
kaminari (~> 1.1)
letter_opener_web
listen (>= 3.0.5, < 3.2)
omniauth (~> 1.9)
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class ProjectsController < ApplicationController
:project_tags
]

PROJECT_PER_PAGE = 25

def index
@projects = @projects.search_by_keyword(params[:keywords]).page(params[:page]).per(PROJECT_PER_PAGE)
# 自分が属している自身のプロジェクトがない場合には作成を促すメッセージを表示するためのフラグ
@is_not_exits_own_project = @projects.all? { |project| project.is_public && !project.users.include?(current_user) }
end

def show
Expand Down
20 changes: 16 additions & 4 deletions app/javascript/components/commons/TicketForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export default {
isNew: Boolean,
afterSubmit: Function
},
data() {
return {
initialFocused: false
};
},
mounted() {
Vue.nextTick(() => {
// Focus Input
Expand All @@ -76,10 +81,17 @@ export default {
},
watch: {
isLoading: function(newLoading, oldLoading) {
Vue.nextTick(() => {
// Focus Input
this.$refs.titleInput.focus()
})
// XXX:
// 一度だけ Title に Focus する
// この条件がないと、新規作成時に isLoading が変わる度に
// titleInput に focus があたってしまう
if (this.initialFocused === false) {
Vue.nextTick(() => {
// Focus Input
this.$refs.titleInput.focus()
this.initialFocused = true
})
}
}
},
methods: {
Expand Down
12 changes: 8 additions & 4 deletions app/javascript/i18n/globals.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"task": "Task",
"tag": "Tags",
"unassigned": "Unassigned",
"search": "Search by keyword"
"search": "Search by keyword",
"is_public": "Public"
},
"ticket": {
"title": "Title",
Expand Down Expand Up @@ -94,7 +95,8 @@
"storyDoesNotExists": "Story doesn't exists. Let's create a story with the \"Add Story\" button.",
"storyDoesNotExistsInSprint": "Story doesn't exists. Let's add the added story to Sprint by D&D from Backlogs.",
"historyIsEmpty": "History is empty.",
"tagInput": "Please input tags"
"tagInput": "Please input tags",
"publicProject": "This is a public project. Non-member users are only allowed to comment on tickets."
},
"tab": {
"comment": "Comment",
Expand Down Expand Up @@ -140,7 +142,8 @@
"task": "タスク",
"tag": "タグ",
"unassigned": "未アサイン",
"search": "キーワード検索"
"search": "キーワード検索",
"is_public": "公開"
},
"ticket": {
"title": "タイトル",
Expand Down Expand Up @@ -196,7 +199,8 @@
"storyDoesNotExists": "Story がありません。「Story を追加」ボタンで Story を作成してみましょう。",
"storyDoesNotExistsInSprint": "Story がありません。Backlogs に追加した Story を D&D で Sprint に追加してみましょう",
"historyIsEmpty": "更新履歴はありません",
"tagInput": "タグを入力してください"
"tagInput": "タグを入力してください",
"publicProject": "これは公開プロジェクトです。メンバーではないユーザはチケットへのコメントのみ許可されています。"
},
"tab": {
"comment": "コメント",
Expand Down
14 changes: 11 additions & 3 deletions app/javascript/packs/backlogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import http from '../commons/custom-axios'
document.addEventListener('DOMContentLoaded', () => {
const rootElement = document.getElementById('content')
const projectId = rootElement.dataset.projectId
const projectTitle = rootElement.dataset.projectTitle
const isPublic = rootElement.dataset.isPublic
Vue.use(VueRouter)
Vue.use(VueI18n)
Vue.use(http, { store })
Expand All @@ -19,23 +21,29 @@ document.addEventListener('DOMContentLoaded', () => {
component: BacklogsPage,
meta: {
newStory: true,
projectId: projectId
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic
}
},
{
path: '/stories/:storyId',
component: BacklogsPage,
meta: {
newStory: false,
projectId: projectId
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic
}
},
{
path: '*',
component: BacklogsPage,
meta: {
newStory: false,
projectId: projectId
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic
}
},
]
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/packs/kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import http from '../commons/custom-axios'
document.addEventListener('DOMContentLoaded', () => {
const rootElement = document.getElementById('content')
const projectId = rootElement.dataset.projectId
const projectTitle = rootElement.dataset.projectTitle
const isPublic = rootElement.dataset.isPublic
const sprintId = rootElement.dataset.sprintId
const sprintTitle = rootElement.dataset.sprintTitle
Vue.use(VueRouter)
Expand All @@ -23,6 +25,8 @@ document.addEventListener('DOMContentLoaded', () => {
meta: {
newTask: true,
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic,
sprintId: sprintId,
sprintTitle: sprintTitle
}
Expand All @@ -34,6 +38,8 @@ document.addEventListener('DOMContentLoaded', () => {
meta: {
newTask: false,
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic,
sprintId: sprintId,
sprintTitle: sprintTitle
}
Expand All @@ -45,6 +51,8 @@ document.addEventListener('DOMContentLoaded', () => {
meta: {
newTask: false,
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic,
sprintId: sprintId,
sprintTitle: sprintTitle
}
Expand All @@ -55,6 +63,8 @@ document.addEventListener('DOMContentLoaded', () => {
meta: {
newTask: false,
projectId: projectId,
projectTitle: projectTitle,
isPublic: isPublic,
sprintId: sprintId,
sprintTitle: sprintTitle
}
Expand Down
20 changes: 19 additions & 1 deletion app/javascript/pages/BacklogsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
loader="dots"></loading>
<div class="row px-2">
<div class="d-flex w-100 align-items-center justify-content-between mb-2">
<h1 class="h4 mb-0 text-gray-700">{{ $t('title.masterBacklogs')}}</h1>
<div class="d-flex flex-column">
<div>
<h1 class="h5 mb-0 text-gray-700">
{{ projectTitle }}
</h1>
</div>
<div class="text-gray-600">
{{ $t('title.masterBacklogs')}}
<span v-if="isPublic == 'true'">
<span class="badge badge-pill badge-info" v-b-tooltip.hover :title="$t('message.publicProject')">
{{ $t('title.is_public') }} <i class="fas fa-question-circle"></i>
</span>
</span>
</div>
</div>
<div class="d-flex align-items-center">
<div class="d-flex align-items-center mr-2">
<b-form-input
Expand Down Expand Up @@ -87,6 +101,8 @@ export default {
data () {
return {
projectId: null,
projectTitle: '',
isPublic: '',
newStory: false,
layout: 'DEFAULT',
searchKeyword: '',
Expand All @@ -111,6 +127,8 @@ export default {
},
mounted() {
this.projectId = this.$route.meta.projectId
this.projectTitle = this.$route.meta.projectTitle
this.isPublic = this.$route.meta.isPublic
this.newStory = this.$route.meta.newStory

this.getSprintsWithStories(this.projectId)
Expand Down
22 changes: 21 additions & 1 deletion app/javascript/pages/KanbanPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@

<div class="row mb-2 bg-light sticky-top">
<nav class="navbar navbar-expand-md px-1 py-0 navbar-light w-100">
<a class="navbar-brand text-gray-700" href="#">{{ sprintTitle }}</a>
<a class="navbar-brand text-gray-700" href="#">
<div class="d-flex flex-column">
<div>
<h1 class="h5 mb-0 text-gray-700">{{ projectTitle }}</h1>
</div>
<div class="text-gray-600">
<p class="h6 mb-0">
{{ sprintTitle }}
<span v-if="isPublic == 'true'">
<span class="badge badge-pill badge-info" v-b-tooltip.hover :title="$t('message.publicProject')">
{{ $t('title.is_public') }} <i class="fas fa-question-circle"></i>
</span>
</span>
</p>
</div>
</div>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="fas fa-bars"></span>
</button>
Expand Down Expand Up @@ -141,6 +157,8 @@ export default {
data () {
return {
projectId: null,
projectTitle: '',
isPublic: '',
sprintId: null,
sprintTitle: null,
newTask: false,
Expand All @@ -149,8 +167,10 @@ export default {
},
mounted() {
this.projectId = this.$route.meta.projectId
this.projectTitle = this.$route.meta.projectTitle
this.sprintId = this.$route.meta.sprintId
this.sprintTitle = this.$route.meta.sprintTitle
this.isPublic = this.$route.meta.isPublic
this.newTask = this.$route.meta.newTask

this.setProjectId(this.projectId)
Expand Down
9 changes: 9 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ class Project < ApplicationRecord
validates :title, presence: true
validates :ticket_prefix, presence: true, uniqueness: true, format: { with: /[a-zA-Z]/}

scope :search_by_keyword, -> (keywords) {
if keywords.present?
columns = %i[title body]
where(keywords.split(/[[:space:]]/).reject(&:empty?).map { |keyword|
columns.map { |a| arel_table[a].matches("%#{keyword}%") }.inject(:or)
}.inject(:and))
end
}

def project_image_url
if image.present?
base64 = Base64.strict_encode64(image.download)
Expand Down
3 changes: 3 additions & 0 deletions app/views/kaminari/_first_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="page-item">
<%= link_to_unless current_page.first?, '', url, remote: remote, class: 'page-link rounded-0 fa fa-angle-double-left' %>
</li>
3 changes: 3 additions & 0 deletions app/views/kaminari/_gap.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class='page-item disabled'>
<%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link rounded-0' %>
</li>
3 changes: 3 additions & 0 deletions app/views/kaminari/_last_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="page-item">
<%= link_to_unless current_page.last?, '', url, remote: remote, class: 'page-link rounded-0 fa fa-angle-double-right' %>
</li>
3 changes: 3 additions & 0 deletions app/views/kaminari/_next_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="page-item">
<%= link_to_unless current_page.last?, '', url, rel: 'next', remote: remote, class: 'page-link rounded-0 fa fa-angle-right' %>
</li>
9 changes: 9 additions & 0 deletions app/views/kaminari/_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if page.current? %>
<li class="page-item active">
<%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link rounded-0' %>
</li>
<% else %>
<li class="page-item">
<%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link rounded-0' %>
</li>
<% end %>
17 changes: 17 additions & 0 deletions app/views/kaminari/_paginator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%= paginator.render do %>
<nav>
<ul class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| %>
<% if page.left_outer? || page.right_outer? || page.inside_window? %>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end %>
<% end %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</nav>
<% end %>
3 changes: 3 additions & 0 deletions app/views/kaminari/_prev_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<li class="page-item">
<%= link_to_unless current_page.first?, '', url, rel: 'prev', remote: remote, class: 'page-link rounded-0 fa fa-angle-left' %>
</li>
8 changes: 5 additions & 3 deletions app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
</div>
<% end %>

<%= f.input :title %>
<%= f.input :body, as: :text, input_html: { rows: 5 } %>
<%= f.input :ticket_prefix, hint: t('message.ticket_prefix_description', default: 'Ticket Prefix is an arbitrary string that is added to the beginning of the ticket number.') %>
<%= f.input :title, placeholder: t('.placeholder.title', default: 'My awesome project') %>
<%= f.input :body, as: :text, input_html: { rows: 5 }, placeholder: t('.placeholder.description', default: 'Description format') %>
<%= f.input :ticket_prefix,
placeholder: t('.placeholder.ticket_prefix', default: 'e.g.) AWE'),
hint: t('message.ticket_prefix_description', default: 'Ticket Prefix is an arbitrary string that is added to the beginning of the ticket number.') %>
<%= f.input :is_public %>

<div class="action d-flex justify-content-end">
Expand Down
Loading

0 comments on commit 15be751

Please sign in to comment.