Skip to content

Commit

Permalink
code linting
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <wkingnumber2@gmail.com>
  • Loading branch information
wadeking98 committed Mar 14, 2023
1 parent e0bee83 commit d0cd3e8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
14 changes: 8 additions & 6 deletions src/components/entity/EntityResult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -815,12 +815,14 @@ export default class EntityResult extends Vue {
return selectFirstAttrItem(
{ key: "type", value: "business_number" },
// find the latest business number
this.entityCredentials?.filter(cred => cred.latest)?.map((cred) => {
return {
type: cred.type,
text: cred.value,
};
})
this.entityCredentials
?.filter((cred) => cred.latest)
?.map((cred) => {
return {
type: cred.type,
text: cred.value,
};
})
)?.text as string;
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/entity/filter/EntityFilterFacetPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<slot name="title">{{ title }}</slot>
</v-expansion-panel-header>
<v-expansion-panel-content>
<EntityFilterFacets :entityType="entityType" :filterField="filterField" :fields="fields" />
<EntityFilterFacets
:entityType="entityType"
:filterField="filterField"
:fields="fields"
/>
<template v-if="more.length">
<span
class="flex-row flex-align-items-center justify-center fake-link"
Expand Down
5 changes: 4 additions & 1 deletion src/components/entity/filter/EntityFilterFacets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
class="checkbox"
></v-simple-checkbox>
</v-list-item-action>
<v-list-item-content class="pt-1 pb-1" v-translate="toTranslationFormat(field.value, entityType)">
<v-list-item-content
class="pt-1 pb-1"
v-translate="toTranslationFormat(field.value, entityType)"
>
</v-list-item-content>
<v-list-item-action class="d-flex justify-end mt-1 mb-1">
<div>{{ field.count }}</div>
Expand Down
62 changes: 34 additions & 28 deletions src/i18n/translate.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import { DirectiveFunction } from "vue";
import { DirectiveBinding } from "vue/types/options";
import VueI18n from "."
import VueI18n from ".";

export const translate: DirectiveFunction = (el: Element, binding: DirectiveBinding) => {
el.textContent = $translate(binding.value)
}
export const translate: DirectiveFunction = (
el: Element,
binding: DirectiveBinding
) => {
el.textContent = $translate(binding.value);
};

// Uses the entity_type as well as the registration description to lookup translations for entries from the LEAR database
export const $translate = (value: string): string => {
const messages = VueI18n.messages
const locale = VueI18n.locale
const bindingValues = value.split(".")
let transReturn
// try old translation first
if (bindingValues.length >= 2) {
const translationAttempt = (messages[locale][bindingValues[0]] as { [key: string]: string | any })?.[bindingValues[1]]
if (typeof (translationAttempt) === "string") {
transReturn = translationAttempt
const messages = VueI18n.messages;
const locale = VueI18n.locale;
const bindingValues = value.split(".");
let transReturn;
// try old translation first
if (bindingValues.length >= 2) {
const translationAttempt = (
messages[locale][bindingValues[0]] as { [key: string]: string | any }
)?.[bindingValues[1]];
if (typeof translationAttempt === "string") {
transReturn = translationAttempt;
} else {
// we know we're working with an entity from LEAR
const description =
translationAttempt?.displayName ?? translationAttempt?.title;
if (typeof description === "string") {
transReturn = description;
} else if (typeof description !== "undefined") {
// we are working with a description object, indexed by entity type: BC, SP, etc.
if (bindingValues.length >= 3) {
// if entity type is passed in as a binding value
transReturn = description[bindingValues[2]];
} else {
// we know we're working with an entity from LEAR
const description = translationAttempt?.displayName ?? translationAttempt?.title
if (typeof (description) === "string") {
transReturn = description
} else if (typeof (description) !== "undefined") {
// we are working with a description object, indexed by entity type: BC, SP, etc.
if (bindingValues.length >= 3) {
// if entity type is passed in as a binding value
transReturn = description[bindingValues[2]]
} else {
transReturn = translationAttempt?.title
}
}
transReturn = translationAttempt?.title;
}
}
}
return transReturn ?? value
}
}
return transReturn ?? value;
};
8 changes: 4 additions & 4 deletions src/utils/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ export function isCredential(item: ICredential | IRelationship): boolean {
return (item as ICredential)?.credential_type !== undefined;
}

// Used to append entity_type to the suffix of the string. This is needed to work with
// Used to append entity_type to the suffix of the string. This is needed to work with
// entries from the LEAR database
export function toTranslationFormat(base: string, entityType?: string): string {
if (entityType) {
const entityTypeSplit = entityType.split('.')
const entityTypeSplit = entityType.split(".");
if (entityTypeSplit.length >= 2) {
return base + "." + entityTypeSplit[1]
return base + "." + entityTypeSplit[1];
}
}
return base
return base;
}

export function getHighlightedAttributes(
Expand Down

0 comments on commit d0cd3e8

Please sign in to comment.