Skip to content

Commit

Permalink
Merge pull request #25 from IBEC-BOX/pinia
Browse files Browse the repository at this point in the history
Pinia
  • Loading branch information
Aidosgd authored Nov 6, 2023
2 parents 5436d82 + 6864161 commit 7951cf4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 58 deletions.
6 changes: 5 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { setup } from "@storybook/vue3";
import { withVuetifyTheme, DEFAULT_THEME } from "./withVuetifyTheme.decorator";
import { createPinia } from 'pinia';

const pinia = createPinia();

import vuetify from '../src/runtime/plugins/vuetify'

setup((app) => {
// Registers your app's plugins into Storybook
app.use(vuetify)
app.use(pinia)
});

export const globalTypes = {
Expand All @@ -31,4 +35,4 @@ export const parameters = {
layout: "fullscreen",
};

export const decorators = [withVuetifyTheme];
export const decorators = [withVuetifyTheme];
53 changes: 21 additions & 32 deletions src/runtime/components/Parts/modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,9 @@

<script setup>
import { defineProps, useAttrs, computed, ref } from 'vue'
import { useMainStore } from "../../../store/mainStore.js";
const attrs = useAttrs()
const getObjectPropertiesWithPrefix = (obj, prefix) => {
const iconProperties = {};
for (const key in obj) {
if (key.startsWith(`${prefix}-`)) {
iconProperties[key.split(`${prefix}-`)[1]] = obj[key];
}
}
return iconProperties;
};
const iconAttrs = ref({
size: 'large',
color: 'white',
...getObjectPropertiesWithPrefix(attrs, 'icon')
})
const imageAttrs = ref({
height: 199,
...getObjectPropertiesWithPrefix(attrs, 'img')
})
const closeButtonAttrs = ref({
elevation: 0,
size: 'small',
icon: 'mdi-window-close',
...getObjectPropertiesWithPrefix(attrs, 'close-button')
})
const mainStore = useMainStore()
const props = defineProps({
modelValue: {
type: Boolean,
Expand Down Expand Up @@ -136,6 +106,25 @@
default: false,
},
})
const attrs = useAttrs()
const iconAttrs = ref({
size: 'large',
color: 'white',
...mainStore.getObjectPropertiesWithPrefix(attrs, 'icon')
})
const imageAttrs = ref({
height: 199,
...mainStore.getObjectPropertiesWithPrefix(attrs, 'img')
})
const closeButtonAttrs = ref({
elevation: 0,
size: 'small',
icon: 'mdi-window-close',
...mainStore.getObjectPropertiesWithPrefix(attrs, 'close-button')
})
// Init v-model
const emit = defineEmits(['update:modelValue'])
Expand Down
16 changes: 3 additions & 13 deletions src/runtime/components/Parts/vacancies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
import Card from './Card.vue'
import Forms from './Forms.vue'
import {defineProps, defineEmits, useAttrs} from 'vue'
import { useMainStore } from "../../../store/mainStore.js";
const attrs = useAttrs()
const emit = defineEmits(['form-data'])
const mainStore = useMainStore()
const props = defineProps({
cards: {
type: Array,
Expand All @@ -57,22 +59,10 @@
}
})
const getObjectPropertiesWithPrefix = (obj, prefix) => {
const properties = {};
for (const key in obj) {
if (key.startsWith(`${prefix}-`)) {
properties[key.split(`${prefix}-`)[1]] = obj[key];
}
}
return properties;
}
const formAttrs = {
...getObjectPropertiesWithPrefix(attrs, 'form')
...mainStore.getObjectPropertiesWithPrefix(attrs, 'form')
}
console.log(formAttrs)
const formData = (data) => {
emit('form-data', data )
}
Expand Down
14 changes: 3 additions & 11 deletions src/runtime/components/Parts/vacancy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<script setup>
import Forms from './Forms.vue'
import {defineProps, defineEmits, useAttrs} from 'vue'
import { useMainStore } from '../../../store/mainStore.js'
const attrs = useAttrs()
const emit = defineEmits(['form-data'])
Expand Down Expand Up @@ -148,19 +149,10 @@
default: () => []
},
})
const getObjectPropertiesWithPrefix = (obj, prefix) => {
const properties = {};
for (const key in obj) {
if (key.startsWith(`${prefix}-`)) {
properties[key.split(`${prefix}-`)[1]] = obj[key];
}
}
return properties;
}
const mainStore = useMainStore()
const formAttrs = {
...getObjectPropertiesWithPrefix(attrs, 'form')
...mainStore.getObjectPropertiesWithPrefix(attrs, 'form')
}
const formData = (data) => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/store.js → src/store/mainStore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {defineStore} from 'pinia'

export const useStore = defineStore('store', {
export const useMainStore = defineStore('mainStore', {
getters: {
getObjectPropertiesWithPrefix: () => {
return (obj, prefix) => {
Expand Down

0 comments on commit 7951cf4

Please sign in to comment.