Commit 35dde2bd92d160d987a924341b59cfbea73b93fa

Authored by Victor Costa
2 parents cdd82a9c 6fb56858

Merge branch 'task_taggable' into production

Conflicts:
	public/stylesheets/tasks.css
app/controllers/my_profile/tasks_controller.rb
... ... @@ -38,18 +38,33 @@ class TasksController < MyProfileController
38 38  
39 39 def close
40 40 failed = {}
  41 + save = false
41 42  
42 43 if params[:tasks]
43 44 params[:tasks].each do |id, value|
44 45 decision = value[:decision]
45   - if request.post? && VALID_DECISIONS.include?(decision) && id && decision != 'skip'
  46 +
  47 + if value[:task].is_a?(Hash) && value[:task][:tag_list]
  48 +
46 49 task = profile.find_in_all_tasks(id)
47   - begin
48   - task.update_attributes(value[:task])
49   - task.send(decision)
50   - rescue Exception => ex
51   - message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})"
52   - failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message]
  50 + task.tag_list = value[:task][:tag_list]
  51 + value[:task].delete('tag_list')
  52 +
  53 + save = true
  54 + end
  55 +
  56 + if request.post?
  57 + if VALID_DECISIONS.include?(decision) && id && decision != 'skip'
  58 + task ||= profile.find_in_all_tasks(id)
  59 + begin
  60 + task.update_attributes(value[:task])
  61 + task.send(decision)
  62 + rescue Exception => ex
  63 + message = "#{task.title} (#{task.requestor ? task.requestor.name : task.author_name})"
  64 + failed[ex.message] ? failed[ex.message] << message : failed[ex.message] = [message]
  65 + end
  66 + elsif save
  67 + task.save!
53 68 end
54 69 end
55 70 end
... ...
app/models/task.rb
... ... @@ -12,6 +12,7 @@
12 12 class Task < ActiveRecord::Base
13 13  
14 14 acts_as_having_settings :field => :data
  15 + acts_as_ordered_taggable
15 16  
16 17 module Status
17 18 # the status of tasks just created
... ...
app/views/tasks/_task.html.erb
... ... @@ -50,6 +50,13 @@
50 50 <%= render :partial => partial_for_class(task.class, nil, :reject_details), :locals => {:task => task, :f => f} %>
51 51 </div>
52 52 <% end %>
  53 +
  54 + <div class="formfieldline">
  55 + <div class="formfield tag-list-fields">
  56 + <%= labelled_text_field(_('Tags'),"tasks[#{task.id}][task][tag_list]", task.tag_list.to_s, :size => 36, :class => 'tag-list') %>
  57 + </div>
  58 + </div>
  59 +
53 60 <% end %>
54 61  
55 62 </div><!-- class="task_box" -->
... ...
app/views/tasks/index.html.erb
... ... @@ -65,6 +65,13 @@
65 65 </p>
66 66 </ul>
67 67  
  68 + <script>
  69 + jQuery('.tag-list').inputosaurus({
  70 + autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/cms/search_tags'," %>
  71 + activateFinalResult : true
  72 + })
  73 + </script>
  74 +
68 75 <%= pagination_links(@tasks)%>
69 76  
70 77 <% button_bar do %>
... ...
public/stylesheets/tasks.css
... ... @@ -48,3 +48,23 @@
48 48 .task_responsible {
49 49 text-align: right;
50 50 }
  51 +
  52 +/* Task tags list */
  53 +
  54 +.formfieldline label {
  55 + font-weight: bold;
  56 + margin: 0 5px 0 10px;
  57 +}
  58 +
  59 +.formfieldline .inputosaurus-container {
  60 + vertical-align: middle;
  61 +}
  62 +
  63 +.tag-list-fields input {
  64 + background-color: #fff !important;
  65 +}
  66 +
  67 +.formfield.tag-list-fields .ui-autocomplete-loading {
  68 + background: url('/images/loading-small.gif') right center no-repeat !important;
  69 + background-color: #fff !important;
  70 +}
... ...