Closed Azinck94 closed 7 years ago
Can you go into more detail about what this last step is and what is not going as expected?
sure, I've created a form on my customer handlebars that is supposed to allow for a string called "scheduledAt" to be posted which will represent a scheduled meeting date between a user and customer. My back end is set up correctly and the form successfully posts a new meeting, but I want to be able to display that meeting and am having trouble with that
I was thinking of trying something along these lines:
{{#each model as |meeting.scheduledAt|}}
I think you need a bound value set up in the .js for that component. What's the .js file for that component look like?
so I just changed meeting.js to look like this:
<span class="list-info">{{meeting.scheduledAt}}</span>
<a href='#' class='deletebutton' {{action 'deleteMeeting'}}>Delete Meeting</a>
and changed customer handlebars to:
<div class="card-block">
<h1> Name: {{model.name}}</h1>
<ul> Phone Number: {{model.phone}} </ul>
<ul> Email Address: {{model.email}} </ul>
{{customer-list
customer=model
toggleMeetingDone='toggleMeetingDone'
deleteMeeting='deleteMeeting'
createMeeting='createMeeting'
}}
{{customer-list/meeting meeting=meeting}}
</div>
</div>
Those are .hbs files. What does the component/.js file look like?
meeting-form.js:
import Ember from 'ember';
export default Ember.Component.extend({
newMeeting: {
scheduledAt: null,
hidden: false
},
actions: {
createMeeting () {
this.sendAction('createMeeting', this.get('newMeeting'));
this.set('newMeeting.scheduledAt', null);
}
}
});
@Azinck94 will you write up an explanation with code examples about how you had to:
pluck
And then close.
Sorry just got home! I added a has_many relationship to the Customer serializer which now looks like this:
class CustomerSerializer < ActiveModel::Serializer
attributes :id, :name, :email, :phone, :meetings
has_one :user
def meetings
object.meetings.pluck(:id)
end
end
Last thing to accomplish is finding a way to show the newly created meeting: I input scheduledAt and receive a successful post response, but am getting hung up on this last step. Here is what I have for the handlebars: