- Import emails from a list to a DB

- Create Template Emails
- Options Email
This commit is contained in:
Paolo Arena
2019-12-04 02:04:54 +01:00
parent 895df43074
commit 8268a09897
20 changed files with 619 additions and 165 deletions

View File

@@ -12,13 +12,14 @@ import { lists } from '../../store/Modules/lists'
import { IParamsQuery } from '../../model/GlobalStore'
import { fieldsTable } from '../../store/Modules/fieldsTable'
import { CMyPopupEdit } from '../CMyPopupEdit'
import { CTitleBanner } from '../CTitleBanner'
@Component({
components: { CMyPopupEdit }
components: { CMyPopupEdit, CTitleBanner }
})
export default class CGridTableRec extends Vue {
@Prop({ required: false }) public prop_mytable: string
@Prop({ required: true }) public prop_mytitle: string
@Prop({ required: false }) public prop_mytable: string
@Prop({ required: false, default: null }) public prop_mycolumns: any[]
@Prop({ required: false, default: '' }) public prop_colkey: string
@Prop({ required: false, default: '' }) public nodataLabel: string
@@ -52,7 +53,7 @@ export default class CGridTableRec extends Vue {
public valPrec: string = ''
public separator: 'horizontal'
public filter = undefined
public myfilter = undefined
public rowsel: any
public dark: boolean = true
public canEdit: boolean = false
@@ -62,6 +63,11 @@ export default class CGridTableRec extends Vue {
public colVisib: any[] = []
public colExtra: any[] = []
public rowclicksel: any = null
public colclicksel: any = null
public selected: any = []
get lists() {
return lists
}
@@ -96,16 +102,36 @@ export default class CGridTableRec extends Vue {
}
public SaveValdb(newVal, valinitial) {
// console.log('SaveValdb', newVal)
// console.log('SaveValue', newVal, 'rowsel', this.rowsel)
this.colsel = this.colclicksel
// console.log('this.colsel', this.colsel)
this.SaveValue(newVal, valinitial)
this.colsel = null
}
public showandsel(row, col, newval, valinitial) {
// console.log('showandsel', row, col, newval)
this.rowsel = row
this.colsel = col
this.idsel = row._id
this.SaveValue(newval, valinitial)
}
public SaveValue(newVal, valinitial) {
// console.log('SaveValue', newVal, 'rowsel', this.rowsel)
// Update value in table memory
if (this.colsel.subfield !== '') {
if (this.rowsel[this.colsel.field] === undefined)
this.rowsel[this.colsel.field] = {}
this.rowsel[this.colsel.field][this.colsel.subfield] = newVal
} else {
this.rowsel[this.colsel.field] = newVal
if (this.colsel) {
// Update value in table memory
if (this.colsel.subfield !== '') {
if (this.rowsel[this.colsel.field] === undefined)
this.rowsel[this.colsel.field] = {}
this.rowsel[this.colsel.field][this.colsel.subfield] = newVal
} else {
this.rowsel[this.colsel.field] = newVal
}
}
const mydata = {
@@ -140,7 +166,7 @@ export default class CGridTableRec extends Vue {
}
public updatedcol() {
console.log('updatedcol')
// console.log('updatedcol')
if (this.mycolumns) {
this.colVisib = []
this.colExtra = []
@@ -160,9 +186,9 @@ export default class CGridTableRec extends Vue {
}
public onRequest(props) {
console.log('onRequest', 'filter = ' , this.filter)
console.log('onRequest', 'myfilter = ', this.myfilter)
const { page, rowsPerPage, rowsNumber, sortBy, descending } = props.pagination
const filter = this.filter
const myfilter = this.myfilter
if (!this.mytable)
return
@@ -185,9 +211,9 @@ export default class CGridTableRec extends Vue {
this.serverData = []
// fetch data from "server"
this.fetchFromServer(startRow, endRow, filter, sortBy, descending).then((ris) => {
this.fetchFromServer(startRow, endRow, myfilter, sortBy, descending).then((ris) => {
this.pagination.rowsNumber = this.getRowsNumberCount(filter)
this.pagination.rowsNumber = this.getRowsNumberCount(myfilter)
// clear out existing data and add new
if (this.returnedData === []) {
@@ -215,7 +241,7 @@ export default class CGridTableRec extends Vue {
// emulate ajax call
// SELECT * FROM ... WHERE...LIMIT...
public async fetchFromServer(startRow, endRow, filter, sortBy, descending) {
public async fetchFromServer(startRow, endRow, myfilter, sortBy, descending) {
let myobj = null
if (sortBy) {
@@ -230,7 +256,7 @@ export default class CGridTableRec extends Vue {
table: this.mytable,
startRow,
endRow,
filter,
filter: myfilter,
sortBy: myobj,
descending
}
@@ -247,15 +273,15 @@ export default class CGridTableRec extends Vue {
return true
// if (!filter) {
// if (!myfilter) {
// data = this.original.slice(startRow, startRow + count)
// }
// else {
// let found = 0
// for (let index = startRow, items = 0; index < this.original.length && items < count; ++index) {
// let row = this.original[index]
// // match filter?
// if (!row['name'].includes(filter)) {
// // match myfilter?
// if (!row['name'].includes(myfilter)) {
// // get a different row, until one is found
// continue
// }
@@ -285,14 +311,14 @@ export default class CGridTableRec extends Vue {
}
// emulate 'SELECT count(*) FROM ...WHERE...'
public getRowsNumberCount(filter) {
public getRowsNumberCount(myfilter) {
// if (!filter) {
// if (!myfilter) {
// return this.original.length
// }
// let count = 0
// this.original.forEach((treat) => {
// if (treat['name'].includes(filter)) {
// if (treat['name'].includes(myfilter)) {
// ++count
// }
// })
@@ -337,9 +363,11 @@ export default class CGridTableRec extends Vue {
public mounted() {
this.canEdit = tools.getCookie(tools.CAN_EDIT, this.canEdit) === 'true'
if (!!this.tablesList) {
this.canEdit = tools.getCookie(tools.CAN_EDIT, this.canEdit) === 'true'
this.tablesel = tools.getCookie('tablesel', this.tablesel)
}
this.tablesel = tools.getCookie('tablesel', this.tablesel)
if (this.tablesel === '') {
if (!!this.tablesList)
this.tablesel = this.tablesList[0].value
@@ -357,11 +385,11 @@ export default class CGridTableRec extends Vue {
console.log('refresh')
// console.log('this.search', this.search)
if (!!this.search && this.search !== '')
this.filter = this.search
this.myfilter = this.search
else
this.filter = undefined
this.myfilter = undefined
// console.log('this.filter', this.filter)
// console.log('this.myfilter', this.myfilter)
this.refresh_table()
}
@@ -411,7 +439,9 @@ export default class CGridTableRec extends Vue {
if (this.tablesel === undefined || this.tablesel === '')
return
console.log('changeTable mysel=', mysel, 'tablesel', this.tablesel)
// console.log('changeTable mysel=', mysel, 'tablesel', this.tablesel)
// console.log('this.tablesList=')
// console.table(this.tablesList)
let mytab = null
if (this.tablesList) {
@@ -457,6 +487,11 @@ export default class CGridTableRec extends Vue {
const myselcol = tools.getCookie(this.mytable, '')
if (!!myselcol && myselcol.length > 0) {
this.colVisib = myselcol.split('|')
} else {
this.mycolumns.forEach((elem) => {
if (elem.field !== tools.NOFIELD)
this.colVisib.push(elem.field + elem.subfield)
})
}
}
@@ -479,4 +514,21 @@ export default class CGridTableRec extends Vue {
tools.setCookie(tools.CAN_EDIT, newval)
}
public clickrowcol(row, col) {
if (!this.canEdit) {
if (this.rowclicksel) {
this.rowclicksel = null
} else {
this.rowclicksel = row
this.colclicksel = col
}
}
}
public getclrow(myrow) {
if (this.rowclicksel === myrow)
return 'colsel'
else
return ''
}
}

View File

@@ -4,7 +4,7 @@
<q-table
:data="serverData"
:columns="mycolumns"
:filter="filter"
:filter="myfilter"
:pagination.sync="pagination"
:row-key="colkey"
:loading="loading"
@@ -35,7 +35,8 @@
<!--<p style="color:red"> Rows: {{ getrows }}</p>-->
<q-input v-model="search" filled dense type="search" debounce="500" hint="Search" v-on:keyup.enter="doSearch">
<q-input v-model="search" filled dense type="search" debounce="500" hint="Search"
v-on:keyup.enter="doSearch">
<template v-slot:after>
<q-btn v-if="mytable" label="" color="primary" @click="refresh" icon="search"></q-btn>
</template>
@@ -91,16 +92,20 @@
</template>
<q-tr v-if="mytable" slot="body" slot-scope="props" :props="props">
<q-td v-for="col in mycolumns" :key="col.name" :props="props" v-if="colVisib.includes(col.field + col.subfield)">
<CMyPopupEdit :canEdit="canEdit"
:col="col"
:row.sync="props.row"
:field="col.field"
:subfield="col.subfield"
@save="SaveValue"
@show="selItem(props.row, col)">
<q-td v-for="col in mycolumns" :key="col.name" :props="props"
v-if="colVisib.includes(col.field + col.subfield)" @click="clickrowcol(props.row, col)">
<div :class="getclrow(props.row)">
<CMyPopupEdit :canEdit="canEdit"
:col="col"
:row.sync="props.row"
:field="col.field"
:subfield="col.subfield"
@save="SaveValue"
@show="selItem(props.row, col)"
@showandsave="showandsel">
</CMyPopupEdit>
</CMyPopupEdit>
</div>
</q-td>
<q-td v-for="col in mycolumns" :key="col.name" :props="props" v-if="colExtra.includes(col.name)">
<div v-if="col.action && visCol(col)">
@@ -119,6 +124,38 @@
-->
<!---->
</q-table>
<div v-if="rowclicksel">
<CTitleBanner title="Record:"></CTitleBanner>
<div class="q-ma-xs q-pa-xs text-center rounded-borders q-list--bordered"
v-for="mycol in mycolumns" :key="mycol.name"
v-if="colVisib.includes(mycol.field + mycol.subfield)">
<div class="row items-center justify-center q-gutter-md q-ma-xs">
<div class="q-ma-xs">
<q-field rounded outlined bg-color="orange-3" dense>
<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">{{mycol.label}}</div>
</template>
</q-field>
</div>
<div class="q-ma-sm q-pa-sm colmodif col-grow rounded-borders " style="border: 1px solid #bbb"
@click="colclicksel = mycol">
<CMyPopupEdit :canEdit="true"
:col="mycol"
:showall="true"
:row="rowclicksel"
:field="mycol.field"
:subfield="mycol.subfield"
@save="SaveValdb"
@show="selItem(rowclicksel, mycol)"
@showandsave="showandsel">
</CMyPopupEdit>
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" src="./CGridTableRec.ts">