-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/search-improvements' into feature/styling-searc…
…h-cards
- Loading branch information
Showing
73 changed files
with
2,841 additions
and
475 deletions.
There are no files selected for viewing
7 changes: 2 additions & 5 deletions
7
app/adapters/index-property-search.ts → app/adapters/related-property-path.ts
This file contains 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,13 +1,10 @@ | ||
import ShareAdapter from './share-adapter'; | ||
|
||
export default class IndexPropertySearchAdapter extends ShareAdapter { | ||
pathForType() { | ||
return 'index-property-search'; | ||
} | ||
export default class RelatedPropertyPathAdapter extends ShareAdapter { | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'index-property-search': IndexPropertySearchAdapter; | ||
'related-property-path': RelatedPropertyPathAdapter; | ||
} // eslint-disable-line semi | ||
} |
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { attr } from '@ember-data/model'; | ||
import { getOwner } from '@ember/application'; | ||
|
||
import GetLocalizedPropertyHelper from 'ember-osf-web/helpers/get-localized-property'; | ||
|
||
import OsfModel from './osf-model'; | ||
import { LanguageText } from './index-card'; | ||
|
||
interface PropertyPath { | ||
'@id': string; | ||
resourceType: Array<{ '@id': string }>; | ||
displayLabel: LanguageText[]; | ||
shortFormLabel: LanguageText[]; | ||
} | ||
|
||
export default class RelatedPropertyPathModel extends OsfModel { | ||
@attr('string') propertyPathKey!: string; | ||
@attr('number') cardSearchResultCount!: number; | ||
@attr('array') osfmapPropertyPath!: string[]; | ||
@attr('array') propertyPath!: PropertyPath[]; | ||
|
||
getLocalizedString = new GetLocalizedPropertyHelper(getOwner(this)); | ||
|
||
get shortFormLabel() { | ||
const labelArray = []; | ||
// propertyPath is likely an array of length 1, | ||
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license) | ||
for (const property of this.propertyPath) { | ||
const label = this.getLocalizedString.compute( | ||
[property as unknown as Record<string, LanguageText[]>, 'shortFormLabel'], | ||
); | ||
if (label) { | ||
labelArray.push(label); | ||
} | ||
} | ||
return labelArray.join(','); | ||
} | ||
|
||
get displayLabel() { | ||
// propertyPath is likely an array of length 1, | ||
// unless it is nested property(e.g. file's isContainedBy.funder, file's isContainedBy.license) | ||
// in which case we just use the last property | ||
const hash = this.propertyPath[this.propertyPath.length-1] as unknown as Record<string, LanguageText[]>; | ||
const label = this.getLocalizedString.compute([hash, 'displayLabel']); | ||
return label || ''; | ||
} | ||
|
||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'related-property-path': RelatedPropertyPathModel; | ||
} // eslint-disable-line semi | ||
} |
This file contains 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 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 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 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
4 changes: 2 additions & 2 deletions
4
app/serializers/index-property-search.ts → app/serializers/related-property-path.ts
This file contains 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,10 +1,10 @@ | ||
import ShareSerializer from './share-serializer'; | ||
|
||
export default class IndexPropertySearchSerializer extends ShareSerializer { | ||
export default class RelatedPropertyPathSerializer extends ShareSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'index-property-search': IndexPropertySearchSerializer; | ||
'related-property-path': RelatedPropertyPathSerializer; | ||
} // eslint-disable-line semi | ||
} |
Oops, something went wrong.