Several tweaks to new item edition dropdown button.

This commit is contained in:
mateuswetah 2022-07-21 17:45:43 -03:00
parent 9d40dc4541
commit 6e45845dd7
5 changed files with 350 additions and 193 deletions

View File

@ -11,16 +11,33 @@
<h1 v-if="isCreatingNewItem">
<span
v-if="(item != null && item != undefined && item.status != undefined && !isLoading)"
class="status-tag">{{ $i18n.get('status_' + item.status) }}</span>
class="status-tag"
@mouseenter="$emit('toggleItemEditionFooterDropdown')">
{{ $i18n.get('status_' + item.status) }}
</span>
{{ $i18n.get('title_create_item_collection') + ' ' }}
<span style="font-weight: 600;">{{ collection && collection.name ? collection.name : '' }}</span>
</h1>
<h1 v-else>
<span
v-if="(item != null && item != undefined && item.status != undefined && !isLoading)"
class="status-tag">{{ $i18n.get('status_' + item.status) }}</span>
class="status-tag"
@mouseenter="$emit('toggleItemEditionFooterDropdown')">
{{ $i18n.get('status_' + item.status) }}
</span>
{{ $i18n.get('title_edit_item') + ' ' }}
<span style="font-weight: 600;">{{ (item != null && item != undefined) ? item.title : '' }}</span>
<span style="font-weight: 600;">
{{ (item != null && item != undefined) ? item.title : '' }}
</span>
<span
v-if="(item != null && item != undefined && item.status != undefined && item.status != 'autodraft' && !isLoading)"
class="icon has-text-gray4"
@mouseenter="$emit('toggleItemEditionFooterDropdown')">
<i
class="tainacan-icon tainacan-icon-1em"
:class="$statusHelper.getIcon(item.status)"
/>
</span>
</h1>
</tainacan-title>
@ -644,8 +661,9 @@
:status="form.status"
:collection-id="form.collectionId"
:is-on-sequence-edit="isOnSequenceEdit"
:group="group"
:item-position="itemPosition"
:is-current-item-on-sequence-edit="(group != null && group.items_count != undefined && group.items_count == itemPosition)"
:has-next-item-on-sequence-edit="(group != null && group.items_count != undefined && group.items_count < itemPosition)"
:has-previous-item-on-sequence-edit="itemPosition > 1"
:is-mobile-screen="isMobileScreen"
:has-some-error="formErrorMessage != undefined && formErrorMessage != ''"
:current-user-can-delete="item && item.current_user_can_delete"
@ -654,7 +672,6 @@
:visibility="visibility"
@onSubmit="onSubmit"
@onDiscard="onDiscard"
@onDeletePermanently="onDeletePermanently"
@onPrevInSequence="onPrevInSequence"
@onNextInSequence="onNextInSequence" />
@ -2181,13 +2198,6 @@ export default {
align-items: center;
transition: bottom 0.5s ease, width 0.2s linear;
.form-submission-footer {
.button {
margin-left: 16px;
margin-right: 6px;
}
}
@keyframes blink {
from { color: var(--tainacan-blue5); }
to { color: var(--tainacan-info-color); }
@ -2246,25 +2256,6 @@ export default {
margin-left: auto;margin-bottom: 0.75em;
margin-top: -0.25em;
}
.form-submission-footer {
display: flex;
justify-content: space-between;
width: 100%;
.button {
margin-left: 6px;
margin-right: 6px;
}
.button:first-of-type {
margin-left: 0px;
}
.button:last-of-type {
margin-right: 0px;
}
.button.is-success {
margin-left: auto;
}
}
}
}

View File

@ -11,31 +11,12 @@
</button>
</template>
<!-- Item is on trash -->
<template v-if="status == 'trash' && !isEditingItemMetadataInsideIframe">
<button
v-if="currentUserCanDelete"
@click="$emit('onDeletePermanently')"
type="button"
class="button is-outlined">{{ $i18n.get('label_delete_permanently') }}</button>
<button
@click="$emit('onSubmit', 'draft')"
type="button"
class="button is-secondary">
<span v-if="!isMobileScreen">{{ $i18n.get('label_save_as_draft') }}</span>
<span v-else>{{ $i18n.get('status_draft') }}</span>
</button>
<button
v-if="currentUserCanPublish"
@click="$emit('onSubmit', visibility)"
type="button"
class="button is-success">{{ $i18n.get('label_verb_publish') }}</button>
</template>
<!-- Normal item edition -->
<template v-else>
<!-- Item is an autodraft or draft -->
<template v-if="(status == 'auto-draft' || status == 'draft' || status == undefined) && !isEditingItemMetadataInsideIframe">
<!-- Sequence edition Previous -->
<button
v-if="isOnSequenceEdit && itemPosition > 1"
v-if="isOnSequenceEdit && hasPreviousItemOnSequenceEdit"
@click="$emit('onPrevInSequence')"
type="button"
class="button sequence-button">
@ -44,88 +25,21 @@
</span>
<span>{{ $i18n.get('previous') }}</span>
</button>
<!-- Item is an autodraft (item creation) -->
<template v-if="(status == 'auto-draft' || status == undefined)">
<button
v-if="status == 'draft' && !isOnSequenceEdit && currentUserCanDelete"
@click="$emit('onSubmit', 'trash')"
type="button"
class="button is-outlined">
<span v-if="!isMobileScreen">{{ $i18n.get('label_send_to_trash') }}</span>
<span v-else>{{ $i18n.get('status_trash') }}</span>
</button>
<button
v-if="status == 'auto-draft'"
@click="$emit('onDiscard')"
type="button"
class="button is-outlined">{{ $i18n.get('label_discard') }}</button>
<button
v-if="!isOnSequenceEdit || (group != null && group.items_count != undefined && group.items_count == itemPosition)"
@click="$emit('onSubmit', 'draft')"
@click="openItemCreationStatusDialog"
type="button"
class="button is-secondary">{{ status == 'draft' ? $i18n.get('label_update') : $i18n.get('label_save_as_draft') }}</button>
<button
v-else
@click="$emit('onSubmit', 'draft'); $emit('onNextInSequence');"
type="button"
class="button is-secondary">
<span v-if="!isMobileScreen">{{ $i18n.get('label_update_draft') }}</span>
<span v-else>{{ $i18n.get('status_draft') }}</span>
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>
</button>
<template v-if="currentUserCanPublish">
<button
v-if="!isOnSequenceEdit || (group != null && group.items_count != undefined && group.items_count == itemPosition)"
@click="$emit('onSubmit', visibility)"
type="button"
class="button is-success">{{ !$adminOptions.hideItemEditionStatusPublishOption ? $i18n.get('label_verb_publish') : $i18n.get('label_verb_publish_privately') }}</button>
<button
v-else
@click="$emit('onSubmit', visibility, 'next')"
type="button"
class="button is-success">
<span>{{ !$adminOptions.hideItemEditionStatusPublishOption ? $i18n.get('label_verb_publish') : $i18n.get('label_verb_publish_privately') }}</span>
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>
</button>
</template>
<template v-else>
<button
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count < itemPosition)"
@click="$emit('onNextInSequence')"
type="button"
class="button is-success">
<span>{{ $i18n.get('label_next') }}</span>
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>
</button>
</template>
<button
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count == itemPosition)"
@click="$router.push($routerHelper.getCollectionPath(collectionId))"
type="button"
class="button sequence-button">
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-approved"/>
</span>
<span>{{ $i18n.get('finish') }}</span>
</button>
class="button is-secondary">{{ $i18n.get('label_create_item') }}</button>
</template>
<!-- Item is published as public or private -->
<template v-if="(status == 'publish' || status == 'private') && !isEditingItemMetadataInsideIframe">
<button
v-if="isOnSequenceEdit && itemPosition > 1"
@click="$emit('onPrevInSequence')"
type="button"
class="button sequence-button">
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-previous"/>
</span>
<span>{{ $i18n.get('previous') }}</span>
</button>
<!-- Item is public, draft or private -->
<template v-else>
<button
v-if="!isOnSequenceEdit && currentUserCanDelete"
@click="$emit('onSubmit', 'trash')"
@ -134,47 +48,93 @@
<span v-if="!isMobileScreen">{{ $i18n.get('label_send_to_trash') }}</span>
<span v-else>{{ $i18n.get('status_trash') }}</span>
</button>
<b-dropdown
ref="item-edition-footer-dropdown"
:triggers="['contextmenu']"
aria-role="list"
animation="item-appear"
:mobile-modal="false"
position="is-top-left"
class="item-edition-footer-dropdown">
<template #trigger>
<button
v-if="!isOnSequenceEdit || (group != null && group.items_count != undefined && group.items_count == itemPosition)"
@click="$emit('onSubmit', 'draft')"
:disabled="hasSomeError && (status == 'publish' || status == 'private')"
@click="!$adminOptions.mobileAppMode ? $emit(
'onSubmit',
( currentUserCanPublish && !$adminOptions.hideItemEditionStatusPublishOption ) ? status : 'draft',
( (isOnSequenceEdit && !isCurrentItemOnSequenceEdit) ? 'next' : null)
) : ($refs && $refs['item-edition-footer-dropdown'] && !$refs['item-edition-footer-dropdown'].isActive ? $refs['item-edition-footer-dropdown'].toggle() : null)"
type="button"
class="button is-secondary">
<span v-if="!isMobileScreen">{{ isOnSequenceEdit ? $i18n.get('label_save_as_draft') : $i18n.get('label_return_to_draft') }}</span>
<span v-else>{{ $i18n.get('status_draft') }}</span>
</button>
<button
v-else
@click="$emit('onSubmit', 'draft', 'next')"
type="button"
class="button is-secondary">
<span>{{ $i18n.get('label_save_as_draft') }}</span>
<span class="icon is-large">
class="button"
:class="{
'is-success': status == 'publish' || status == 'private',
'is-secondary': status == 'draft'
}">
{{ $i18n.get('label_update') }}
<span
v-if="isOnSequenceEdit && !isCurrentItemOnSequenceEdit"
class="icon is-large"
style="margin-left: 0em;">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>
</button>
<template v-if="currentUserCanPublish">
<button
v-if="!isOnSequenceEdit || (group != null && group.items_count != undefined && group.items_count == itemPosition)"
:disabled="hasSomeError"
@click="$emit('onSubmit', visibility)"
type="button"
class="button is-success">{{ $i18n.get('label_update') }}</button>
<button
v-else
:disabled="hasSomeError"
@click="$emit('onSubmit', visibility, 'next')"
type="button"
class="button is-success">
<span>{{ $i18n.get('label_update') }}</span>
<span class="icon is-large">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
<span
v-if="!$adminOptions.mobileAppMode"
@mouseenter="$refs && $refs['item-edition-footer-dropdown'] && !$refs['item-edition-footer-dropdown'].isActive ? $refs['item-edition-footer-dropdown'].toggle() : null"
style="margin-left: 0.5em;"
class="icon is-small">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-arrowup" />
</span>
</button>
</template>
<template v-else>
<b-dropdown-item
@click="$emit(
'onSubmit',
'draft',
( (isOnSequenceEdit && !isCurrentItemOnSequenceEdit) ? 'next' : null)
)"
:class="{ 'is-forced-last-option': status == 'draft' }"
aria-role="listitem">
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-draft"/>
</span>
{{ status == 'draft' ? $i18n.get('label_update_draft') : $i18n.get('label_change_to_draft') }}
</b-dropdown-item>
<b-dropdown-item
v-if="currentUserCanPublish && !$adminOptions.hideItemEditionStatusPublishOption"
@click="$emit(
'onSubmit',
'private',
( (isOnSequenceEdit && !isCurrentItemOnSequenceEdit) ? 'next' : null)
)"
:class="{ 'is-forced-last-option': status == 'private' }"
aria-role="listitem">
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-private"/>
</span>
{{ status == 'private' ? $i18n.get('label_update_as_private') : ( status == 'draft' ? $i18n.get('label_verb_publish_privately') : $i18n.get('label_change_to_private') ) }}
</b-dropdown-item>
<b-dropdown-item
v-if="currentUserCanPublish && !$adminOptions.hideItemEditionStatusPublishOption"
@click="$emit(
'onSubmit',
'publish',
( (isOnSequenceEdit && !isCurrentItemOnSequenceEdit) ? 'next' : null)
)"
aria-role="listitem">
<span class="icon has-text-gray4">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-public"/>
</span>
{{ status == 'publish' ? $i18n.get('label_update_as_public') : $i18n.get('label_verb_publish') }}
</b-dropdown-item>
</b-dropdown>
</template>
<!-- Sequence edition Next button if user cannot publish (only goes to next, without changing status) -->
<button
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count < itemPosition)"
:disabled="hasSomeError"
v-if="!currentUserCanPublish && isOnSequenceEdit && hasNextItemOnSequenceEdit"
:disabled="(status == 'publish' || status == 'private') && hasSomeError"
@click="$emit('onNextInSequence')"
type="button"
class="button is-success">
@ -183,9 +143,10 @@
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-next"/>
</span>
</button>
</template>
<!-- Sequence edition Finish -->
<button
v-if="isOnSequenceEdit && (group != null && group.items_count != undefined && group.items_count == itemPosition)"
v-if="isOnSequenceEdit && isCurrentItemOnSequenceEdit"
@click="$router.push($routerHelper.getCollectionPath(collectionId))"
type="button"
class="button sequence-button">
@ -194,25 +155,99 @@
</span>
<span>{{ $i18n.get('finish') }}</span>
</button>
</template>
</div>
</template>
<script>
import ItemCreationStatusDialog from '../other/item-creation-status-dialog.vue';
export default {
props: {
status: String,
collectionId: Number,
isOnSequenceEdit: Boolean,
group: Object,
itemPosition: Number,
isCurrentItemOnSequenceEdit: Boolean,
hasNextItemOnSequenceEdit: Boolean,
hasPreviousItemOnSequenceEdit: Boolean,
isMobileScreen: Boolean,
hasSomeError: Boolean,
currentUserCanDelete: Boolean,
currentUserCanPublish: Boolean,
isEditingItemMetadataInsideIframe: Boolean,
visibility: String
},
mounted() {
this.$parent.$on('toggleItemEditionFooterDropdown', () => {
if (this.$refs && this.$refs['item-edition-footer-dropdown'])
this.$refs['item-edition-footer-dropdown'].toggle();
});
},
beforeDestroy() {
this.$parent.$off('toggleItemEditionFooterDropdown');
},
methods: {
openItemCreationStatusDialog() {
this.$buefy.modal.open({
parent: this,
component: ItemCreationStatusDialog,
canCancel: false,
props: {
icon: 'item',
onConfirm: (selectedStatus) => {
this.$emit('onSubmit', selectedStatus);
}
},
trapFocus: true,
customClass: 'tainacan-modal',
closeButtonAriaLabel: this.$i18n.get('close')
});
},
}
}
</script>
<style lang="scss" scoped>
.form-submission-footer {
.button {
margin-left: 16px;
margin-right: 6px;
}
.button:last-of-type {
margin-right: 0px;
}
/deep/ .item-edition-footer-dropdown {
.dropdown-menu>.dropdown-content {
display: flex;
flex-direction: column;
.dropdown-item.is-forced-last-option {
order: 99;
}
}
}
}
@media screen and (max-width: 782px) {
.form-submission-footer {
display: flex;
justify-content: space-between;
width: 100%;
.button {
margin-left: 6px;
margin-right: 6px;
}
.button:first-of-type {
margin-left: 0px;
}
.button.is-success {
margin-left: auto;
}
}
}
</style>

View File

@ -0,0 +1,124 @@
<template>
<div
aria-labelledby="alert-dialog-title"
autofocus
role="alertdialog"
tabindex="-1"
aria-modal
class="tainacan-form tainacan-dialog dialog"
ref="itemCreationStatusDialog">
<div
class="modal-card"
style="width: auto">
<div
v-if="icon != undefined && icon != ''"
class="modal-custom-icon">
<span class="icon is-large">
<i
:class="'tainacan-icon-' + icon"
class="tainacan-icon"/>
</span>
</div>
<section
tabindex="1"
class="modal-card-body">
<header
class="modal-card-head">
<h1
id="alert-dialog-title"
class="modal-card-title">
{{ $i18n.get('label_ready_to_create_item') }}
</h1>
</header>
{{ $i18n.get('instruction_create_item_select_status') }}
<!-- Status -------------------------------- -->
<div class="status-radios">
<b-radio
v-model="selectedStatus"
v-for="(statusOption, index) of $statusHelper.getStatuses().filter((status) => status.slug != 'trash')"
:key="index"
:native-value="statusOption.slug">
<span class="icon has-text-gray">
<i
class="tainacan-icon tainacan-icon-18px"
:class="$statusHelper.getIcon(statusOption.slug)"/>
</span>
{{ statusOption.name }}
</b-radio>
</div>
</section>
<footer class="modal-card-foot form-submit">
<button
type="button"
style="margin-right: auto"
class="button is-outlined"
@click="$parent.close();">
{{ $i18n.get('cancel') }}
</button>
<button
type="submit"
class="button is-success"
@click="onConfirm(selectedStatus); $parent.close();">
{{ $i18n.get('label_create_item') }}
</button>
</footer>
</div>
</div>
</template>
<script>
export default {
name: 'ItemCreationStatusDialog',
props: {
icon: String,
onConfirm: {
type: Function,
default: () => {}
}
},
data() {
return {
selectedStatus: 'publish'
}
},
mounted() {
if (this.$refs.itemCreationStatusDialog)
this.$refs.itemCreationStatusDialog.focus();
}
}
</script>
<style scoped>
.modal-card {
max-width: 600px;
}
.modal-custom-icon i.tainacan-icon,
.modal-custom-icon i.tainacan-icon::before {
font-size: 42px;
}
button.is-success {
margin-left: auto;
}
.field.is-horizontal {
margin-top: 8px !important;
align-items: flex-end;
}
.status-radios {
margin-top: 1rem;
display: flex;
font-size: 1.125em;
}
.status-radios /deep/ .b-radio {
margin-bottom: 0px !important;
}
.modal-card-foot {
margin-top: 12px;
}
</style>

View File

@ -642,6 +642,12 @@ return apply_filters( 'tainacan-i18n', [
'label_document_and_thumbnail' => __( 'Document and thumbnail', 'tainacan' ),
'label_all_attachments' => __( 'All attachments', 'tainacan' ),
'label_only_required_metadata' => __( 'Only required metadata', 'tainacan' ),
'label_update_as_public' => __( 'Update as public', 'tainacan' ),
'label_update_as_private' => __( 'Update as private', 'tainacan' ),
'label_change_to_private' => __( 'Change to private', 'tainacan' ),
'label_change_to_draft' => __( 'Change to draft', 'tainacan' ),
'label_create_item' => __( 'Create item', 'tainacan' ),
'label_ready_to_create_item' => __( 'Ready to create this item?', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -713,6 +719,7 @@ return apply_filters( 'tainacan-i18n', [
'instruction_collection_description' => __( 'Enter the collection description here...', 'tainacan' ),
'instruction_collection_name' => __( 'Enter the collection name here...', 'tainacan' ),
'instruction_click_to_easily_see' => __( 'Click to easily see', 'tainacan' ),
'instruction_create_item_select_status' => __( 'Select a status for the item visiblity on the site. Remember, whichever you select will still be restricted by the collection status as well.', 'tainacan' ),
// Info. Other feedback to user.
'info_items_tab_all' => __( 'Every item, except by those sent to trash.', 'tainacan' ),