-
Notifications
You must be signed in to change notification settings - Fork 1
Allow corrections to fields and additions to empty fields #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tijmenbaarda
wants to merge
23
commits into
develop
Choose a base branch
from
feature/corrections
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1cc01c4
Add venv to gitignore
tijmenbaarda af7c6f7
Change icon of annotation button to pen
tijmenbaarda 37a762c
Prefill original text for new correcting annotations
tijmenbaarda 63057a0
Do not use nested table
tijmenbaarda 23bd7c4
Allow submitting annotation with Enter
tijmenbaarda 98da03b
Allow OA.editing as a motivation in backend
tijmenbaarda ecc1628
Correctly show edit annotations
tijmenbaarda 35eaa6a
Merge branch 'develop' into feature/corrections
tijmenbaarda b0a5a36
Separate motivations for additions and corrections
tijmenbaarda 6a3c5e6
Show corrected values in table
tijmenbaarda 292a90b
Update table when annotations are deleted
tijmenbaarda 2543014
Give modal focus on opening to make Esc key work
tijmenbaarda 33b326f
Show annotations to empty fields in table
tijmenbaarda 2b4eecc
Close annotation editor on escape
tijmenbaarda 1e22a2a
Allow dismissing the modal with escape after closing annotation editor
tijmenbaarda 5a6b981
Add clarification about textarea focus timeout
tijmenbaarda 5a147b1
Remove redundant line
tijmenbaarda bec3dbd
Fix incomplete comment
tijmenbaarda 6af110a
Simplify code
tijmenbaarda cde9d6f
Use has method of Backbone.js model
tijmenbaarda bddd079
Change confusing template data key name
tijmenbaarda 4a1552f
Remove code duplication
tijmenbaarda 84e7017
Update changed attribute name in other area
tijmenbaarda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| # Virtual environment | ||
| ENV/ | ||
| .env/ | ||
| venv/ | ||
|
|
||
| # node | ||
| node_modules | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 +1 @@ | ||
| <td title="{{publishedDate}}{{#updatedDate}} (updated: {{updatedDate}}){{/updatedDate}}"><span {{#isFieldAnnotation}}class="field-annotation"{{/isFieldAnnotation}}>{{#isTag}}<b>Tag: </b>{{/isTag}}{{displayText}} </span>{{#author}}<span class="authored-by">@{{author}}</span>{{/author}} </td> | ||
| <td title="{{#originalText}}Text before correction: {{originalText}}. {{/originalText}}{{publishedDate}}{{#updatedDate}} (updated: {{updatedDate}}){{/updatedDate}}"><span {{#isFieldComment}}class="field-annotation"{{/isFieldComment}}>{{#isTag}}<b>Tag: </b>{{/isTag}}{{displayText}} </span>{{#author}}<span class="authored-by">@{{author}}</span>{{/author}} </td> |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,15 +11,46 @@ import { | |
| } from "../utils/record-ontology"; | ||
| import {getStringLiteral} from "../utils/jsonld.model"; | ||
|
|
||
| /** | ||
| * Get correction for a field value based on | ||
| * @param {Object} value - the specific value to get the display of | ||
| * @param {Field} field - the whole field object | ||
| * @param {Annotations} [annotations] - annotations for the record | ||
| * @returns {string|undefined} | ||
| */ | ||
| function getCorrectedTextForFieldValue(value, field, annotations) { | ||
| if (!annotations) return undefined; | ||
| var annotation; | ||
| if (!value) { | ||
| // Field missing in the source data: edpopcol:originalText should not be present | ||
| annotation = annotations.find(x => { | ||
| return x.get('edpopcol:field') === field.id && !x.get('edpopcol:originalText'); | ||
| }); | ||
| } else { | ||
| // Field present in the source data: check if edpopcol:originalText matches | ||
| annotation = annotations.find(x => { | ||
| return x.get('edpopcol:field') === field.id && x.get('edpopcol:originalText') === value['edpoprec:originalText'] | ||
| }); | ||
| } | ||
|
tijmenbaarda marked this conversation as resolved.
Outdated
|
||
| if (annotation) { | ||
| return annotation.get('oa:hasBody'); | ||
| } | ||
| return undefined; | ||
|
tijmenbaarda marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Get a default main display string of the `value` attribute of a | ||
| * field flattened using {@link FlatterFields}. Currently, this is | ||
| * the normalized "summary text" if available and otherwise the | ||
| * original text from the source database. | ||
| * @param {object} value | ||
| * original text from the source database. If | ||
|
tijmenbaarda marked this conversation as resolved.
Outdated
|
||
| * @param {Object} value - the specific value to get the display of | ||
| * @param {Field} field - the whole field object | ||
| * @param {Annotations} [annotations] - annotations for the field | ||
| * @return {string} | ||
| */ | ||
| function getMainDisplayOfFieldValue(value) { | ||
| function getMainDisplayOfFieldValue(value, field, annotations = null) { | ||
| var correctedText = getCorrectedTextForFieldValue(value, field, annotations); | ||
| if (correctedText) return correctedText; | ||
| return value['edpoprec:summaryText'] || value['edpoprec:originalText']; | ||
| } | ||
|
|
||
|
|
@@ -28,16 +59,26 @@ export var Field = Backbone.Model.extend({ | |
| idAttribute: 'key', | ||
| /** | ||
| * Get the default rendering of the field | ||
| * | ||
| * @param {Annotations} annotations - Optional annotations for the field | ||
| * @return {string} | ||
| */ | ||
| getMainDisplay() { | ||
| getMainDisplay(annotations = null) { | ||
| // Currently, only normalizedText is supported. | ||
| const value = this.get('value'); | ||
| if (!value) return value; | ||
| if (_.isArray(value)) { | ||
| return _.map(value, getMainDisplayOfFieldValue).join(' ; '); | ||
| if (!value) { | ||
| // Field is missing in the source data: return annotation if present | ||
| var correctedText = getCorrectedTextForFieldValue(null, this, annotations); | ||
| if (correctedText) | ||
| return correctedText; | ||
| else | ||
| return ''; | ||
|
tijmenbaarda marked this conversation as resolved.
Outdated
|
||
| } else if (_.isArray(value)) { | ||
| // Field is repeated: concatenate all values | ||
| return _.map(value, (value) => getMainDisplayOfFieldValue(value, this, annotations)).join(' ; '); | ||
| } else { | ||
| return getMainDisplayOfFieldValue(value, this, annotations); | ||
| } | ||
|
Comment on lines
+70
to
75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't really need the |
||
| return getMainDisplayOfFieldValue(value); | ||
| }, | ||
| getFieldInfo() { | ||
| const property = properties.get(this.id); | ||
|
|
||
This file contains hidden or 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 hidden or 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,6 +1,9 @@ | ||
| <td><u title="{{fieldInfo.description}}">{{fieldInfo.name}}</u></td> | ||
| <td><div> | ||
| <td>{{#hasEdit}}<div> | ||
| {{#linkedRecordUri}}<a href="/record/{{linkedRecordUri}}" target="_blank" title="Go to linked record">{{displayText}}</a>{{/linkedRecordUri}} | ||
| {{^linkedRecordUri}}{{displayText}}{{/linkedRecordUri}} | ||
| </div><div class="annotations"></div></td> | ||
| <td><a class="fa-regular fa-message comment" role="button"></a></td> | ||
| </div>{{/hasEdit}}<div class="annotations"></div></td> | ||
| <td>{{#hasEdit}} | ||
| {{#isEmpty}}<a class="fa-solid fa-plus comment text-decoration-none" role="button" title="Make addition"></a>{{/isEmpty}} | ||
| {{^isEmpty}}<a class="fa-solid fa-pen comment text-decoration-none" role="button" title="Add correction"></a>{{/isEmpty}} | ||
| {{/hasEdit}}</td> |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.