- Update the way to use the data records on Vuex with Getters!
- Fix: mongodb call passing array todos and categiroes already splitted
This commit is contained in:
1
src/components/admin/testp1/index.ts
Normal file
1
src/components/admin/testp1/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {default as testp1} from './testp1.vue'
|
||||
0
src/components/admin/testp1/testp1.scss
Normal file
0
src/components/admin/testp1/testp1.scss
Normal file
95
src/components/admin/testp1/testp1.ts
Normal file
95
src/components/admin/testp1/testp1.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import Vue from 'vue'
|
||||
import { Component, Watch } from 'vue-property-decorator'
|
||||
|
||||
import { GlobalStore, UserStore } from '@store'
|
||||
import { Getter } from "vuex-class"
|
||||
import { ICfgServer, IGlobalState, ITodo, ITodosState } from '@src/model'
|
||||
|
||||
const namespace: string = 'GlobalModule'
|
||||
|
||||
@Component({})
|
||||
export default class Testp1 extends Vue {
|
||||
public myvar:number = 5
|
||||
public paramcategory: string = ''
|
||||
public mioobj: any
|
||||
|
||||
// @Getter('todos_dacompletare', { namespace })
|
||||
// public todos_dacompletare: (state: ITodosState, category: string) => ITodo[]
|
||||
|
||||
@Getter('testpao1_getter_contatore', { namespace })
|
||||
public testpao1: (state: IGlobalState, param1: number) => number
|
||||
|
||||
@Getter('testpao1_getter_array', { namespace })
|
||||
public testpao1_array: (state: IGlobalState, miorec: ICfgServer) => ICfgServer[]
|
||||
|
||||
@Watch('GlobalStore.state.testp1.mioarray', { immediate: true, deep: true })
|
||||
array_changed() {
|
||||
console.log('*** array_changed *** ', GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1])
|
||||
}
|
||||
|
||||
@Watch('$route.params.category') changecat() {
|
||||
// this.mytypetransgroup = ''
|
||||
console.log('PRIMA this.paramcategory', this.paramcategory)
|
||||
this.paramcategory = this.$route.params.category
|
||||
console.log('DOPO this.paramcategory', this.paramcategory)
|
||||
}
|
||||
|
||||
created() {
|
||||
this.mioobj = {
|
||||
arr1: [{chiave: 'key1', valore: 'val1'}],
|
||||
arr2: [{chiave: 'key2', valore: 'val2'}]
|
||||
}
|
||||
}
|
||||
|
||||
get getarr1 () {
|
||||
// return this.mioobj.arr1
|
||||
return this.mioobj['arr1']
|
||||
}
|
||||
|
||||
get prova2() {
|
||||
return GlobalStore.state.testp1.contatore
|
||||
}
|
||||
|
||||
get provagetter() {
|
||||
return GlobalStore.getters.testpao1_getter_contatore(130)
|
||||
}
|
||||
|
||||
get provagetterarray() {
|
||||
return GlobalStore.getters.testpao1_getter_array(GlobalStore.state.testp1.contatore)
|
||||
}
|
||||
|
||||
|
||||
TestBtnCambioaParamPassing () {
|
||||
this.paramcategory += 's'
|
||||
}
|
||||
|
||||
TestBtn() {
|
||||
GlobalStore.state.testp1.contatore++
|
||||
}
|
||||
|
||||
TestBtn2() {
|
||||
GlobalStore.state.testp1.mioarray.push({chiave: 'pippo2', valore: GlobalStore.state.testp1.contatore.toString() })
|
||||
}
|
||||
|
||||
TestBtnModify() {
|
||||
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||
GlobalStore.mutations.setPaoArray({chiave: 'pippo', valore: '20' } )
|
||||
|
||||
}
|
||||
|
||||
TestBtnCambiaTutto() {
|
||||
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||
GlobalStore.mutations.NewArray([{chiave: 'nuovorec1', valore: '1' }, {chiave: 'nuovorec2', valore: '2' }] )
|
||||
|
||||
}
|
||||
|
||||
TestBtnAction() {
|
||||
GlobalStore.actions.prova()
|
||||
}
|
||||
|
||||
TestBtnDelete() {
|
||||
// GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] = GlobalStore.state.testp1.mioarray[GlobalStore.state.testp1.mioarray.length - 1] + 1
|
||||
GlobalStore.mutations.setPaoArray_Delete()
|
||||
}
|
||||
|
||||
}
|
||||
43
src/components/admin/testp1/testp1.vue
Normal file
43
src/components/admin/testp1/testp1.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div>
|
||||
CATEGORY: <strong>{{ paramcategory }}</strong> <br>
|
||||
|
||||
<label>TEST Prova Paolo</label><br>
|
||||
|
||||
|
||||
GETTER CONTATORE:
|
||||
{{ testpao1(300) }} <br>
|
||||
ARRAY:
|
||||
{{ testpao1_array(300) }} <br>
|
||||
|
||||
TEST OBJECT {{ mioobj }} <br>
|
||||
ARR1 {{ getarr1 }} <br>
|
||||
<!--ARR2 {{ mioobj.arr2 }} <br>-->
|
||||
|
||||
<!--<q-input v-model="testpao1(myvar)"></q-input>-->
|
||||
|
||||
<q-input v-model="prova2" float-label="PROVA2:"></q-input>
|
||||
|
||||
<q-input v-model="provagetter" float-label="PROVA GETTER:"></q-input>
|
||||
<q-input v-model="provagetterarray" float-label="GETTER ARRAY:"></q-input>
|
||||
|
||||
<br>
|
||||
|
||||
<q-btn color="secondary" rounded icon="refresh"
|
||||
@click="TestBtn" label="Test 1"/>
|
||||
|
||||
<q-btn color="secondary" rounded icon="refresh" @click="TestBtn2" label="ADD TO ARRAY"/>
|
||||
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnModify" label="MODIFY"/>
|
||||
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnAction" label="MODIF_BYACTION"/>
|
||||
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnDelete" label="DEL LAST"/>
|
||||
<!--<q-btn color="secondary" rounded icon="refresh" @click="TestBtnCambiaTutto" label="NEW ARR"/>-->
|
||||
<q-btn color="secondary" rounded icon="refresh" @click="TestBtnCambioaParamPassing" label="CAMBIA PARAM"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" src="./testp1.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './testp1.scss';
|
||||
</style>
|
||||
Reference in New Issue
Block a user