Add enable switch on code snippets
This commit is contained in:
@@ -71,6 +71,13 @@
|
||||
title-class="text-capitalize"
|
||||
@ok="modal.updater(modal.data)"
|
||||
>
|
||||
<b-checkbox
|
||||
v-model="modal.data.enabled"
|
||||
class="mb-3"
|
||||
>
|
||||
{{ $t('code-snippets.enabled') }}
|
||||
</b-checkbox>
|
||||
|
||||
<b-form-group
|
||||
:label="$t('code-snippets.form.provider.label')"
|
||||
label-class="text-primary"
|
||||
@@ -234,6 +241,7 @@ export default {
|
||||
data: {
|
||||
name: '',
|
||||
script: '<' + 'script> ' + '</' + 'script>',
|
||||
enabled: true,
|
||||
},
|
||||
updater: (changed) => {
|
||||
this.codeSnippets.push(changed)
|
||||
|
||||
@@ -4,6 +4,7 @@ editor:
|
||||
code-snippets:
|
||||
add: Add code snippet
|
||||
empty: No snippets yet
|
||||
enabled: Enabled
|
||||
table-headers:
|
||||
provider: Provider
|
||||
value: Script value
|
||||
|
||||
@@ -167,7 +167,9 @@ func serveConfig(r chi.Router, config webappConfig) {
|
||||
|
||||
snippetScripts := ""
|
||||
for _, snippet := range codeSnippets {
|
||||
snippetScripts += snippet.Script
|
||||
if snippet.Enabled {
|
||||
snippetScripts += snippet.Script
|
||||
}
|
||||
}
|
||||
|
||||
doc, err := html.Parse(strings.NewReader(snippetScripts))
|
||||
|
||||
@@ -420,6 +420,7 @@ type (
|
||||
CodeSnippet struct {
|
||||
Name string `json:"name"`
|
||||
Script string `json:"script"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
SmtpServers struct {
|
||||
|
||||
Reference in New Issue
Block a user