Move Project

This commit is contained in:
Paolo Arena
2019-04-27 20:12:41 +02:00
parent d2cae3cc32
commit 2ba3cd6b3f
11 changed files with 217 additions and 26 deletions

View File

@@ -6,11 +6,13 @@
// Questo è il swSrc
console.log(' [ VER-0.0.27 ] _---------________------ PAO: this is my custom service worker');
console.log(' [ VER-0.0.61 ] _---------________------ PAO: this is my custom service worker');
importScripts('../statics/js/idb.js');
importScripts('../statics/js/storage.js');
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); //++Todo: Replace with local workbox.js
importScripts('../statics/js/workbox-sw.js');
// importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js');
let port = 3000;

View File

@@ -324,7 +324,7 @@ export default class SingleProject extends Vue {
}
// console.log('focus()')
}, 500)
}, 400)
}
public getFocus(e) {
@@ -486,6 +486,12 @@ export default class SingleProject extends Vue {
return await this.enableExpiring()
} else if (action === tools.MenuAction.EDIT) {
this.activeEdit()
} else if (action === tools.MenuAction.CUT) {
const myaction = {
type: tools.MenuAction.CUT,
_id: this.itemproject._id
}
return await Projects.actions.ActionCutPaste(myaction)
} else if (action === 0) {
this.deselectAndExitEdit()
}

View File

@@ -2,6 +2,11 @@ import objectId from '@src/js/objectId'
import { UserStore } from '@store'
import { tools } from '@src/store/Modules/tools'
export interface IAction {
type: number
_id: any
}
export interface IProject {
_id?: any,
userId?: string
@@ -43,6 +48,7 @@ export interface IProjectsState {
projects: IProject[]
insidePending: boolean
visuLastCompleted: number
action: IAction
}
export const Privacy = {

View File

@@ -246,6 +246,7 @@ const messages = {
proj: {
newproj: 'Titolo Progetto',
newsubproj: 'Titolo Sotto-Progetto',
insertbottom: 'Inserisci Nuovo Project',
longdescr: 'Descrizione',
hoursplanned: 'Ore Preventivate',
hoursadded: 'Ore Aggiuntive',
@@ -502,6 +503,7 @@ const messages = {
proj: {
newproj: 'Título Projecto',
newsubproj: 'Título Sub-Projecto',
insertbottom: 'Añadir nuevo Proyecto',
longdescr: 'Descripción',
hoursplanned: 'Horas Estimadas',
hoursadded: 'Horas Adicional',
@@ -758,6 +760,7 @@ const messages = {
proj: {
newproj: 'Project Title',
newsubproj: 'SubProject Title',
insertbottom: 'Insert New Project',
longdescr: 'Description',
hoursplanned: 'Estimated Hours',
hoursadded: 'Additional Hours',

View File

@@ -108,14 +108,22 @@ async function Sync_Execute(cmd, tablesync, nametab, method, item: ITodo, id, ms
cmdSw = DB.CMD_SYNC
}
// console.log('cmdSw', cmdSw)
// if ('serviceWorker' in navigator) {
// console.log('serviceWorker PRESENTE')
// } else {
// console.log('serviceWorker NON PRESENTE !')
// }
if ('serviceWorker' in navigator) {
return await navigator.serviceWorker.ready
.then((sw) => {
// console.log('---------------------- navigator.serviceWorker.ready')
return globalroutines(null, 'write', tablesync, item, id)
.then((id) => {
// console.log('id', id)
.then((ris) => {
console.log('ris write:', ris)
const sep = '|'
const multiparams = cmdSw + sep + tablesync + sep + nametab + sep + method + sep + UserStore.state.x_auth_token + sep + UserStore.state.lang
@@ -145,6 +153,9 @@ async function Sync_Execute(cmd, tablesync, nametab, method, item: ITodo, id, ms
console.error('Errore in globalroutines', tablesync, nametab, err)
})
})
.catch((err) => {
console.error('Errore catch in globalroutines write', tablesync, nametab, err)
})
})
}
}
@@ -408,6 +419,7 @@ export async function table_ModifyRecord(nametable, myitem, listFieldsToChange,
tools.notifyarraychanged(miorec)
// 2) Modify on IndexedDb
console.log('// 2) Modify on IndexedDb', miorec)
return globalroutines(null, 'write', nametable, miorec)
.then((ris) => {

View File

@@ -181,15 +181,12 @@ namespace Getters {
addRoute(arrroutes, { route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' }) // HOME
if (!process.env.PROD) {
addRoute(arrroutes, {
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
routes2: lista,
level_parent: 0.5,
level_child: 0.5
})
}
addRoute(arrroutes, {
route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo',
routes2: lista,
level_parent: 0.5,
level_child: 0.5
})
const myarrproj = []
for (const myitem of listaprojectMenu) {

View File

@@ -1,4 +1,4 @@
import { IProject, IProjectsState, IDrag, IMenuList } from 'model'
import { IProject, IProjectsState, IDrag, IMenuList, IAction } from 'model'
import { Privacy } from '@src/model'
import { storeBuilder } from './Store/Store'
@@ -18,7 +18,11 @@ const stateglob: IProjectsState = {
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
projects: [],
insidePending: false,
visuLastCompleted: 10
visuLastCompleted: 10,
action: {
type: 0,
_id: ''
}
}
const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'statusproj',
@@ -94,7 +98,7 @@ namespace Getters {
begin_development: tools.getDateNull(),
begin_test: tools.getDateNull(),
hoursweeky_plannedtowork: 0,
endwork_estimate: tools.getDateNull()
endwork_estimate: tools.getDateNull(),
}
return obj
@@ -240,10 +244,23 @@ namespace Mutations {
ApiTables.removeitemfromarray(state.projects, ind)
}
async function movemyitem(state: IProjectsState, { myitemorig, myitemdest } ) {
const indorig = tools.getIndexById(state.projects, myitemorig._id)
// console.log('myitemorig', myitemorig, 'indorig', indorig)
// console.log('myitemdest', myitemdest)
state.projects.splice(indorig, 1)
state.projects.push(myitemdest)
await Actions.actions.modify({ myitem: myitemdest, field: 'id_parent' })
}
export const mutations = {
deletemyitem: b.commit(deletemyitem),
createNewItem: b.commit(createNewItem),
updateProject: b.commit(updateProject)
updateProject: b.commit(updateProject),
movemyitem: b.commit(movemyitem)
}
}
@@ -380,12 +397,43 @@ namespace Actions {
}
async function ActionCutPaste(context, action: IAction) {
if (action.type === tools.MenuAction.CUT)
stateglob.action = action
else if (action.type === tools.MenuAction.PASTE) {
if (stateglob.action.type === tools.MenuAction.CUT) {
// Change id_parent
const orig_obj = Getters.getters.getRecordById(stateglob.action._id)
const dest = Getters.getters.getRecordById(action._id)
// console.log('dest', dest)
const dest_obj = tools.jsonCopy(orig_obj)
if (!!dest_obj) {
dest_obj.id_parent = dest._id
dest_obj.id_main_project = dest.id_main_project
dest_obj.modified = true
dest_obj.id_prev = null
await Mutations.mutations.movemyitem({ myitemorig: orig_obj, myitemdest: dest_obj })
}
stateglob.action.type = 0
}
}
return true
}
export const actions = {
dbLoad: b.dispatch(dbLoad),
swapElems: b.dispatch(swapElems),
deleteItem: b.dispatch(deleteItem),
dbInsert: b.dispatch(dbInsert),
modify: b.dispatch(modify)
modify: b.dispatch(modify),
ActionCutPaste: b.dispatch(ActionCutPaste)
}
}

View File

@@ -61,6 +61,8 @@ export const tools = {
},
MenuAction: {
CUT: 71,
PASTE: 72,
DELETE: 100,
TOGGLE_EXPIRING: 101,
COMPLETED: 110,
@@ -480,6 +482,12 @@ export const tools = {
menuPopupProj: {
it: [
{
id: 5,
label: 'Taglia',
value: 71, // CUT
icon: 'undo'
},
{
id: 10,
label: 'Modifica',
@@ -503,6 +511,12 @@ export const tools = {
],
es:
[
{
id: 5,
label: 'Cortar',
value: 71, // CUT
icon: 'undo'
},
{
id: 10,
label: 'Editar',
@@ -526,6 +540,12 @@ export const tools = {
],
enUs:
[
{
id: 5,
label: 'Cut',
value: 71, // CUT
icon: 'undo'
},
{
id: 10,
label: 'Edit',
@@ -582,14 +602,23 @@ export const tools = {
menuPopupConfigProject: {
it: [
{
id: 3,
disable: false,
label: translation.it.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
disable: false,
label: translation.it.proj.newsubproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
},
{
id: 10,
disable: false,
label: translation.it.task.showtask,
value: 150, // SHOW_TASK
icon: 'rowing'
@@ -597,14 +626,23 @@ export const tools = {
],
es:
[
{
id: 3,
disable: false,
label: translation.es.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
disable: false,
label: translation.es.proj.newsubproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
},
{
id: 10,
disable: false,
label: translation.es.task.showtask,
value: 150,
icon: 'rowing'
@@ -612,14 +650,23 @@ export const tools = {
],
enUs:
[
{
id: 3,
disable: false,
label: translation.enUs.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
label: translation.it.proj.newsubproj,
disable: false,
label: translation.enUs.proj.newsubproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
},
{
id: 10,
disable: false,
label: translation.enUs.task.showtask,
value: 150,
icon: 'rowing'
@@ -629,8 +676,16 @@ export const tools = {
menuPopupConfigMAINProject: {
it: [
{
id: 3,
disable: false,
label: translation.it.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
disable: false,
label: translation.it.proj.newproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
@@ -638,8 +693,16 @@ export const tools = {
],
es:
[
{
id: 3,
disable: false,
label: translation.es.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
disable: false,
label: translation.es.proj.newproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
@@ -647,9 +710,17 @@ export const tools = {
],
enUs:
[
{
id: 3,
disable: false,
label: translation.enUs.action.paste,
value: 72, // Action.PASTE
icon: 'file_copy'
},
{
id: 5,
label: translation.it.proj.newproj,
disable: false,
label: translation.enUs.proj.newproj,
value: 200, // ADD_PROJECT
icon: 'next_week'
}
@@ -660,6 +731,7 @@ export const tools = {
it: [
{
id: 10,
disable: false,
label: 'Mostra gli ultimi N completati',
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
icon: 'rowing',
@@ -667,6 +739,7 @@ export const tools = {
},
{
id: 20,
disable: false,
label: 'Compiti da Completare',
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
icon: 'rowing',
@@ -674,6 +747,7 @@ export const tools = {
},
{
id: 30,
disable: false,
label: 'Tutti i compiti',
value: costanti.ShowTypeTask.SHOW_ALL,
icon: 'check_circle',
@@ -684,6 +758,7 @@ export const tools = {
[
{
id: 10,
disable: false,
label: 'Mostrar los ultimos N completados',
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
icon: 'rowing',
@@ -691,6 +766,7 @@ export const tools = {
},
{
id: 20,
disable: false,
label: 'Tareas para completar',
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
icon: 'rowing',
@@ -698,6 +774,7 @@ export const tools = {
},
{
id: 30,
disable: false,
label: 'Todos las Tareas',
value: costanti.ShowTypeTask.SHOW_ALL,
icon: 'check_circle',
@@ -708,6 +785,7 @@ export const tools = {
[
{
id: 10,
disable: false,
label: 'Show last N Completed',
value: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
icon: 'rowing',
@@ -715,6 +793,7 @@ export const tools = {
},
{
id: 20,
disable: false,
label: 'Task to complete',
value: costanti.ShowTypeTask.SHOW_ONLY_TOCOMPLETE,
icon: 'rowing',
@@ -722,6 +801,7 @@ export const tools = {
},
{
id: 30,
disable: false,
label: 'All Tasks',
value: costanti.ShowTypeTask.SHOW_ALL,
icon: 'check_circle',
@@ -1405,6 +1485,6 @@ export const tools = {
lista.push(item)
}
return lista
}
},
}

View File

@@ -14,6 +14,9 @@ export const translation = {
task: {
showtask: 'Mostra Task',
},
action: {
paste: 'Incolla'
},
end: ''
},
es: {
@@ -31,6 +34,9 @@ export const translation = {
task: {
showtask: 'Mostrar Tarea',
},
action: {
paste: 'Pegar'
},
end: ''
},
enUs: {
@@ -48,6 +54,9 @@ export const translation = {
task: {
showtask: 'Show Task',
},
action: {
paste: 'Paste'
},
end: ''
}
}

View File

@@ -1,7 +1,7 @@
import Vue from 'vue'
import { Component, Watch } from 'vue-property-decorator'
import { IDrag, IProject, IProjectsState, ITodo, Privacy, TypeProj } from '../../../model/index'
import { IAction, IDrag, IProject, IProjectsState, ITodo, Privacy, TypeProj } from '../../../model/index'
import { SingleProject } from '../../../components/projects/SingleProject/index'
import { CTodo } from '../../../components/todos/CTodo'
@@ -164,10 +164,16 @@ export default class ProjList extends Vue {
}
get menuPopupConfigProject() {
let mymenu = null
if (this.isMainProject)
return tools.menuPopupConfigMAINProject[UserStore.state.lang]
mymenu = tools.menuPopupConfigMAINProject[UserStore.state.lang]
else
return tools.menuPopupConfigProject[UserStore.state.lang]
mymenu = tools.menuPopupConfigProject[UserStore.state.lang]
if (mymenu.length > 0)
mymenu[0].disable = !(Projects.state.action.type === tools.MenuAction.CUT)
return mymenu
}
get listOptionShowTask() {
@@ -370,6 +376,14 @@ export default class ProjList extends Vue {
// @ts-ignore
elem.activeEdit()
// console.log('idnewelem', idnewelem, 'Elem Trovato', elem)
} else if (action === tools.MenuAction.PASTE) {
const myaction: IAction = {
type: tools.MenuAction.PASTE,
_id: this.itemselproj._id
}
return await Projects.actions.ActionCutPaste(myaction)
}
}

View File

@@ -61,7 +61,7 @@
</q-list>
</q-menu>
</q-item>
<q-item v-else v-close-popup clickable :icon="field.icon"
<q-item v-else v-close-popup clickable :icon="field.icon" :disable="field.disable"
@click="clickMenuProjList(field.value)">
<q-item-section avatar>
@@ -100,6 +100,20 @@
</div>
<q-separator></q-separator>
<q-input v-if="CanIModifyPanelPrivacy" ref="insertProjBottom" v-model="projbottom"
style="margin-left: 6px;"
color="blue-12"
:label="$t('proj.insertbottom')"
:after="[{icon: 'arrow_forward', content: true, handler () {}}]"
v-on:keyup.enter="dbInsert(false)">
</q-input>
<br>
<q-separator></q-separator>
<!--CanIModifyPanelPrivacy = {{CanIModifyPanelPrivacy}}<br>-->
<!--CanIModifyPanelPrivacySel = {{CanIModifyPanelPrivacySel}}<br>-->
<!--CanISeeProject = {{CanISeeProject}}<br>-->