parent
8630f91a13
commit
7980558461
@ -0,0 +1,20 @@
|
||||
import statusPoster from '../../services/status_poster/status_poster.service.js'
|
||||
|
||||
const PostStatusForm = {
|
||||
data() {
|
||||
return {
|
||||
newStatus: { }
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
postStatus(newStatus) {
|
||||
statusPoster.postStatus({
|
||||
status: newStatus.status,
|
||||
store: this.$store
|
||||
})
|
||||
this.newStatus = { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default PostStatusForm
|
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div class="post-status-form">
|
||||
<form v-on:submit.prevent="postStatus(newStatus)">
|
||||
<div class="form-group" >
|
||||
<textarea v-model="newStatus.status" placeholder="Just landed in L.A." rows="3" class="form-control"></textarea>
|
||||
</div>
|
||||
<div class="attachments">
|
||||
<div class="attachment" v-for="file in newStatus.files">
|
||||
<img class="thumbnail media-upload" :src="file.image"></img>
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-bottom'>
|
||||
<media-upload files="newStatus.files"></media-upload>
|
||||
<button type="submit" class="btn btn-default" >Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="./post_status_form.js"></script>
|
@ -0,0 +1,52 @@
|
||||
import { map } from 'lodash'
|
||||
import apiService from '../api/api.service.js'
|
||||
|
||||
const postStatus = ({ store, status, media = [], inReplyToStatusId = undefined }) => {
|
||||
const mediaIds = map(media, 'id')
|
||||
|
||||
return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, mediaIds, inReplyToStatusId})
|
||||
.then((data) => data.json())
|
||||
.then((data) => {
|
||||
store.commit('addNewStatuses',
|
||||
{ statuses: [data], timeline: 'friends', showImmediately: true })
|
||||
})
|
||||
}
|
||||
|
||||
const statusPosterService = {
|
||||
postStatus
|
||||
}
|
||||
|
||||
export default statusPosterService
|
||||
|
||||
// const statusPosterServiceFactory = (apiService, $ngRedux) => {
|
||||
// const postStatus = ({status, media = [], in_reply_to_status_id = undefined}) => {
|
||||
// const mediaIds = map(media, 'id');
|
||||
|
||||
// return apiService.postStatus({status, mediaIds, in_reply_to_status_id}).
|
||||
// then((data) => data.json()).
|
||||
// then((data) => {
|
||||
// $ngRedux.dispatch({type: 'ADD_NEW_STATUSES', data: { statuses: [data], timeline: 'friends', showImmediately: true }});
|
||||
// });
|
||||
// };
|
||||
|
||||
// const uploadMedia = (formData) => {
|
||||
// return apiService.uploadMedia(formData).then((xml) => {
|
||||
// return {
|
||||
// id: xml.getElementsByTagName('media_id')[0].textContent,
|
||||
// url: xml.getElementsByTagName('media_url')[0].textContent,
|
||||
// image: xml.getElementsByTagName('atom:link')[0].getAttribute('href')
|
||||
// };
|
||||
// });
|
||||
// };
|
||||
|
||||
// const statusPosterService = {
|
||||
// postStatus,
|
||||
// uploadMedia
|
||||
// };
|
||||
|
||||
// return statusPosterService;
|
||||
// };
|
||||
|
||||
// statusPosterServiceFactory.$inject = ['apiService', '$ngRedux'];
|
||||
|
||||
// export default statusPosterServiceFactory;
|
Loading…
Reference in new issue