Creates some especific options for admin and groups them on 'modes' #659.

This commit is contained in:
mateuswetah 2022-02-01 11:22:33 -03:00
parent 8422a63d3c
commit 224a7c7811
8 changed files with 117 additions and 87 deletions

View File

@ -8,36 +8,37 @@
'tainacan-admin-read-mode': $adminOptions.readmode
}">
<template v-if="activeRoute == 'HomePage'">
<tainacan-header />
<tainacan-header v-if="!$adminOptions.hideTainacanHeader" />
<router-view />
</template>
<template v-else>
<template v-if="!$adminOptions.iframemode && !$adminOptions.mobilemode">
<primary-menu
:active-route="activeRoute"
:is-menu-compressed="isMenuCompressed"/>
<button
class="is-hidden-mobile"
id="menu-compress-button"
@click="isMenuCompressed = !isMenuCompressed">
<span
v-tooltip="{
content: $i18n.get('label_shrink_menu'),
autoHide: true,
placement: 'auto-end',
classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip']
}"
class="icon">
<i
:class="{ 'tainacan-icon-arrowleft' : !isMenuCompressed, 'tainacan-icon-arrowright' : isMenuCompressed }"
class="tainacan-icon tainacan-icon-1-25em"/>
</span>
</button>
<tainacan-header />
<tainacan-repository-subheader
:is-repository-level="isRepositoryLevel"
:is-menu-compressed="isMenuCompressed"/>
</template>
<primary-menu
v-if="!$adminOptions.hidePrimaryMenu"
:active-route="activeRoute"
:is-menu-compressed="isMenuCompressed"/>
<button
v-if="!$adminOptions.hideMenuCompressButton"
class="is-hidden-mobile"
id="menu-compress-button"
@click="isMenuCompressed = !isMenuCompressed">
<span
v-tooltip="{
content: $i18n.get('label_shrink_menu'),
autoHide: true,
placement: 'auto-end',
classes: ['tainacan-tooltip', 'tooltip', 'repository-tooltip']
}"
class="icon">
<i
:class="{ 'tainacan-icon-arrowleft' : !isMenuCompressed, 'tainacan-icon-arrowright' : isMenuCompressed }"
class="tainacan-icon tainacan-icon-1-25em"/>
</span>
</button>
<tainacan-header v-if="!$adminOptions.hideTainacanHeader" />
<tainacan-repository-subheader
v-if="!$adminOptions.hideTainacanRepositorySubheader"
:is-repository-level="isRepositoryLevel"
:is-menu-compressed="isMenuCompressed"/>
<div
id="repository-container"
class="column is-main-content">

View File

@ -5,7 +5,7 @@
:active.sync="isLoading"
:can-cancel="false"/>
<div
v-if="!$adminOptions.mobilemode"
v-if="!$adminOptions.hideBulkEditionPageTitle"
class="tainacan-page-title">
<h1>{{ $i18n.get('add_items_bulk') }}</h1>
<a

View File

@ -6,7 +6,7 @@
:can-cancel="false"/>
<div
v-if="!$adminOptions.mobilemode || ($adminOptions.mobilemode && isEditingMetadataIframeMode)"
v-if="!$adminOptions.hideItemEditionPageTitle || ($adminOptions.hideItemEditionPageTitle && isEditingMetadataIframeMode)"
class="tainacan-page-title">
<h1 v-if="isCreatingNewItem">
<span
@ -23,7 +23,7 @@
<span style="font-weight: 600;">{{ (item != null && item != undefined) ? item.title : '' }}</span>
</h1>
<a
v-if="!$adminOptions.iframemode"
v-if="!$adminOptions.hideItemEditionPageBackButton"
@click="$router.go(-1)"
class="back-link has-text-secondary">
{{ $i18n.get('back') }}
@ -57,7 +57,7 @@
<!-- Collection -------------------------------- -->
<div
v-if="!$adminOptions.mobilemode"
v-if="!$adminOptions.hideCollectionNameInItemPage"
class="column is-narrow">
<div class="section-label">
<label>{{ $i18n.get('collection') }}</label>

View File

@ -5,7 +5,9 @@
<div
v-if="collectionId && collection && collection.current_user_can_edit_items && collection.current_user_can_bulk_edit"
class="selection-control">
<div class="field select-all is-pulled-left">
<div
v-if="!$adminOptions.hideMultipleItemSelection"
class="field select-all is-pulled-left">
<span>
<b-checkbox
@click.native.prevent="selectAllItemsOnPage()"
@ -48,6 +50,7 @@
</button>
</span>
<div
v-if="!$adminOptions.hideBulkActionsDropdown"
style="margin-left: auto;"
class="field">
<b-dropdown
@ -112,7 +115,7 @@
<!-- Context menu for right click selection -->
<div
v-if="cursorPosY > 0 && cursorPosX > 0 && !$adminOptions.readmode"
v-if="cursorPosY > 0 && cursorPosX > 0 && !$adminOptions.hideContextMenu"
class="context-menu">
<!-- Backdrop for escaping context menu -->
@ -127,12 +130,12 @@
trap-focus>
<b-dropdown-item
@click="openItem()"
v-if="!isOnTrash && !$adminOptions.iframemode">
v-if="!isOnTrash && !$adminOptions.hideContextMenuOpenItemOption">
{{ $i18n.getFrom('items','view_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="openItemOnNewTab()"
v-if="!isOnTrash && !$adminOptions.iframemode">
v-if="!isOnTrash && !$adminOptions.hideContextMenuOpenItemOnNewTabOption">
{{ $i18n.get('label_open_item_new_tab') }}
</b-dropdown-item>
<b-dropdown-item
@ -142,17 +145,17 @@
</b-dropdown-item>
<b-dropdown-item
@click="goToItemEditPage(contextMenuItem)"
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.iframemode">
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.hideContextMenuEditItemOption">
{{ $i18n.getFrom('items','edit_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="makeCopiesOfOneItem(contextMenuItem.id)"
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.iframemode">
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.hideContextMenuCopyItemOption">
{{ $i18n.get('label_make_copies_of_item') }}
</b-dropdown-item>
<b-dropdown-item
@click="deleteOneItem(contextMenuItem.id)"
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.iframemode">
v-if="contextMenuItem != null && contextMenuItem.current_user_can_edit && !$adminOptions.hideContextMenuDeleteItemOption">
{{ $i18n.get('label_delete_item') }}
</b-dropdown-item>
</b-dropdown>
@ -172,9 +175,9 @@
class="tainacan-grid-item">
<!-- Checkbox -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit in repository is done -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit for repository level is implemented -->
<div
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="grid-item-checkbox">
<b-checkbox
@ -241,7 +244,7 @@
<!-- Actions -->
<div
v-if="item.current_user_can_edit && !$adminOptions.iframemode"
v-if="item.current_user_can_edit && !$adminOptions.hideItemActionArea"
class="actions-area"
:label="$i18n.get('label_actions')">
<a
@ -315,7 +318,7 @@
<!-- Checkbox -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit in repository is done -->
<div
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="masonry-item-checkbox">
<label
@ -381,7 +384,7 @@
<!-- Actions -->
<div
v-if="item.current_user_can_edit && !$adminOptions.iframemode"
v-if="item.current_user_can_edit && !$adminOptions.hideItemActionArea"
class="actions-area"
:label="$i18n.get('label_actions')">
<a
@ -450,7 +453,7 @@
<!-- Checkbox -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit in repository is done -->
<div
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="card-checkbox">
<b-checkbox
@ -502,7 +505,7 @@
</div>
<!-- Actions -->
<div
v-if="item.current_user_can_edit && !$adminOptions.iframemode"
v-if="item.current_user_can_edit && !$adminOptions.hideItemActionArea"
class="actions-area"
:label="$i18n.get('label_actions')">
<a
@ -643,7 +646,7 @@
<!-- Checkbox -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit in repository is done -->
<div
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="record-checkbox">
<label
@ -722,7 +725,7 @@
</div>
<!-- Actions -->
<div
v-if="item.current_user_can_edit && !$adminOptions.iframemode"
v-if="item.current_user_can_edit && !$adminOptions.hideItemActionArea"
class="actions-area"
:label="$i18n.get('label_actions')">
<a
@ -837,7 +840,7 @@
<tr>
<!-- Checking list -->
<th
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)">
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)">
&nbsp;
<!-- nothing to show on header for checkboxes -->
</th>
@ -886,7 +889,7 @@
<!-- Checking list -->
<!-- TODO: Remove v-if="collectionId" from this element when the bulk edit in repository is done -->
<td
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="checkbox-cell">
<b-checkbox
@ -1051,7 +1054,7 @@
<!-- Actions -->
<td
v-if="(item.current_user_can_edit || item.current_user_can_delete) && !$adminOptions.iframemode"
v-if="(item.current_user_can_edit || item.current_user_can_delete) && !$adminOptions.hideItemActionArea"
class="actions-cell"
:label="$i18n.get('label_actions')">
<div class="actions-container">
@ -1122,7 +1125,7 @@
:class="{ 'selected-list-item': getSelectedItemChecked(item.id) == true }">
<div
v-if="collectionId && !$adminOptions.readmode && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
v-if="collectionId && !$adminOptions.hideItemSelection && ($adminOptions.iframemode || collection && collection.current_user_can_bulk_edit)"
:class="{ 'is-selecting': isSelectingItems }"
class="list-checkbox">
<label
@ -1185,7 +1188,7 @@
<!-- Actions -->
<div
v-if="item.current_user_can_edit && !$adminOptions.iframemode"
v-if="item.current_user_can_edit && !$adminOptions.hideItemActionArea"
class="actions-area"
:label="$i18n.get('label_actions')">
<a

View File

@ -440,7 +440,10 @@ CommentsStatusHelperPlugin.install = function (Vue, options = {}) {
// ADMIN OPTIONS HELPER PLUGIN - Stores options passed to the data-options in the admin div.
export const AdminOptionsHelperPlugin = {};
AdminOptionsHelperPlugin.install = function (Vue, options = {}) {
// Passes options to global variable
try {
let objectOptions = JSON.parse(options);
for (let key in objectOptions) {
if (objectOptions.hasOwnProperty(key)) {
@ -455,4 +458,55 @@ AdminOptionsHelperPlugin.install = function (Vue, options = {}) {
} catch(e) {
Vue.prototype.$adminOptions = {};
}
// Declares common 'modes', which group certain admin options
// Order matters here, as the latest overrides previous ones
const iframeMode = {
hideTainacanHeader: true,
hideMenuCompressButton: true,
hidePrimaryMenu: true,
hideTainacanRepositorySubheader: true,
hideTainacanCollectionSubheader: true,
hideItemEditionPageBackButton: true,
hideMultipleItemSelection: true,
hideBulkActionsDropdown: true,
hideContextMenuOpenItemOption: true,
hideContextMenuOpenItemOnNewTabOption: true,
hideContextMenuEditItemOption: true,
hideContextMenuCopyItemOption: true,
hideContextMenuDeleteItemOption: true,
hideItemActionArea: true,
hideItemsListPageTitle: true,
hideItemCreationDropdown: true,
hideExposersButton: true
};
if (Vue.prototype.$adminOptions.iframemode)
for (let option in iframeMode)
Vue.prototype.$adminOptions[option] = iframeMode[option];
const readMode = {
hideItemsListPageTitle: true,
hideContextMenu: true,
hideItemSelection: true
};
if (Vue.prototype.$adminOptions.readmode)
for (let option in readMode)
Vue.prototype.$adminOptions[option] = readMode[option];
const mobileMode = {
hideTainacanHeader: true,
hideMenuCompressButton: true,
hidePrimaryMenu: true,
hideTainacanRepositorySubheader: true,
hideTainacanCollectionSubheader: true,
hideItemEditionPageBackButton: true,
hideItemsListPageTitle: true,
hideItemEditionPageTitle: true,
hideBulkEditionPageTitle: true,
hideCollectionNameInItemPage: true
};
if (Vue.prototype.$adminOptions.mobilemode)
for (let option in mobileMode)
Vue.prototype.$adminOptions[option] = mobileMode[option];
};

View File

@ -9,7 +9,7 @@
<!-- PAGE TITLE --------------------- -->
<tainacan-title
v-if="!$adminOptions.iframemode && !$adminOptions.readmode && !openAdvancedSearch"
v-if="!$adminOptions.hideItemsListPageTitle && !openAdvancedSearch"
:bread-crumb-items="[{ path: '', label: this.$i18n.get('items') }]"/>
<div
v-else-if="openAdvancedSearch"
@ -98,10 +98,10 @@
</div>
</div>
<!-- Item Creation Dropdown, only on Admin -->
<!-- Item Creation Dropdown -->
<div
class="search-control-item"
v-if="!$adminOptions.iframemode &&
v-if="!$adminOptions.hideItemCreationDropdown &&
!openAdvancedSearch &&
collection &&
collection.current_user_can_edit_items">
@ -413,7 +413,7 @@
<!-- Exposers or alternative links modal button -->
<div
v-if="!$adminOptions.iframemode"
v-if="!$adminOptions.hideExposersButton"
class="search-control-item">
<button
class="button is-white"
@ -596,7 +596,7 @@
</p>
<router-link
v-if="!isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$adminOptions.iframemode"
v-if="!isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$adminOptions.hideItemCreationDropdown"
id="button-create-item"
tag="button"
class="button is-secondary"
@ -604,7 +604,7 @@
{{ $i18n.getFrom('items', 'add_new') }}
</router-link>
<button
v-else-if="isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$adminOptions.iframemode"
v-else-if="isRepositoryLevel && !isSortingByCustomMetadata && !hasFiltered && (status == undefined || status == '') && !$adminOptions.hideItemCreationDropdown"
id="button-create-item"
class="button is-secondary"
@click="onOpenCollectionsModal">

View File

@ -3,7 +3,7 @@
class="columns is-fullheight"
:class="{ 'tainacan-admin-collection-mobile-mode': $adminOptions.mobilemode }">
<section class="column is-secondary-content">
<tainacan-collection-subheader v-if="!$adminOptions.iframemode && !$adminOptions.mobilemode" />
<tainacan-collection-subheader v-if="!$adminOptions.hideTainacanCollectionSubheader" />
<router-view
id="collection-page-container"

View File

@ -1,14 +1,6 @@
// IFRAME MODE
// Used on gutenberg block modals, hiding content not relevant to be rendered inside iframe
#tainacan-admin-app.tainacan-admin-iframe-mode {
#primary-menu,
#menu-compress-button,
#tainacan-header,
#tainacan-repository-subheader,
#tainacan-subheader {
display: none;
visibility: hidden;
}
#repository-container .is-secondary-content {
margin-top: 0;
height: 100%;
@ -16,12 +8,6 @@
.page-container-small {
height: 100%;
#item-creation-options-dropdown,
#items-list-results .selection-control .field {
display: none;
visibility: hidden;
}
@media screen and (min-width: 769px) {
#filters-modal {
padding-left: 0em;
@ -65,14 +51,6 @@
// MOBILE MODE
// Used on the mobile app, to show only necessary elements inside the webview
#tainacan-admin-app.tainacan-admin-mobile-mode {
#primary-menu,
#menu-compress-button,
#tainacan-header,
#tainacan-repository-subheader,
#tainacan-subheader {
display: none;
visibility: hidden;
}
#repository-container .is-secondary-content {
margin-top: 0;
height: 100%;
@ -80,12 +58,6 @@
.page-container-small {
height: 100%;
#item-creation-options-dropdown,
#items-list-results .selection-control .field {
display: none;
visibility: hidden;
}
@media screen and (min-width: 769px) {
#filters-modal {
padding-left: 0em;