lib/taskwarrior-web/model/task.rb in taskwarrior-web-1.1.7 vs lib/taskwarrior-web/model/task.rb in taskwarrior-web-1.1.8

- old
+ new

@@ -5,12 +5,11 @@ ################# class Task attr_accessor :entry, :project, :priority, :uuid, :description, :status, :due, :start, :end, :tags, :depends, :wait, :annotations, - :_errors, :remove_tags - alias :annotate= :annotations= + :urgency, :_errors, :remove_tags #################################### # MODEL METHODS FOR INDIVIDUAL TASKS #################################### @@ -19,10 +18,11 @@ send("#{attr}=", value) if respond_to?(attr.to_sym) end @_errors = [] @tags = [] if @tags.nil? + @annotations = [] if @annotations.nil? end def save! @uuid ? Command.new(:update, uuid, self.to_hash).run : Command.new(:add, nil, self.to_hash).run end @@ -39,9 +39,18 @@ def tags=(value) @tags = value.is_a?(String) ? value.split(/[, ]+/).reject(&:empty?) : value if @uuid @remove_tags = Task.find_by_uuid(uuid).first.tags - @tags + end + end + + # Create annotation instances. + def annotations=(annotations) + @annotations = [] + annotations.each do |annotation| + annotation.merge({ :task_id => self.uuid }) + @annotations << Annotation.new(annotation) end end def is_valid? @_errors << 'You must provide a description' if self.description.blank?