11<template >
2- <div class =" mb-3" >
3- <label class =" form-label" >{{ label }}</label >
2+ <fieldset class =" mb-3" >
3+ <legend class =" form-label h6 " >{{ label }}</legend >
44 <div class =" form-text" >{{ description }}</div >
55
66 <!-- Column headers (only once there's at least one row) -->
6666
6767 <FileBrowserModal v-model :open =" browserOpen " type="executable" :title =" $t (' file_browser.select_executable' )"
6868 :start-path =" browserStartPath " @confirm =" onBrowserConfirm " />
69- </div >
69+ </fieldset >
7070</template >
7171
72- <script >
72+ <script setup>
73+ import { computed , ref } from ' vue'
7374import Checkbox from ' @/components/Checkbox.vue'
7475import FileBrowserModal from ' @/components/FileBrowserModal.vue'
7576import {
@@ -81,63 +82,53 @@ import {
8182 Trash2 ,
8283} from ' @lucide/vue'
8384
84- export default {
85- components: {
86- Checkbox,
87- FileBrowserModal,
88- FolderOpen,
89- Play,
90- Plus,
91- RotateCcw,
92- Shield,
93- Trash2,
94- },
95- props: {
96- modelValue: { type: Array , default : () => [] },
97- platform: String ,
98- label: String ,
99- description: String ,
100- addLabel: String ,
101- },
102- emits: [' update:modelValue' ],
103- data () {
104- return {
105- browserOpen: false ,
106- browserTargetIndex: null ,
107- browserTargetField: null ,
108- };
109- },
110- computed: {
111- browserStartPath () {
112- if (this .browserTargetIndex === null ) {
113- return ' ' ;
114- }
115- return this .modelValue [this .browserTargetIndex ][this .browserTargetField ] || ' ' ;
116- },
117- },
118- methods: {
119- addCmd () {
120- let template = {
121- do: " " ,
122- undo: " " ,
123- };
85+ const props = defineProps ({
86+ platform: String ,
87+ label: String ,
88+ description: String ,
89+ addLabel: String ,
90+ })
12491
125- if (this .platform === ' windows' ) {
126- template = { ... template, elevated: false };
127- }
128- this .modelValue .push (template);
129- },
130- removeCmd (index ) {
131- this .modelValue .splice (index, 1 );
132- },
133- browse (index , field ) {
134- this .browserTargetIndex = index;
135- this .browserTargetField = field;
136- this .browserOpen = true ;
137- },
138- onBrowserConfirm (path ) {
139- this .modelValue [this .browserTargetIndex ][this .browserTargetField ] = path;
140- },
141- },
92+ const modelValue = defineModel ({ type: Array , default : () => [] })
93+
94+ const browserOpen = ref (false )
95+ const browserTargetIndex = ref (null )
96+ const browserTargetField = ref (null )
97+
98+ const browserStartPath = computed (() => {
99+ if (browserTargetIndex .value === null ) {
100+ return ' ' ;
101+ }
102+ return modelValue .value [browserTargetIndex .value ][browserTargetField .value ] || ' ' ;
103+ })
104+
105+ function addCmd () {
106+ let template = {
107+ do: " " ,
108+ undo: " " ,
109+ };
110+
111+ if (props .platform === ' windows' ) {
112+ template = { ... template, elevated: false };
113+ }
114+ modelValue .value = [... modelValue .value , template];
115+ }
116+
117+ function removeCmd (index ) {
118+ const updated = [... modelValue .value ];
119+ updated .splice (index, 1 );
120+ modelValue .value = updated;
121+ }
122+
123+ function browse (index , field ) {
124+ browserTargetIndex .value = index;
125+ browserTargetField .value = field;
126+ browserOpen .value = true ;
127+ }
128+
129+ function onBrowserConfirm (path ) {
130+ const updated = [... modelValue .value ];
131+ updated[browserTargetIndex .value ] = { ... updated[browserTargetIndex .value ], [browserTargetField .value ]: path };
132+ modelValue .value = updated;
142133}
143134 </script >
0 commit comments