Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
size="small"
theme="primary"
:value="localValue"
:disabled="isReadonly"
:disabled="isReadOnly"
@change="handleChange">
</bk-switcher>
</div>
Expand All @@ -30,7 +30,7 @@
type: [String, Boolean],
default: false
},
isReadonly: Boolean
isReadOnly: Boolean
},
data() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@
},
getPreFieldUpdateParams() {
const allowKey = ['option', 'unit', 'placeholder']
if (this.fieldInfo.bk_property_type === PROPERTY_TYPES.BOOL) {
allowKey.push('default')
}
const params = {}
allowKey.forEach((key) => {
params[key] = this.fieldInfo[key]
Expand Down
15 changes: 13 additions & 2 deletions src/ui/src/utils/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ export function getInstFormValues(properties, inst = {}, autoSelect = true) {
values[propertyId] = value ?? ''
} else if (['bool'].includes(propertyType)) {
if ([null, undefined].includes(inst[propertyId]) && autoSelect) {
values[propertyId] = typeof property.option === 'boolean' ? property.option : false
let defaultValue = propertyDefault
if (typeof defaultValue !== 'boolean') {
defaultValue = property.option
}
values[propertyId] = typeof defaultValue === 'boolean' ? defaultValue : false
} else {
values[propertyId] = !!inst[propertyId]
}
Expand Down Expand Up @@ -147,7 +151,8 @@ export function getInstFormDefaults(properties) {
LONGCHAR,
INT,
FLOAT,
OBJUSER
OBJUSER,
BOOL
} = PROPERTY_TYPES
const defaultValue = {}
properties.forEach((property) => {
Expand All @@ -159,6 +164,12 @@ export function getInstFormDefaults(properties) {

if ([SINGLECHAR, LONGCHAR, INT, FLOAT, OBJUSER].includes(propertyType)) {
defaultValue[propertyId] = propertyDefault || ''
} else if (propertyType === BOOL) {
let val = propertyDefault
if (typeof val !== 'boolean') {
val = property.option
}
defaultValue[propertyId] = typeof val === 'boolean' ? val : false
}
})
return defaultValue
Expand Down