Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[modify] gws/message : add message sort
- Loading branch information
Showing
9 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Gws::Addon::Memo::MessageSort | ||
extend ActiveSupport::Concern | ||
extend SS::Addon | ||
|
||
included do | ||
field :gws_memo_message_sort, type: Hash, default: {} | ||
end | ||
|
||
public | ||
|
||
def memo_message_sort_hash(folder, sort, order) | ||
return @sort_hash if @sort_hash | ||
|
||
order = (order == "1") ? 1 : -1 | ||
if sort.present? && %w(from_member_name to_member_name subject priority send_date size).include?(sort) | ||
@sort_hash = { sort => order, "updated" => -1 } | ||
else | ||
@sort_hash = gws_memo_message_sort.dig(folder.site_id, folder.folder_path.gsub(/\./, "_")) | ||
@sort_hash ||= { "send_date" => -1, "updated" => -1 } | ||
end | ||
self.gws_memo_message_sort[folder.site_id] ||= {} | ||
self.gws_memo_message_sort[folder.site_id][folder.folder_path.gsub(/\./, "_")] = @sort_hash | ||
update | ||
|
||
@sort_hash | ||
end | ||
|
||
def memo_message_sort_query(sort_hash, name) | ||
if sort_hash[name] == -1 | ||
{ "sort" => name, "order" => 1 } | ||
else | ||
{ "sort" => name, "order" => -1 } | ||
end | ||
end | ||
|
||
def memo_message_sort_icon(sort_hash, name) | ||
if sort_hash[name] == -1 | ||
'<i class="material-icons md-18"></i>' | ||
elsif sort_hash[name] == 1 | ||
'<i class="material-icons md-18"></i>' | ||
else | ||
'<i class="material-icons md-18" style="visibility: hidden;"></i>' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# set to_member_ids | ||
class SS::Migration20180124000000 | ||
def change | ||
Gws::Memo::Message.each do |message| | ||
|
13 changes: 13 additions & 0 deletions
13
lib/migrations/gws/20180201000000_fix_gws_memo_messages.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# set member name for sort feature | ||
class SS::Migration20180201000000 | ||
def change | ||
Gws::Memo::Message.each do |message| | ||
if message.user && message.from_member_name.blank? | ||
message.set(from_member_name: message.user.long_name) | ||
end | ||
if message.display_to.present? && message.to_member_name.blank? | ||
message.set(to_member_name: message.display_to.join("; ")) | ||
end | ||
end | ||
end | ||
end |