mail/ui/outbox.lua

53 lines
1.9 KiB
Lua
Raw Normal View History

local sent_formspec = "size[8.5,10;]" .. mail.theme .. [[
tabheader[0.3,1;boxtab;]] .. S("Inbox") .. "," .. S("Sent messages") .. [[;2;false;false]
View sent messages (new database, add maillists) (#26) * Add tabheader & sent formspec * Add show_sent function and show sent messages * Remove comment on selected_idxs test (show_sent) * Add variable to keep the previous tab instead of going back to the first one * Remove index variable verification on mark read/unread buttons since they are necessarily clicked on inbox view * Resize messages table to be aligned with close button at the bottom * Show date time (#27) * Show date in message reading * Fix wrong registered dates Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Rework header layout to add better space for date --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Add insertion of messages into global storage mail.messages.json * Receive player messages from global storage * Add automatic generation of status for a new message (unread) * Mark read/unread/delete a message * Fix messages loading * Show every message received/sent via specific functions * Use global contacts functions and reconfigure add/remove functions * Create mail lists formspec based on contacts * Add deleting contact * Add ability to create mail lists * Fix inability to edit contact * Rework on editing/deletion of contacts/maillists * Add at symbol as prefix on maillists view * Add ability to choose default status (to/cc/bcc) Signed-off-by: Athozus <athozus@gmail.com> * Add ability to add multiples players and choose their default status (to/cc/bcc) * Add ability to use maillist in messages and receive messages from them * Fix repetition of code causing a crash * Avoid multiples occurences of the same messages due to player both in maillist and receivers * Fix selected indexes for inbox/sent Now separated, fixed show_message() func selection of id from table dcl/read btn * Fix many issues related to maillists Notably : edit, delete, selection, creation, registration of players * Set up database version v3 and its migration from v2 + Check versions to choose v1->v2 or v2->v3 * Fix mtt.lua Due to old function getMessages(), replaced by getPlayerInboxMessages() * Add 10 seconds security to mtt.lua * Fix migrate.lua non-declared variable * Send msg table with string keys in mtt * Better log messages * Add message check * Fix mtt crash * Better syntax in storage.lua * Fix bcc forgotten in mail.send() * Fix mtt issue * Better compatibility for messages storage Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Replace mail.split by builtin func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func in storage.lua * re-add mtt if * luacheck on PR * add check for an ancient issue with missing `to` field * Fix luacheck on storage.lua * Fix luacheck warnings in migrate.lua * Fix luacheck warnings in gui.lua * Fix luacheck (too long lines) in storage.lua * Unused loop values in migrate.lua * Whitespace line in gui.lua * Whitespace line (init.lua) * Whitespace line (api.lua) * Significantly improve maillist behaviour Replace maillist by its players when sending a message List of players separated by , Avoid doublons when editing more than 2 times a maillist * Fix luacheck * Fix table insertions at first index when no needed * Use funcs * Do not add maillist as a new contact when sending a mail * Fix removing elements from tables * Check maillists not added in contacts * storage rewrite wip * storage format docs * refactor ui components * show_compose cleanup * remove unused channel.lua * error -> err * status refactoring * contacts refactoring * maillist refactoring * docs * tests * fix some issues * re-enable migrations * contributors * prefix mail entries in the mod storage * internalize old mail-paths to migration module * add v1 and v2 player db examples and migration test * Ui improvements & fixes Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward * Show most recent messages at first (outbox) * unified-inv fix --------- Signed-off-by: Athozus <athozus@gmail.com> Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2023-03-29 18:25:01 +03:00
button[6,0.10;2.5,0.5;new;]] .. S("New") .. [[]
button[6,0.95;2.5,0.5;read;]] .. S("Read") .. [[]
button[6,1.70;2.5,0.5;reply;]] .. S("Reply") .. [[]
button[6,2.45;2.5,0.5;replyall;]] .. S("Reply all") .. [[]
button[6,3.20;2.5,0.5;forward;]] .. S("Forward") .. [[]
button[6,3.95;2.5,0.5;delete;]] .. S("Delete") .. [[]
button[6,6.8;2.5,0.5;contacts;]] .. S("Contacts") .. [[]
button[6,7.6;2.5,0.5;maillists;]] .. S("Mail lists") .. [[]
button[6,8.7;2.5,0.5;about;]] .. S("About") .. [[]
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
View sent messages (new database, add maillists) (#26) * Add tabheader & sent formspec * Add show_sent function and show sent messages * Remove comment on selected_idxs test (show_sent) * Add variable to keep the previous tab instead of going back to the first one * Remove index variable verification on mark read/unread buttons since they are necessarily clicked on inbox view * Resize messages table to be aligned with close button at the bottom * Show date time (#27) * Show date in message reading * Fix wrong registered dates Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Rework header layout to add better space for date --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Add insertion of messages into global storage mail.messages.json * Receive player messages from global storage * Add automatic generation of status for a new message (unread) * Mark read/unread/delete a message * Fix messages loading * Show every message received/sent via specific functions * Use global contacts functions and reconfigure add/remove functions * Create mail lists formspec based on contacts * Add deleting contact * Add ability to create mail lists * Fix inability to edit contact * Rework on editing/deletion of contacts/maillists * Add at symbol as prefix on maillists view * Add ability to choose default status (to/cc/bcc) Signed-off-by: Athozus <athozus@gmail.com> * Add ability to add multiples players and choose their default status (to/cc/bcc) * Add ability to use maillist in messages and receive messages from them * Fix repetition of code causing a crash * Avoid multiples occurences of the same messages due to player both in maillist and receivers * Fix selected indexes for inbox/sent Now separated, fixed show_message() func selection of id from table dcl/read btn * Fix many issues related to maillists Notably : edit, delete, selection, creation, registration of players * Set up database version v3 and its migration from v2 + Check versions to choose v1->v2 or v2->v3 * Fix mtt.lua Due to old function getMessages(), replaced by getPlayerInboxMessages() * Add 10 seconds security to mtt.lua * Fix migrate.lua non-declared variable * Send msg table with string keys in mtt * Better log messages * Add message check * Fix mtt crash * Better syntax in storage.lua * Fix bcc forgotten in mail.send() * Fix mtt issue * Better compatibility for messages storage Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Replace mail.split by builtin func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func in storage.lua * re-add mtt if * luacheck on PR * add check for an ancient issue with missing `to` field * Fix luacheck on storage.lua * Fix luacheck warnings in migrate.lua * Fix luacheck warnings in gui.lua * Fix luacheck (too long lines) in storage.lua * Unused loop values in migrate.lua * Whitespace line in gui.lua * Whitespace line (init.lua) * Whitespace line (api.lua) * Significantly improve maillist behaviour Replace maillist by its players when sending a message List of players separated by , Avoid doublons when editing more than 2 times a maillist * Fix luacheck * Fix table insertions at first index when no needed * Use funcs * Do not add maillist as a new contact when sending a mail * Fix removing elements from tables * Check maillists not added in contacts * storage rewrite wip * storage format docs * refactor ui components * show_compose cleanup * remove unused channel.lua * error -> err * status refactoring * contacts refactoring * maillist refactoring * docs * tests * fix some issues * re-enable migrations * contributors * prefix mail entries in the mod storage * internalize old mail-paths to migration module * add v1 and v2 player db examples and migration test * Ui improvements & fixes Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward * Show most recent messages at first (outbox) * unified-inv fix --------- Signed-off-by: Athozus <athozus@gmail.com> Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2023-03-29 18:25:01 +03:00
tablecolumns[color;text;text]
table[0,0.7;5.75,9.35;sent;#999,]] .. S("To") .. "," .. S("Subject")
View sent messages (new database, add maillists) (#26) * Add tabheader & sent formspec * Add show_sent function and show sent messages * Remove comment on selected_idxs test (show_sent) * Add variable to keep the previous tab instead of going back to the first one * Remove index variable verification on mark read/unread buttons since they are necessarily clicked on inbox view * Resize messages table to be aligned with close button at the bottom * Show date time (#27) * Show date in message reading * Fix wrong registered dates Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Rework header layout to add better space for date --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Add insertion of messages into global storage mail.messages.json * Receive player messages from global storage * Add automatic generation of status for a new message (unread) * Mark read/unread/delete a message * Fix messages loading * Show every message received/sent via specific functions * Use global contacts functions and reconfigure add/remove functions * Create mail lists formspec based on contacts * Add deleting contact * Add ability to create mail lists * Fix inability to edit contact * Rework on editing/deletion of contacts/maillists * Add at symbol as prefix on maillists view * Add ability to choose default status (to/cc/bcc) Signed-off-by: Athozus <athozus@gmail.com> * Add ability to add multiples players and choose their default status (to/cc/bcc) * Add ability to use maillist in messages and receive messages from them * Fix repetition of code causing a crash * Avoid multiples occurences of the same messages due to player both in maillist and receivers * Fix selected indexes for inbox/sent Now separated, fixed show_message() func selection of id from table dcl/read btn * Fix many issues related to maillists Notably : edit, delete, selection, creation, registration of players * Set up database version v3 and its migration from v2 + Check versions to choose v1->v2 or v2->v3 * Fix mtt.lua Due to old function getMessages(), replaced by getPlayerInboxMessages() * Add 10 seconds security to mtt.lua * Fix migrate.lua non-declared variable * Send msg table with string keys in mtt * Better log messages * Add message check * Fix mtt crash * Better syntax in storage.lua * Fix bcc forgotten in mail.send() * Fix mtt issue * Better compatibility for messages storage Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Replace mail.split by builtin func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func in storage.lua * re-add mtt if * luacheck on PR * add check for an ancient issue with missing `to` field * Fix luacheck on storage.lua * Fix luacheck warnings in migrate.lua * Fix luacheck warnings in gui.lua * Fix luacheck (too long lines) in storage.lua * Unused loop values in migrate.lua * Whitespace line in gui.lua * Whitespace line (init.lua) * Whitespace line (api.lua) * Significantly improve maillist behaviour Replace maillist by its players when sending a message List of players separated by , Avoid doublons when editing more than 2 times a maillist * Fix luacheck * Fix table insertions at first index when no needed * Use funcs * Do not add maillist as a new contact when sending a mail * Fix removing elements from tables * Check maillists not added in contacts * storage rewrite wip * storage format docs * refactor ui components * show_compose cleanup * remove unused channel.lua * error -> err * status refactoring * contacts refactoring * maillist refactoring * docs * tests * fix some issues * re-enable migrations * contributors * prefix mail entries in the mod storage * internalize old mail-paths to migration module * add v1 and v2 player db examples and migration test * Ui improvements & fixes Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward * Show most recent messages at first (outbox) * unified-inv fix --------- Signed-off-by: Athozus <athozus@gmail.com> Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2023-03-29 18:25:01 +03:00
function mail.show_sent(name)
local formspec = { sent_formspec }
local entry = mail.get_storage_entry(name)
local messages = entry.outbox
mail.message_drafts[name] = nil
if messages[1] then
for _, message in ipairs(messages) do
formspec[#formspec + 1] = ","
formspec[#formspec + 1] = ","
formspec[#formspec + 1] = minetest.formspec_escape(message.to)
formspec[#formspec + 1] = ","
if message.subject ~= "" then
if string.len(message.subject) > 30 then
formspec[#formspec + 1] = minetest.formspec_escape(string.sub(message.subject, 1, 27))
formspec[#formspec + 1] = "..."
else
formspec[#formspec + 1] = minetest.formspec_escape(message.subject)
end
else
formspec[#formspec + 1] = S("(No subject)")
View sent messages (new database, add maillists) (#26) * Add tabheader & sent formspec * Add show_sent function and show sent messages * Remove comment on selected_idxs test (show_sent) * Add variable to keep the previous tab instead of going back to the first one * Remove index variable verification on mark read/unread buttons since they are necessarily clicked on inbox view * Resize messages table to be aligned with close button at the bottom * Show date time (#27) * Show date in message reading * Fix wrong registered dates Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Rework header layout to add better space for date --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Add insertion of messages into global storage mail.messages.json * Receive player messages from global storage * Add automatic generation of status for a new message (unread) * Mark read/unread/delete a message * Fix messages loading * Show every message received/sent via specific functions * Use global contacts functions and reconfigure add/remove functions * Create mail lists formspec based on contacts * Add deleting contact * Add ability to create mail lists * Fix inability to edit contact * Rework on editing/deletion of contacts/maillists * Add at symbol as prefix on maillists view * Add ability to choose default status (to/cc/bcc) Signed-off-by: Athozus <athozus@gmail.com> * Add ability to add multiples players and choose their default status (to/cc/bcc) * Add ability to use maillist in messages and receive messages from them * Fix repetition of code causing a crash * Avoid multiples occurences of the same messages due to player both in maillist and receivers * Fix selected indexes for inbox/sent Now separated, fixed show_message() func selection of id from table dcl/read btn * Fix many issues related to maillists Notably : edit, delete, selection, creation, registration of players * Set up database version v3 and its migration from v2 + Check versions to choose v1->v2 or v2->v3 * Fix mtt.lua Due to old function getMessages(), replaced by getPlayerInboxMessages() * Add 10 seconds security to mtt.lua * Fix migrate.lua non-declared variable * Send msg table with string keys in mtt * Better log messages * Add message check * Fix mtt crash * Better syntax in storage.lua * Fix bcc forgotten in mail.send() * Fix mtt issue * Better compatibility for messages storage Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Replace mail.split by builtin func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func in storage.lua * re-add mtt if * luacheck on PR * add check for an ancient issue with missing `to` field * Fix luacheck on storage.lua * Fix luacheck warnings in migrate.lua * Fix luacheck warnings in gui.lua * Fix luacheck (too long lines) in storage.lua * Unused loop values in migrate.lua * Whitespace line in gui.lua * Whitespace line (init.lua) * Whitespace line (api.lua) * Significantly improve maillist behaviour Replace maillist by its players when sending a message List of players separated by , Avoid doublons when editing more than 2 times a maillist * Fix luacheck * Fix table insertions at first index when no needed * Use funcs * Do not add maillist as a new contact when sending a mail * Fix removing elements from tables * Check maillists not added in contacts * storage rewrite wip * storage format docs * refactor ui components * show_compose cleanup * remove unused channel.lua * error -> err * status refactoring * contacts refactoring * maillist refactoring * docs * tests * fix some issues * re-enable migrations * contributors * prefix mail entries in the mod storage * internalize old mail-paths to migration module * add v1 and v2 player db examples and migration test * Ui improvements & fixes Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward * Show most recent messages at first (outbox) * unified-inv fix --------- Signed-off-by: Athozus <athozus@gmail.com> Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2023-03-29 18:25:01 +03:00
end
end
if mail.selected_idxs.sent[name] then
formspec[#formspec + 1] = ";"
formspec[#formspec + 1] = tostring(mail.selected_idxs.sent[name] + 1)
end
formspec[#formspec + 1] = "]"
else
formspec[#formspec + 1] = "]label[2.25,4.5;" .. S("No mail") .. "]"
View sent messages (new database, add maillists) (#26) * Add tabheader & sent formspec * Add show_sent function and show sent messages * Remove comment on selected_idxs test (show_sent) * Add variable to keep the previous tab instead of going back to the first one * Remove index variable verification on mark read/unread buttons since they are necessarily clicked on inbox view * Resize messages table to be aligned with close button at the bottom * Show date time (#27) * Show date in message reading * Fix wrong registered dates Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Rework header layout to add better space for date --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Add insertion of messages into global storage mail.messages.json * Receive player messages from global storage * Add automatic generation of status for a new message (unread) * Mark read/unread/delete a message * Fix messages loading * Show every message received/sent via specific functions * Use global contacts functions and reconfigure add/remove functions * Create mail lists formspec based on contacts * Add deleting contact * Add ability to create mail lists * Fix inability to edit contact * Rework on editing/deletion of contacts/maillists * Add at symbol as prefix on maillists view * Add ability to choose default status (to/cc/bcc) Signed-off-by: Athozus <athozus@gmail.com> * Add ability to add multiples players and choose their default status (to/cc/bcc) * Add ability to use maillist in messages and receive messages from them * Fix repetition of code causing a crash * Avoid multiples occurences of the same messages due to player both in maillist and receivers * Fix selected indexes for inbox/sent Now separated, fixed show_message() func selection of id from table dcl/read btn * Fix many issues related to maillists Notably : edit, delete, selection, creation, registration of players * Set up database version v3 and its migration from v2 + Check versions to choose v1->v2 or v2->v3 * Fix mtt.lua Due to old function getMessages(), replaced by getPlayerInboxMessages() * Add 10 seconds security to mtt.lua * Fix migrate.lua non-declared variable * Send msg table with string keys in mtt * Better log messages * Add message check * Fix mtt crash * Better syntax in storage.lua * Fix bcc forgotten in mail.send() * Fix mtt issue * Better compatibility for messages storage Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Replace mail.split by builtin func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Use builtin split func in storage.lua * re-add mtt if * luacheck on PR * add check for an ancient issue with missing `to` field * Fix luacheck on storage.lua * Fix luacheck warnings in migrate.lua * Fix luacheck warnings in gui.lua * Fix luacheck (too long lines) in storage.lua * Unused loop values in migrate.lua * Whitespace line in gui.lua * Whitespace line (init.lua) * Whitespace line (api.lua) * Significantly improve maillist behaviour Replace maillist by its players when sending a message List of players separated by , Avoid doublons when editing more than 2 times a maillist * Fix luacheck * Fix table insertions at first index when no needed * Use funcs * Do not add maillist as a new contact when sending a mail * Fix removing elements from tables * Check maillists not added in contacts * storage rewrite wip * storage format docs * refactor ui components * show_compose cleanup * remove unused channel.lua * error -> err * status refactoring * contacts refactoring * maillist refactoring * docs * tests * fix some issues * re-enable migrations * contributors * prefix mail entries in the mod storage * internalize old mail-paths to migration module * add v1 and v2 player db examples and migration test * Ui improvements & fixes Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward * Show most recent messages at first (outbox) * unified-inv fix --------- Signed-off-by: Athozus <athozus@gmail.com> Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
2023-03-29 18:25:01 +03:00
end
minetest.show_formspec(name, "mail:sent", table.concat(formspec, ""))
end