-
Notifications
You must be signed in to change notification settings - Fork 78
Refactor skills-list #1025
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
Refactor skills-list #1025
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
File renamed without changes.
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
6 changes: 3 additions & 3 deletions
6
app/styles/components/skills-input.scss → app/styles/components/skills-typeahead.scss
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{skill-textfield | ||
| autofocus=true | ||
| focus-in="focus" | ||
| focus-out="blur" | ||
| getKeyDown=(action "getKeyDown") | ||
| placeholder="Start typing a skill, like Ruby or PhotoShop" | ||
| value=query | ||
| }} | ||
|
|
||
| {{#if canShow}} | ||
| <div class="dropdown-menu"> | ||
| {{#each results as |skill index|}} | ||
| {{skills-typeahead-result | ||
| hover="hoverSkill" | ||
| query=query | ||
| selectSkill="selectSkill" | ||
| skill=skill | ||
| skillsList=skillsList | ||
| }} | ||
| {{/each}} | ||
| </div> | ||
| {{/if}} |
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import Ember from 'ember'; | ||
|
|
||
| const { get } = Ember; | ||
|
|
||
| export default { | ||
| /** | ||
| Returns `true` or `false` depending on whether an array of models contains | ||
| the target model instance. | ||
| @method contains | ||
| @param {[DS.Model]} records The records to search | ||
| @param {DS.Model} target The target model | ||
| @return {Boolean} `true` if found, otherwise `false` | ||
| @public | ||
| */ | ||
| contains(records, target) { | ||
| if (records) { | ||
| return records.any((found) => { | ||
| let targetId = get(target, 'id'); | ||
| let targetModelName = get(target, 'constructor.modelName') | ||
| || get(target, 'content.constructor.modelName'); | ||
| let foundId = found.belongsTo(targetModelName).id(); | ||
|
|
||
| return (foundId === targetId); | ||
| }); | ||
| } else { | ||
| false; | ||
| } | ||
| }, | ||
|
|
||
| /** | ||
| Returns the first record within an array of join model relationships | ||
| for the given target and relationship. For example given `user-skill` | ||
| records, we can pass in a `skill` as `target` and a `user` as the | ||
| relationship. | ||
| @method find | ||
| @param {[DS.Model]} records The relationship records to search | ||
| @param {DS.Model} target The target model | ||
| @param {DS.Model} relationship The relationship model | ||
| @return {DS.Model} Found item or `undefined` | ||
| @public | ||
| */ | ||
| find(records, target, relationship) { | ||
| if (records) { | ||
| return records.find((found) => { | ||
| // Get relationship id and model name | ||
| let relationshipId = get(relationship, 'id'); | ||
| let relationshipModelName = get(relationship, 'constructor.modelName') | ||
| || get(relationship, 'content.constructor.modelName'); | ||
|
|
||
| // Get target id and model name | ||
| let targetId = get(target, 'id'); | ||
| let targetModelName = get(target, 'constructor.modelName') | ||
| || get(target, 'content.constructor.modelName'); | ||
|
|
||
| // Exit early with `false` if we're missing values | ||
| if (!(relationshipId && relationshipModelName && targetId && targetModelName)) { | ||
| return false; | ||
| } | ||
|
|
||
| // Get the id of the found model instance and | ||
| // get the id of the found model's relationship model instance | ||
| let foundId = found.belongsTo(targetModelName).id(); | ||
| let foundRelationshipId = found.belongsTo(relationshipModelName).id(); | ||
|
|
||
| return (foundRelationshipId === relationshipId) // relationships match | ||
| && (foundId === targetId); // found matches target | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't we usually align the
||with the=?