Merge pull request #475 from tainacan/feature/473

Feature/473
This commit is contained in:
Mateus Machado Luna 2021-01-21 17:58:57 -03:00 committed by GitHub
commit 28d1c654b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 124 additions and 82 deletions

View File

@ -35,7 +35,7 @@ class Theme_Helper {
// Redirect to post type archive if no cover page is set
add_action('wp', array($this, 'collection_single_redirect'));
add_action('wp_print_scripts', array($this, 'enqueue_scripts'));
add_action('wp_print_scripts', array($this, 'enqueue_scripts'), 90);
// make archive for terms work with items
add_action('pre_get_posts', array($this, 'tax_archive_pre_get_posts'));
@ -62,6 +62,7 @@ class Theme_Helper {
$this->register_view_mode('table', [
'label' => __('Table', 'tainacan'),
'description' => 'The classic table display.',
'dynamic_metadata' => true,
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewtable tainacan-icon-1-25em"></i></span>',
'type' => 'component',
@ -71,7 +72,7 @@ class Theme_Helper {
$this->register_view_mode('cards', [
'label' => __('Cards', 'tainacan'),
'dynamic_metadata' => false,
'description' => 'A cards view, displaying title, description, author name and creation date.',
'description' => 'A cards view, displaying cropped thumbnails, title and description.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewcards tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,
@ -80,7 +81,7 @@ class Theme_Helper {
$this->register_view_mode('records', [
'label' => __('Records', 'tainacan'),
'dynamic_metadata' => true,
'description' => 'A records view, similiar to cards, but flexible for metadata',
'description' => 'A records view, similiar to cards, but flexible for metadata.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewrecords tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,
@ -97,7 +98,7 @@ class Theme_Helper {
$this->register_view_mode('slideshow', [
'label' => __('Slideshow', 'tainacan'),
'dynamic_metadata' => false,
'description' => 'A fullscreen slideshow view.',
'description' => 'A fullscreen slideshow view, that shows the item document instead of just thumbnails.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewgallery tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'show_pagination' => false,
@ -106,7 +107,7 @@ class Theme_Helper {
$this->register_view_mode('list', [
'label' => __('List', 'tainacan'),
'dynamic_metadata' => true,
'description' => 'A list view, similiar to the records, but full width',
'description' => 'A list view, similiar to the records, but full width.',
'icon' => '<span class="icon"><i class="tainacan-icon tainacan-icon-viewlist tainacan-icon-1-25em"></i></span>',
'type' => 'component',
'implements_skeleton' => true,

View File

@ -221,7 +221,7 @@
:message="$i18n.getHelperMessage('collections', 'enabled_view_modes')"/>
<div class="control">
<b-dropdown
class="two-columns-dropdown"
class="two-columns-dropdown enabled-view-modes-dropdown"
ref="enabledViewModesDropdown"
:mobile-modal="true"
:disabled="Object.keys(registeredViewModes).length < 0"
@ -247,14 +247,19 @@
@input="updateViewModeslist(viewMode)"
:value="checkIfViewModeEnabled(viewMode)"
:disabled="checkIfViewModeEnabled(viewMode) && form.enabled_view_modes.filter((aViewMode) => (registeredViewModes[aViewMode] && registeredViewModes[aViewMode].full_screen != true)).length <= 1">
<span
class="gray-icon"
:class="{
'has-text-secondary' : checkIfViewModeEnabled(viewMode),
'has-text-gray4' : !checkIfViewModeEnabled(viewMode)
}"
v-html="registeredViewModes[viewMode].icon"/>
<span>{{ registeredViewModes[viewMode].label }}</span>
<p>
<strong>
<span
class="gray-icon"
:class="{
'has-text-secondary' : checkIfViewModeEnabled(viewMode),
'has-text-gray4' : !checkIfViewModeEnabled(viewMode)
}"
v-html="registeredViewModes[viewMode].icon"/>
&nbsp;{{ registeredViewModes[viewMode].label }}
</strong>
</p>
<p v-if="registeredViewModes[viewMode].description">{{ registeredViewModes[viewMode].description }}</p>
</b-checkbox>
</b-dropdown-item>
</b-dropdown>
@ -1249,6 +1254,17 @@ export default {
margin-top: -1.5em;
border-left: 1px solid var(--tainacan-gray2);
}
.enabled-view-modes-dropdown {
/deep/ .dropdown-item {
display: flex !important;
}
p {
white-space: normal;
}
/deep/ svg {
margin: 0 0 -8px -3px;
}
}
</style>

View File

@ -972,7 +972,8 @@
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: false
isContextEdit: false,
includeControlMetadataTypes: true
})
.then((resp) => {
resp.request
@ -1028,39 +1029,41 @@
let fetchOnlyMetadatumIds = [];
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never') {
if (metadatum.display !== 'never' || metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Control') {
let display;
if (metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Control') {
let display;
// Deciding display based on collection settings
if (metadatum.display == 'no')
display = false;
else if (metadatum.display == 'yes')
display = true;
// Deciding display based on collection settings
if (metadatum.display == 'no')
display = false;
else if (metadatum.display == 'yes')
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;
display = index >= 0;
}
metadata.push({
name: metadatum.name,
metadatum: metadatum.description,
slug: metadatum.slug,
metadata_type: metadatum.metadata_type,
metadata_type_object: metadatum.metadata_type_object,
metadata_type_options: metadatum.metadata_type_options,
id: metadatum.id,
display: display,
collection_id: metadatum.collection_id,
multiple: metadatum.multiple,
});
if (display)
fetchOnlyMetadatumIds.push(metadatum.id);
}
metadata.push({
name: metadatum.name,
metadatum: metadatum.description,
slug: metadatum.slug,
metadata_type: metadatum.metadata_type,
metadata_type_object: metadatum.metadata_type_object,
metadata_type_options: metadatum.metadata_type_options,
id: metadatum.id,
display: display,
collection_id: metadatum.collection_id,
multiple: metadatum.multiple,
});
if (display)
fetchOnlyMetadatumIds.push(metadatum.id);
if (
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
@ -1153,7 +1156,7 @@
}
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never' &&
if ((metadatum.display !== 'never' || metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Control') &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship'&&

View File

@ -6,6 +6,9 @@
.icon {
color: var(--tainacan-secondary);
align-items: center;
svg {
fill: var(--tainacan-secondary);
}
}
.gray-icon {
padding-right: 0 !important;

View File

@ -254,7 +254,7 @@ class Admin {
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key")
];
$maps = [
'collections' => $Tainacan_Collections->get_map(),
'metadata' => $Tainacan_Metadata->get_map(),

View File

@ -31,13 +31,21 @@ class Component_Hooks {
private function init() {
// the priority should see less than on function
// `load_admin_page()` of class `Admin` in file /src/views/class-tainacan-admin.php
add_action( 'admin_enqueue_scripts', array( &$this, 'register_component' ), 80 );
add_action( 'init', array( &$this, 'register_component' ), 80 );
}
public function register_component() {
do_action('tainacan-register-vuejs-component', $this);
foreach($this->registered_component as $handle => $component) {
wp_enqueue_script($handle, $component['script_path']);
$deps = isset($component['args']['deps']) ? $component['args']['deps'] : [];
if ( is_admin() ) {
wp_enqueue_script($handle, $component['script_path'], $deps);
} else {
if (isset($component['args']['public']) == true && $component['args']['public'] != false) {
wp_enqueue_script($handle, $component['script_path'], $deps);
}
}
}
}

View File

@ -28,7 +28,8 @@ function tainacan_blocks_add_gutenberg_blocks_actions() {
add_action('init', 'tainacan_blocks_register_tainacan_facets_list');
add_action('init', 'tainacan_blocks_register_tainacan_item_submission_form');
add_action('init', 'tainacan_blocks_add_plugin_settings');
add_action('init', 'tainacan_blocks_add_plugin_settings', 90);
add_action('init', 'tainacan_blocks_add_plugin_admin_settings', 90);
add_filter('block_categories', 'tainacan_blocks_register_categories', 10, 2);
add_action('init', 'tainacan_blocks_register_category_icon');
@ -403,14 +404,13 @@ function tainacan_blocks_get_plugin_js_settings(){
'base_url' => $TAINACAN_BASE_URL,
'admin_url' => admin_url(),
'site_url' => site_url(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug()
];
return $settings;
}
function tainacan_blocks_add_plugin_settings() {
$settings = tainacan_blocks_get_plugin_js_settings();
wp_localize_script( 'terms-list', 'tainacan_blocks', $settings );
@ -423,6 +423,9 @@ function tainacan_blocks_add_plugin_settings() {
wp_localize_script( 'collections-list', 'tainacan_blocks', $settings );
wp_localize_script( 'carousel-collections-list', 'tainacan_blocks', $settings );
wp_localize_script( 'facets-list', 'tainacan_blocks', $settings );
}
function tainacan_blocks_add_plugin_admin_settings() {
// The faceded search block uses a different settings object, the same used on the theme items list
wp_localize_script( 'tainacan-search', 'tainacan_plugin', \Tainacan\Admin::get_instance()->get_admin_js_localization_params() );

View File

@ -411,7 +411,7 @@
:trap-focus="filtersAsModal"
full-screen
:custom-class="'tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '')"
:can-cancel="hideHideFiltersButton ? ['x', 'outside'] : ['x', 'escape', 'outside']">
:can-cancel="hideHideFiltersButton || !filtersAsModal ? ['x', 'outside'] : ['x', 'escape', 'outside']">
<filters-items-list
:is-loading-items="isLoadingItems"
:autofocus="filtersAsModal"
@ -956,7 +956,8 @@
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: false
isContextEdit: false,
includeControlMetadataTypes: true
}).then((resp) => {
resp.request
.then(() => {
@ -1012,39 +1013,41 @@
let fetchOnlyMetadatumIds = [];
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never') {
if (metadatum.display !== 'never' || metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Control') {
let display;
if (metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Control') {
let display;
// Deciding display based on collection settings
if (metadatum.display == 'no')
display = false;
else if (metadatum.display == 'yes')
display = true;
// Deciding display based on collection settings
if (metadatum.display == 'no')
display = false;
else if (metadatum.display == 'yes')
display = true;
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
// Deciding display based on user prefs
if (prefsFetchOnlyMetaObject.length) {
let index = prefsFetchOnlyMetaObject.findIndex(metadatumId => metadatumId == metadatum.id);
display = index >= 0;
display = index >= 0;
}
metadata.push({
name: metadatum.name,
metadatum: metadatum.description,
slug: metadatum.slug,
metadata_type: metadatum.metadata_type,
metadata_type_object: metadatum.metadata_type_object,
metadata_type_options: metadatum.metadata_type_options,
id: metadatum.id,
display: display,
collection_id: metadatum.collection_id,
multiple: metadatum.multiple,
});
if (display)
fetchOnlyMetadatumIds.push(metadatum.id);
}
metadata.push({
name: metadatum.name,
metadatum: metadatum.description,
slug: metadatum.slug,
metadata_type: metadatum.metadata_type,
metadata_type_object: metadatum.metadata_type_object,
metadata_type_options: metadatum.metadata_type_options,
id: metadatum.id,
display: display,
collection_id: metadatum.collection_id,
multiple: metadatum.multiple,
});
if (display)
fetchOnlyMetadatumIds.push(metadatum.id);
if (
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
@ -1108,7 +1111,7 @@
}
for (let metadatum of this.metadata) {
if (metadatum.display !== 'never' &&
if ((metadatum.display !== 'never' || metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Control') &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Core_Description' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Taxonomy' &&
metadatum.metadata_type != 'Tainacan\\Metadata_Types\\Relationship' &&
@ -1118,7 +1121,7 @@
this.sortingMetadata.push(metadatum);
}
}
this.sortingMetadata.push({
name: this.$i18n.get('label_creation_date'),
metadatum: 'row_creation',
@ -1127,7 +1130,6 @@
id: undefined,
display: true
})
}
this.isLoadingMetadata = false;
@ -1445,10 +1447,16 @@
font-size: 1.3125em !important;
color: var(--tainacan-info-color) !important;
max-width: 1.25em;
svg {
color: var(--tainacan-info-color) !important;
}
}
.has-text-secondary.gray-icon .icon i::before,
.has-text-secondary.gray-icon i::before {
color: var(--tainacan-secondary) !important;
svg {
fill: var(--tainacan-secondary) !important;
}
}
.dropdown-menu {