add mapper prop to collection creation actions

This commit is contained in:
Jacson Passold 2018-05-29 20:16:36 -03:00
parent 3beaced591
commit bc99d7eae4
2 changed files with 8 additions and 5 deletions

View File

@ -351,6 +351,7 @@ export default {
formErrorMessage: '', formErrorMessage: '',
isNewCollection: false, isNewCollection: false,
isMapped: false, isMapped: false,
mapper: false,
thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png', thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png',
headerPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_rectangle.png', headerPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_rectangle.png',
isFetchingModerators: false, isFetchingModerators: false,
@ -429,7 +430,7 @@ export default {
this.isLoading = true; this.isLoading = true;
// Creates draft Collection // Creates draft Collection
let data = { name: '', description: '', status: 'auto-draft'}; let data = { name: '', description: '', status: 'auto-draft', mapper: (this.isMapped && this.mapper != false ? this.mapper : false ) };
this.sendCollection(data).then(res => { this.sendCollection(data).then(res => {
this.collectionId = res.id; this.collectionId = res.id;
@ -642,7 +643,8 @@ export default {
var mapper = tmppath.pop(); var mapper = tmppath.pop();
if(tmppath.pop() == 'new') { if(tmppath.pop() == 'new') {
this.isNewCollection = true; this.isNewCollection = true;
this.isMapped = mapper; this.isMapped = true;
this.mapper = mapper;
this.createNewCollection(); this.createNewCollection();
} }
} }

View File

@ -139,15 +139,16 @@ export const updateCollection = ({ commit }, { collection_id, name, description,
}); });
} }
export const sendCollection = ( { commit }, { name, description, status }) => { export const sendCollection = ( { commit }, { name, description, status, mapper }) => {
return new Promise(( resolve, reject ) => { return new Promise(( resolve, reject ) => {
axios.tainacan.post('/collections/', { axios.tainacan.post('/collections/', {
name: name, name: name,
description: description, description: description,
status: status status: status,
'exposer-map': mapper
}) })
.then( res => { .then( res => {
commit('setCollection', { name: name, description: description, status: status }); commit('setCollection', { name: name, description: description, status: status, mapper: mapper });
resolve( res.data ); resolve( res.data );
}) })
.catch(error => { .catch(error => {