- adding Progress %

This commit is contained in:
Paolo Arena
2019-01-29 00:48:04 +01:00
parent e087bdcef5
commit 0225f27535
9 changed files with 131 additions and 13 deletions

View File

@@ -150,6 +150,8 @@ module.exports = function (ctx) {
'QSlideTransition', 'QSlideTransition',
'QTable', 'QTable',
'QContextMenu', 'QContextMenu',
'QProgress',
'QSlider',
], ],
directives: [ directives: [
'Ripple', 'Ripple',

View File

@@ -42,7 +42,10 @@
.pos-item { .pos-item {
max-width: 24px; max-width: 24px;
min-width: 24px; min-width: 24px;
margin: 0 auto; margin-left: 1px;
margin-right: 1px;
padding-left: 1px;
padding-right: 1px;
height: 36px; height: 36px;
line-height: 36px; line-height: 36px;
text-align: center; text-align: center;
@@ -122,6 +125,38 @@
min-width: 24px; min-width: 24px;
} }
.progress-item {
max-width: 32px;
min-width: 24px;
flex: 1;
order: 2;
text-align: right;
}
.percProgress {
height: 24px;
line-height: 24px;
color: #888;
}
.menuProgress {
width:50px;
}
.colProgress {
}
.lowperc {
color: red;
}
.medperc {
color: blue;
}
.highperc {
color: green;
}
.myexpired { .myexpired {
padding-top: 0px; padding-top: 0px;
padding-bottom: 0px; padding-bottom: 0px;

View File

@@ -27,6 +27,9 @@ export default class SingleTodo extends Vue {
public sel: boolean = false public sel: boolean = false
public inEdit: boolean = false public inEdit: boolean = false
public precDescr: string = '' public precDescr: string = ''
public menuProgress: string = 'menuprogress'
public percProgress: string = 'percProgress'
public colProgress: string = 'blue'
$q: any $q: any
@Prop({ required: true }) itemtodo: ITodo @Prop({ required: true }) itemtodo: ITodo
@@ -48,10 +51,15 @@ export default class SingleTodo extends Vue {
this.watchupdate() this.watchupdate()
} }
@Watch('itemtodo.descr') valueChanged5() { @Watch('itemtodo.descr') valueChanged5() {
this.precDescr = this.itemtodo.descr this.precDescr = this.itemtodo.descr
} }
@Watch('itemtodo.progress') valueChanged6() {
this.updateClasses()
}
isTodo() { isTodo() {
return this.isTodoByElem(this.itemtodo) return this.isTodoByElem(this.itemtodo)
} }
@@ -82,6 +90,23 @@ export default class SingleTodo extends Vue {
this.classExpiringEx += ' status_completed' this.classExpiringEx += ' status_completed'
} }
this.menuProgress = 'menuProgress'
this.percProgress = 'percProgress'
let mycolcl = ''
if (this.itemtodo.progress < 33) {
mycolcl = ' lowperc'
} else if (this.itemtodo.progress < 66) {
mycolcl = ' medperc'
} else {
mycolcl = ' highperc'
}
this.colProgress = mycolcl
this.menuProgress += mycolcl
this.percProgress += mycolcl
// if (this.inEdit) { // if (this.inEdit) {
// this.classDescr += ' hide' // this.classDescr += ' hide'
// this.classDescrEdit += ' show' // this.classDescrEdit += ' show'
@@ -293,4 +318,11 @@ export default class SingleTodo extends Vue {
// this.$q.notify('setPriority: ' + elem) // this.$q.notify('setPriority: ' + elem)
} }
getPercentageProgress() {
if (this.itemtodo.completed)
return 100
else
return this.itemtodo.progress
}
} }

View File

@@ -1,5 +1,5 @@
<template> <template>
<div :class="getClassRow()" > <div :class="getClassRow()">
<q-context-menu> <q-context-menu>
<q-list link separator no-border class="todo-menu"> <q-list link separator no-border class="todo-menu">
<q-item v-for="field in menuPopupTodo" :key="field.value" <q-item v-for="field in menuPopupTodo" :key="field.value"
@@ -16,6 +16,16 @@
<q-item-side v-if="field.value === 110"> <q-item-side v-if="field.value === 110">
<q-checkbox v-model="itemtodo.completed"/> <q-checkbox v-model="itemtodo.completed"/>
</q-item-side> </q-item-side>
<q-item-side v-if="field.value === 120">
<q-slider :class="menuProgress" v-model="itemtodo.progress" :min="0" :max="100"/>
</q-item-side>
<q-item-side v-if="field.value === 120">
<div :class="percProgress">
{{getPercentageProgress()}}%
</div>
</q-item-side>
</q-item> </q-item>
</q-list> </q-list>
</q-context-menu> </q-context-menu>
@@ -41,6 +51,14 @@
<q-item-side v-if="field.value === 110"> <q-item-side v-if="field.value === 110">
<q-checkbox v-model="itemtodo.completed"/> <q-checkbox v-model="itemtodo.completed"/>
</q-item-side> </q-item-side>
<q-item-side v-if="field.value === 120">
<q-slider :class="menuProgress" v-model="itemtodo.progress" :min="0" :max="100"/>
</q-item-side>
<q-item-side v-if="field.value === 120">
<div :class="percProgress">
{{getPercentageProgress()}}%
</div>
</q-item-side>
</q-item> </q-item>
</q-list> </q-list>
</q-popover> </q-popover>
@@ -87,16 +105,29 @@
<!--:after="[{icon: 'arrow_forward', content: true, handler () {}}]"--> <!--:after="[{icon: 'arrow_forward', content: true, handler () {}}]"-->
<!--<div :class="classDescr" @mousedown.left="editTodo()">--> <!--<div :class="classDescr" @mousedown.left="editTodo()">-->
<!--<q-field>{{ itemtodo.descr }}</q-field>--> <!--<q-field>{{ itemtodo.descr }}</q-field>-->
<!--</div>--> <!--</div>-->
<div v-if="isTodo()" class="flex-item progress-item">
<q-progress
:percentage="getPercentageProgress()"
class="progress-item"
:color="colProgress"
>
</q-progress>
<div :class="percProgress">
{{getPercentageProgress()}}%
</div>
</div>
<div v-if="itemtodo.enableExpiring"> <div v-if="itemtodo.enableExpiring">
<div :class="classExpiring"> <div :class="classExpiring">
<q-datetime <q-datetime
:class="classExpiringEx" :class="classExpiringEx"
v-model="itemtodo.expiring_at" v-model="itemtodo.expiring_at"
class="myexpired"/> class="myexpired">
</q-datetime>
</div> </div>
</div> </div>
<!--<div class="flex-item btn-item">--> <!--<div class="flex-item btn-item">-->

View File

@@ -263,7 +263,8 @@ export default class Todo extends Vue {
id_prev: 0, id_prev: 0,
id_next: 0, id_next: 0,
pos: 0, pos: 0,
modified: true modified: true,
progress: 0
} }
return objtodo return objtodo
@@ -546,6 +547,8 @@ export default class Todo extends Vue {
this.modifyField(miorec, myobj, 'id_next') this.modifyField(miorec, myobj, 'id_next')
this.modifyField(miorec, myobj, 'pos') this.modifyField(miorec, myobj, 'pos')
this.modifyField(miorec, myobj, 'enableExpiring') this.modifyField(miorec, myobj, 'enableExpiring')
this.modifyField(miorec, myobj, 'progress')
if (miorec.modified) { if (miorec.modified) {
miorec.modify_at = new Date() miorec.modify_at = new Date()

View File

@@ -3,10 +3,6 @@
<div class="panel"> <div class="panel">
<p class="caption"></p> <p class="caption"></p>
<q-input ref="insertTask" v-model="todo" inverted :float-label="$t('todo.insert')"
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="insertTodo"/>
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div> <div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
<div class="drag"> <div class="drag">
@@ -31,6 +27,9 @@
</transition-group> </transition-group>
</draggable> </draggable>
</div> </div>
<q-input ref="insertTask" v-model="todo" inverted :float-label="$t('todo.insert')"
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="insertTodo"/>
</div> </div>
</q-page> </q-page>

View File

@@ -11,7 +11,8 @@ export interface ITodo {
id_prev?: number, id_prev?: number,
id_next?: number, id_next?: number,
modified?: boolean, modified?: boolean,
pos?: number pos?: number,
progress?: number
} }
export interface ITodosState { export interface ITodosState {

View File

@@ -9,7 +9,7 @@ export default ({ Vue }) => {
database: 'test', database: 'test',
schemas: [ schemas: [
{ categories: '++id, sub_categ_id, descr_it, campo2bool, campo3bool' }, { categories: '++id, sub_categ_id, descr_it, campo2bool, campo3bool' },
{ todos: '++id, userId, pos, descr, priority, completed, created_at, modify_at, expiring_at' } { todos: '++id, userId, pos, descr, priority, completed, created_at, modify_at, expiring_at, progress, enableExpiring' }
], ],
options: { options: {
todos: { type: 'list', primary: 'pos', label: 'label', updated_at: 'updated_at' }, todos: { type: 'list', primary: 'pos', label: 'label', updated_at: 'updated_at' },

View File

@@ -27,7 +27,8 @@ export const rescodes = {
MenuAction: { MenuAction: {
DELETE: 100, DELETE: 100,
TOGGLE_EXPIRING: 101, TOGGLE_EXPIRING: 101,
COMPLETED: 110 COMPLETED: 110,
PROGRESS_BAR: 120
}, },
@@ -77,6 +78,13 @@ export const rescodes = {
'it': [ 'it': [
{ {
id: 1, id: 1,
label: 'Progressi',
value: 120, // PROGRESS_BAR
icon: 'check_circle',
checked: true
},
{
id: 2,
label: 'Completato', label: 'Completato',
value: 110, // COMPLETED value: 110, // COMPLETED
icon: 'check_circle', icon: 'check_circle',
@@ -100,13 +108,20 @@ export const rescodes = {
'enUk': [ 'enUk': [
{ {
id: 1, id: 1,
label: 'Progress',
value: 120, // PROGRESS_BAR
icon: 'check_circle',
checked: true
},
{
id: 2,
label: 'Completed', label: 'Completed',
value: 110, // COMPLETED value: 110, // COMPLETED
icon: 'check_circle', icon: 'check_circle',
checked: true checked: true
}, },
{ {
id: 2, id: 3,
label: 'Set Expiring', label: 'Set Expiring',
value: 101, // TOGGLE_EXPIRING value: 101, // TOGGLE_EXPIRING
icon: 'date_range', icon: 'date_range',