Skip to content

Commit

Permalink
UI Template - Fix validation problems in ui-template
Browse files Browse the repository at this point in the history
  • Loading branch information
joepavitt committed Jan 25, 2024
1 parent 0227678 commit d5b1f80
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions nodes/widgets/ui_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@
page: {
type: 'ui-page',
validate: function () {
return (this.templateScope === 'widget:page' && !!this.page) || (this.templateScope !== 'widget:page')
const valid = (this.templateScope === 'widget:page' && !!this.page) || (this.templateScope !== 'widget:page')
return valid
}
}, // for when template is scoped to 'page'
ui: {
type: 'ui-base',
validate: function () {
return (this.templateScope === 'widget:ui' && !!this.ui) || (this.templateScope !== 'widget:ui')
const valid = (this.templateScope === 'widget:ui' && !!this.ui) || (this.templateScope !== 'widget:ui')
return valid
}
}, // for when template is scoped to 'site'
name: { value: '' },
Expand Down Expand Up @@ -167,44 +169,34 @@
}

$templateScope.on('change', function () {
that._def.defaults.group.required = false
that._def.defaults.page.required = false
that._def.defaults.ui.required = false
$('#template-row-group, #template-row-page, #template-row-ui, #template-row-class').hide()
switch ($templateScope.val()) {
case 'site:style':
$('#template-row-ui').show()
that._def.defaults.ui.required = true
that.editor.getSession().setMode('ace/mode/css')
break
case 'page:style':
$('#template-row-page').show()
that._def.defaults.page.required = true
that.editor.getSession().setMode('ace/mode/css')
break
case 'site:script':
$('#template-row-ui').show()
that._def.defaults.ui.required = true
that.editor.getSession().setMode('ace/mode/javascript')
break
case 'page:script':
$('#template-row-page').show()
that._def.defaults.page.required = true
that.editor.getSession().setMode('ace/mode/javascript')
break
case 'widget:ui':
$('#template-row-ui').show()
that._def.defaults.ui.required = true
that.editor.getSession().setMode('ace/mode/html')
break
case 'widget:page':
$('#template-row-page').show()
that._def.defaults.page.required = true
that.editor.getSession().setMode('ace/mode/html')
break
default:
$('#template-row-group, #template-row-class').show()
that._def.defaults.group.required = true
that.editor.getSession().setMode('ace/mode/html')
break
}
Expand Down

0 comments on commit d5b1f80

Please sign in to comment.