Merge pull request #823 from tainacan/feature/809
Adds author filter to collections list #809
This commit is contained in:
commit
50f503ce02
|
@ -171,7 +171,7 @@
|
|||
--tainacan-sidebar-width: 3.0em;
|
||||
}
|
||||
#primary-menu:not(.is-compressed)~.is-main-content {
|
||||
--tainacan-sidebar-width: 10em;
|
||||
--tainacan-sidebar-width: 11em;
|
||||
}
|
||||
|
||||
.is-secondary-content {
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
<span>
|
||||
<b-checkbox
|
||||
@click.native="selectAllCollectionsOnPage()"
|
||||
:value="allCollectionsOnPageSelected">{{ $i18n.get('label_select_all_collections_page') }}</b-checkbox>
|
||||
:native-value="allCollectionsOnPageSelected">
|
||||
{{ $i18n.get('label_select_all_collections_page') }}
|
||||
</b-checkbox>
|
||||
</span>
|
||||
</div>
|
||||
<div class="field is-pulled-right">
|
||||
|
|
|
@ -517,6 +517,10 @@
|
|||
|
||||
.sub-header {
|
||||
@include logs-container();
|
||||
|
||||
.header-item {
|
||||
min-height: 1.875em;
|
||||
}
|
||||
}
|
||||
|
||||
.selection-control {
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
<span>
|
||||
<b-checkbox
|
||||
@click.native="selectAllOnPage()"
|
||||
:value="allOnPageSelected">{{ $i18n.get('label_select_all_taxonomies_page') }}</b-checkbox>
|
||||
:native-value="allOnPageSelected">
|
||||
{{ $i18n.get('label_select_all_taxonomies_page') }}
|
||||
</b-checkbox>
|
||||
</span>
|
||||
</div>
|
||||
<div class="field is-pulled-right">
|
||||
|
|
|
@ -157,7 +157,7 @@ export default {
|
|||
max-height: 100vh;
|
||||
overflow: auto;
|
||||
z-index: 9;
|
||||
max-width: 10em;
|
||||
max-width: 11em;
|
||||
-webkit-transition: max-width 0.2s linear; /* Safari */
|
||||
transition: max-width 0.2s linear;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@
|
|||
}
|
||||
.logo-area {
|
||||
height: $header-height;
|
||||
min-width: 10em;
|
||||
min-width: 11em;
|
||||
cursor: pointer;
|
||||
|
||||
h1 {
|
||||
|
|
|
@ -168,7 +168,7 @@ export default {
|
|||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
padding-right: 0;
|
||||
padding-left: calc((var(--tainacan-one-column) - 6.666666667px) + 10em);
|
||||
padding-left: calc((var(--tainacan-one-column) - 6.666666667px) + 11em);
|
||||
margin: 0px;
|
||||
display: flex;
|
||||
vertical-align: middle;
|
||||
|
|
|
@ -142,6 +142,7 @@ UserPrefsPlugin.install = function (Vue, options = {}) {
|
|||
'taxonomies_order_by': 'title',
|
||||
'collections_order': 'desc',
|
||||
'collections_order_by': 'date',
|
||||
'collections_author_filter': '',
|
||||
'map_view_mode_selected_geocoordinate_metadatum': 0
|
||||
},
|
||||
init() {
|
||||
|
|
|
@ -146,7 +146,7 @@ export const deleteItem = ({ commit }, { itemId, isPermanently }) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const fetchCollections = ({commit} , { page, collectionsPerPage, status, contextEdit, order, orderby, search, collectionTaxonomies }) => {
|
||||
export const fetchCollections = ({commit} , { page, collectionsPerPage, status, contextEdit, order, orderby, search, collectionTaxonomies, authorid }) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = '/collections?paged='+page+'&perpage='+collectionsPerPage;
|
||||
|
@ -187,6 +187,9 @@ export const fetchCollections = ({commit} , { page, collectionsPerPage, status,
|
|||
endpoint = endpoint + '&' + qs.stringify(taxQuery);
|
||||
}
|
||||
|
||||
if (authorid != '' && authorid != undefined)
|
||||
endpoint = endpoint + '&authorid=' + authorid;
|
||||
|
||||
axios.tainacan.get(endpoint)
|
||||
.then(res => {
|
||||
let collections = res.data;
|
||||
|
|
|
@ -652,7 +652,7 @@
|
|||
|
||||
.header-item {
|
||||
margin-bottom: 0 !important;
|
||||
min-height: 2em;
|
||||
min-height: 1.875em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
|
|
@ -199,10 +199,9 @@
|
|||
top: calc(-1 * var(--tainacan-container-padding));
|
||||
z-index: 2;
|
||||
background: var(--tainacan-background-color);
|
||||
min-height: $header-height;
|
||||
min-height: 2.5em;
|
||||
padding: 0.5em 0;
|
||||
height: auto;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
|
@ -212,7 +211,7 @@
|
|||
|
||||
.header-item {
|
||||
margin-bottom: 0 !important;
|
||||
min-height: 2em;
|
||||
min-height: 1.875em;
|
||||
|
||||
&:first-child {
|
||||
margin-right: auto;
|
||||
|
|
|
@ -102,8 +102,27 @@
|
|||
</b-field>
|
||||
</template>
|
||||
|
||||
<!-- Author filtering options ---- -->
|
||||
<b-field
|
||||
id="collections-page-author-filter"
|
||||
class="header-item">
|
||||
<label class="label">{{ $i18n.get('label_show_only_created_by_me') }} </label>
|
||||
<b-switch
|
||||
size="is-small"
|
||||
class="author-filter-switch"
|
||||
:disabled="collections.length <= 0 && isLoading"
|
||||
@input="onChangeAuthorFilter($event)"
|
||||
:value="authorFilter"
|
||||
:true-value="'current-author'"
|
||||
:false-value="''"
|
||||
:label="$i18n.get('label_show_only_created_by_me')">
|
||||
</b-switch>
|
||||
</b-field>
|
||||
|
||||
<!-- Sorting options ---- -->
|
||||
<b-field class="header-item">
|
||||
<b-field
|
||||
id="collections-page-sorting-options"
|
||||
class="header-item">
|
||||
<label class="label">{{ $i18n.get('label_sort') }} </label>
|
||||
<b-dropdown
|
||||
:mobile-modal="true"
|
||||
|
@ -172,7 +191,9 @@
|
|||
</b-field>
|
||||
|
||||
<!-- Textual Search -------------->
|
||||
<b-field class="header-item">
|
||||
<b-field
|
||||
id="collection-page-search"
|
||||
class="header-item">
|
||||
<b-input
|
||||
:placeholder="$i18n.get('instruction_search')"
|
||||
type="search"
|
||||
|
@ -252,6 +273,8 @@
|
|||
</p>
|
||||
<p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_collection_created') }}</p>
|
||||
<p v-else>{{ $i18n.get('info_no_collections_' + status) }}</p>
|
||||
<p v-if="searchQuery">{{ $i18n.get('info_try_empting_the_textual_search') }}</p>
|
||||
<p v-if="authorFilter !== '' && !searchQuery">{{ $i18n.get('info_try_selecting_all_collections_in_filter') }}</p>
|
||||
<div v-if="!$adminOptions.hideCollectionsListCreationDropdown && $userCaps.hasCapability('tnc_rep_edit_collections') && status == undefined || status == ''">
|
||||
<b-dropdown
|
||||
id="collection-creation-options-dropdown"
|
||||
|
@ -372,6 +395,7 @@ export default {
|
|||
order: 'desc',
|
||||
orderBy: 'date',
|
||||
searchQuery: '',
|
||||
authorFilter: '',
|
||||
sortingOptions: [
|
||||
{ label: this.$i18n.get('label_title'), value: 'title' },
|
||||
{ label: this.$i18n.get('label_creation_date'), value: 'date' },
|
||||
|
@ -439,6 +463,13 @@ export default {
|
|||
this.$userPrefs.set('collections_order_by', 'date');
|
||||
}
|
||||
|
||||
if (this.authorFilter != this.$userPrefs.get('collections_author_filter'))
|
||||
this.authorFilter = this.$userPrefs.get('collections_author_filter');
|
||||
if (this.authorFilter === undefined) {
|
||||
this.authorFilter = '';
|
||||
this.$userPrefs.set('collections_author_filter', '');
|
||||
}
|
||||
|
||||
this.loadCollections();
|
||||
},
|
||||
methods: {
|
||||
|
@ -483,6 +514,19 @@ export default {
|
|||
this.orderBy = newOrderBy;
|
||||
this.loadCollections();
|
||||
},
|
||||
onChangeAuthorFilter(newAuthorFilter) {
|
||||
if (newAuthorFilter != this.authorFilter) {
|
||||
this.$userPrefs.set('collections_author_filter', newAuthorFilter)
|
||||
.then((newAuthorFilter) => {
|
||||
this.authorFilter = newAuthorFilter;
|
||||
})
|
||||
.catch(() => {
|
||||
this.$console.log("Error settings user prefs for collections author filter")
|
||||
});
|
||||
}
|
||||
this.authorFilter = newAuthorFilter;
|
||||
this.loadCollections();
|
||||
},
|
||||
onChangeCollectionsPerPage(value) {
|
||||
|
||||
if (value != this.collectionsPerPage) {
|
||||
|
@ -521,6 +565,7 @@ export default {
|
|||
orderby: this.orderBy,
|
||||
search: this.searchQuery,
|
||||
collectionTaxonomies: this.collectionTaxonomies,
|
||||
authorid: this.authorFilter === 'current-author' && tainacan_plugin.user_data && tainacan_plugin.user_data.ID ? tainacan_plugin.user_data.ID : ''
|
||||
})
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
|
@ -568,20 +613,20 @@ export default {
|
|||
@import '../../scss/_variables.scss';
|
||||
|
||||
.sub-header {
|
||||
min-height: $header-height;
|
||||
min-height: 2.5em;
|
||||
padding: 0.5em 0;
|
||||
height: auto;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
gap: 4px;
|
||||
|
||||
.header-item {
|
||||
margin-bottom: 0 !important;
|
||||
min-height: 2em;
|
||||
min-height: 1.875em;
|
||||
|
||||
&:first-child {
|
||||
margin-right: auto;
|
||||
|
@ -593,9 +638,11 @@ export default {
|
|||
.label {
|
||||
font-size: 0.875em;
|
||||
font-weight: normal;
|
||||
margin-top: 5px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
cursor: default;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&:not(:first-child) {
|
||||
|
@ -629,7 +676,9 @@ export default {
|
|||
font-size: 1.125em !important;
|
||||
height: 1.75em
|
||||
}
|
||||
|
||||
.collections-page-author-filter {
|
||||
display: flex;
|
||||
}
|
||||
.dropdown-menu {
|
||||
display: block;
|
||||
|
||||
|
@ -660,7 +709,6 @@ export default {
|
|||
}
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
height: 120px;
|
||||
margin-top: -0.5em;
|
||||
padding-top: 0.9em;
|
||||
|
||||
|
|
|
@ -387,10 +387,9 @@
|
|||
@import '../../scss/_variables.scss';
|
||||
|
||||
.sub-header {
|
||||
min-height: $header-height;
|
||||
height: auto;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
min-height: 2.5em;
|
||||
padding: 0.5em 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
|
@ -400,7 +399,7 @@
|
|||
|
||||
.header-item {
|
||||
margin-bottom: 0 !important;
|
||||
min-height: 2em;
|
||||
min-height: 1.875em;
|
||||
|
||||
&:first-child {
|
||||
margin-right: auto;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
font-family: var(--tainacan-font-family, inherit);
|
||||
line-height: 1.75em !important;
|
||||
height: auto !important;
|
||||
padding: calc(0.375em - 1px) 20px calc(0.375em - 1px) 10px !important;
|
||||
padding: calc(0.375em - 1px) 24px calc(0.375em - 1px) 10px !important;
|
||||
margin-top: 0px !important;
|
||||
margin-bottom: 0px !important;
|
||||
color: var(--tainacan-input-color);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
&.is-narrow {
|
||||
tbody td {
|
||||
height: 42px;
|
||||
height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,15 +191,15 @@ $checkbox-border-width: 1px;
|
|||
top: calc(-1 * var(--tainacan-container-padding));
|
||||
z-index: 2;
|
||||
background: var(--tainacan-background-color);
|
||||
min-height: $header-height;
|
||||
height: auto;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
min-height: 2.5em;
|
||||
padding: 0.5em 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
// A copy of bootstrap's screen reader only class to be used for accessibility.
|
||||
|
|
|
@ -94,6 +94,7 @@ return apply_filters( 'tainacan-i18n', [
|
|||
'delete' => __( 'Delete', 'tainacan' ),
|
||||
'skip' => __( 'Skip', 'tainacan' ),
|
||||
'add' => __( 'Add', 'tainacan' ),
|
||||
'show' => __( 'Show', 'tainacan' ),
|
||||
|
||||
// Wordpress Comments Status
|
||||
'comments_status_open' => __( 'Open', 'tainacan' ),
|
||||
|
@ -296,6 +297,8 @@ return apply_filters( 'tainacan-i18n', [
|
|||
/* translators: 'Published' here refers to the sum of public and private items, not including draft or trashed ones. The are visible to those with permission */
|
||||
'label_all_items' => __( 'All items', 'tainacan' ),
|
||||
'label_all_collections' => __( 'All collections', 'tainacan' ),
|
||||
'label_show_only_created_by_me' => __( 'Show only created by me', 'tainacan' ),
|
||||
'label_collections_that_i_can_edit' => __( 'Collections that I can edit', 'tainacan' ),
|
||||
'label_all_taxonomies' => __( 'All taxonomies', 'tainacan' ),
|
||||
'label_bulk_actions' => __( 'Bulk actions', 'tainacan' ),
|
||||
'label_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
@ -1041,6 +1044,8 @@ return apply_filters( 'tainacan-i18n', [
|
|||
'info_you_searched_for_%s' => __( 'You searched for %s', 'tainacan' ),
|
||||
'info_try_enabling_search_by_word' => __( 'Try enabling the search by words.', 'tainacan' ),
|
||||
'info_try_disabling_search_by_word' => __( 'Try disabling the search by words, to search for the complete phrase.', 'tainacan' ),
|
||||
'info_try_empting_the_textual_search' => __( 'Try empting the textual search.', 'tainacan' ),
|
||||
'info_try_selecting_all_collections_in_filter' => __( 'Try selecting All Collections in the filter above.', 'tainacan' ),
|
||||
'info_details_about_search_by_word' => __( 'They may be located on different metadata and order, but you will still be able to use quotes to group them.', 'tainacan' ),
|
||||
'info_item_submission_draft_status' => __( 'Warning: draft items may be submitted even without filling all required metadata.', 'tainacan' ),
|
||||
'info_empty_geocoordinate_metadata_list' => __( 'No geocoordinate metadata was found. Try enabling it in the "displayed metadata" dropdown.', 'tainacan' ),
|
||||
|
|
Loading…
Reference in New Issue