Skip to content

Commit

Permalink
♻️ Refactor RegisterTable usage: remove redundant editable prop and e…
Browse files Browse the repository at this point in the history
…nhance prop type definitions
  • Loading branch information
tcorzo committed Nov 7, 2024
1 parent a2e6b2c commit a80002e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const globalState: GlobalState = inject('globalState') || {} as GlobalState;
<template>
<div id="editor">
<OperationsTable />
<RegisterTable :editable="true" :title="'Registros Auxiliares'" :registers="globalState.program.aux_registers" />
<RegisterTable :editable="true" :title="'Program'" :registers="globalState.program.registers" />
<RegisterTable :editable="true" :title="'Data'" :registers="globalState.program.data_registers" />
<RegisterTable editable :title="'Registros Auxiliares'" :registers="globalState.program.aux_registers" />
<RegisterTable editable :title="'Program'" :registers="globalState.program.registers" />
<RegisterTable editable :title="'Data'" :registers="globalState.program.data_registers" />
</div>
</template>

Expand Down
21 changes: 15 additions & 6 deletions src/components/RegisterTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { PropType, ref } from 'vue';
import { Register } from './../abacus/program';
const props = defineProps<{
title: string
registers: Register[],
editable: boolean
}>()
const props = defineProps({
title: String,
registers: {
type: Array as PropType<Register[]>,
required: true
},
editable: {
type: Boolean,
required: false,
default(_: any) {
return false;
}
}
})
const editMode = props.editable ? 'cell' : undefined
Expand Down
2 changes: 1 addition & 1 deletion src/components/emulator/AuxRegisters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const registers = computed(
</script>

<template>
<RegisterTable :editable="false" :title="'Registros Auxiliares'" :registers="registers" />
<RegisterTable :title="'Registros Auxiliares'" :registers="registers" />
</template>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion src/components/emulator/DataRegisters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const registers = computed(() => {
</script>

<template>
<RegisterTable :editable="false" :title="'Data'" :registers="registers" />
<RegisterTable :title="'Data'" :registers="registers" />
</template>

<style scoped>
Expand Down

0 comments on commit a80002e

Please sign in to comment.