modify props and fields name

This commit is contained in:
MaysWind
2023-08-21 23:42:07 +08:00
parent c026ab1777
commit eaaea8a64f
2 changed files with 17 additions and 17 deletions
+14 -14
View File
@@ -12,14 +12,14 @@
<template #selection> <template #selection>
<div class="d-flex align-center text-truncate cursor-pointer"> <div class="d-flex align-center text-truncate cursor-pointer">
<span class="text-truncate" v-if="selectionText">{{ selectionText }}</span> <span class="text-truncate" v-if="selectionText">{{ selectionText }}</span>
<span class="text-truncate" v-if="!selectionText && !selectedPrimaryItem && !selectedSecondaryItem">{{ noItemDisplayName }}</span> <span class="text-truncate" v-if="!selectionText && !selectedPrimaryItem && !selectedSecondaryItem">{{ noSelectionText }}</span>
<span class="text-truncate" v-if="!selectionText && showPrimaryName && selectedPrimaryItem">{{ primaryItemDisplayName }}</span> <span class="text-truncate" v-if="!selectionText && showSelectionPrimaryText && selectedPrimaryItem">{{ selectionPrimaryItemText }}</span>
<v-icon class="disabled" :icon="icons.chevronRight" size="23" v-if="!selectionText && showPrimaryName && selectedPrimaryItem && selectedSecondaryItem" /> <v-icon class="disabled" :icon="icons.chevronRight" size="23" v-if="!selectionText && showSelectionPrimaryText && selectedPrimaryItem && selectedSecondaryItem" />
<ItemIcon class="mr-2" icon-type="account" size="21.5px" <ItemIcon class="mr-2" icon-type="account" size="21.5px"
:icon-id="selectedSecondaryItem ? selectedSecondaryItem[secondaryIconField] : null" :icon-id="selectedSecondaryItem ? selectedSecondaryItem[secondaryIconField] : null"
:color="selectedSecondaryItem ? selectedSecondaryItem[secondaryColorField] : null" :color="selectedSecondaryItem ? selectedSecondaryItem[secondaryColorField] : null"
v-if="!selectionText && selectedSecondaryItem && showSecondaryIcon" /> v-if="!selectionText && selectedSecondaryItem && showSelectionSecondaryIcon" />
<span class="text-truncate" v-if="!selectionText && selectedSecondaryItem">{{ secondaryItemDisplayName }}</span> <span class="text-truncate" v-if="!selectionText && selectedSecondaryItem">{{ selectionSecondaryItemText }}</span>
</div> </div>
</template> </template>
@@ -87,8 +87,8 @@ export default {
'readonly', 'readonly',
'label', 'label',
'selectionText', 'selectionText',
'showPrimaryName', 'showSelectionPrimaryText',
'showSecondaryIcon', 'showSelectionSecondaryIcon',
'primaryKeyField', 'primaryKeyField',
'primaryValueField', 'primaryValueField',
'primaryTitleField', 'primaryTitleField',
@@ -165,26 +165,26 @@ export default {
return null; return null;
} }
}, },
noItemDisplayName() { noSelectionText() {
return this.noItemText ? this.noItemText : this.$t('None'); return this.noItemText ? this.noItemText : this.$t('None');
}, },
primaryItemDisplayName() { selectionPrimaryItemText() {
if (this.primaryValueField && this.primaryTitleField) { if (this.primaryValueField && this.primaryTitleField) {
if (this.currentPrimaryValue) { if (this.currentPrimaryValue) {
return getNameByKeyValue(this.items, this.currentPrimaryValue, this.primaryValueField, this.primaryTitleField, this.noItemDisplayName); return getNameByKeyValue(this.items, this.currentPrimaryValue, this.primaryValueField, this.primaryTitleField, this.noSelectionText);
} else { } else {
return this.noItemDisplayName; return this.noSelectionText;
} }
} else { } else {
return this.currentPrimaryValue; return this.currentPrimaryValue;
} }
}, },
secondaryItemDisplayName() { selectionSecondaryItemText() {
if (this.secondaryValueField && this.secondaryTitleField) { if (this.secondaryValueField && this.secondaryTitleField) {
if (this.currentSecondaryValue && this.selectedPrimaryItem && this.selectedPrimaryItem[this.primarySubItemsField]) { if (this.currentSecondaryValue && this.selectedPrimaryItem && this.selectedPrimaryItem[this.primarySubItemsField]) {
return getNameByKeyValue(this.selectedPrimaryItem[this.primarySubItemsField], this.currentSecondaryValue, this.secondaryValueField, this.secondaryTitleField, this.noItemDisplayName); return getNameByKeyValue(this.selectedPrimaryItem[this.primarySubItemsField], this.currentSecondaryValue, this.secondaryValueField, this.secondaryTitleField, this.noSelectionText);
} else { } else {
return this.noItemDisplayName; return this.noSelectionText;
} }
} else { } else {
return this.currentSecondaryValue; return this.currentSecondaryValue;
@@ -85,7 +85,7 @@
secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color" secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color"
:readonly="mode === 'view'" :readonly="mode === 'view'"
:disabled="loading || submitting || !hasAvailableExpenseCategories" :disabled="loading || submitting || !hasAvailableExpenseCategories"
:show-primary-name="true" :show-selection-primary-text="true"
:label="$t('Category')" :placeholder="$t('Category')" :label="$t('Category')" :placeholder="$t('Category')"
:items="allCategories[allCategoryTypes.Expense]" :items="allCategories[allCategoryTypes.Expense]"
v-model="transaction.expenseCategory"> v-model="transaction.expenseCategory">
@@ -99,7 +99,7 @@
secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color" secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color"
:readonly="mode === 'view'" :readonly="mode === 'view'"
:disabled="loading || submitting || !hasAvailableIncomeCategories" :disabled="loading || submitting || !hasAvailableIncomeCategories"
:show-primary-name="true" :show-selection-primary-text="true"
:label="$t('Category')" :placeholder="$t('Category')" :label="$t('Category')" :placeholder="$t('Category')"
:items="allCategories[allCategoryTypes.Income]" :items="allCategories[allCategoryTypes.Income]"
v-model="transaction.incomeCategory"> v-model="transaction.incomeCategory">
@@ -113,7 +113,7 @@
secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color" secondary-icon-field="icon" secondary-icon-type="category" secondary-color-field="color"
:readonly="mode === 'view'" :readonly="mode === 'view'"
:disabled="loading || submitting || !hasAvailableTransferCategories" :disabled="loading || submitting || !hasAvailableTransferCategories"
:show-primary-name="true" :show-selection-primary-text="true"
:label="$t('Category')" :placeholder="$t('Category')" :label="$t('Category')" :placeholder="$t('Category')"
:items="allCategories[allCategoryTypes.Transfer]" :items="allCategories[allCategoryTypes.Transfer]"
v-model="transaction.transferCategory"> v-model="transaction.transferCategory">