Skip to content

Commit

Permalink
Fix property error and undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Jan 20, 2024
1 parent 9f7065f commit bb9ef89
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
2 changes: 1 addition & 1 deletion elebox/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.dev.elebox",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
Expand Down
4 changes: 2 additions & 2 deletions elebox/src/components/PartDel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ defineProps({
part: String
})
async function partDel(part: String) {
async function partDel(part: string) {
console.debug(`Part delete: ${part}`);
await invoke("part_del", { part });
}
</script>

<template>
<button @click="partDel(part)">🗑️</button>
<button @click="partDel(part!)">🗑️</button>
</template>
16 changes: 12 additions & 4 deletions elebox/src/components/PartList.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, reactive } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
import PartQty from "./PartQty.vue";
import PartDel from "./PartDel.vue";
const parts = ref("");
interface Parts {
[index: number]: {
name: string;
quantity: number;
part_type: string;
}
}
let parts = reactive<Parts>({});
async function getParts() {
parts.value = await invoke("get_parts", {});
console.log(parts.value);
parts = await invoke("get_parts", {});
console.log(parts);
}
onMounted(getParts);
Expand Down
15 changes: 11 additions & 4 deletions elebox/src/components/PartNew.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, ref, reactive } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
interface Types {
[index: number]: {
name: string;
parent: string;
}
}
const partName = ref("");
const partQty = ref("");
const partType = ref("");
const types = ref("");
let types = reactive<Types>({});
async function newPart() {
await invoke("part_new", { name: partName.value, qty: parseInt(partQty.value), ptype: partType.value });
}
async function getTypes() {
types.value = await invoke("get_types", {});
console.debug(`Types: ${types.value}`);
types = await invoke("get_types", {});
console.debug(`Types: ${types}`);
}
onMounted(async () => {
Expand Down
6 changes: 3 additions & 3 deletions elebox/src/components/PartQty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ defineProps({
part: String
})
async function partAdd(part: String, qty: Number) {
async function partAdd(part: string, qty: Number) {
await invoke("part_add", { part, qty });
console.log(part);
}
</script>

<template>
<button @click="partAdd(part, 1)">+</button>
<button @click="partAdd(part, -1)">-</button>
<button @click="partAdd(part!, 1)">+</button>
<button @click="partAdd(part!, -1)">-</button>
</template>
15 changes: 11 additions & 4 deletions elebox/src/components/TypeNew.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, ref, reactive } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
interface Types {
[index: number]: {
name: string;
parent: string;
}
}
const typeName = ref("");
const typeParent = ref("");
const types = ref("");
let types = reactive<Types>({});
async function newType() {
await invoke("type_new", { name: typeName.value, parent: typeParent.value });
Expand All @@ -14,8 +21,8 @@ async function newType() {
}
async function getTypes() {
types.value = await invoke("get_types", {});
console.debug(`Types: ${types.value}`);
types = await invoke("get_types", {});
console.debug(`Types: ${types}`);
}
onMounted(async () => {
Expand Down
15 changes: 11 additions & 4 deletions elebox/src/views/NewPart.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, ref, reactive } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
import router from '../router.js';
interface Types {
[index: number]: {
name: string;
parent: string;
}
}
const partName = ref("");
const partQty = ref("");
const partType = ref("");
const types = ref("");
let types = reactive<Types>({});
const location = ref("");
function goHome() {
Expand All @@ -18,8 +25,8 @@ async function newPart() {
}
async function getTypes() {
types.value = await invoke("get_types", {});
console.debug(`Types: ${types.value}`);
types = await invoke("get_types", {});
console.debug(`Types: ${types}`);
}
onMounted(async () => {
Expand Down

0 comments on commit bb9ef89

Please sign in to comment.