Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Capitalize the itemName #214

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions packages/vue/src/components/SpCrud/SpCrud.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<div class="row">
<div class="col-6">
<SpTypography modifier="highlight" size="md" style="font-weight: 700">
{{ itemName }} items
{{ moduleNameNormalized }} items
</SpTypography>
</div>
<div class="col-6 text-align--right">
<SpButton type="primary" :disabled='!address' @click="visibleModal = 'create-item'">
Create {{ itemName.toLowerCase() }}
Create {{ moduleNameNormalized }}
</SpButton>
</div>
</div>

<SpCrudRead
:store-name="storeName"
:item-name="itemName"
:command-name="`/Query${itemName}All`"
:item-name="moduleNameNormalized"
:command-name="`/Query${moduleNameNormalized}All`"
@createItem="visibleModal = 'create-item'"
@editItem="
(item) => {
Expand All @@ -35,31 +35,31 @@
<SpCrudCreate
v-if="visibleModal === 'create-item'"
:store-name="storeName"
:item-name="itemName"
:command-name="`/sendMsgCreate${itemName}`"
:item-name="moduleNameNormalized"
:command-name="`/sendMsgCreate${moduleNameNormalized}`"
@close="visibleModal = ''"
/>
<SpCrudUpdate
v-if="visibleModal === 'edit-item'"
:store-name="storeName"
:item-name="itemName"
:item-name="moduleNameNormalized"
:item-data="activeItem"
:command-name="`/sendMsgUpdate${itemName}`"
:command-name="`/sendMsgUpdate${moduleNameNormalized}`"
@close="visibleModal = ''"
/>
<SpCrudDelete
v-if="visibleModal === 'delete-item'"
:store-name="storeName"
:item-name="itemName"
:item-name="moduleNameNormalized"
:item-data="activeItem"
:command-name="`/sendMsgDelete${itemName}`"
:command-name="`/sendMsgDelete${moduleNameNormalized}`"
@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 { useAddress } from '../../composables'
Expand All @@ -79,7 +79,7 @@ export interface State {
export let initialState: State = {
visibleModal: '',
activeItem: {},
moduleAvailable: true
moduleAvailable: false
}

export default defineComponent({
Expand Down Expand Up @@ -116,11 +116,17 @@ export default defineComponent({
// state
let state: State = reactive(initialState)
mihailmarcu marked this conversation as resolved.
Show resolved Hide resolved

// computed
let moduleNameNormalized = computed (() =>
props.itemName.replace(/^\w/, (c) => c.toUpperCase())
)

state.moduleAvailable = $s.hasModule(props.storeName)

return {
...toRefs(state),
address
address,
moduleNameNormalized
}
}
})
Expand Down