From 948d2af0e836e013544bddc8459cb34e0c48754c Mon Sep 17 00:00:00 2001 From: Christophe Lejeune Date: Mon, 2 Nov 2020 16:37:15 +0100 Subject: [PATCH] FEATURE: Storing selected text when coding a memo (#106) If the user selects a portion of a field/interview/transcript memo and then creates a coding memo, the resulting memo includes the selected text as a quotation (formatted as a `blockquote`). If the user grounds an already existing code, the quotation is appended to the existing coding memo. --- app/_attachments/main.css | 14 ++++++++++++++ app/lib/shared.js | 3 ++- app/templates/diary.html | 2 +- app/templates/memo.html | 12 +++++++----- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/_attachments/main.css b/app/_attachments/main.css index a047a9a..d5fd61d 100644 --- a/app/_attachments/main.css +++ b/app/_attachments/main.css @@ -9,6 +9,13 @@ body { margin: 0; } +blockquote { + color: gray; + margin-left: 1rem; + padding-left: 1rem; + border-left: 3px gray solid; +} + #leaves a, #groundings a, #content a { color: gray !important; @@ -145,6 +152,13 @@ div.post { width: 100%; } +.mytooltip:hover .preview blockquote { + color: white; + padding-left: 1rem; + padding-left: 0rem; + border-left: 0px; +} + .card>p>.moment, .comment>.meta, #negative-case>.meta, diff --git a/app/lib/shared.js b/app/lib/shared.js index 9c58832..0c870c0 100644 --- a/app/lib/shared.js +++ b/app/lib/shared.js @@ -189,7 +189,7 @@ var shared = { create(classlist[classlist.length - 1], $('#leave-name').val().trim());\ }\ });\ - function create(type, name) {\ + function create(type, name, highlight) {\ $('.spinner').removeClass('d-none');\ if (name.replace(/[ ,]/g, '') == '' && type != 'diagram') {\ $('.spinner').addClass('d-none');\ @@ -297,6 +297,7 @@ var shared = { destination += 'editable_memo/';\ data.diary = '{{diary}}',\ data.body = '';\ + if (type == 'coding' && highlight.length > 0) data.body += '> '+highlight+'\\n';\ data.type = type;\ }\ if (type) {\ diff --git a/app/templates/diary.html b/app/templates/diary.html index e33171c..baab564 100644 --- a/app/templates/diary.html +++ b/app/templates/diary.html @@ -291,7 +291,7 @@

{{diary_name}} momentRelative('#memos'); converter.setFlavor('github'); $('.preview').html(function(i, text) { - return converter.makeHtml(text.trim()); + return converter.makeHtml(text.replace(/>/g, '>').trim()); }); var nothing_to_show = '{{i18n.i_nothing-to-show}}'; {{^logged}}nothing_to_show +='. {{i18n.i_sign-in-for-more}}';{{/logged}} diff --git a/app/templates/memo.html b/app/templates/memo.html index 1abf7e5..b3dba38 100644 --- a/app/templates/memo.html +++ b/app/templates/memo.html @@ -395,7 +395,7 @@

{{name}}

strikethrough: 'true' }); $('.post').html(function(i, text) { - return converter.makeHtml(text.trim()); + return converter.makeHtml(text.replace(/>/g, '>').trim()); }); if ($('#groundings li').length == 1) $("#groundings").find('legend').text("{{i18n.i_grounding}}"); if ($('#groundings li').length < 1) $("#groundings").addClass('hidden'); @@ -537,31 +537,33 @@

{{name}}

$("#field-leaf").prop("checked", true).trigger("click"); $('#field_title_dialog').modal('show'); } else { - create(type, $('#leave-name').val().trim()); + create(type, $('#leave-name').val().trim(), $('#kwic').val()); } }); $('#create').on('click', function() { var name = $('#leave-name').val().trim(), classlist = $(this)[0].classList, + highlight = $('#kwic').val(), type = classlist[classlist.length - 1]; if (type == 'diagram') name = $('#name').val().trim(); if (type == 'interview') { $("#transcript-leaf").prop("checked", true).trigger("click"); $('#field_title_dialog').modal('show'); } else { - create(type, name); + create(type, name, highlight); } }); $('#create_field-memo').on('click', function() { var name = $('#location').val().trim() + ', ' + $('#date').val().trim(), + highlight = $('#kwic').val(), type = $('input[name="type-of-field-memo"]:checked').val(); if (type != 'field') name = $('#pseudonym').val().trim() + ', ' + name; if ([$('#location').val().trim(), $('#date').val().trim()].indexOf('') > -1) { alert('{{i18n.i_enter_location_date}}'); } else { - create(type, name); + create(type, name, highlight); } }); @@ -582,7 +584,7 @@

{{name}}

$('#create-table').on('click', function() { var classlist = $(this)[0].classList; type = classlist[classlist.length - 1]; - create(type, $('#leave-name').val().trim()); + create(type, $('#leave-name').val().trim(), $('#kwic').val()); }); $('#link_leaf').on('click', function() {