609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
# File 'lib/sup/modes/thread_index_mode.rb', line 609
def multi_edit_labels threads
user_labels = BufferManager.ask_for_labels :labels, "Add/remove labels (use -label to remove): ", [], @hidden_labels
return unless user_labels
user_labels.map! { |l| (l.to_s =~ /^-/)? [l.to_s.gsub(/^-?/, '').to_sym, true] : [l, false] }
hl = user_labels.select { |(l,_)| @hidden_labels.member? l }
unless hl.empty?
BufferManager.flash "'#{hl}' is a reserved label!"
return
end
old_labels = threads.map { |t| t.labels.dup }
threads.each do |t|
user_labels.each do |(l, to_remove)|
if to_remove
t.remove_label l
else
t.apply_label l
LabelManager << l
end
end
UpdateManager.relay self, :labeled, t.first
end
regen_text
UndoManager.register "labeling #{threads.size.pluralize 'thread'}" do
threads.zip(old_labels).map do |t, old_labels|
t.labels = old_labels
UpdateManager.relay self, :labeled, t.first
Index.save_thread t
end
regen_text
end
threads.each { |t| Index.save_thread t }
end
|