Commit 73403c4c authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'issuable-new-due-date' into 'master'

Issuable form due date

For some reason, this was never in the original merge request for due date?

![Screen_Shot_2016-04-22_at_21.49.44](/uploads/7d4e2b07f75a33009e3170fdb076a4bd/Screen_Shot_2016-04-22_at_21.49.44.png)

Closes #15516

See merge request !3895
parents 98b1daf3 f307ff34
...@@ -20,6 +20,15 @@ class @IssuableForm ...@@ -20,6 +20,15 @@ class @IssuableForm
@initWip() @initWip()
$issuableDueDate = $('#issuable-due-date')
if $issuableDueDate.length
$('.datepicker').datepicker(
dateFormat: 'yy-mm-dd',
onSelect: (dateText, inst) ->
$issuableDueDate.val dateText
).datepicker 'setDate', $.datepicker.parseDate('yy-mm-dd', $issuableDueDate.val())
initAutosave: -> initAutosave: ->
new Autosave @titleField, [ new Autosave @titleField, [
document.location.pathname, document.location.pathname,
......
...@@ -28,10 +28,6 @@ input[type='text'].danger { ...@@ -28,10 +28,6 @@ input[type='text'].danger {
} }
label { label {
&.control-label {
@extend .col-sm-2;
}
&.inline-label { &.inline-label {
margin: 0; margin: 0;
} }
...@@ -41,6 +37,10 @@ label { ...@@ -41,6 +37,10 @@ label {
} }
} }
.control-label {
@extend .col-sm-2;
}
.inline-input-group { .inline-input-group {
width: 250px; width: 250px;
} }
......
...@@ -44,22 +44,23 @@ ...@@ -44,22 +44,23 @@
This issue is confidential and should only be visible to team members This issue is confidential and should only be visible to team members
- if can?(current_user, :"admin_#{issuable.to_ability_name}", issuable.project) - if can?(current_user, :"admin_#{issuable.to_ability_name}", issuable.project)
- has_due_date = issuable.has_attribute?(:due_date)
%hr %hr
.form-group .row
.issue-assignee %div{ class: (has_due_date ? "col-lg-6" : "col-sm-12") }
= f.label :assignee_id, "Assignee", class: 'control-label' .form-group.issue-assignee
.col-sm-10 = f.label :assignee_id, "Assignee", class: "control-label #{"col-lg-4" if has_due_date}"
.col-sm-10{ class: ("col-lg-8" if has_due_date) }
.issuable-form-select-holder .issuable-form-select-holder
= users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]", = users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]",
placeholder: 'Select assignee', class: 'custom-form-control', null_user: true, placeholder: 'Select assignee', class: 'custom-form-control', null_user: true,
selected: issuable.assignee_id, project: @target_project || @project, selected: issuable.assignee_id, project: @target_project || @project,
first_user: true, current_user: true, include_blank: true) first_user: true, current_user: true, include_blank: true)
  %div
= link_to 'Assign to me', '#', class: 'btn assign-to-me-link' = link_to 'Assign to me', '#', class: 'assign-to-me-link prepend-top-5 inline'
.form-group .form-group.issue-milestone
.issue-milestone = f.label :milestone_id, "Milestone", class: "control-label #{"col-lg-4" if has_due_date}"
= f.label :milestone_id, "Milestone", class: 'control-label' .col-sm-10{ class: ("col-lg-8" if has_due_date) }
.col-sm-10
- if milestone_options(issuable).present? - if milestone_options(issuable).present?
.issuable-form-select-holder .issuable-form-select-holder
= f.select(:milestone_id, milestone_options(issuable), = f.select(:milestone_id, milestone_options(issuable),
...@@ -67,22 +68,29 @@ ...@@ -67,22 +68,29 @@
- else - else
.prepend-top-10 .prepend-top-10
%span.light No open milestones available. %span.light No open milestones available.
 
- if can? current_user, :admin_milestone, issuable.project - if can? current_user, :admin_milestone, issuable.project
= link_to 'Create new milestone', new_namespace_project_milestone_path(issuable.project.namespace, issuable.project), target: :blank %div
= link_to 'Create new milestone', new_namespace_project_milestone_path(issuable.project.namespace, issuable.project), target: :blank, class: "prepend-top-5 inline"
.form-group .form-group
- has_labels = issuable.project.labels.any? - has_labels = issuable.project.labels.any?
= f.label :label_ids, "Labels", class: 'control-label' = f.label :label_ids, "Labels", class: "control-label #{"col-lg-4" if has_due_date}"
.col-sm-10{ class: ('issuable-form-padding-top' if !has_labels) } .col-sm-10{ class: "#{"col-lg-8" if has_due_date} #{'issuable-form-padding-top' if !has_labels}" }
- if has_labels - if has_labels
.issuable-form-select-holder .issuable-form-select-holder
= f.collection_select :label_ids, issuable.project.labels.all, :id, :name, = f.collection_select :label_ids, issuable.project.labels.all, :id, :name,
{ selected: issuable.label_ids }, multiple: true, class: 'select2', data: { placeholder: "Select labels" } { selected: issuable.label_ids }, multiple: true, class: 'select2', data: { placeholder: "Select labels" }
- else - else
%span.light No labels yet. %span.light No labels yet.
 
- if can? current_user, :admin_label, issuable.project - if can? current_user, :admin_label, issuable.project
= link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank %div
= link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank, class: "prepend-top-5 inline"
- if has_due_date
.col-lg-6
.form-group
= f.label :due_date, "Due date", class: "control-label"
= f.hidden_field :due_date, id: "issuable-due-date"
.col-sm-10
.datepicker
- if issuable.can_move?(current_user) - if issuable.can_move?(current_user)
%hr %hr
......
...@@ -64,6 +64,64 @@ describe 'Issues', feature: true do ...@@ -64,6 +64,64 @@ describe 'Issues', feature: true do
end end
end end
describe 'due date', js: true do
context 'on new form' do
before do
visit new_namespace_project_issue_path(project.namespace, project)
end
it 'should save with due date' do
date = Date.today.at_beginning_of_month
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
page.within '.datepicker' do
click_link date.day
end
expect(find('#issuable-due-date', visible: false).value).to eq date.to_s
click_button 'Submit issue'
page.within '.issuable-sidebar' do
expect(page).to have_content date.to_s(:medium)
end
end
end
context 'on edit form' do
let(:issue) { create(:issue, author: @user,project: project, due_date: Date.today.at_beginning_of_month.to_s) }
before do
visit edit_namespace_project_issue_path(project.namespace, project, issue)
end
it 'should save with due date' do
date = Date.today.at_beginning_of_month
expect(find('#issuable-due-date', visible: false).value).to eq date.to_s
date = date.tomorrow
fill_in 'issue_title', with: 'bug 345'
fill_in 'issue_description', with: 'bug description'
page.within '.datepicker' do
click_link date.day
end
expect(find('#issuable-due-date', visible: false).value).to eq date.to_s
click_button 'Save changes'
page.within '.issuable-sidebar' do
expect(page).to have_content date.to_s(:medium)
end
end
end
end
describe 'Issue info' do describe 'Issue info' do
it 'excludes award_emoji from comment count' do it 'excludes award_emoji from comment count' do
issue = create(:issue, author: @user, assignee: @user, project: project, title: 'foobar') issue = create(:issue, author: @user, assignee: @user, project: project, title: 'foobar')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment