[Uploader] Correctly show tag category for implications

When a character implies a copyright both would display as copyright
This commit is contained in:
Earlopain 2021-07-23 12:14:54 +02:00
parent 1b0ebe4504
commit ca66c01856
2 changed files with 7 additions and 6 deletions

View File

@ -29,16 +29,16 @@
switch (tag.type) {
default:
case 'tag':
return h('span', {staticClass: 'tag-preview'}, [create_tag_link(tag.a, tag.tagType)]);
return h('span', {staticClass: 'tag-preview'}, [create_tag_link(tag.a, tag.tagTypeA)]);
case 'alias':
return h('span', {staticClass: 'tag-preview tag-preview-alias'}, [
h('del', undefined, [
create_tag_link(tag.a, tag.tagType)
]), ' → ', create_tag_link(tag.b, tag.tagType)
create_tag_link(tag.a, tag.tagTypeA)
]), ' → ', create_tag_link(tag.b, tag.tagTypeB)
]);
case 'implication':
return h('span', {staticClass: 'tag-preview tag-preview-implication'}, [
create_tag_link(tag.a, tag.tagType), ' ⇐ ', create_tag_link(tag.b, tag.tagType)
create_tag_link(tag.a, tag.tagTypeA), ' ⇐ ', create_tag_link(tag.b, tag.tagTypeB)
]);
}
}

View File

@ -27,10 +27,11 @@ class TagsPreview
end
def tag_types
names = @tags.map { |tag| tag[:b] || tag[:a] }
names = @tags.map { |tag| [tag[:a], tag[:b]] }.flatten.compact.uniq
categories = Tag.categories_for(names)
@tags.map! do |tag|
tag[:tagType] = categories.fetch(tag[:b] || tag[:a], -1)
tag[:tagTypeA] = categories.fetch(tag[:a], -1)
tag[:tagTypeB] = categories.fetch(tag[:b], -1) if tag[:b]
tag
end
end