Add media upload to PostStatusForm.

This commit is contained in:
Roger Braun 2016-11-06 19:30:35 +01:00
parent 7e2e2d3ec3
commit e21a60096c
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,6 @@
import statusPoster from '../../services/status_poster/status_poster.service.js' import statusPoster from '../../services/status_poster/status_poster.service.js'
import MediaUpload from '../media_upload/media_upload.vue'
import { reject, map, uniqBy } from 'lodash'; import { reject, map, uniqBy } from 'lodash';
const buildMentionsString = ({user, attentions}, currentUser) => { const buildMentionsString = ({user, attentions}, currentUser) => {
@ -23,6 +25,9 @@ const PostStatusForm = {
'repliedUser', 'repliedUser',
'attentions' 'attentions'
], ],
components: {
MediaUpload
},
data () { data () {
let statusText = '' let statusText = ''
@ -33,7 +38,8 @@ const PostStatusForm = {
return { return {
newStatus: { newStatus: {
status: statusText status: statusText,
files: []
} }
} }
}, },
@ -41,11 +47,18 @@ const PostStatusForm = {
postStatus (newStatus) { postStatus (newStatus) {
statusPoster.postStatus({ statusPoster.postStatus({
status: newStatus.status, status: newStatus.status,
media: newStatus.files,
store: this.$store, store: this.$store,
inReplyToStatusId: this.replyTo inReplyToStatusId: this.replyTo
}) })
this.newStatus = { } this.newStatus = {
status: '',
files: []
}
this.$emit('posted') this.$emit('posted')
},
addMediaFile (fileInfo) {
this.newStatus.files.push(fileInfo)
} }
} }
} }

View File

@ -10,7 +10,7 @@
</div> </div>
</div> </div>
<div class='form-bottom'> <div class='form-bottom'>
<media-upload files="newStatus.files"></media-upload> <media-upload v-on:uploaded="addMediaFile"></media-upload>
<button type="submit" class="btn btn-default" >Submit</button> <button type="submit" class="btn btn-default" >Submit</button>
</div> </div>
</form> </form>