From 7db6eb6855891c22b2b1a45a0b3c61c260f09e64 Mon Sep 17 00:00:00 2001 From: Russell Cloran Date: Fri, 12 May 2023 16:44:32 -0700 Subject: [PATCH] Add option to not set keyword synonyms --- .../ExportServiceProvider.lua | 24 +++++++++++++++++++ .../SyncObservations.lua | 7 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lr-inaturalist-publish.lrdevplugin/ExportServiceProvider.lua b/lr-inaturalist-publish.lrdevplugin/ExportServiceProvider.lua index fe5f6a4..68f03a6 100644 --- a/lr-inaturalist-publish.lrdevplugin/ExportServiceProvider.lua +++ b/lr-inaturalist-publish.lrdevplugin/ExportServiceProvider.lua @@ -16,6 +16,7 @@ local exportServiceProvider = { { key = "login", default = "" }, { key = "syncKeywords", default = true }, { key = "syncKeywordsCommon", default = true }, + { key = "syncKeywordsSynonym", default = true }, { key = "syncKeywordsIncludeOnExport", default = true }, { key = "syncKeywordsRoot", default = -1 }, { key = "syncOnPublish", default = true }, @@ -233,6 +234,29 @@ function exportServiceProvider.sectionsForTopOfDialog(f, propertyTable) enabled = bind("syncKeywords"), }), }), + f:row({ + spacing = f:control_spacing(), + f:static_text({ + title = bind({ + keys = { "syncKeywordsCommon" }, + transform = function() + local r = "Set common name as a keyword synonym" + if propertyTable.syncKeywordsCommon then + r = "Set scientific name as a keyword synonym" + end + r = r .. '\nKeyword synonyms are always exported (see "Help...")' + return r + end, + }), + alignment = "right", + width = LrView.share("inaturalistSyncLabel"), + enabled = bind("syncKeywords"), + }), + f:checkbox({ + value = bind("syncKeywordsSynonym"), + enabled = bind("syncKeywords"), + }), + }), f:row({ spacing = f:control_spacing(), f:static_text({ diff --git a/lr-inaturalist-publish.lrdevplugin/SyncObservations.lua b/lr-inaturalist-publish.lrdevplugin/SyncObservations.lua index 5b442b1..b94c8c6 100644 --- a/lr-inaturalist-publish.lrdevplugin/SyncObservations.lua +++ b/lr-inaturalist-publish.lrdevplugin/SyncObservations.lua @@ -181,8 +181,11 @@ local function createKeyword(kw, cache, settings) withWriteAccessDo("Create keyword " .. kw[#kw][1], function() for _, part in pairs(kw) do if not cache[part[1]] then - local tmp = - catalog:createKeyword(part[1], { part[2] }, settings.syncKeywordsIncludeOnExport, parent, true) + local syn = nil + if settings.syncKeywordsSynonym then + syn = { part[2] } + end + local tmp = catalog:createKeyword(part[1], syn, settings.syncKeywordsIncludeOnExport, parent, true) cache[part[1]] = { tmp } end cache = cache[part[1]]