Skip to content

Commit

Permalink
#201: Capitalize the itemName since the query depends on this
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailmarcu committed Feb 18, 2022
1 parent 90af632 commit 1abd48e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/vue/src/components/SpCrud/SpCrud.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>

<div v-if="moduleAvailable" class="container crud--position">
<div class="row">
<div class="col-6">
<SpTypography modifier="highlight" size="md" style="font-weight: 700">
{{ itemName }} items
{{ moduleName }} items
</SpTypography>
</div>
<div class="col-6 text-align--right">
Expand All @@ -15,8 +16,8 @@

<SpCrudRead
:store-name="storeName"
:item-name="itemName"
:command-name="`/Query${itemName}All`"
:item-name="moduleName"
:command-name="`/Query${moduleName}All`"
@createItem="visibleModal = 'create-item'"
@editItem="
(item) => {
Expand All @@ -35,31 +36,31 @@
<SpCrudCreate
v-if="visibleModal === 'create-item'"
:store-name="storeName"
:item-name="itemName"
:command-name="`/sendMsgCreate${itemName}`"
:item-name="moduleName"
:command-name="`/sendMsgCreate${moduleName}`"
@close="visibleModal = ''"
/>
<SpCrudUpdate
v-if="visibleModal === 'edit-item'"
:store-name="storeName"
:item-name="itemName"
:item-name="moduleName"
:item-data="activeItem"
:command-name="`/sendMsgUpdate${itemName}`"
:command-name="`/sendMsgUpdate${moduleName}`"
@close="visibleModal = ''"
/>
<SpCrudDelete
v-if="visibleModal === 'delete-item'"
:store-name="storeName"
:item-name="itemName"
:item-name="moduleName"
:item-data="activeItem"
:command-name="`/sendMsgDelete${itemName}`"
:command-name="`/sendMsgDelete${moduleName}`"
@close="visibleModal = ''"
/>
</div>
</template>

<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue'
import { computed, defineComponent, reactive, ref, toRefs } from 'vue'
import { useStore } from 'vuex'
import SpButton from '../SpButton'
Expand Down Expand Up @@ -117,11 +118,17 @@ export default defineComponent({
// state
let state: State = reactive(initialState)
let moduleName = computed (() =>
props.itemName.replace(/^\w/, (c) => c.toUpperCase())
)
console.log(moduleName.value)
state.moduleAvailable = $s.hasModule(props.storeName)
return {
...toRefs(state)
...toRefs(state),
moduleName
}
}
})
Expand Down

0 comments on commit 1abd48e

Please sign in to comment.