Skip to content

Commit

Permalink
fix: list rendering & station form
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Nov 17, 2023
1 parent 7e7055a commit be131cf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
11 changes: 11 additions & 0 deletions .changeset/new-humans-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@personalhealthtrain/client-vue": patch
"@personalhealthtrain/client-ui": patch
"@personalhealthtrain/core": patch
"@personalhealthtrain/server-api": patch
"@personalhealthtrain/server-core": patch
"@personalhealthtrain/server-realtime": patch
"@personalhealthtrain/server-train-manager": patch
---

minor fixes
10 changes: 2 additions & 8 deletions packages/client-ui/pages/admin/stations/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,11 @@ export default defineNuxtComponent({
},
}));

const listNode = ref<null | typeof StationList>(null);
const handleDeleted = async (item: Station) => {
if (listNode.value) {
listNode.value.handleDeleted(item);
}

emit('deleted', item);
};

return {
listNode,
fields,
realmManagementId,
canView,
Expand All @@ -92,9 +86,9 @@ export default defineNuxtComponent({
</script>
<template>
<StationList
ref="listNode"
:query="query"
:load-on-init="true"
@deleted="handleDeleted"
>
<template #header="props">
<ListTitle />
Expand Down Expand Up @@ -131,7 +125,7 @@ export default defineNuxtComponent({
:entity-id="data.item.id"
:entity-type="'station'"
:with-text="false"
@deleted="handleDeleted"
@deleted="props.deleted"
/>
</template>
<template #cell(created_at)="data">
Expand Down
2 changes: 1 addition & 1 deletion packages/client-vue/src/components/station/StationForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default defineComponent({
realm_id: '',
registry_id: '',
hidden: false,
ecosystem: Ecosystem.DEFAULT,
ecosystem: '',
});

const $v = useVuelidate({
Expand Down
11 changes: 9 additions & 2 deletions packages/client-vue/src/core/list/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,27 @@ export function createList<
noMore: options.noMore,
body: options.body,
loading: options.loading,
total,
total: total.value,
load,
busy: busy.value,
data: data.value as Entity<T>[],
meta: meta.value,
meta: {
...meta.value,
total: total.value,
},
onCreated(value: T) {
if (context.setup.emit) {
context.setup.emit('created', value);
}

total.value++;
},
onDeleted(value: T) {
if (context.setup.emit) {
context.setup.emit('deleted', value);
}

total.value--;
},
onUpdated(value: T) {
if (context.setup.emit) {
Expand Down
5 changes: 1 addition & 4 deletions packages/client-vue/src/core/list/utils/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export function buildListCreatedHandler<T>(
};
}

export function buildListUpdatedHandler<T>(
items: Ref<T[]>,
cb?: (entity: T) => void | Promise<void>,
) {
export function buildListUpdatedHandler<T>(items: Ref<T[]>) {
return (item: T) => {
if (!isObject(item)) {
return;
Expand Down

0 comments on commit be131cf

Please sign in to comment.