Skip to content

Commit ef951fe

Browse files
committed
feat: add "disabled" option
issue: Add "readonly" option #38
1 parent d3c402b commit ef951fe

File tree

13 files changed

+60
-20
lines changed

13 files changed

+60
-20
lines changed

ant/src/components/cron-ant.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
item-value="id"
99
:items="period.items"
1010
@update:model-value="period.select($event)"
11+
:disabled="disabled"
1112
:button-props="buttonProps"
1213
/>
1314
</div>
@@ -26,6 +27,7 @@
2627
:selection="f.text.value"
2728
multiple
2829
clearable
30+
:disabled="disabled"
2931
:button-props="buttonProps"
3032
:dropdown-props="dropdownProps"
3133
:hideOnClick="false"

ant/src/components/select.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<template>
22
<span class="custom-select">
3-
<a-dropdown :trigger="['click']" v-model:visible="visible" v-bind="dropdownProps">
3+
<a-dropdown
4+
:trigger="['click']"
5+
v-model:visible="visible"
6+
v-bind="dropdownProps"
7+
:disabled="disabled"
8+
>
49
<a-button v-bind="buttonProps">
510
{{ selection ?? selectedStr
611
}}<CloseCircleFilled v-if="clearable && !isEmpty" @click="clear()" @click.stop="" />

core/src/components/cron-core.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ export const cronCoreProps = () => ({
331331
}
332332
},
333333
},
334+
/** Disable the cron editor */
335+
disabled: {
336+
type: Boolean,
337+
default: false,
338+
},
334339
})
335340

336341
/**

core/src/components/select.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ export function selectProps<T, V>() {
118118
type: [String, Function] as PropType<string | ((item: T) => V)>,
119119
default: 'value',
120120
},
121+
disabled: {
122+
type: Boolean,
123+
default: false,
124+
},
121125
}
122126
}
123127

docs/src/.vuepress/components/cron-demo.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
<div class="cron-demo">
33
<p>Flavor</p>
44
<v-btn-toggle
5-
v-model="text"
5+
v-model="toggle"
66
tile
77
color="secondary"
88
group
99
density="compact"
10-
class="mb-5 elevation-5">
10+
class="mb-5 elevation-5"
11+
mandatory>
1112

12-
<v-btn v-for="item in flavors" :value="item.name" :key="item.name" @click="flavor = item">
13+
<v-btn v-for="item in flavors" :key="item.name" @click="flavor = item">
1314
{{item.name}}
1415
</v-btn>
1516

@@ -36,14 +37,16 @@
3637
color="secondary"
3738
group
3839
density="compact"
39-
class="mb-10 elevation-5">
40+
class="mb-5 elevation-5">
4041

4142
<v-btn v-for="item in formats" :value="item" :key="item">
4243
{{item}}
4344
</v-btn>
4445

4546
</v-btn-toggle>
4647

48+
<v-switch v-model="disabled" color="secondary" label="Disabled"></v-switch>
49+
4750
<iframe :src="src"></iframe>
4851

4952
</div>
@@ -54,12 +57,6 @@ import { withBase, } from '@vuepress/client'
5457
import { computed, ref } from 'vue'
5558
5659
export default {
57-
props: {
58-
index: {
59-
type: Number,
60-
default: 0,
61-
}
62-
},
6360
setup (props) {
6461
const flavors = [
6562
{
@@ -81,9 +78,10 @@ export default {
8178
const locales = ['en', 'de', 'pt', 'es', 'da', 'zh-cn']
8279
const formats = ['crontab', 'quartz']
8380
84-
const flavor = ref(flavors[props.index])
81+
const flavor = ref(flavors[0])
8582
const locale = ref('en')
8683
const format = ref(formats[0])
84+
const disabled = ref(false)
8785
8886
const selectFlavor = (name) => {
8987
let i = flavors.map(f => f.name).indexOf(name)
@@ -95,7 +93,8 @@ export default {
9593
const params = {
9694
locale: locale.value,
9795
format: format.value,
98-
'initial-value': format.value == 'quartz' ? '* * * * * *' : '* * * * *'
96+
'initial-value': format.value == 'quartz' ? '* * * * * *' : '* * * * *',
97+
...(disabled.value ? { disabled:true } : {})
9998
}
10099
const query = new URLSearchParams(params)
101100
const path = 'demo/' + flavor.value.name.replace(' ', '-').toLowerCase() + '/index.html?' + query.toString()
@@ -108,11 +107,12 @@ export default {
108107
flavor: flavor,
109108
flavors,
110109
selectFlavor,
111-
text: ref(flavor.name),
110+
toggle: ref(0),
112111
locales,
113112
locale: locale,
114113
formats,
115114
format,
115+
disabled,
116116
value: ref('* * * * *')
117117
}
118118
}

element-plus/src/components/cron-element-plus.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
item-value="id"
88
:items="period.items"
99
@update:model-value="period.select($event)"
10+
:disabled="disabled"
1011
:button-props="buttonProps"
1112
/>
1213

@@ -24,6 +25,7 @@
2425
:selection="f.text.value"
2526
multiple
2627
clearable
28+
:disabled="disabled"
2729
:button-props="buttonProps"
2830
:dropdown-props="{ hideOnClick: false }"
2931
/>

element-plus/src/components/select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<span class="custom-select">
33
<el-dropdown style="vertical-align: baseline" trigger="click" v-bind="dropdownProps">
4-
<el-button v-bind="buttonProps">
4+
<el-button v-bind="buttonProps" :disabled="disabled">
55
{{ selection ?? selectedStr }}
66
<el-icon v-if="clearable && !isEmpty" class="el-icon--right" @click="clear()" @click.stop=""
77
><Close

light/src/components/cron-light.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:items="period.items"
99
@update:model-value="period.select($event)"
1010
:cols="cols['period'] || 1"
11+
:disabled="disabled"
1112
/>
1213
</div>
1314
<span>{{ period.suffix.value }}</span>
@@ -23,6 +24,7 @@
2324
:selection="f.text.value"
2425
multiple
2526
clearable
27+
:disabled="disabled"
2628
></custom-select>
2729
</div>
2830
<span>{{ f.suffix.value }}</span>

light/src/components/select.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
22
<div class="vcron-select-container">
3-
<span class="vcron-select-input" @click="toggleMenu">
3+
<span
4+
class="vcron-select-input"
5+
:class="{ 'vcron-select-disabled': disabled }"
6+
@click="
7+
() => {
8+
if (!disabled) toggleMenu()
9+
}
10+
"
11+
>
412
{{ selection ?? selectedStr }}
513

614
<span v-if="clearable && !isEmpty" @click="clear">&#x2715;</span>
@@ -73,13 +81,21 @@ export default defineComponent({
7381
display: inline-block;
7482
border-radius: 3px;
7583
border: 1px solid #ddd;
76-
background-color: #eee;
7784
user-select: none;
7885
padding: 0 0.5em;
7986
color: black;
8087
}
8188
82-
.vcron-select-input:hover {
89+
.vcron-select-disabled {
90+
background-color: #ccc;
91+
color: #444;
92+
}
93+
94+
:not(.vcron-select-disabled).vcron-select-input {
95+
background-color: #eee;
96+
}
97+
98+
:not(.vcron-select-disabled).vcron-select-input:hover {
8399
border: 1px solid #ccc;
84100
background-color: #ddd;
85101
}

quasar/src/components/cron-quasar.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
item-value="id"
99
:items="period.items"
1010
@update:model-value="period.select($event)"
11+
:disabled="disabled"
1112
:button-props="buttonProps"
1213
:menu-props="{ autoClose: true }"
1314
/>
@@ -25,6 +26,7 @@
2526
:selection="f.text.value"
2627
multiple
2728
clearable
29+
:disabled="disabled"
2830
:button-props="buttonProps"
2931
/>
3032

quasar/src/components/select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<span>
3-
<q-btn class="q-ma-xs" v-bind="buttonProps">
3+
<q-btn class="q-ma-xs" v-bind="buttonProps" :disabled="disabled">
44
{{ selection ?? selectedStr }}
55
<q-icon
66
class="q-pl-xs"

vuetify/src/components/cron-vuetify.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
item-value="id"
99
:items="period.items"
1010
@update:model-value="period.select($event)"
11+
:disabled="disabled"
1112
:chip-props="chipProps"
1213
/>
1314
</v-col>
@@ -24,6 +25,7 @@
2425
:selection="f.text.value"
2526
multiple
2627
clearable
28+
:disabled="disabled"
2729
:chip-props="chipProps"
2830
:menu-props="{ closeOnContentClick: false }"
2931
/>

vuetify/src/components/select.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<v-chip v-bind="chipProps">
2+
<v-chip v-bind="chipProps" :disabled="disabled">
33
<template #append v-if="clearable && !isEmpty">
44
<v-icon size="small" icon="mdi-close" @click.stop="clear()"> </v-icon>
55
</template>

0 commit comments

Comments
 (0)