setting changed 3
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div
|
||||
class="setting-card"
|
||||
:class="{
|
||||
'setting-card--readonly': readonly,
|
||||
'setting-card--saving': saving,
|
||||
'setting-card--inactive': !isActive && fieldType !== 'switch'
|
||||
}"
|
||||
>
|
||||
<div class="setting-card__head">
|
||||
<div class="setting-card__title-row">
|
||||
<span v-if="readonly" class="setting-card__lock" title="فقطخواندنی">🔒</span>
|
||||
<span class="setting-card__title">{{ title }}</span>
|
||||
<a-switch
|
||||
v-if="fieldType !== 'switch'"
|
||||
:checked="isActive"
|
||||
size="small"
|
||||
class="setting-card__active-switch"
|
||||
@change="onActiveChange"
|
||||
>
|
||||
<template #checkedChildren>فعال</template>
|
||||
<template #unCheckedChildren>غیرفعال</template>
|
||||
</a-switch>
|
||||
</div>
|
||||
<div class="setting-card__key">کلید: {{ settingKey }}</div>
|
||||
<div v-if="help" class="setting-card__help">{{ help }}</div>
|
||||
</div>
|
||||
<div
|
||||
class="setting-card__body"
|
||||
:class="{ 'setting-card__body--switch': fieldType === 'switch' }"
|
||||
>
|
||||
<SettingValueField
|
||||
:model-value="modelValue"
|
||||
:setting-key="settingKey"
|
||||
:setting-type="settingType"
|
||||
:description="description"
|
||||
:disabled="readonly"
|
||||
:rows="fieldType === 'longtext' ? 4 : 6"
|
||||
@update:value="emit('update:value', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="saving" class="setting-card__status">
|
||||
<a-spin size="small" />
|
||||
<span>در حال ذخیره...</span>
|
||||
</div>
|
||||
<div v-else-if="savedFlash" class="setting-card__status setting-card__status--ok">ذخیره شد</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SettingValueField from './SettingValueField.vue'
|
||||
import { helpText, resolveSettingFieldType, type SettingFieldType } from './settingTypes'
|
||||
import type { Const } from '@/model/configuration'
|
||||
|
||||
const props = defineProps<{
|
||||
row: Const
|
||||
modelValue: string
|
||||
readonly?: boolean
|
||||
saving?: boolean
|
||||
savedFlash?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:value': [value: string]
|
||||
'update:isActive': [value: boolean]
|
||||
}>()
|
||||
|
||||
const settingKey = computed(() => props.row.key ?? '')
|
||||
const settingType = computed(() => props.row.type)
|
||||
const description = computed(() => props.row.description)
|
||||
const title = computed(() => props.row.title_fa || props.row.key || '—')
|
||||
|
||||
const fieldType = computed<SettingFieldType>(() =>
|
||||
resolveSettingFieldType({ key: props.row.key, type: props.row.type })
|
||||
)
|
||||
|
||||
const isActive = computed(() => props.row.is_active !== false && props.row.is_active !== 0)
|
||||
|
||||
function onActiveChange(checked: boolean) {
|
||||
emit('update:isActive', checked)
|
||||
}
|
||||
|
||||
const help = computed(() => helpText(props.row))
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.setting-card {
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 10px;
|
||||
padding: 14px 16px;
|
||||
background: #fff;
|
||||
min-height: 108px;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&:hover:not(.setting-card--readonly) {
|
||||
border-color: #91caff;
|
||||
box-shadow: 0 2px 8px rgba(22, 119, 255, 0.08);
|
||||
}
|
||||
|
||||
&--readonly {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
&--saving {
|
||||
border-color: #91caff;
|
||||
}
|
||||
|
||||
&--inactive {
|
||||
opacity: 0.72;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
&__head {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__title-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
&__active-switch {
|
||||
margin-right: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__lock {
|
||||
flex-shrink: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
color: rgba(0, 0, 0, 0.88);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
&__key {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
direction: ltr;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
&__help {
|
||||
margin-top: 4px;
|
||||
font-size: 11px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
&__body {
|
||||
margin-top: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
&--switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__status {
|
||||
margin-top: 8px;
|
||||
font-size: 11px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 18px;
|
||||
|
||||
&--ok {
|
||||
color: #52c41a;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user