Rework user-interface for editing recurring tasks
This commit is contained in:
parent
a8a434ef7b
commit
a00e7c94be
7 changed files with 79 additions and 58 deletions
|
@ -34,10 +34,8 @@ class TasksController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@task = Task.find(params[:id])
|
@task = Task.find(params[:id])
|
||||||
|
@periodic = !!params[:periodic]
|
||||||
@task.current_user_id = current_user.id
|
@task.current_user_id = current_user.id
|
||||||
if @task.periodic?
|
|
||||||
flash.now[:alert] = I18n.t('tasks.edit.warning_periodic').html_safe
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
@ -1,31 +1,11 @@
|
||||||
- content_for :javascript do
|
= form.hidden_field :current_user_id
|
||||||
:javascript
|
= form.input :name
|
||||||
$(function() {
|
= form.input :description, as: :text, input_html: {rows: 10}
|
||||||
$("#task_user_list").tokenInput("#{users_path(:format => :json)}", {
|
= form.input :duration, :as => :select, :collection => 1..3
|
||||||
crossDomain: false,
|
- unless local_assigns[:periodic]
|
||||||
prePopulate: $("#task_user_list").data("pre"),
|
= form.input :user_list, :as => :string, :input_html => { 'data-pre' => form.object.users.map(&:token_attributes).to_json }
|
||||||
hintText: '#{escape_javascript(t('.search.hint'))}',
|
= form.input :required_users
|
||||||
noResultText: '#{escape_javascript(t('.search.noresult'))}',
|
= form.association :workgroup
|
||||||
searchingText: '#{escape_javascript(t('.search.placeholder'))}',
|
= form.input :due_date, as: :date_picker
|
||||||
theme: 'facebook'
|
- unless local_assigns[:periodic]
|
||||||
});
|
= form.input :done
|
||||||
});
|
|
||||||
|
|
||||||
- content_for :sidebar do
|
|
||||||
= render "shared/workgroup_members"
|
|
||||||
|
|
||||||
= simple_form_for @task do |f|
|
|
||||||
= f.hidden_field :current_user_id
|
|
||||||
= f.input :name
|
|
||||||
= f.input :description, as: :text, input_html: {rows: 10}
|
|
||||||
= f.input :duration, :as => :select, :collection => 1..3
|
|
||||||
= f.input :user_list, :as => :string, :input_html => { 'data-pre' => @task.users.map(&:token_attributes).to_json }
|
|
||||||
= f.input :required_users
|
|
||||||
= f.association :workgroup
|
|
||||||
= f.input :due_date, as: :date_picker
|
|
||||||
= f.input :done
|
|
||||||
.form-actions
|
|
||||||
= f.submit class: 'btn btn-primary'
|
|
||||||
- if @task.new_record? or @task.periodic?
|
|
||||||
= f.submit t('.submit.periodic'), name: 'periodic', class: 'btn'
|
|
||||||
= link_to t('ui.or_cancel'), :back
|
|
||||||
|
|
15
app/views/tasks/_form_sidebar.html.haml
Normal file
15
app/views/tasks/_form_sidebar.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
- content_for :javascript do
|
||||||
|
:javascript
|
||||||
|
$(function() {
|
||||||
|
$("#task_user_list").tokenInput("#{users_path(:format => :json)}", {
|
||||||
|
crossDomain: false,
|
||||||
|
prePopulate: $("#task_user_list").data("pre"),
|
||||||
|
hintText: '#{escape_javascript(t('.search.hint'))}',
|
||||||
|
noResultText: '#{escape_javascript(t('.search.noresult'))}',
|
||||||
|
searchingText: '#{escape_javascript(t('.search.placeholder'))}',
|
||||||
|
theme: 'facebook'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
- content_for :sidebar do
|
||||||
|
= render "shared/workgroup_members"
|
|
@ -1,3 +1,15 @@
|
||||||
- title t('.title')
|
- title @periodic ? t('.title_periodic') : t('.title')
|
||||||
|
|
||||||
= render 'form'
|
- if @task.periodic? && !@periodic
|
||||||
|
.alert.alert-info= raw t('tasks.edit.warning_periodic')
|
||||||
|
|
||||||
|
= render 'form_sidebar'
|
||||||
|
|
||||||
|
= simple_form_for @task do |form|
|
||||||
|
= render 'form', form: form, periodic: @periodic
|
||||||
|
.form-actions
|
||||||
|
- if @periodic
|
||||||
|
= form.submit t('.submit_periodic'), name: 'periodic', class: 'btn btn-primary'
|
||||||
|
- else
|
||||||
|
= form.submit class: 'btn btn-primary'
|
||||||
|
= link_to t('ui.or_cancel'), :back
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
- title t('.title')
|
- title t('.title')
|
||||||
|
|
||||||
= render 'form'
|
= render 'form_sidebar'
|
||||||
|
|
||||||
|
= simple_form_for @task do |form|
|
||||||
|
= render 'form', form: form, periodic: nil
|
||||||
|
.form-actions
|
||||||
|
= form.submit class: 'btn btn-primary'
|
||||||
|
= form.submit t('.submit_periodic'), name: 'periodic', class: 'btn'
|
||||||
|
= link_to t('ui.or_cancel'), :back
|
||||||
|
|
|
@ -30,8 +30,14 @@
|
||||||
- unless @task.done?
|
- unless @task.done?
|
||||||
= link_to t('.mark_done'), set_done_task_path(@task), method: :post, class: 'btn'
|
= link_to t('.mark_done'), set_done_task_path(@task), method: :post, class: 'btn'
|
||||||
= link_to t('ui.edit'), edit_task_path(@task), class: 'btn'
|
= link_to t('ui.edit'), edit_task_path(@task), class: 'btn'
|
||||||
= link_to t('ui.delete'), task_path(@task), :method => :delete, :data => {:confirm => t('.confirm_delete_single')},
|
|
||||||
class: 'btn btn-danger'
|
|
||||||
- if @task.periodic?
|
- if @task.periodic?
|
||||||
= link_to t('.delete_group'), task_path(@task, periodic: true), method: :delete,
|
= link_to edit_task_path(@task, periodic: true), class: 'btn' do
|
||||||
:data => {confirm: t('.confirm_delete_group')}, class: 'btn btn-danger'
|
%i.icon.icon-repeat
|
||||||
|
= t('.edit_group')
|
||||||
|
= link_to t('ui.delete'), task_path(@task), method: :delete, class: 'btn btn-danger',
|
||||||
|
data: {confirm: @task.periodic? ? t('.confirm_delete_single_from_group') : t('.confirm_delete_single')}
|
||||||
|
- if @task.periodic?
|
||||||
|
= link_to task_path(@task, periodic: true), method: :delete, class: 'btn btn-danger',
|
||||||
|
data: {confirm: t('.confirm_delete_group')} do
|
||||||
|
%i.icon.icon-repeat
|
||||||
|
= t('.delete_group')
|
||||||
|
|
|
@ -1624,6 +1624,8 @@ en:
|
||||||
notice: Task has been deleted
|
notice: Task has been deleted
|
||||||
edit:
|
edit:
|
||||||
title: Edit task
|
title: Edit task
|
||||||
|
title_periodic: Edit periodic task
|
||||||
|
submit_periodic: Save periodic task
|
||||||
warning_periodic: "<strong>Warning:</strong> This task is part of a group of <em>weekly tasks</em>. When saving it will be excluded from the group and it will be converted to a <em>regular task</em>."
|
warning_periodic: "<strong>Warning:</strong> This task is part of a group of <em>weekly tasks</em>. When saving it will be excluded from the group and it will be converted to a <em>regular task</em>."
|
||||||
error_not_found: No workgroup found
|
error_not_found: No workgroup found
|
||||||
form:
|
form:
|
||||||
|
@ -1631,8 +1633,6 @@ en:
|
||||||
hint: Search for user
|
hint: Search for user
|
||||||
noresult: No user found
|
noresult: No user found
|
||||||
placeholder: Search ...
|
placeholder: Search ...
|
||||||
submit:
|
|
||||||
periodic: Save weekly task
|
|
||||||
index:
|
index:
|
||||||
show_group_tasks: Show group tasks
|
show_group_tasks: Show group tasks
|
||||||
title: Tasks
|
title: Tasks
|
||||||
|
@ -1653,7 +1653,8 @@ en:
|
||||||
new_task: Create new task
|
new_task: Create new task
|
||||||
pages: Pages
|
pages: Pages
|
||||||
new:
|
new:
|
||||||
title: Create new tasks
|
title: Create new task
|
||||||
|
submit_periodic: Create periodic task
|
||||||
repeated: Task is repeated weekly
|
repeated: Task is repeated weekly
|
||||||
set_done:
|
set_done:
|
||||||
notice: The state of the task has been updated
|
notice: The state of the task has been updated
|
||||||
|
@ -1661,7 +1662,9 @@ en:
|
||||||
accept_task: Accept task
|
accept_task: Accept task
|
||||||
confirm_delete_group: Really delete this and all subsequent tasks?
|
confirm_delete_group: Really delete this and all subsequent tasks?
|
||||||
confirm_delete_single: Are you sure you want to delete the task?
|
confirm_delete_single: Are you sure you want to delete the task?
|
||||||
|
confirm_delete_single_from_group: Are you sure you want to delete this task (and keep related periodic tasks)?
|
||||||
delete_group: Delete task and subsequent
|
delete_group: Delete task and subsequent
|
||||||
|
edit_group: Edit periodic
|
||||||
hours: "%{count}h"
|
hours: "%{count}h"
|
||||||
mark_done: Mark task as done
|
mark_done: Mark task as done
|
||||||
reject_task: Reject task
|
reject_task: Reject task
|
||||||
|
|
Loading…
Reference in a new issue