3535 v-model:value =" form.intervaltype"
3636 button-style =" solid"
3737 @change =" handleChangeIntervalType" >
38- <a-radio-button value =" hourly" :disabled =" handleVisibleInterval('HOURLY ')" >
38+ <a-radio-button value =" hourly" :disabled =" isIntervalDisabled('hourly ')" >
3939 {{ $t('label.hourly') }}
4040 </a-radio-button >
41- <a-radio-button value =" daily" :disabled =" handleVisibleInterval('DAILY ')" >
41+ <a-radio-button value =" daily" :disabled =" isIntervalDisabled('daily ')" >
4242 {{ $t('label.daily') }}
4343 </a-radio-button >
44- <a-radio-button value =" weekly" :disabled =" handleVisibleInterval('WEEKLY ')" >
44+ <a-radio-button value =" weekly" :disabled =" isIntervalDisabled('weekly ')" >
4545 {{ $t('label.weekly') }}
4646 </a-radio-button >
47- <a-radio-button value =" monthly" :disabled =" handleVisibleInterval('MONTHLY ')" >
47+ <a-radio-button value =" monthly" :disabled =" isIntervalDisabled('monthly ')" >
4848 {{ $t('label.monthly') }}
4949 </a-radio-button >
5050 </a-radio-group >
5454 <a-form-item :label =" $t('label.time')" ref =" time" name =" time" >
5555 <a-input-number
5656 style =" width : 100% "
57+ :disabled =" isIntervalDisabled(form.intervaltype)"
5758 v-model:value =" form.time"
5859 :placeholder =" $t('label.minute.past.hour')"
5960 :min =" 1"
7071 <a-time-picker
7172 use12Hours
7273 format =" h:mm A"
74+ :disabled =" isIntervalDisabled(form.intervaltype)"
7375 v-model:value =" form.timeSelect"
7476 style =" width : 100% ;" />
7577 </a-form-item >
7981 <a-select
8082 v-model:value =" form['day-of-week']"
8183 showSearch
84+ :disabled =" isIntervalDisabled(form.intervaltype)"
8285 optionFilterProp =" label"
8386 :filterOption =" (input, option) => {
8487 return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
9497 <a-select
9598 v-model:value =" form['day-of-month']"
9699 showSearch
100+ :disabled =" isIntervalDisabled(form.intervaltype)"
97101 optionFilterProp =" label"
98102 :filterOption =" (input, option) => {
99103 return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
@@ -214,6 +218,38 @@ export default {
214218 this .fetchTimeZone ()
215219 this .fetchBackupOffering ()
216220 },
221+ mounted () {
222+ if (this .form .intervaltype && this .isIntervalDisabled (this .form .intervaltype )) {
223+ const nextAvailable = this .getNextAvailableIntervalType (this .form .intervaltype )
224+ if (nextAvailable) {
225+ this .form .intervaltype = nextAvailable
226+ this .handleChangeIntervalType ()
227+ }
228+ }
229+ },
230+ watch: {
231+ dataSource: {
232+ handler () {
233+ if (this .form .intervaltype && this .getNextAvailableIntervalType && this .isIntervalDisabled (this .form .intervaltype )) {
234+ const nextAvailable = this .getNextAvailableIntervalType (this .form .intervaltype )
235+ if (nextAvailable) {
236+ this .form .intervaltype = nextAvailable
237+ this .handleChangeIntervalType ()
238+ }
239+ }
240+ },
241+ deep: true
242+ },
243+ ' form.intervaltype' (newVal) {
244+ if (newVal && this .getNextAvailableIntervalType && this .isIntervalDisabled (newVal)) {
245+ const nextAvailable = this .getNextAvailableIntervalType (newVal)
246+ if (nextAvailable) {
247+ this .form .intervaltype = nextAvailable
248+ this .handleChangeIntervalType ()
249+ }
250+ }
251+ }
252+ },
217253 inject: [' refreshSchedule' , ' closeSchedule' ],
218254 computed: {
219255 isQuiesceVmSupported () {
@@ -278,20 +314,30 @@ export default {
278314 })
279315 }
280316 },
281- handleChangeIntervalType (e ) {
282- switch (this .form .intervaltype ) {
283- case ' weekly' :
284- this .fetchDayOfWeek ()
285- break
286- case ' monthly' :
287- this .intervalValue = ' MONTHLY'
288- this .fetchDayOfMonth ()
289- break
290- default :
291- break
317+ handleChangeIntervalType () {
318+ if (this .form .intervaltype === ' weekly' ) {
319+ this .fetchDayOfWeek ()
320+ } else if (this .form .intervaltype === ' monthly' ) {
321+ this .fetchDayOfMonth ()
322+ }
323+ },
324+ getNextAvailableIntervalType (currentIntervalType ) {
325+ const intervalTypes = [' hourly' , ' daily' , ' weekly' , ' monthly' ]
326+ const currentIndex = intervalTypes .indexOf (currentIntervalType ? currentIntervalType .toLowerCase () : ' ' )
327+ const startIndex = currentIndex >= 0 ? currentIndex : - 1
328+
329+ for (let i = 1 ; i <= intervalTypes .length ; i++ ) {
330+ const nextIndex = (startIndex + i) % intervalTypes .length
331+ const nextIntervalType = intervalTypes[nextIndex]
332+
333+ if (! this .isIntervalDisabled (nextIntervalType)) {
334+ return nextIntervalType
335+ }
292336 }
337+ return null
293338 },
294- handleVisibleInterval (intervalType ) {
339+ isIntervalDisabled (intervalType ) {
340+ intervalType = intervalType .toUpperCase ()
295341 if (this .dataSource ? .length === 0 ) {
296342 return false
297343 }
@@ -308,7 +354,7 @@ export default {
308354 const values = this .handleRemoveFields (formRaw)
309355 const params = {}
310356 params .virtualmachineid = this .resource .id
311- params .intervaltype = values .intervaltype
357+ params .intervaltype = values .intervaltype . toUpperCase ()
312358 params .maxbackups = values .maxbackups
313359 params .timezone = values .timezone
314360 if (values .quiescevm ) {
0 commit comments