Skip to content
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

Person list #45

Closed
wants to merge 7 commits into from
Closed

Person list #45

wants to merge 7 commits into from

Conversation

k9
Copy link

@k9 k9 commented Sep 18, 2016

Adds a list of all people for issue #12

I initially tried using mdl-select from vue-mdl, but that component is fairly buggy. I ran into posva/vue-mdc#46 and also there seem to be some deeper problems with data binding.

Anyway, I switched to a regular select which works fine.

<mdl-textfield floating-label="Birth Year" :value.sync="personData.birth_year"></mdl-textfield>
<mdl-textfield floating-label="Gender" :value.sync="personData.gender"></mdl-textfield>
<div class="mdl-card__actions">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label is-upgraded is-dirty">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is-updgraded and is-dirty are dynamic classes that should be added by mdl once you make a call to the component handler to upgrade the elements

<select class="full-width-select"
name="person-select"
v-model="idForName"
v-on:change="fetchPerson">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you the shorthand @change here instead of v-on:change

this.loading = true;
this.imageShow = false;
this.personImageMsg = '';
const randomPersonId = Math.floor((Math.random() * 87) + 1);
person.fetch(randomPersonId).then((personData) => {
person.fetch(this.idForName).then((personData) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not need the parens around personData

name="person-select"
v-model="idForName"
v-on:change="fetchPerson">
<option v-for="option in nameList" v-bind:value="option.value">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v:bind:value is the long form. Can use just :value

person.fetchPage = (resolve, pageNumber) => {
const pageToGet = `${personBaseUrl}?page=${pageNumber}`;
Vue.http.get(pageToGet).then(response => {
for (const result of response.data.results) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use an object with a constructor to encapsulate this logic and move it to a testable unit.

@alexkramer alexkramer closed this Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants