proper disable

This commit is contained in:
Henry Jameson 2024-12-31 13:05:15 +02:00
parent f653ac4a62
commit acbb53d6a4
5 changed files with 47 additions and 7 deletions

View file

@ -402,6 +402,10 @@ nav {
color: var(--text); color: var(--text);
font-size: 100%; font-size: 100%;
} }
&.disabled {
cursor: not-allowed;
}
} }
.menu-item, .menu-item,

View file

@ -27,8 +27,15 @@
/> />
</div> </div>
<div class="status-preview"> <div class="status-preview">
<p v-if="draft.status">{{ draft.status }}</p> <span class="status_content">
<p v-else class="faint">{{ $t('drafts.empty') }}</p> <p v-if="draft.spoilerText">
<i>
{{ draft.spoilerText }}:
</i>
</p>
<p v-if="draft.status">{{ draft.status }}</p>
<p v-else class="faint">{{ $t('drafts.empty') }}</p>
</span>
<gallery <gallery
v-if="draft.files?.length !== 0" v-if="draft.files?.length !== 0"
class="attachments media-body" class="attachments media-body"

View file

@ -11,8 +11,9 @@ export default {
'Avatar' 'Avatar'
], ],
states: { states: {
hover: ':hover', hover: ':hover:not(.disabled)',
active: '.-active' active: '.-active',
disabled: '.disabled'
}, },
defaultRules: [ defaultRules: [
{ {
@ -85,6 +86,28 @@ export default {
textColor: '--link', textColor: '--link',
textAuto: 'no-preserve' textAuto: 'no-preserve'
} }
},
{
component: 'Text',
parent: {
component: 'MenuItem',
state: ['disabled']
},
directives: {
textOpacity: 0.25,
textOpacityMode: 'blend'
}
},
{
component: 'Icon',
parent: {
component: 'MenuItem',
state: ['disabled']
},
directives: {
textOpacity: 0.25,
textOpacityMode: 'blend'
}
} }
] ]
} }

View file

@ -352,6 +352,12 @@ const PostStatusForm = {
return this.$t('post_status.auto_save_nothing_new') return this.$t('post_status.auto_save_nothing_new')
} }
}, },
safeToSaveDraft () {
return this.newStatus.status ||
this.newStatus.spoilerText ||
this.newStatus.files?.length ||
this.newStatus.hasPoll
},
...mapGetters(['mergedConfig']), ...mapGetters(['mergedConfig']),
...mapState({ ...mapState({
mobileLayout: state => state.interface.mobileLayout mobileLayout: state => state.interface.mobileLayout
@ -747,9 +753,7 @@ const PostStatusForm = {
saveDraft () { saveDraft () {
if (!this.disableDraft && if (!this.disableDraft &&
!this.saveInhibited) { !this.saveInhibited) {
if (this.newStatus.status || if (this.safeToSaveDraft) {
this.newStatus.files?.length ||
this.newStatus.hasPoll) {
return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus }) return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
.then(id => { .then(id => {
if (this.newStatus.id !== id) { if (this.newStatus.id !== id) {

View file

@ -339,6 +339,8 @@
v-if="!disableDraft" v-if="!disableDraft"
class="menu-item dropdown-item dropdown-item-icon" class="menu-item dropdown-item dropdown-item-icon"
role="menu" role="menu"
:disabled="!safeToSaveDraft"
:class="{ disabled: !safeToSaveDraft }"
@click.prevent="saveDraft" @click.prevent="saveDraft"
@click="close" @click="close"
> >