Merge remote-tracking branch 'origin/develop' into issue-#92

This commit is contained in:
Jacson Passold 2018-08-28 00:33:10 -03:00
commit 7ed94e5ae4
45 changed files with 685 additions and 312 deletions

View File

@ -45,7 +45,7 @@
</div>
</b-field>
<!-- Name -------------- -->
<b-field
:addons="false"
:type="((formErrors.name !== '' || formErrors.repeated !== '') && (formErrors.name !== undefined || formErrors.repeated !== undefined )) ? 'is-danger' : ''"
@ -63,6 +63,7 @@
@focus="clearErrors({ name: 'name', repeated: 'repeated' })"/>
</b-field>
<!-- Description -------------- -->
<b-field
:addons="false"
:type="formErrors['description'] !== '' && formErrors['description'] !== undefined ? 'is-danger' : ''"
@ -80,7 +81,48 @@
@focus="clearErrors('description')"/>
</b-field>
<!-- Parent -------------- -->
<b-field
:addons="false"
:type="((formErrors.parent !== '' || formErrors.repeated !== '') && (formErrors.parent !== undefined || formErrors.repeated !== undefined )) ? 'is-danger' : ''"
:message="formErrors.parent ? formErrors : formErrors.repeated">
<label class="label is-inline">
{{ $i18n.get('label_parent_term') }}
<b-switch
@input="onToggleSwitch()"
id="tainacan-checkbox-has-parent"
size="is-small"
v-model="hasParent" />
<help-button
:title="$i18n.get('label_parent_term')"
:message="$i18n.get('info_help_parent_term')"/>
</label>
<b-autocomplete
id="tainacan-text-cover-page"
:placeholder="$i18n.get('instruction_parent_term')"
:data="parentTerms"
field="name"
v-model="parentTermName"
@select="onSelectParentTerm($event)"
:loading="isFetchingParentTerms"
@input="fecthParentTerms($event)"
@focus="clearErrors('parent');"
:disabled="!hasParent">
<template slot-scope="props">
{{ props.option.name }}
</template>
<template slot="empty">{{ $i18n.get('info_no_parent_term_found') }}</template>
</b-autocomplete>
<transition name="fade">
<p
class="checkboxes-warning"
v-show="showCheckboxesWarning == true">
{{ $i18n.get('info_warning_changing_parent_term') }}
</p>
</transition>
</b-field>
<!-- Submit buttons -------------- -->
<div class="field is-grouped form-submit">
<div class="control">
<button
@ -121,7 +163,14 @@
return {
formErrors: {},
headerPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_rectangle.png',
headerImageMediaFrame: undefined
headerImageMediaFrame: undefined,
isFetchingParentTerms: false,
parentTerms: [],
parentTermName: '',
showCheckboxesWarning: false,
hasParent: false,
hasChangedParent: false,
initialParentId: undefined
}
},
props: {
@ -132,6 +181,8 @@
...mapActions('taxonomy', [
'sendChildTerm',
'updateChildTerm',
'fetchParentName',
'fetchPossibleParentTerms'
]),
...mapGetters('taxonomy', [
'getTerms'
@ -143,11 +194,11 @@
taxonomyId: this.taxonomyId,
name: this.editForm.name,
description: this.editForm.description,
parent: this.editForm.parent,
parent: this.hasParent ? this.editForm.parent : 0,
headerImageId: this.editForm.header_image_id,
})
.then((term) => {
this.$emit('onEditionFinished', term);
this.$emit('onEditionFinished', {term: term, hasChangedParent: this.hasChangedParent });
this.editForm = {};
this.formErrors = {};
})
@ -161,17 +212,18 @@
});
} else {
this.updateChildTerm({
taxonomyId: this.taxonomyId,
termId: this.editForm.id,
name: this.editForm.name,
description: this.editForm.description,
parent: this.editForm.parent,
parent: this.hasParent ? this.editForm.parent : 0,
headerImageId: this.editForm.header_image_id,
})
.then(() => {
.then((term) => {
this.formErrors = {};
this.$emit('onEditionFinished', this.editForm);
this.$emit('onEditionFinished', { term: term, hasChangedParent: this.hasChangedParent });
})
.catch((errors) => {
for (let error of errors.errors) {
@ -223,9 +275,63 @@
this.formErrors[attributes] = undefined;
}
},
fecthParentTerms(search) {
this.isFetchingParentTerms = true;
this.fetchPossibleParentTerms({
taxonomyId: this.taxonomyId,
termId: this.editForm.id,
search: search })
.then((parentTerms) => {
this.parentTerms = parentTerms;
this.isFetchingParentTerms = false;
})
.catch((error) => {
this.$console.error(error);
this.isFetchingParentTerms = false;
});
},
onToggleSwitch() {
if (this.editForm.parent == 0) {
this.hasChangedParent = this.hasParent;
} else {
this.hasChangedParent = !this.hasParent;
}
this.showCheckboxesWarning = true;
this.clearErrors('parent');
},
onSelectParentTerm(selectedParentTerm) {
this.hasChangedParent = this.initialParentId != selectedParentTerm.id;
this.editForm.parent = selectedParentTerm.id;
this.selectedParentTerm = selectedParentTerm;
this.parentTermName = selectedParentTerm.name;
this.showCheckboxesWarning = true;
}
},
mounted() {
this.showCheckboxesWarning = false;
this.hasParent = this.editForm.parent != undefined && this.editForm.parent > 0;
this.initialParentId = this.editForm.parent;
this.initializeMediaFrames();
if (this.hasParent) {
this.isFetchingParentTerms = true;
this.showCheckboxesWarning = false;
this.fetchParentName({ taxonomyId: this.taxonomyId, parentId: this.editForm.parent })
.then((parentName) => {
this.parentTermName = parentName;
this.isFetchingParentTerms = false;
this.showCheckboxesWarning = false;
})
.catch((error) => {
this.$console.error(error);
this.isFetchingParentTerms = false;
this.showCheckboxesWarning = false;
});
}
}
}
</script>
@ -321,6 +427,11 @@
position: relative;
}
}
.checkboxes-warning {
color: $gray5;
font-style: italic;
padding: 0.2rem 0.75rem;
}
}
</style>

View File

@ -88,7 +88,7 @@
<!-- Thumbnail -->
<td
class="thumbnail-cell column-default-width"
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
:label="$i18n.get('label_thumbnail')"
:aria-label="$i18n.get('label_thumbnail')">
<span>
@ -100,7 +100,7 @@
<!-- Name -->
<td
class="column-default-width column-main-content"
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
:label="$i18n.get('label_name')"
:aria-label="$i18n.get('label_name') + ': ' + collection.name">
<p
@ -114,7 +114,7 @@
<!-- Description -->
<td
class="column-large-width"
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
:label="$i18n.get('label_description')"
:aria-label="$i18n.get('label_description') + ': ' + collection.description">
<p
@ -127,7 +127,7 @@
</td>
<!-- Creation Date -->
<td
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
class="table-creation column-default-width"
:label="$i18n.get('label_creation_date')"
:aria-label="$i18n.get('label_creation_date') + ': ' + collection.creation_date">
@ -141,7 +141,7 @@
</td>
<!-- Created by -->
<td
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
class="table-creation column-default-width"
:label="$i18n.get('label_created_by')"
:aria-label="$i18n.get('label_created_by') + ': ' + collection.author_name">
@ -155,7 +155,7 @@
</td>
<!-- Total items -->
<td
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
class="column-small-width column-align-right"
:label="$i18n.get('label_total_items')"
v-if="collection.total_items != undefined"
@ -170,7 +170,7 @@
</td>
<!-- Actions -->
<td
@click="goToCollectionPage(collection.id)"
@click="onClickCollection($event, collection.id, index)"
class="actions-cell column-default-width"
:label="$i18n.get('label_actions')">
<div class="actions-container">
@ -325,8 +325,12 @@ export default {
}
});
},
goToCollectionPage(collectionId) {
this.$router.push(this.$routerHelper.getCollectionPath(collectionId));
onClickCollection($event, collectionId, index) {
if ($event.ctrlKey) {
this.$set(this.selectedCollections, index, !this.selectedCollections[index]);
} else {
this.$router.push(this.$routerHelper.getCollectionPath(collectionId));
}
},
goToCollectionEditPage(collectionId) {
this.$router.push(this.$routerHelper.getCollectionEditPath(collectionId));

View File

@ -64,14 +64,14 @@
autoHide: false,
placement: 'auto-start'
}"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
{{ item.title != undefined ? item.title : '' }}
</p>
</div>
<!-- Thumbnail -->
<a
v-if="item.thumbnail != undefined"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
<img :src="item['thumbnail'].tainacan_medium ? item['thumbnail'].tainacan_medium : (item['thumbnail'].medium ? item['thumbnail'].medium : thumbPlaceholderPath)">
</a>
@ -130,14 +130,14 @@
<!-- Title -->
<div
@click="goToItemPage(item)"
@click="onClickItem($event, item, index)"
class="metadata-title">
<p>{{ item.title != undefined ? item.title : '' }}</p>
</div>
<!-- Thumbnail -->
<div
@click="goToItemPage(item)"
@click="onClickItem($event, item, index)"
v-if="item.thumbnail != undefined"
class="thumbnail"
:style="{ backgroundImage: 'url(' + (item['thumbnail'].tainacan_medium_full ? item['thumbnail'].tainacan_medium_full : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large : thumbPlaceholderPath)) + ')' }">
@ -197,7 +197,7 @@
autoHide: false,
placement: 'auto-start'
}"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
{{ item.title != undefined ? item.title : '' }}
</p>
</div>
@ -227,7 +227,7 @@
<!-- Remaining metadata -->
<div
class="media"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
<img
v-if="item.thumbnail != undefined"
@ -244,7 +244,6 @@
}"
class="metadata-description"
v-html="item.description != undefined ? getLimitedDescription(item.description) : ''" />
<br>
<!-- Author-->
<p
v-tooltip="{
@ -312,7 +311,7 @@
v-for="(column, index) in tableMetadata"
:key="index"
v-if="collectionId != undefined && column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
@click="goToItemPage(item)"
@click="onClickItem($event, item, index)"
v-html="item.metadata != undefined ? renderMetadata(item.metadata, column) : ''" />
<p
v-tooltip="{
@ -324,7 +323,7 @@
v-for="(column, index) in tableMetadata"
:key="index"
v-if="collectionId == undefined && column.display && column.metadata_type_object != undefined && (column.metadata_type_object.related_mapped_prop == 'title')"
@click="goToItemPage(item)"
@click="onClickItem($event, item, index)"
v-html="item.title != undefined ? item.title : ''" />
</div>
<!-- Actions -->
@ -353,7 +352,7 @@
<!-- Remaining metadata -->
<div
class="media"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
<div class="list-metadata media-body">
<div class="thumbnail">
<img
@ -436,8 +435,8 @@
<!-- Item Displayed Metadata -->
<td
:key="index"
v-for="(column, index) in tableMetadata"
:key="columnIndex"
v-for="(column, columnIndex) in tableMetadata"
v-if="column.display"
:label="column.name"
class="column-default-width"
@ -454,7 +453,7 @@
column.metadata_type_object.primitive_type == 'compound') : false,
'column-large-width' : column.metadata_type_object != undefined ? (column.metadata_type_object.primitive_type == 'long_string' || column.metadata_type_object.related_mapped_prop == 'description') : false,
}"
@click="goToItemPage(item)">
@click="onClickItem($event, item, index)">
<p
v-tooltip="{
@ -669,8 +668,12 @@ export default {
}
});
},
goToItemPage(item) {
this.$router.push(this.$routerHelper.getItemPath(item.collection_id, item.id));
onClickItem($event, item, index) {
if ($event.ctrlKey) {
this.$set(this.selectedItems, index, !this.selectedItems[index]);
} else {
this.$router.push(this.$routerHelper.getItemPath(item.collection_id, item.id));
}
},
goToItemEditPage(item) {
this.$router.push(this.$routerHelper.getItemEditPath(item.collection_id, item.id));
@ -688,7 +691,8 @@ export default {
}
},
getLimitedDescription(description) {
return description.length > 120 ? description.substring(0, 117) + '...' : description;
let maxCharacter = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= 480 ? 100 : 220;
return description.length > maxCharacter ? description.substring(0, maxCharacter - 3) + '...' : description;
}
}
}

View File

@ -79,7 +79,6 @@
:index="childIndex"
:taxonomy-id="taxonomyId"
:order="order"/>
</div>
<a
class="view-more-terms"
@ -334,7 +333,7 @@ export default {
}
}
}
.controls.is-disabled a, .children-dropdown.is-disabled {
.controls.is-disabled a, .children-dropdown i.is-disabled {
color: $gray4 !important;
cursor: not-allowed !important;
user-select: none;
@ -342,7 +341,7 @@ export default {
&.opened-term:first-child {
cursor: default;
background-color: $blue1;
background-color: $gray1;
&:before {
content: '';
@ -353,7 +352,7 @@ export default {
width: 0;
height: 0;
border-style: solid;
border-color: transparent transparent transparent $blue1;
border-color: transparent transparent transparent $gray1;
border-left-width: 24px;
border-top-width: 20px;
border-bottom-width: 20px;

View File

@ -75,7 +75,7 @@
<!-- Name -->
<td
class="column-default-width column-main-content"
@click="goToTaxonomyEditPage(taxonomy.id)"
@click="onClickTaxonomy($event, taxonomy.id, index)"
:label="$i18n.get('label_name')"
:aria-label="$i18n.get('label_name') + ': ' + taxonomy.name">
<p
@ -89,7 +89,7 @@
<!-- Description -->
<td
class="column-large-width"
@click="goToTaxonomyEditPage(taxonomy.id)"
@click="onClickTaxonomy($event, taxonomy.id, index)"
:label="$i18n.get('label_description')"
:aria-label="$i18n.get('label_description') + ': ' + taxonomy.description">
<p
@ -102,14 +102,14 @@
</td>
<!-- Actions -->
<td
@click="goToTaxonomyEditPage(taxonomy.id)"
@click="onClickTaxonomy($event, taxonomy.id, index)"
class="actions-cell column-default-width"
:label="$i18n.get('label_actions')">
<div class="actions-container">
<a
id="button-edit"
:aria-label="$i18n.getFrom('taxonomies','edit_item')"
@click="goToTaxonomyEditPage(taxonomy.id)">
@click="onClickTaxonomy($event, taxonomy.id, index)">
<b-icon
type="is-secondary"
icon="pencil"/>
@ -254,11 +254,12 @@
}
});
},
goToTaxonomyPage(taxonomyId) {
this.$router.push(this.$routerHelper.getTaxonomyPath(taxonomyId));
},
goToTaxonomyEditPage(taxonomyId) {
this.$router.push(this.$routerHelper.getTaxonomyEditPath(taxonomyId));
onClickTaxonomy($event, taxonomyId, index) {
if ($event.ctrlKey) {
this.$set(this.selected, index, !this.selected[index]);
} else {
this.$router.push(this.$routerHelper.getTaxonomyEditPath(taxonomyId));
}
}
}
}

View File

@ -358,7 +358,7 @@ export default {
}
this.$termsListBus.$on('editTerm', (term) => {
// Position edit form in a visible area
// Position edit form in a visible area
let container = document.getElementById('repository-container');
if (container && container.scrollTop && container.scrollTop > 80)
this.termEditionFormTop = container.scrollTop - 80;
@ -368,9 +368,12 @@ export default {
this.editTerm = term;
this.isEditingTerm = true;
});
this.$termsListBus.$on('termEditionSaved', () => {
this.$termsListBus.$on('termEditionSaved', ({hasChangedParent}) => {
this.isEditingTerm = false;
this.editTerm = null;
if (hasChangedParent)
this.loadTerms(0);
});
this.$termsListBus.$on('termEditionCanceled', () => {
this.isEditingTerm = false;

View File

@ -297,7 +297,7 @@ export default {
span {
text-overflow: ellipsis;
white-space: nowrap;
overflow-x: hidden;
overflow: hidden;
max-width: 115px;
margin: 0 0.1rem;
display: inline-block;

View File

@ -176,7 +176,7 @@ export default {
span {
text-overflow: ellipsis;
white-space: nowrap;
overflow-x: hidden;
overflow: hidden;
max-width: 75%;
margin: 0 0.1rem;
display: inline-block;

View File

@ -46,7 +46,7 @@ export default {
}
.help-tooltip {
z-index: 99999999999999999999;
color: $blue5;
color: $turquoise5;
background-color: $turquoise2;
border: none;
display: block;

View File

@ -10,8 +10,8 @@ export default {
onEditTerm(term) {
this.$emit('editTerm', term);
},
onTermEditionSaved(term) {
this.$emit('termEditionSaved', term);
onTermEditionSaved({term, hasChangedParent}) {
this.$emit('termEditionSaved', { term: term, hasChangedParent: hasChangedParent });
},
onTermEditionCanceled(term) {
this.$emit('termEditionCanceled', term);

View File

@ -186,14 +186,17 @@ export default {
this.loadCollections();
},
onChangeCollectionsPerPage(value) {
if (value != this.collectionsPerPage) {
this.$userPrefs.set('collections_per_page', value)
.then((newValue) => {
this.collectionsPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for collection per page")
});
}
this.collectionsPerPage = value;
this.$userPrefs.set('collections_per_page', value)
.then((newValue) => {
this.collectionsPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for collection per page")
});
this.loadCollections();
},
onPageChange(page) {

View File

@ -183,25 +183,31 @@
}
},
onChangeEventsPerPage(value) {
if (value != this.eventsPerPage) {
this.$userPrefs.set('events_per_page', value)
.then((newValue) => {
this.eventsPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for events per page")
});
}
this.eventsPerPage = value;
this.$userPrefs.set('events_per_page', value)
.then((newValue) => {
this.eventsPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for events per page")
});
this.loadEvents();
},
onChangeProcessesPerPage(value) {
if (value != this.processesPerPage) {
this.$userPrefs.set('processes_per_page', value)
.then((newValue) => {
this.processesPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for processes per page")
});
}
this.processesPerPage = value;
this.$userPrefs.set('processes_per_page', value)
.then((newValue) => {
this.processesPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for processes per page")
});
this.loadProcesses();
},
onPageChange(page) {

View File

@ -9,8 +9,7 @@
v-if="!openAdvancedSearch"
class="is-hidden-mobile"
id="filter-menu-compress-button"
:class="{'filter-menu-compress-button-top-repo': isRepositoryLevel}"
:style="{ top: !isOnTheme ? '120px' : '76px' }"
:style="{ top: !isOnTheme ? (isRepositoryLevel ? '172px' : '120px') : '76px' }"
@click="isFiltersMenuCompressed = !isFiltersMenuCompressed">
<b-icon :icon="isFiltersMenuCompressed ? 'menu-right' : 'menu-left'" />
</button>
@ -19,8 +18,7 @@
v-if="!openAdvancedSearch"
class="is-hidden-tablet"
id="filter-menu-compress-button"
:class="{'filter-menu-compress-button-top-repo': isRepositoryLevel}"
:style="{ top: !isOnTheme ? (searchControlHeight + 70) + 'px' : (searchControlHeight - 25) + 'px' }"
:style="{ top: !isOnTheme ? (isRepositoryLevel ? (searchControlHeight + 100) : (searchControlHeight + 70) + 'px') : (searchControlHeight - 25) + 'px' }"
@click="isFilterModalActive = !isFilterModalActive">
<b-icon :icon="isFiltersMenuCompressed ? 'menu-right' : 'menu-left'" />
<span class="text">{{ $i18n.get('filters') }}</span>
@ -770,7 +768,7 @@
'getAdminViewMode'
]),
onSwipeFiltersMenu($event) {
let screenWidth = window.screen.width;
let screenWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
if ($event.offsetDirection == 4 && screenWidth <= 768) {
if (!this.isFilterModalActive)
@ -1274,9 +1272,6 @@
}
}
.filter-menu-compress-button-top-repo {
top: 123px !important;
}
#filter-menu-compress-button {
position: absolute;
z-index: 99;
@ -1287,7 +1282,7 @@
width: 23px;
border: none;
background-color: $turquoise1;
color: $blue5;
color: $turquoise5;
padding: 0;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;

View File

@ -141,14 +141,17 @@
this.load();
},
onChangePerPage(value) {
this.taxonomiesPerPage = value;
this.$userPrefs.set('taxonomies_per_page', value)
.then((newValue) => {
this.taxonomiesPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for taxonomies per page")
});
if (value != this.taxonomiesPerPage) {
this.$userPrefs.set('taxonomies_per_page', value)
.then((newValue) => {
this.taxonomiesPerPage = newValue;
})
.catch(() => {
this.$console.log("Error settings user prefs for taxonomies per page")
});
}
this.taxonomiesPerPage = value;
this.load();
},
onPageChange(page) {

View File

@ -771,7 +771,7 @@
'getAdminViewMode'
]),
onSwipeFiltersMenu($event) {
let screenWidth = window.screen.width;
let screenWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
if ($event.offsetDirection == 4 && screenWidth <= 768) {
if (!this.isFilterModalActive)
@ -1289,7 +1289,7 @@
width: 23px;
border: none;
background-color: $turquoise1;
color: $blue5;
color: $turquoise5;
padding: 0;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;

View File

@ -0,0 +1,91 @@
// Repository-level pages
// This garantees that any component inside a .repository-level-page
// will have a blue color instead of a turquoise.
.repository-level-page {
margin-top: 94px;
height: $page-height !important;
@media screen and (max-width: 769px) {
margin-top: 42px;
}
.is-primary:not(.upload-draggable), .is-primary:hover, .is-primary:focus {
background-color: $blue4 !important;
color: white !important;
}
.is-secondary, .is-secondary:hover, .is-secondary:focus {
background-color: $blue5 !important;
color: white !important;
}
.has-text-primary, .has-text-primary:hover, .is-has-text-primary:focus {
color: $blue4 !important;
}
a, a:hover,
.has-text-secondary, .has-text-secondary:hover, .is-has-text-secondary:focus {
color: $blue3 !important;
}
.tainacan-page-title hr{
background-color: $blue3;
}
.button[disabled]:not(.is-white), .button:hover[disabled]:not(.is-white) {
border: none !important;
cursor: not-allowed !important;
color: $gray4 !important;
background-color: $gray2 !important;
}
.button.is-outlined {
color: $blue5 !important;
}
.tabs {
li.is-active a {
border-bottom: 5px solid $blue5;
color: $blue5;
}
}
.select:not(.is-multiple)::after {
color: $blue5;
option:checked, option:hover {
background-color: $gray2 !important;
}
}
.tainacan-table {
tr.selected-row {
background-color: $blue1 !important;
.checkbox-cell .checkbox, .actions-cell .actions-container {
background-color: $blue2 !important;
}
}
}
.dropdown-trigger {
.button .icon {
color: $blue5;
}
}
.dropdown-menu .dropdown-content {
.dropdown-item.is-active { background-color: $blue2; }
}
.switch {
&:hover input[type="checkbox"]:checked + .check {
background-color: $blue2;
}
input[type="checkbox"]:checked + .check {
border: 2px solid $blue5;
&::before {
background-color: $blue5;
}
}
&.is-small {
input[type="checkbox"]:checked + .check {
border: 1.5px solid $blue5;
}
}
}
#filter-menu-compress-button {
background-color: $blue1 !important;
color: $blue5 !important;
}
}

View File

@ -30,6 +30,7 @@
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: top;
}
.required-metadatum-asterisk {
color: $gray3;
@ -74,7 +75,7 @@
padding-left: 0.8em;
font-size: 12px;
text-overflow: ellipsis;
overflow-x: hidden;
overflow: hidden;
white-space: nowrap;
}
.select {

View File

@ -20,24 +20,26 @@
padding: 0px;
flex-basis: 0;
margin: 0.75rem;
max-width: 410px;
min-width: 410px;
max-width: 425px;
min-width: 425px;
min-height: 218px;
max-height: 218px;
cursor: pointer;
@media screen and (max-width: 450px) {
@media screen and (max-width: 480px) {
max-width: 100%;
min-width: 100%;
min-height: 176px;
max-height: 176px;
img {
width: 33.333333% !important;
height: 33.333333% !important;
width: 130px !important;
height: 130px !important;
}
}
&:hover {
background-color: #f2f2f2 !important;
background-color: $gray1 !important;
}
.card-checkbox {
@ -109,7 +111,7 @@
p.metadata-description {
font-size: 0.6875rem !important;
overflow: hidden;
margin-bottom: 1.5rem;
margin-bottom: 1rem;
max-height: 152px;
}

View File

@ -17,6 +17,7 @@
}
.tainacan-record {
background-color: #f6f6f6;
padding: 0px;
flex-basis: 0;
margin: 0 auto 42px auto;
@ -28,7 +29,7 @@
display: block;
&:hover {
background-color: #f2f2f2 !important;
background-color: $gray1 !important;
}
.record-checkbox {
@ -86,6 +87,7 @@
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
transition: background-color 0.3s;
}
}
&:hover .metadata-title {

View File

@ -23,6 +23,7 @@
@import "../scss/_tags.scss";
@import "../scss/_notices.scss";
@import "../scss/_filters-menu-modal.scss";
@import "../scss/_repository-level-overrides.scss";
// Clears wordpress content
body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter, body.tainacan-admin-page #wp-auth-check-wrap {
@ -65,92 +66,6 @@ a:hover {
}
}
// Repository-level pages
.repository-level-page {
margin-top: 94px;
height: $page-height !important;
@media screen and (max-width: 769px) {
margin-top: 42px;
}
.is-primary:not(.upload-draggable), .is-primary:hover, .is-primary:focus {
background-color: $blue4 !important;
color: white !important;
}
.is-secondary, .is-secondary:hover, .is-secondary:focus {
background-color: $blue5 !important;
color: white !important;
}
.has-text-primary, .has-text-primary:hover, .is-has-text-primary:focus {
color: $blue4 !important;
}
a, a:hover,
.has-text-secondary, .has-text-secondary:hover, .is-has-text-secondary:focus {
color: $blue5 !important;
}
.tainacan-page-title {
h1 {
color: $blue5 !important;
}
}
.button[disabled]:not(.is-white), .button:hover[disabled]:not(.is-white) {
border: none !important;
cursor: not-allowed !important;
color: $gray4 !important;
background-color: $gray2 !important;
}
.button.is-outlined {
color: $blue5 !important;
}
.tabs {
li.is-active a {
border-bottom: 5px solid $blue5;
color: $blue5;
}
}
.select:not(.is-multiple)::after {
color: $blue5;
option:checked, option:hover {
background-color: $gray2 !important;
}
}
.tainacan-table {
tr.selected-row {
background-color: $blue1 !important;
.checkbox-cell .checkbox, .actions-cell .actions-container {
background-color: $blue2 !important;
}
}
}
.dropdown-trigger {
.button .icon {
color: $blue5;
}
}
.dropdown-menu .dropdown-content {
.dropdown-item.is-active { background-color: $blue2; }
}
.switch {
&:hover input[type="checkbox"]:checked + .check {
background-color: $blue2;
}
input[type="checkbox"]:checked + .check {
border: 2px solid $blue5;
&::before {
background-color: $blue5;
}
}
&.is-small {
input[type="checkbox"]:checked + .check {
border: 1.5px solid $blue5;
}
}
}
}
// Generic page container
.page-container {
padding: $page-top-padding $page-side-padding;

View File

@ -317,6 +317,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_insert_mapper_metadatum_info' => __( 'Insert the new mapper\'s metadatum info', 'tainacan' ),
'instruction_select_max_options_to_show' => __( 'Select max options to show', 'tainacan' ),
'instruction_select_collection_fetch_items' => __( 'Select a collection to fecth items', 'tainacan' ),
'instruction_parent_term' => __( 'Type to search a Parent Term to choose.', 'tainacan' ),
// Info. Other feedback to user.
'info_search_results' => __( 'Search Results', 'tainacan' ),
@ -384,6 +385,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_possible_external_sources' => __( 'Possible external sources: CSV, Instagram, Youtube, etc.', 'tainacan' ),
'info_help_term_name' => __( 'The term name', 'tainacan' ),
'info_help_term_description' => __( 'The description of the Term.', 'tainacan' ),
'info_help_parent_term' => __( 'The parent term', 'tainacan' ),
'info_no_attachments_on_item_yet' => __( 'The are no attachments on this item so far.', 'tainacan' ),
'info_repository_metadata_inheritance' => __( 'Repository Metadata will be inherited by all collections.', 'tainacan' ),
'info_repository_filters_inheritance' => __( 'Repository Filters will be inherited by all collections.', 'tainacan' ),
@ -415,6 +417,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_there_are_no_metadata_in_repository_level' => __( 'There are no metadata in repository level', 'tainacan' ),
'info_import_collection' => __( 'Import from external sources.', 'tainacan' ),
'info_import_items' => __( 'Import items from external sources.', 'tainacan' ),
'info_no_parent_term_found' => __( 'No valid parent term was found with this name.', 'tainacan' ),
'info_warning_changing_parent_term' => __( 'Warning! Changing parent term will reload the terms list, thus uncheking any selection.', 'tainacan' ),
// Tainacan Metadatum Types
'tainacan-text' => __( 'Text', 'tainacan' ),

View File

@ -42,11 +42,9 @@ class REST_Controller extends \WP_REST_Controller {
* @return \Tainacan\Entities\Entity
*/
protected function prepare_item_for_updating($object, $new_values){
foreach ($new_values as $key => $value) {
$object->set($key, $value);
}
return $object;
}
@ -84,8 +82,10 @@ class REST_Controller extends \WP_REST_Controller {
'postin' => 'post__in',
'relation' => 'relation',
'nopaging' => 'nopaging',
'meta_key' => 'meta_key',
'meta_type' => 'meta_type'
'metatype' => 'meta_type',
'hierarchical' => 'hierarchical',
'exclude' => 'exclude',
'excludetree' => 'exclude_tree'
];
$meta_query = [

View File

@ -82,6 +82,21 @@ class REST_Bulkedit_Controller extends REST_Controller {
'permission_callback' => array($this, 'bulk_edit_permissions_check'),
),
)
);
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/(?P<group_id>[0-9a-f]+)/set_status',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array($this, 'set_status'),
'permission_callback' => array($this, 'bulk_edit_permissions_check'),
'args' => [
'value' => [
'type' => 'string',
'description' => __( 'The new status value', 'tainacan' ),
],
],
),
)
);
register_rest_route($this->namespace, '/collection/(?P<collection_id>[\d]+)/' . $this->rest_base . '/(?P<group_id>[0-9a-f]+)/set',
array(
@ -221,6 +236,33 @@ class REST_Bulkedit_Controller extends REST_Controller {
return $this->generic_action('replace_value', $request, ['old_value', 'new_value']);
}
public function set_status($request) {
$body = json_decode($request->get_body(), true);
if( !isset($body['value']) ){
return new \WP_REST_Response([
'error_message' => __('Value must be provided', 'tainacan'),
], 400);
}
$group_id = $request['group_id'];
$args = ['id' => $group_id];
$bulk = new \Tainacan\Bulk_Edit($args);
$action = $bulk->set_status($body['value']);
if ( is_wp_error($action) ) {
return new \WP_REST_Response([
'error_message' => $action->get_error_message(),
], 400);
} else {
return new \WP_REST_Response($action, 200);
}
}
public function trash_items($request) {

View File

@ -142,6 +142,33 @@ class Bulk_Edit {
}
/**
* Sets the status to all items in the current group
*
*/
public function set_status($value) {
if (!$this->get_id()) {
return new \WP_Error( 'no_id', __( 'Bulk Edit group not initialized', 'tainacan' ) );
}
$possible_values = ['draft', 'publish', 'private'];
// Specific validation
if (!in_array($value, $possible_values)) {
return new \WP_Error( 'invalid_action', __( 'Invalid status', 'tainacan' ) );
}
global $wpdb;
$select_q = $this->_build_select( 'post_id' );
$query = $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s WHERE ID IN ($select_q)", $value);
return $wpdb->query($query);
}
/**
* Adds a value to a metadatum to all items in the current group
* Must be used with a multiple metadatum

View File

@ -452,7 +452,7 @@ if ( ! class_exists( 'WP_Background_Process' ) ) {
exit;
}
$this->handle();
$this->dispatch();
exit;
}

View File

@ -245,13 +245,9 @@ class Collections extends Repository {
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => true,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => true,

View File

@ -125,13 +125,9 @@ class Filters extends Repository {
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => true,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => true,

View File

@ -425,7 +425,7 @@ class Items extends Repository {
$TainacanMedia = \Tainacan\Media::get_instance();
$thumb_blob = $TainacanMedia->get_pdf_cover( $filepath );
if ( $thumb_blob ) {
$thumb_id = $TainacanMedia->insert_attachment_from_blob( $thumb_blob, basename( $filepath ) . '-cover.jpg', $item->get_id() );
$thumb_id = $TainacanMedia->insert_attachment_from_blob( $thumb_blob, basename( $filepath ) . '-cover.jpg' );
return $thumb_id;
}
@ -443,7 +443,7 @@ class Items extends Repository {
return $existing_thumb;
} else {
$TainacanMedia = \Tainacan\Media::get_instance();
$thumb_id = $TainacanMedia->insert_attachment_from_url( $thumb_url, $item->get_id() );
$thumb_id = $TainacanMedia->insert_attachment_from_url( $thumb_url );
update_post_meta( $item->get_id(), $meta_key, $thumb_id );
return $thumb_id;

View File

@ -141,13 +141,10 @@ class Logs extends Repository {
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => false,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'show_in_nav_menus' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'has_archive' => false,

View File

@ -227,13 +227,9 @@ class Metadata extends Repository {
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => true,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => true,

View File

@ -105,13 +105,9 @@ class Taxonomies extends Repository {
$args = array(
'labels' => $labels,
'hierarchical' => true,
//'supports' => array('title'),
//'taxonomies' => array(self::TAXONOMY),
'public' => true,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_in_menu' => tnc_enable_dev_wp_interface(),
//'menu_position' => 5,
//'show_in_nav_menus' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'has_archive' => false,
@ -119,6 +115,7 @@ class Taxonomies extends Repository {
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'show_in_nav_menus' => false,
'capability_type' => Entities\Taxonomy::get_capability_type(),
'supports' => [
'title',

View File

@ -52,7 +52,7 @@ class Terms extends Repository {
'type' => 'integer',
'description' => __( 'The parent of the term', 'tainacan' ),
'default' => 0,
'validation' => ''
//'validation' => ''
],
'description' => [
'map' => 'description',
@ -60,7 +60,7 @@ class Terms extends Repository {
'type' => 'string',
'description' => __( 'The term description', 'tainacan' ),
'default' => '',
'validation' => ''
//'validation' => ''
],
'taxonomy' => [
'map' => 'taxonomy',
@ -139,10 +139,11 @@ class Terms extends Repository {
if ( $mapped['map'] != 'termmeta' ) {
$get_ = 'get_' . $prop;
if ( ! empty( $term->WP_Term->{$mapped['map']} ) ) {
if ( $term->WP_Term->{$mapped['map']} ||
($mapped['map'] == 'parent' && $term->WP_Term->{$mapped['map']} >= 0) ) {
$args[ $mapped['map'] ] = $term->$get_();
}
}
}

View File

@ -29,29 +29,29 @@ class CSV extends Importer {
* @inheritdoc
*/
public function get_source_metadata(){
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file->seek(0);
if (($handle = fopen($this->tmp_file, "r")) !== false) {
$columns = [];
$rawColumns = str_getcsv( $file->fgets(), $this->get_option('delimiter'), $this->get_option('enclosure') );
$rawColumns = fgetcsv($handle, 0, $this->get_option('delimiter'));
$columns = [];
if( $rawColumns ){
foreach( $rawColumns as $index => $rawColumn ){
if( $rawColumns ){
foreach( $rawColumns as $index => $rawColumn ){
if( strpos($rawColumn,'special_') === 0 ){
if( strpos($rawColumn,'special_') === 0 ){
if( $rawColumn === 'special_document' ){
$this->set_option('document_index', $index);
} else if( $rawColumn === 'special_attachments' ){
$this->set_option('attachment_index', $index);
if( $rawColumn === 'special_document' ){
$this->set_option('document_index', $index);
} else if( $rawColumn === 'special_attachments' ){
$this->set_option('attachment_index', $index);
}
} else {
$columns[] = $rawColumn;
}
} else {
$columns[] = $rawColumn;
}
}
return $columns;
return $columns;
}
}
return [];
@ -62,9 +62,12 @@ class CSV extends Importer {
* returns all header including special
*/
public function raw_source_metadata(){
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file->seek(0);
return $file->fgetcsv( $this->get_option('delimiter') );
if (($handle = fopen($this->tmp_file, "r")) !== false) {
return fgetcsv($handle, 0, $this->get_option('delimiter'));
}
return false;
}
/**
@ -75,29 +78,42 @@ class CSV extends Importer {
$headers = $this->raw_source_metadata();
$this->add_log('Proccessing item index ' . $index . ' in collection ' . $collection_definition['id'] );
// search the index in the file and get values
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file->setFlags(\SplFileObject::SKIP_EMPTY);
$file->seek( $index );
if (($handle = fopen($this->tmp_file, "r")) !== false) {
$file = $handle;
} else {
$this->add_error_log(' Error reading the file ');
return false;
}
if( $index === 0 ){
$file->current();
$file->next();
$this->add_log(' Delimiter to parse' . $this->get_option('delimiter') );
$values = str_getcsv( $file->fgets(), $this->get_option('delimiter'), $this->get_option('enclosure') );
}else{
$this->add_log(' Delimiter to parse' . $this->get_option('delimiter') );
$values = str_getcsv( rtrim($file->fgets()), $this->get_option('delimiter'), $this->get_option('enclosure') );
// moves the pointer forward
fgetcsv($file, 0, $this->get_option('delimiter'));
} else {
//get the pointer
$csv_pointer= $this->get_transient('csv_pointer');
if( $csv_pointer ){
fseek($file, $csv_pointer);
}
}
$this->add_transient('csv_last_pointer', ftell($file)); // add reference to post_process item in after_inserted_item()
$values = fgetcsv($file, 0, $this->get_option('delimiter'), $this->get_option('enclosure'));
$this->add_transient('csv_pointer', ftell($file)); // add reference for insert
if( count( $headers ) !== count( $values ) ){
$string = (is_array($values)) ? implode('::', $values ) : $values;
$this->add_log(' Mismatch count headers and row columns ');
$this->add_log(' Headers count: ' . count( $headers ) );
$this->add_log(' Values count: ' . count( $values ) );
$this->add_log(' Values string: ' . $string );
$this->add_error_log(' Mismatch count headers and row columns ');
$this->add_error_log(' Headers count: ' . count( $headers ) );
$this->add_error_log(' Values count: ' . count( $values ) );
$this->add_error_log(' enclosure : ' . $enclosure );
$this->add_error_log(' Values string: ' . $string );
return false;
}
@ -120,7 +136,6 @@ class CSV extends Importer {
}
$this->add_log('Success to proccess index: ' . $index );
$this->add_transient('actual_index', $index); // add reference for insert
return $processedItem;
}
@ -133,17 +148,17 @@ class CSV extends Importer {
if( !empty($column_document) || !empty( $column_attachment ) ){
$index = $this->get_transient('actual_index');
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file->setFlags(\SplFileObject::SKIP_EMPTY);
$file->seek( $index );
if (($handle = fopen($this->tmp_file, "r")) !== false) {
$file = $handle;
} else {
$this->add_error_log(' Error reading the file ');
return false;
}
if( $index === 0 ){
$file->current();
$file->next();
}
$csv_pointer= $this->get_transient('csv_last_pointer');
fseek($file, $csv_pointer);
$values = str_getcsv( rtrim($file->fgets()), $this->get_option('delimiter'), $this->get_option('enclosure') );
$values = fgetcsv($file, 0, $this->get_option('delimiter'), $this->get_option('enclosure'));
if( is_array($values) && !empty($column_document) ){
$this->handle_document( $values[$column_document], $inserted_item);
@ -159,14 +174,17 @@ class CSV extends Importer {
* @inheritdoc
*/
public function get_source_number_of_items(){
if (isset($this->tmp_file) && file_exists($this->tmp_file)) {
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file->seek(PHP_INT_MAX);
// -1 removing header
return $this->total_items = $file->key() - 1;
if ( isset($this->tmp_file) && file_exists($this->tmp_file) && ($handle = fopen($this->tmp_file, "r")) !== false) {
$cont = 0;
while ( ($data = fgetcsv($handle, 0, $this->get_option('delimiter')) ) !== false ) {
$cont++;
}
// does not count the header
return $cont - 1;
}
return false;
}
@ -329,6 +347,7 @@ class CSV extends Importer {
*/
private function handle_document($column_value, $item_inserted){
$TainacanMedia = \Tainacan\Media::get_instance();
$this->items_repo->disable_logs();
if( strpos($column_value,'url:') === 0 ){
$correct_value = trim(substr($column_value, 4));
@ -394,6 +413,8 @@ class CSV extends Importer {
set_post_thumbnail( $item_inserted->get_id(), (int) $thumb_id );
}
$this->items_repo->enable_logs();
return true;
}
@ -404,6 +425,8 @@ class CSV extends Importer {
private function handle_attachment( $column_value, $item_inserted){
$TainacanMedia = \Tainacan\Media::get_instance();
$this->items_repo->disable_logs();
$attachments = explode( $this->get_option('multivalued_delimiter'), $column_value);
if( $attachments ){
@ -433,5 +456,8 @@ class CSV extends Importer {
$this->add_log('Attachment file in Server imported from ' . $attachment);
}
}
$this->items_repo->enable_logs();
}
}

View File

@ -763,6 +763,7 @@ abstract class Importer {
*/
public function insert( $processed_item, $collection_index ) {
remove_action( 'post_updated', 'wp_save_post_revision' );
$collections = $this->get_collections();
$collection_definition = isset($collections[$collection_index]) ? $collections[$collection_index] : false;
if ( !$collection_definition || !is_array($collection_definition) || !isset($collection_definition['id']) || !isset($collection_definition['mapping']) ) {
@ -778,6 +779,7 @@ abstract class Importer {
$Tainacan_Items->disable_logs();
$Tainacan_Metadata->disable_logs();
$Tainacan_Item_Metadata->disable_logs();
$item = new Entities\Item();
$itemMetadataArray = [];

View File

@ -272,7 +272,8 @@ class Old_Tainacan extends Importer{
* @return Tainacan\Entities\Item Item inserted
*/
public function insert( $processed_item, $collection_index ) {
$collection_id = $processed_item['collection_definition'];
$this->items_repo->disable_logs();
$collection_id = $processed_item['collection_definition'];
$item_Old = $processed_item['item']->item;
$collection = new Entities\Collection($collection_id['id']);
@ -321,6 +322,7 @@ class Old_Tainacan extends Importer{
*/
public function add_item_metadata( $item, $metadata_old, $collection_id ){
$relationships = [];
$this->item_metadata_repo->disable_logs();
foreach( $metadata_old as $metadatum ){

View File

@ -287,7 +287,7 @@ class Test_Importer extends Importer {
<h5><?php _e('Keyword Search', 'tainacan'); ?></h5>
</div>
<div class="help-tooltip-body">
<p><?php _e('Type one keyword which it will be used to find images in flickr (e.g. dogs, cat)', 'tainacan'); ?></p>
<p><?php _e('Optionally ype one keyword which it will be used to find images in flickr (e.g. dogs, cat). Default is "kitten".', 'tainacan'); ?></p>
</div>
</div>
</span>
@ -595,6 +595,10 @@ class Test_Importer extends Importer {
}
/**
* Example of a method that takes a long time to run
* and may run through multiple requests
*/
public function finish_processing() {
$this->add_log('finish_processing');
@ -651,7 +655,7 @@ class Test_Importer extends Importer {
$inserted_item->set_document( $id );
$inserted_item->set_document_type( 'attachment' );
$this->add_log('Document URL imported from ' . $correct_value);
$this->add_log('Document URL imported from ' . $url);
if( $inserted_item->validate() ) {
$inserted_item = $this->items_repo->update($inserted_item);

View File

@ -160,7 +160,6 @@ export default {
this.loadItems(to);
}
}
},
methods: {
@ -192,15 +191,14 @@ export default {
this.updateURLQueries();
},
addFetchOnly( metadatum ){
let prefsFetchOnly = this.collectionId != undefined ? 'fetch_only_' + this.collectionId : 'fetch_only';
if(this.$userPrefs.get(prefsFetchOnly) != metadatum) {
this.$userPrefs.set(prefsFetchOnly, metadatum)
.catch(() => {});
}
this.$store.dispatch('search/add_fetchonly', metadatum );
this.updateURLQueries();
let prefsFetchOnly = this.collectionId != undefined ? 'fetch_only_' + this.collectionId : 'fetch_only';
if (JSON.stringify(this.$userPrefs.get(prefsFetchOnly)) != JSON.stringify(metadatum)) {
this.$userPrefs.set(prefsFetchOnly, metadatum)
.catch(() => { this.$console.log("Error setting user prefs for fetch_only"); });
}
},
cleanFetchOnly() {
this.$store.dispatch('search/cleanFetchOnly');
@ -228,14 +226,14 @@ export default {
this.updateURLQueries();
},
setItemsPerPage(itemsPerPage) {
this.$store.dispatch('search/setItemsPerPage', itemsPerPage);
this.updateURLQueries();
let prefsPerPage = this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page';
if(this.$userPrefs.get(prefsPerPage) != itemsPerPage) {
this.$userPrefs.set(prefsPerPage, itemsPerPage)
.catch(() => {});
}
this.$store.dispatch('search/setItemsPerPage', itemsPerPage);
this.updateURLQueries();
},
setOrderBy(orderBy) {
let prefsOrderBy = this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by';
@ -265,24 +263,24 @@ export default {
this.updateURLQueries();
},
setViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries();
let prefsViewMode = this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode';
if(this.$userPrefs.get(prefsViewMode) != viewMode) {
this.$userPrefs.set(prefsViewMode, viewMode)
.catch(() => {});
}
this.$store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries();
},
setAdminViewMode(adminViewMode) {
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries();
let prefsAdminViewMode = this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode';
if(this.$userPrefs.get(prefsAdminViewMode) != adminViewMode) {
this.$userPrefs.set(prefsAdminViewMode, adminViewMode)
.catch(() => { });
.catch(() => { });
}
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries();
},
setInitialViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode);

View File

@ -79,16 +79,16 @@ export const setOrderBy = ({ state, commit }, orderBy ) => {
} else if (orderBy.slug == 'author_name') {
commit('setPostQueryAttribute', { attr: 'orderby', value: 'author_name' } );
} else if (orderBy.metadata_type_object.primitive_type == 'float' || orderBy.metadata_type_object.primitive_type == 'int') {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value_num' } );
} else if (orderBy.metadata_type_object.primitive_type == 'date') {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'meta_type', value: 'DATETIME' } );
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'metatype', value: 'DATETIME' } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );
} else if (orderBy.metadata_type_object.core) {
commit('setPostQueryAttribute', { attr: 'orderby', value: orderBy.metadata_type_object.related_mapped_prop } );
} else {
commit('setPostQueryAttribute', { attr: 'meta_key', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'metakey', value: orderBy.id } );
commit('setPostQueryAttribute', { attr: 'orderby', value: 'meta_value' } );
}

View File

@ -301,3 +301,28 @@ export const clearTerms = ({ commit }) => {
commit('clearTerms');
};
// Used only on Term Edition form, for autocomplete searhc for parents
export const fetchPossibleParentTerms = ({ commit }, { taxonomyId, termId, search } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms?searchterm=' + search + '&hierarchical=1&exclude_tree=' + termId + "&hideempty=0&offset=0&number=20")
.then(res => {
let parentTerms = res.data;
resolve( parentTerms );
})
.catch(error => {
reject( error );
});
});
};
export const fetchParentName = ({ commit }, { taxonomyId, parentId } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/taxonomy/' + taxonomyId + '/terms/' + parentId + '?fetch_only=name')
.then(res => {
let parentName = res.data.name;
resolve( parentName );
})
.catch(error => {
reject( error );
});
});
};

View File

@ -70,7 +70,7 @@ function tainacan_get_the_document() {
if (!$item)
return;
return $item->get_document_html();
return apply_filters('tainacan-get-the-document', $item->get_document_html(), $item);
}
@ -140,7 +140,7 @@ function tainacan_get_the_collection_name() {
if ( $collection ) {
$name = $collection->get_name();
}
return $name;
return apply_filters('tainacan-get-collection-name', $name, $collection);
}
/**
@ -163,7 +163,7 @@ function tainacan_get_the_collection_description() {
if ( $collection ) {
$description = $collection->get_description();
}
return $description;
return apply_filters('tainacan-get-collection-description', $description, $collection);
}
/**
@ -221,6 +221,52 @@ function tainacan_get_term() {
return false;
}
/**
* When visiting a taxonomy archive, returns the term name
*
* @return string
*/
function tainacan_get_the_term_name() {
$term = tainacan_get_term();
$name = '';
if ( $term ) {
$name = $term->name;
}
return apply_filters('tainacan-get-term-name', $name, $term);
}
/**
* When visiting a taxonomy archive, prints the term name
*
* @return void
*/
function tainacan_the_term_name() {
echo tainacan_get_the_term_name();
}
/**
* When visiting a taxonomy archive, returns the term description
*
* @return string
*/
function tainacan_get_the_term_description() {
$term = tainacan_get_term();
$description = '';
if ( $term ) {
$description = $term->description;
}
return apply_filters('tainacan-get-term-description', $description, $term);
}
/**
* When visiting a taxonomy archive, prints the term description
*
* @return void
*/
function tainacan_the_term_description() {
echo tainacan_get_the_term_description();
}
/**
* @see \Tainacan\Theme_Helper->register_view_mode()
*/
@ -310,5 +356,6 @@ function tainacan_get_initials($string, $one = false) {
$second = $words[ sizeof($words) - 1 ][0];
}
return strtoupper($first . $second);
$result = strtoupper($first . $second);
return apply_filters('tainacan-get-initials', $result, $string, $one);
}

View File

@ -87,7 +87,8 @@ export default {
collectionId: Number,
displayedMetadata: Array,
items: Array,
isLoading: false
isLoading: false,
shouldUseSmallCard: false
},
data () {
return {
@ -111,7 +112,8 @@ export default {
}
},
getLimitedDescription(description) {
return description.length > 300 ? description.substring(0, 297) + '...' : description;
let maxCharacter = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= 480 ? 155 : 330;
return description.length > maxCharacter ? description.substring(0, maxCharacter - 3) + '...' : description;
}
}
}
@ -121,10 +123,11 @@ export default {
$turquoise1: #e6f6f8;
$turquoise2: #d1e6e6;
$tainacan-input-color: #1d1d1d;
$gray1: #f2f2f2;
$gray2: #e5e5e5;
$gray4: #898d8f;
$gray3: #dcdcdc;
$gray4: #898d8f;
$gray5: #454647;
@import "../../src/admin/scss/_view-mode-cards.scss";

View File

@ -125,10 +125,11 @@ export default {
$turquoise1: #e6f6f8;
$turquoise2: #d1e6e6;
$tainacan-input-color: #1d1d1d;
$gray1: #f2f2f2;
$gray2: #e5e5e5;
$gray4: #898d8f;
$gray3: #dcdcdc;
$gray4: #898d8f;
$gray5: #454647;
@import "../../src/admin/scss/_view-mode-records.scss";

View File

@ -606,6 +606,35 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
$this->assertEquals(20, $items->found_posts);
}
function test_set_status() {
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$ids = array_slice($this->items_ids, 4, 11);
$bulk = new \Tainacan\Bulk_Edit([
'items_ids' => $ids,
]);
$id = $bulk->get_id();
$bulk->set_status('draft');
$items = $Tainacan_Items->fetch([
'status' => 'draft',
'posts_per_page' => -1
]);
$this->assertEquals(11, $items->found_posts);
$items = $Tainacan_Items->fetch([
'publish' => 'draft',
'posts_per_page' => -1
]);
$this->assertEquals(29, $items->found_posts);
}
function test_set_regular_multi_meta() {
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
@ -840,6 +869,42 @@ class BulkEdit extends TAINACAN_UnitApiTestCase {
$this->assertEquals(14, $items->found_posts);
}
/**
* @group api
*/
public function test_api_set_status() {
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$ids = array_slice($this->items_ids, 2, 14);
$bulk = new \Tainacan\Bulk_Edit([
'items_ids' => $ids,
]);
$body = json_encode([
'value' => 'private'
]);
$request = new \WP_REST_Request(
'POST', $this->api_baseroute . '/' . $bulk->get_id() . '/set_status'
);
$request->set_body( $body );
$response = $this->server->dispatch($request);
$items = $Tainacan_Items->fetch([
'status' => 'private',
'posts_per_page' => -1
]);
$this->assertEquals(14, $items->found_posts);
}
/**

View File

@ -262,7 +262,11 @@ class ImporterTests extends TAINACAN_UnitTestCase {
// Sample data
$data = array(
array('Data 11', 'Data 12', 'Data 13||TESTE', 'Data 14', 'Data 15'),
array('Data 21', 'Data 22', 'Data 23', 'Data 24', 'Data 25'),
array('Data 21', 'Data 22', 'this
is
having
multiple
lines', 'Data 24', 'Data 25'),
array('Data 31', 'Data 32', utf8_decode( 'Data 33||Rééço' ), 'Data 34', 'Data 35'),
array('Data 41', 'Data 42', 'Data 43||limbbo', 'Data 44', 'Data 45'),
array('Data 51', 'Data 52', 'Data 53', 'Data 54', 'Data 55')