add allow_commets prop to collection module

This commit is contained in:
Jacson Passold 2018-08-28 00:20:52 -03:00
parent add549b881
commit 8910ad2ab8
4 changed files with 34 additions and 4 deletions

View File

@ -174,6 +174,20 @@ export const fetchCollectionCommentStatus = ({ commit }, id) => {
});
};
export const fetchCollectionAllowComments = ({ commit }, id) => {
return new Promise((resolve, reject) =>{
axios.tainacan.get('/collections/' + id + '?fetch_only=allow_comments')
.then(res => {
let collectionAllowComments = res.data;
commit('setCollectionAllowComments', collectionAllowComments.allow_comments);
resolve( collectionAllowComments.allow_comments );
})
.catch(error => {
reject(error);
})
});
};
export const fetchCollectionNameAndURL = ({ commit }, id) => {
//commit('cleanCollectionName');
return new Promise((resolve, reject) =>{
@ -223,7 +237,8 @@ export const updateCollection = ({ commit }, {
parent,
enabled_view_modes,
default_view_mode,
comment_status
comment_status,
allow_comments
}) => {
return new Promise((resolve, reject) => {
axios.tainacan.patch('/collections/' + collection_id, {
@ -237,7 +252,8 @@ export const updateCollection = ({ commit }, {
parent: parent,
enabled_view_modes: enabled_view_modes,
default_view_mode: default_view_mode,
comment_status: comment_status
comment_status: comment_status,
allow_comments: allow_comments
}).then( res => {
commit('setCollection', {
id: collection_id,
@ -251,7 +267,8 @@ export const updateCollection = ({ commit }, {
parent: parent,
enabled_view_modes: enabled_view_modes,
default_view_mode: default_view_mode,
comment_status: comment_status
comment_status: comment_status,
allow_comments: allow_comments
});
commit('setCollectionName', res.data.name);
commit('setCollectionURL', res.data.url);

View File

@ -28,4 +28,8 @@ export const getAttachments = state => {
export const getCollectionCommentStatus = state => {
return state.collectionCommentStatus;
}
export const getCollectionAllowComments = state => {
return state.collectionAllowComments;
}

View File

@ -11,7 +11,8 @@ const state = {
collectionName: '',
collectionURL: '',
attachments: [],
collectionCommentStatus: ''
collectionCommentStatus: '',
collectionAllowComments: ''
};
export default {

View File

@ -77,4 +77,12 @@ export const setCollectionCommentStatus = (state, collectionCommentStatus) => {
export const cleanCollectionCommentStatus = (state) => {
state.collectionCommentStatus = '';
}
export const setCollectionAllowComments = (state, collectionAllowComments) => {
state.collectionAllowComments = collectionAllowComments;
}
export const cleanCollectionAllowComments = (state) => {
state.collectionAllowComments = '';
}