Skip to content

Feature/semantic search #465

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

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"lodash": "^4.17.10",
"rangy": "^1.3.0",
"rdf-parse": "^1.1.1",
"select2": "^4.0.13",
"select2": "^4.1.0-rc.0",
"streamify-string": "^1.0.1"
},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/forms/select2-picker-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'select2';

import BasePicker from './base-picker-view';

/**
* A very thin wrapper around `BasePicker` that enables the select2 plugin.
*/
export default class Select2PickerView extends BasePicker {
beforeRender(): this {
this.$('select').select2('destroy');
return this;
}

afterRender(): this {
this.$('select').select2({ dropdownAutoWidth: true });
return this;
}

remove(): this {
this.$('select').select2('destroy');
return super.remove();
}
}
12 changes: 3 additions & 9 deletions frontend/src/panel-annotation/annotation-edit-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Node from '../common-rdf/node';
import Graph from '../common-rdf/graph';

import ItemEditor from '../item-edit/item-edit-view';
import PickerView from '../forms/base-picker-view';
import PickerView from '../forms/select2-picker-view';
import FilteredCollection from '../common-adapters/filtered-collection';
import ItemGraph from '../common-adapters/item-graph';
import ClassPickerView from '../forms/ontology-class-picker-view';
Expand Down Expand Up @@ -50,12 +50,7 @@ export default class AnnotationEditView extends CompositeView<FlatItem> {
initialize() {
this.itemOptions = new ItemGraph();
this.itemOptions.comparator = this.sortOptions;
this.itemPicker = new PickerView({
collection: this.itemOptions,
className: '',
});
// Replace Bulma select by select2 select. TODO: make this less hacky.
this.itemPicker.$('select').width('95%').select2();
this.itemPicker = new PickerView({ collection: this.itemOptions });
this.classPicker = new ClassPickerView({
collection: getOntologyClasses(),
preselection: this.model.get('class'),
Expand Down Expand Up @@ -112,7 +107,6 @@ export default class AnnotationEditView extends CompositeView<FlatItem> {

remove(): this {
if (this.validator) this.validator.destroy();
this.itemPicker.$('select').select2('destroy');
super.remove();
return this;
}
Expand Down Expand Up @@ -263,7 +257,7 @@ export default class AnnotationEditView extends CompositeView<FlatItem> {
if (isBlank(this.model.underlying)) {
// Remove the placeholder.
this.collection.underlying.remove(this.model.underlying);
}
}
explorerChannel.trigger('annotationEditView:close', this);
return this;
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/panel-related-items/related-items-edit-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import Graph from '../common-rdf/graph';
import ItemGraph from '../common-adapters/item-graph';
import explorerChannel from '../explorer/explorer-radio';
import { announceRoute } from '../explorer/utilities';
import { applicablePredicates, relationsFromModel } from '../utilities/relation-utilities';

import RelationEditor from './relation-editor-view';
import { applicablePredicates, relationsFromModel } from './relation-utilities';
import relatedItemsTemplate from './related-items-edit-template';

const announce = announceRoute('item:related:edit', ['model', 'id']);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/panel-related-items/related-items-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import Node from '../common-rdf/node';
import explorerChannel from '../explorer/explorer-radio';
import { announceRoute } from '../explorer/utilities';
import { getLabel, getLabelFromId } from '../utilities/linked-data-utilities';
import { applicablePredicates, relationsFromModel } from '../utilities/relation-utilities';

import relatedItemsTemplate from './related-items-template';
import RelatedItemsRelationView from './related-items-relation-view';
import { applicablePredicates, relationsFromModel } from './relation-utilities';

const announce = announceRoute('item:related', ['model', 'id']);
const getPredicateId = r => r.get('predicate').id;
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/style/forms.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import bulma-custom

.form-feedback-bar
p
margin-left: 0.25em
Expand Down Expand Up @@ -26,3 +28,19 @@

.upload-source-form p.filename
padding: 7px

.readit-picker.select
span.select2
@extend .input
box-shadow: none
padding-right: 2.5em
padding-left: .75em
&.select2-container .select2-selection--single
border: none
.select2-selection__rendered
padding: 0
.select2-selection__arrow
width: 43px
height: 100%
b
border: none
8 changes: 4 additions & 4 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6963,10 +6963,10 @@ scss-tokenizer@^0.2.3:
js-base64 "^2.1.8"
source-map "^0.4.2"

select2@^4.0.13:
version "4.0.13"
resolved "https://registry.yarnpkg.com/select2/-/select2-4.0.13.tgz#0dbe377df3f96167c4c1626033e924372d8ef44d"
integrity sha512-1JeB87s6oN/TDxQQYCvS5EFoQyvV6eYMZZ0AeA4tdFDYWN3BAGZ8npr17UBFddU0lgAt3H0yjX3X6/ekOj1yjw==
select2@^4.1.0-rc.0:
version "4.1.0-rc.0"
resolved "https://registry.yarnpkg.com/select2/-/select2-4.1.0-rc.0.tgz#ba3cd3901dda0155e1c0219ab41b74ba51ea22d8"
integrity sha512-Hr9TdhyHCZUtwznEH2CBf7967mEM0idtJ5nMtjvk3Up5tPukOLXbHUNmh10oRfeNIhj+3GD3niu+g6sVK+gK0A==

semver-greatest-satisfied-range@^1.1.0:
version "1.1.0"
Expand Down