Fix: first elem added not working...

This commit is contained in:
Paolo Arena
2019-03-04 18:48:07 +01:00
parent 9803c451f9
commit a63f744869
10 changed files with 76 additions and 44 deletions

View File

@@ -128,6 +128,7 @@ const messages = {
confirmed: 'Notifiche Attivate!',
denied: 'Notifiche Disabilitate! Attenzione così non vedrai arrivarti i messaggi. Riabilitali per vederli.',
titlegranted: 'Permesso Notifiche Abilitato!',
statusnot: 'Stato Notifiche',
titledenied: 'Permesso Notifiche Disabilitato!',
title_subscribed: 'Sottoscrizione a FreePlanet.app!',
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.',
@@ -264,6 +265,7 @@ const messages = {
confirmed: 'Notificaciones activadas!',
denied: 'Notificaciones deshabilitadas! Ten cuidado, así no verás llegar los mensajes. Rehabilítalos para verlos.',
titlegranted: 'Notificaciones permitidas habilitadas!',
statusnot: 'Estado Notificaciones',
titledenied: 'Notificaciones permitidas deshabilitadas!',
title_subscribed: 'Suscripción a FreePlanet.app!',
subscribed: 'Ahora puedes recibir mensajes y notificaciones.',
@@ -400,6 +402,7 @@ const messages = {
confirmed: 'Notifications Enabled!',
denied: 'Notifications Disabled! Attention, you will not see your messages incoming. Reenable it for see it',
titlegranted: 'Notification Permission Granted!',
statusnot: 'status Notification',
titledenied: 'Notification Permission Denied!',
title_subscribed: 'Subscribed to FreePlanet.app!',
subscribed: 'You can now receive Notification and Messages.',

View File

@@ -125,7 +125,7 @@ $heightdescr: 20px;
// animation: none;
//}
.pos-item:hover, .pos-item-popover:hover {
.pos-item:hover, .pos-item-popover_cursor:hover {
cursor: grab;
}

View File

@@ -142,6 +142,11 @@ export default class SingleTodo extends Vue {
this.clButtPopover = this.sel ? 'pos-item-popover comp_selected' : 'pos-item-popover'
if (!this.itemtodo.completed) {
this.clButtPopover += ' pos-item-popover_cursor'
}
// if (this.inEdit) {
// this.classDescr += ' hide'
@@ -245,8 +250,6 @@ export default class SingleTodo extends Vue {
this.faiFocus('inputdescr')
}
// console.log('FINE - editTodo')
}

View File

@@ -1,6 +1,6 @@
.flex-container{
background-color: rgb(250, 250, 250);
padding: 5px;
padding: 2px;
display: flex;
align-items: center;
flex-direction: row;

View File

@@ -15,6 +15,8 @@ import { Getter, State, Mutation } from 'vuex-class'
import { costanti } from '@src/store/Modules/costanti'
const namespace: string = 'Todos'
import globalroutines from './../../../globalroutines/index'
@Component({
@@ -44,6 +46,7 @@ export default class Todo extends Vue {
public service: any
public actualMaxPosition: number = 15
public scrollable = true
public tmpstrTodos: string = ''
public categoryAtt: string = ''
// public showtype: number = Todos.state.showtype
@@ -502,5 +505,36 @@ export default class Todo extends Vue {
}
getArrTodos() {
let mystr = ''
let mythis = this
mythis.tmpstrTodos = ''
return globalroutines(null, 'readall', 'todos', null)
.then(function (alldata) {
const myrecs = [...alldata]
myrecs.forEach(rec => {
mystr = mystr + rec.descr + rec.completed + '] ['
})
mythis.tmpstrTodos = 'TODOS: ' + mystr
})
}
// setArrTodos() {
//
// let mystr = ''
// let mythis = this
//
// mythis.tmpstrTodos = ''
// return globalroutines(null, 'write', 'todos', this.todos_arr[0])
// .then(function (alldata) {
// mythis.getArrTodos()
// })
// }
//
}

View File

@@ -1,9 +1,6 @@
<template>
<q-page>
<div class="panel">
<p class="caption"></p>
showtype = {{showtype}}
<div class="divtitlecat">
<div class="flex-container">
<div class="flex-item categorytitle">{{categoryAtt | capitalize}}</div>
@@ -29,17 +26,6 @@
<q-item-main v-else>
<q-item-tile label class="item-menu">{{field.label}}</q-item-tile>
</q-item-main>
<!--<q-item-side>-->
<!--<div>-->
<!--<q-input v-model="itemtodo.progress"-->
<!--class="menuInputCompleted"-->
<!--type="number"-->
<!--suffix=""-->
<!--@change="val => { model = val }"-->
<!--&gt;-->
<!--</div>-->
<!--</q-item-side>-->
</q-item>
</div>
</q-list>
@@ -55,13 +41,6 @@
<div style="display: none">{{ prior = 0, priorcomplet = false }}</div>
<div>
<!--<draggable v-model="todos_arr" :options="{draggable:'.myitemdrag'}"-->
<!--@start="onStart" @end="onEnd" class="dragArea">-->
<!--<transition-group :name="mytypetransgroup">-->
<!--<div :id="getmyid(mytodo._id)" v-for="(mytodo, index) in todos_arr" :key="mytodo._id" class="myitemdrag"-->
<!--draggable="true" @dragstart="dragStart(index, $event)" @dragover.prevent @dragenter="dragEnter(index)"-->
<!--@dragleave="dragLeave(index)" @dragend="dragEnd" @drop="dragFinish(index, $event)" >-->
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
<div class="container" v-dragula="todos_dacompletare(categoryAtt)" drake="first">
<div :id="getmyid(mytodo._id)" :index="index"
@@ -89,7 +68,7 @@
</div>
<!--<q-infinite-scroll :handler="loadMoreTodo" :offset="7">-->
<div class="container" v-dragula="todos_completati(categoryAtt)" drake="second">
<div class="container">
<div :id="getmyid(mytodo._id)" :index="index"
v-for="(mytodo, index) in todos_completati(categoryAtt)"
:key="mytodo._id" class="myitemdrag">
@@ -105,8 +84,6 @@
</div>
</div>
<!--</q-infinite-scroll>-->
<!--</transition-group>-->
<!--</draggable>-->
</div>
@@ -117,14 +94,16 @@
<br>
<!--
<div class="flex-item btn-item">
<q-btn class="mybtn" round color="" icon="lock" @click="getArrTodos">Get Todo</q-btn>
<q-btn class="mybtn" round color="" icon="person" @click="setArrTodos">Set Todo</q-btn>
<q-btn class="mybtn" round color="" icon="list" @click="reload_fromServer++">Reload</q-btn>
<!--{{ tmpstrTodos }}-->
<!--<div class="flex-item btn-item">-->
<!--<q-btn class="mybtn" round color="" icon="lock" @click="getArrTodos">Get Todo</q-btn>-->
<!--&lt;!&ndash;<q-btn class="mybtn" round color="" icon="person" @click="setArrTodos">Set Todo</q-btn>&ndash;&gt;-->
<!--&lt;!&ndash;<q-btn class="mybtn" round color="" icon="list" @click="reload_fromServer++">Reload</q-btn>&ndash;&gt;-->
<!--</div>-->
<!--&lt;!&ndash;<q-input v-model="testPao" float-label="testPao"/>&ndash;&gt;-->
<!--
<!--&lt;!&ndash;<q-input v-model="testPao" float-label="testPao"/>&ndash;&gt;-->
<!--<q-input v-model="todos_changed" float-label="todos_changed"/>-->
<!--<q-input v-model="reload_fromServer" float-label="reload_fromServer"/>-->
@@ -139,7 +118,7 @@
<!--<q-btn class="mybtn" round color="" icon="lock" @click="clickaggshowtype()"></q-btn>-->
<!--<span style="white-space: pre;">{{ todos_vista }}</span>-->
<span style="white-space: pre;">{{ todos_vista }}</span>
</div>
</q-page>

View File

@@ -37,7 +37,7 @@ export interface IDrag {
export interface ITodosState {
showtype: number
todos: [ITodo[]]
todos: {}
categories: string[]
// todos_changed: number
reload_fromServer: number

View File

@@ -54,7 +54,7 @@
icon="notifications"
class="shadow"
:label="$t('notification.titlegranted')"
helper="Stato Notifiche">
:helper="$t('notification.statusnot')">
</q-field>
<q-field
v-if="NotServiceWorker()"

View File

@@ -246,7 +246,7 @@ namespace Actions {
return
}
console.log('createPushSubscription')
// console.log('createPushSubscription')
let reg
const mykey = process.env.PUBLICKEY_PUSH

View File

@@ -15,7 +15,7 @@ import { costanti } from '@src/store/Modules/costanti'
const state: ITodosState = {
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
todos: [[]],
todos: {},
categories: [],
// todos_changed: 1,
reload_fromServer: 0,
@@ -288,15 +288,19 @@ namespace Mutations {
return -1
}
function createNewItem(state: ITodosState, { objtodo, atfirst, categorySel }) {
const indcat = state.categories.indexOf(categorySel)
let indcat = state.categories.indexOf(categorySel)
if (indcat == -1) {
state.categories.push(categorySel)
indcat = state.categories.indexOf(categorySel)
}
console.log('createNewItem', objtodo, 'cat=', categorySel, 'state.todos[indcat]', state.todos[indcat])
if (state.todos[indcat] === undefined) {
state.todos[indcat] = []
}
if (!state.todos[indcat]) {
state.todos[indcat].push(objtodo)
console.log('state.todos[indcat]', state.todos[indcat])
console.log('push state.todos[indcat]', state.todos)
return
}
if (atfirst)
@@ -796,19 +800,25 @@ namespace Actions {
async function swapElems(context, itemdragend: IDrag) {
// console.log('swapElems', itemdragend)
console.log('swapElems', itemdragend)
console.log('state.todos', state.todos)
console.log('state.categories', state.categories)
const cat = itemdragend.category
const indcat = state.categories.indexOf(cat)
if (itemdragend.field === 'priority') {
// get last elem priority
console.log('get last elem priority')
itemdragend.newIndex = getLastFirstElemPriority(itemdragend.category, itemdragend.prioritychosen, itemdragend.atfirst, itemdragend.idelemtochange)
itemdragend.oldIndex = getIndexById(itemdragend.category, itemdragend.idelemtochange)
console.log('swapElems PRIORITY', itemdragend)
}
console.log('indcat', indcat)
if (isValidIndex(cat, indcat) && isValidIndex(cat, itemdragend.newIndex) && isValidIndex(cat, itemdragend.oldIndex)) {
console.log('isValidIndex')
state.todos[indcat].splice(itemdragend.newIndex, 0, state.todos[indcat].splice(itemdragend.oldIndex, 1)[0])
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
tools.notifyarraychanged(state.todos[indcat][itemdragend.oldIndex])
@@ -819,18 +829,21 @@ namespace Actions {
if (isValidIndex(cat, precind) && isValidIndex(cat, nextind)) {
if ((state.todos[indcat][precind].priority === state.todos[indcat][nextind].priority) && (state.todos[indcat][precind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
console.log(' 1)')
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][precind].priority
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
}
} else {
if (!isValidIndex(cat, precind)) {
if ((state.todos[indcat][nextind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
console.log(' 2)')
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][nextind].priority
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
}
} else {
if ((state.todos[indcat][precind].priority !== state.todos[indcat][itemdragend.newIndex].priority)) {
console.log(' 3)')
state.todos[indcat][itemdragend.newIndex].priority = state.todos[indcat][precind].priority
tools.notifyarraychanged(state.todos[indcat][itemdragend.newIndex])
}