Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
vnmedeiros 2020-04-21 21:56:46 -03:00
commit 2cc2489418
4 changed files with 36 additions and 21 deletions

View File

@ -188,6 +188,9 @@
query['perpage'] = 12;
query['paged'] = this.page;
if (this.selected.length > 0)
query['exclude'] = this.selected.map((item) => item.value);
return qs.stringify(query);
}
}

View File

@ -77,30 +77,32 @@ export default {
]),
onInput(newSelected) {
this.selected = newSelected;
this.$emit('input', newSelected.map((user) => user.id));
this.$emit('input', newSelected.map((user) => user.id || user.value));
},
onBlur() {
this.$emit('blur');
},
loadCurrentUsers() {
this.isLoading = true;
let query = qs.stringify({ include: this.itemMetadatum.value });
let endpoint = '/users/';
if ((Array.isArray(this.itemMetadatum.value) && this.itemMetadatum.value.length) || (!Array.isArray(this.itemMetadatum.value) && this.itemMetadatum.value)) {
this.isLoading = true;
let query = qs.stringify({ include: this.itemMetadatum.value });
let endpoint = '/users/';
wpAxios.get(endpoint + '?' + query)
.then((res) => {
if (res.data.items) {
wpAxios.get(endpoint + '?' + query)
.then((res) => {
for (let user of res.data) {
this.selected.push({
label: user.name,
name: user.name,
value: user.id,
img: user.avatar_urls && user.avatar_urls['24'] ? user.avatar_urls['24'] : ''
}) ;
}
}
this.isLoading = false;
})
.catch(() => this.isLoading = false );
}
this.isLoading = false;
})
.catch(() => this.isLoading = false );
}
},
search: _.debounce(function (search) {
@ -128,12 +130,16 @@ export default {
if (this.usersSearchQuery !== '') {
this.isLoading = true;
this.fetchUsers({ search: this.usersSearchQuery, page: this.usersSearchPage })
this.fetchUsers({ search: this.usersSearchQuery, page: this.usersSearchPage, exclude: this.selected.map((user) => user.value || user.id ) })
.then((res) => {
if (res.users) {
for (let user of res.users)
this.options.push(user);
this.options.push({
name: user.name,
value: user.id,
img: user.avatar_urls && user.avatar_urls['24'] ? user.avatar_urls['24'] : ''
});
}
if (res.totalUsers)

View File

@ -166,14 +166,20 @@ export const notApprove = ({commit}, activityId) => {
};
// Users for filtering and core author metadata
export const fetchUsers = ({ commit }, { search, page }) => {
let endpoint = '/users?search=' + search;
export const fetchUsers = ({ commit }, { search, page, exclude }) => {
let endpoint = '/users';
let params = {
search: search
};
if (page)
endpoint += '&page=' + page;
params.page = page;
if (exclude)
params.exclude = exclude;
return new Promise((resolve, reject) => {
axios.wp.get(endpoint)
axios.wp.get(endpoint + '?' + qs.stringify(params))
.then(res => {
resolve({ users: res.data, totalUsers: res.headers['x-wp-total'] } );
})

View File

@ -213,7 +213,7 @@
class="content">
<component
:is="itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ? 'div' : 'p'"
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<p><span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span></p>`"/>
</div>
</div>
</div>