2019-03-31 14:27:27 +02:00
|
|
|
import { IProject, IProjectsState, IDrag, IMenuList } from 'model'
|
2019-04-20 13:58:58 +02:00
|
|
|
import { Privacy } from '@src/model'
|
2019-03-22 20:51:42 +01:00
|
|
|
import { storeBuilder } from './Store/Store'
|
|
|
|
|
|
|
|
|
|
import Api from '@api'
|
|
|
|
|
import { tools } from './tools'
|
|
|
|
|
import * as ApiTables from './ApiTables'
|
|
|
|
|
import { GlobalStore, UserStore } from '@store'
|
|
|
|
|
import globalroutines from './../../globalroutines/index'
|
|
|
|
|
import objectId from '@src/js/objectId'
|
|
|
|
|
import { costanti } from '@src/store/Modules/costanti'
|
|
|
|
|
|
2019-03-28 12:58:34 +01:00
|
|
|
const nametable = 'projects'
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
// import _ from 'lodash'
|
|
|
|
|
|
2019-04-06 21:02:33 +02:00
|
|
|
const stateglob: IProjectsState = {
|
2019-03-22 20:51:42 +01:00
|
|
|
showtype: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED,
|
2019-03-28 12:58:34 +01:00
|
|
|
projects: [],
|
2019-03-22 20:51:42 +01:00
|
|
|
insidePending: false,
|
|
|
|
|
visuLastCompleted: 10
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 21:07:16 +02:00
|
|
|
const listFieldsToChange: string [] = ['descr', 'longdescr', 'hoursplanned', 'hoursworked', 'id_parent', 'statusproj',
|
|
|
|
|
'category', 'expiring_at', 'priority', 'id_prev', 'pos', 'enableExpiring', 'progressCalc', 'live_url', 'test_url',
|
|
|
|
|
'begin_development', 'begin_test', 'actualphase', 'totalphases', 'hoursweeky_plannedtowork', 'endwork_estimate',
|
|
|
|
|
'privacyread', 'privacywrite', 'id_main_project', 'typeproj']
|
2019-04-07 21:24:10 +02:00
|
|
|
|
|
|
|
|
const listFieldsUpdateCalculation: string [] = ['hoursplanned', 'hoursworked', 'progressCalc', 'endwork_estimate']
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-06 21:02:33 +02:00
|
|
|
const b = storeBuilder.module<IProjectsState>('Projects', stateglob)
|
2019-03-22 20:51:42 +01:00
|
|
|
const stateGetter = b.state()
|
|
|
|
|
|
2019-03-28 12:58:34 +01:00
|
|
|
function getarrByCategory(category: string) {
|
2019-04-06 21:02:33 +02:00
|
|
|
if (!stateglob.projects) {
|
2019-03-22 20:51:42 +01:00
|
|
|
return []
|
|
|
|
|
}
|
2019-04-06 21:02:33 +02:00
|
|
|
return stateglob.projects
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initcat() {
|
2019-04-03 02:48:05 +02:00
|
|
|
const rec = Getters.getters.getRecordEmpty()
|
2019-03-30 02:57:40 +01:00
|
|
|
rec.userId = UserStore.state.userId
|
|
|
|
|
|
|
|
|
|
return rec
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-07 21:24:10 +02:00
|
|
|
function updateDataCalculated(projout, projin) {
|
|
|
|
|
listFieldsUpdateCalculation.forEach((field) => {
|
2019-04-09 21:07:16 +02:00
|
|
|
projout[field] = projin[field]
|
|
|
|
|
})
|
2019-04-07 21:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
function getproj(projects, idproj, miei: boolean) {
|
|
|
|
|
if (miei) {
|
|
|
|
|
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && proj.userId === UserStore.state.userId))
|
|
|
|
|
} else {
|
|
|
|
|
return tools.mapSort(projects.filter((proj) => (proj.id_parent === idproj) && proj.userId !== UserStore.state.userId ))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-22 20:51:42 +01:00
|
|
|
namespace Getters {
|
2019-03-30 02:57:40 +01:00
|
|
|
const getRecordEmpty = b.read((state: IProjectsState) => (): IProject => {
|
2019-04-05 16:16:29 +02:00
|
|
|
// const tomorrow = tools.getDateNow()
|
2019-03-30 02:57:40 +01:00
|
|
|
// tomorrow.setDate(tomorrow.getDate() + 1)
|
|
|
|
|
|
|
|
|
|
const obj: IProject = {
|
|
|
|
|
_id: objectId(),
|
|
|
|
|
descr: '',
|
2019-04-02 00:18:01 +02:00
|
|
|
longdescr: '',
|
2019-04-09 21:07:16 +02:00
|
|
|
typeproj: 0,
|
2019-03-30 02:57:40 +01:00
|
|
|
id_parent: '',
|
2019-04-09 21:07:16 +02:00
|
|
|
id_main_project: '',
|
2019-03-30 02:57:40 +01:00
|
|
|
priority: tools.Priority.PRIORITY_NORMAL,
|
2019-04-06 21:52:27 +02:00
|
|
|
statusproj: tools.Status.OPENED,
|
2019-04-05 16:16:29 +02:00
|
|
|
created_at: tools.getDateNow(),
|
|
|
|
|
modify_at: tools.getDateNow(),
|
|
|
|
|
completed_at: tools.getDateNull(),
|
2019-03-30 02:57:40 +01:00
|
|
|
category: '',
|
|
|
|
|
// expiring_at: tomorrow,
|
|
|
|
|
enableExpiring: false,
|
|
|
|
|
id_prev: '',
|
|
|
|
|
pos: 0,
|
|
|
|
|
modified: false,
|
2019-04-02 00:18:01 +02:00
|
|
|
live_url: '',
|
|
|
|
|
test_url: '',
|
2019-04-07 21:24:10 +02:00
|
|
|
totalphases: 1,
|
|
|
|
|
actualphase: 1,
|
|
|
|
|
hoursworked: 0,
|
|
|
|
|
hoursplanned: 0,
|
2019-04-05 16:16:29 +02:00
|
|
|
progressCalc: 0,
|
2019-04-20 13:58:58 +02:00
|
|
|
privacyread: 'onlyme',
|
|
|
|
|
privacywrite: 'onlyme',
|
2019-04-05 16:16:29 +02:00
|
|
|
begin_development: tools.getDateNull(),
|
2019-04-07 21:24:10 +02:00
|
|
|
begin_test: tools.getDateNull(),
|
|
|
|
|
hoursweeky_plannedtowork: 0,
|
|
|
|
|
endwork_estimate: tools.getDateNull()
|
2019-03-30 02:57:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj
|
|
|
|
|
}, 'getRecordEmpty')
|
|
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
const projs_dacompletare = b.read((state: IProjectsState) => (id_parent: string, miei: boolean): IProject[] => {
|
|
|
|
|
// console.log('projs_dacompletare', miei)
|
2019-03-28 12:58:34 +01:00
|
|
|
if (state.projects) {
|
2019-04-02 00:18:01 +02:00
|
|
|
// console.log('state.projects', state.projects)
|
2019-04-22 01:43:53 +02:00
|
|
|
return getproj(state.projects, id_parent, miei)
|
2019-03-22 20:51:42 +01:00
|
|
|
} else {
|
|
|
|
|
return []
|
|
|
|
|
}
|
2019-04-22 01:43:53 +02:00
|
|
|
}, 'projs_dacompletare')
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
const listaprojects = b.read((state: IProjectsState) => (miei: boolean): IMenuList[] => {
|
2019-03-31 14:27:27 +02:00
|
|
|
if (state.projects) {
|
2019-04-13 03:04:40 +02:00
|
|
|
// console.log('state.projects', state.projects)
|
2019-04-22 01:43:53 +02:00
|
|
|
const listaproj = getproj(state.projects, process.env.PROJECT_ID_MAIN, miei)
|
2019-03-31 14:27:27 +02:00
|
|
|
const myarr: IMenuList[] = []
|
|
|
|
|
for (const proj of listaproj) {
|
2019-04-07 21:24:10 +02:00
|
|
|
myarr.push({ nametranslate: '', description: proj.descr, idelem: proj._id })
|
2019-03-31 14:27:27 +02:00
|
|
|
}
|
2019-04-09 21:07:16 +02:00
|
|
|
console.log(' myarr', myarr, listaproj)
|
2019-03-31 14:27:27 +02:00
|
|
|
return myarr
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
}, 'listaprojects')
|
|
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
const getDescrById = b.read((state: IProjectsState) => (id: string): string => {
|
2019-04-06 21:02:33 +02:00
|
|
|
if (id === process.env.PROJECT_ID_MAIN)
|
2019-03-30 02:57:40 +01:00
|
|
|
return 'Projects'
|
2019-03-28 12:58:34 +01:00
|
|
|
if (state.projects) {
|
2019-04-06 21:02:33 +02:00
|
|
|
const itemtrov = state.projects.find((item) => item._id === id)
|
|
|
|
|
if (!!itemtrov)
|
|
|
|
|
return itemtrov.descr
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
return ''
|
|
|
|
|
}, 'getDescrById')
|
|
|
|
|
|
|
|
|
|
const getRecordById = b.read((state: IProjectsState) => (id: string): IProject => {
|
|
|
|
|
if (state.projects) {
|
|
|
|
|
return state.projects.find((item) => item._id === id)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
2019-03-30 02:57:40 +01:00
|
|
|
return null
|
|
|
|
|
}, 'getRecordById')
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-20 13:58:58 +02:00
|
|
|
const getifCanISeeProj = b.read((state: IProjectsState) => (proj: IProject): boolean => {
|
2019-04-22 01:43:53 +02:00
|
|
|
if (proj === undefined)
|
2019-04-20 13:58:58 +02:00
|
|
|
return false
|
|
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
if (!!UserStore.state) {
|
2019-04-20 13:58:58 +02:00
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
if (UserStore.state.userId === proj.userId) // If it's the owner
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
return (proj.privacyread === Privacy.all) ||
|
|
|
|
|
(proj.privacyread === Privacy.friends) && (UserStore.getters.IsMyFriend(proj.userId))
|
|
|
|
|
|| ((proj.privacyread === Privacy.mygroup) && (UserStore.getters.IsMyGroup(proj.userId)))
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2019-04-20 13:58:58 +02:00
|
|
|
|
|
|
|
|
}, 'getifCanISeeProj')
|
|
|
|
|
|
|
|
|
|
const CanIModifyPanelPrivacy = b.read((state: IProjectsState) => (proj: IProject): boolean => {
|
2019-04-22 01:43:53 +02:00
|
|
|
if (proj === undefined)
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
if (!!UserStore) {
|
|
|
|
|
if (!!UserStore.state)
|
|
|
|
|
return ((UserStore.state.userId === proj.userId) || (proj.privacywrite === Privacy.all)) // If it's the owner
|
|
|
|
|
else
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return false
|
2019-04-20 13:58:58 +02:00
|
|
|
}, 'CanIModifyPanelPrivacy')
|
|
|
|
|
|
2019-03-22 20:51:42 +01:00
|
|
|
export const getters = {
|
2019-04-20 13:58:58 +02:00
|
|
|
get getifCanISeeProj() {
|
|
|
|
|
return getifCanISeeProj()
|
|
|
|
|
},
|
|
|
|
|
get CanIModifyPanelPrivacy() {
|
|
|
|
|
return CanIModifyPanelPrivacy()
|
|
|
|
|
},
|
2019-03-30 02:57:40 +01:00
|
|
|
get getRecordEmpty() {
|
|
|
|
|
return getRecordEmpty()
|
|
|
|
|
},
|
2019-04-22 01:43:53 +02:00
|
|
|
get projs_dacompletare() {
|
|
|
|
|
return projs_dacompletare()
|
2019-03-22 20:51:42 +01:00
|
|
|
},
|
2019-03-31 14:27:27 +02:00
|
|
|
get listaprojects() {
|
|
|
|
|
return listaprojects()
|
|
|
|
|
},
|
2019-03-30 02:57:40 +01:00
|
|
|
get getDescrById() {
|
|
|
|
|
return getDescrById()
|
2019-03-22 20:51:42 +01:00
|
|
|
},
|
2019-03-30 02:57:40 +01:00
|
|
|
get getRecordById() {
|
|
|
|
|
return getRecordById()
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Mutations {
|
|
|
|
|
|
|
|
|
|
function createNewItem(state: IProjectsState, { objproj, atfirst, categorySel }) {
|
2019-04-02 00:18:01 +02:00
|
|
|
// console.log('createNewItem', objproj, 'cat=', categorySel, 'state.projects', state.projects)
|
2019-03-28 12:58:34 +01:00
|
|
|
if (state.projects === undefined) {
|
|
|
|
|
state.projects = []
|
|
|
|
|
state.projects.push(objproj)
|
|
|
|
|
console.log('push state.projects', state.projects)
|
2019-03-22 20:51:42 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (atfirst) {
|
2019-03-28 12:58:34 +01:00
|
|
|
state.projects.unshift(objproj)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-03-28 12:58:34 +01:00
|
|
|
state.projects.push(objproj)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
2019-04-07 21:24:10 +02:00
|
|
|
}
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-07 21:24:10 +02:00
|
|
|
function updateProject(state: IProjectsState, { objproj }) {
|
|
|
|
|
if (!!objproj) {
|
|
|
|
|
console.log('updateProject', objproj)
|
|
|
|
|
const index = tools.getIndexById(state.projects, objproj._id)
|
|
|
|
|
console.log('index', index)
|
|
|
|
|
if (index >= 0) {
|
|
|
|
|
updateDataCalculated(state.projects[index], objproj)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-07 21:24:10 +02:00
|
|
|
// state.projects.splice(index, 1, objproj)
|
|
|
|
|
// tools.notifyarraychanged(state.projects)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deletemyitem(state: IProjectsState, myitem: IProject) {
|
|
|
|
|
// Find record
|
2019-03-28 12:58:34 +01:00
|
|
|
const ind = tools.getIndexById(state.projects, myitem._id)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-03-28 12:58:34 +01:00
|
|
|
ApiTables.removeitemfromarray(state.projects, ind)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const mutations = {
|
|
|
|
|
deletemyitem: b.commit(deletemyitem),
|
2019-04-07 21:24:10 +02:00
|
|
|
createNewItem: b.commit(createNewItem),
|
|
|
|
|
updateProject: b.commit(updateProject)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Actions {
|
|
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
async function dbLoad(context, { checkPending, onlyiffirsttime }) {
|
|
|
|
|
|
|
|
|
|
if (onlyiffirsttime) {
|
2019-04-06 21:02:33 +02:00
|
|
|
if (stateglob.projects.length > 0) {
|
2019-03-30 02:57:40 +01:00
|
|
|
// if already set, then exit.
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-13 03:04:40 +02:00
|
|
|
// if (UserStore.state.userId === '') {
|
|
|
|
|
// return false // Login not made
|
|
|
|
|
// }
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
console.log('dbLoad', nametable, checkPending, 'userid=', UserStore.state.userId)
|
|
|
|
|
|
2019-03-22 20:51:42 +01:00
|
|
|
const ris = await Api.SendReq('/projects/' + UserStore.state.userId, 'GET', null)
|
|
|
|
|
.then((res) => {
|
2019-03-28 12:58:34 +01:00
|
|
|
if (res.data.projects) { // console.log('RISULTANTE CATEGORIES DAL SERVER = ', res.data.categories)
|
2019-04-06 21:02:33 +02:00
|
|
|
stateglob.projects = res.data.projects
|
2019-03-22 20:51:42 +01:00
|
|
|
} else {
|
2019-04-06 21:02:33 +02:00
|
|
|
stateglob.projects = []
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-06 21:02:33 +02:00
|
|
|
stateglob.showtype = parseInt(GlobalStore.getters.getConfigStringbyId({
|
2019-03-22 20:51:42 +01:00
|
|
|
id: costanti.CONFIG_ID_SHOW_TYPE_TODOS,
|
|
|
|
|
default: costanti.ShowTypeTask.SHOW_LAST_N_COMPLETED
|
|
|
|
|
}), 10)
|
|
|
|
|
|
|
|
|
|
if (process.env.DEBUG === '1') {
|
2019-04-06 21:02:33 +02:00
|
|
|
console.log('dbLoad', 'state.projects', stateglob.projects)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
2019-03-28 12:58:34 +01:00
|
|
|
console.log('error dbLoad', error)
|
2019-03-22 20:51:42 +01:00
|
|
|
UserStore.mutations.setErrorCatch(error)
|
|
|
|
|
return error
|
|
|
|
|
})
|
|
|
|
|
|
2019-04-02 00:18:01 +02:00
|
|
|
ApiTables.aftercalling(ris, checkPending, nametable)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
async function deleteItem(context, { idobj }) {
|
2019-03-22 20:51:42 +01:00
|
|
|
console.log('deleteItem: KEY = ', idobj)
|
|
|
|
|
|
2019-03-30 02:57:40 +01:00
|
|
|
const myarr = getarrByCategory('')
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
const myobjtrov = tools.getElemById(myarr, idobj)
|
|
|
|
|
|
|
|
|
|
console.log('myobjtrov', myobjtrov.descr)
|
|
|
|
|
|
|
|
|
|
if (!!myobjtrov) {
|
|
|
|
|
const myobjnext = tools.getElemPrevById(myarr, myobjtrov._id)
|
|
|
|
|
|
|
|
|
|
if (!!myobjnext) {
|
|
|
|
|
myobjnext.id_prev = myobjtrov.id_prev
|
|
|
|
|
myobjnext.modified = true
|
|
|
|
|
await modify(context, { myitem: myobjnext, field: 'id_prev' })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiTables.table_DeleteRecord(nametable, myobjtrov, idobj)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 12:58:34 +01:00
|
|
|
async function dbInsert(context, { myobj, atfirst }) {
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
const objproj = initcat()
|
|
|
|
|
|
|
|
|
|
objproj.descr = myobj.descr
|
|
|
|
|
objproj.category = myobj.category
|
2019-03-30 02:57:40 +01:00
|
|
|
objproj.id_parent = myobj.id_parent
|
2019-04-09 21:07:16 +02:00
|
|
|
objproj.id_main_project = myobj.id_main_project
|
|
|
|
|
objproj.typeproj = myobj.typeproj
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
let elemtochange: IProject = null
|
|
|
|
|
|
2019-03-28 12:58:34 +01:00
|
|
|
const myarr = getarrByCategory(objproj.category)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
if (atfirst) {
|
|
|
|
|
console.log('INSERT AT THE TOP')
|
|
|
|
|
elemtochange = tools.getFirstList(myarr)
|
|
|
|
|
objproj.id_prev = ApiTables.LIST_START
|
|
|
|
|
} else {
|
|
|
|
|
console.log('INSERT AT THE BOTTOM')
|
|
|
|
|
// INSERT AT THE BOTTOM , so GET LAST ITEM
|
2019-03-30 02:57:40 +01:00
|
|
|
const lastelem = tools.getLastListNotCompleted(nametable, objproj.id_parent)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
objproj.id_prev = (!!lastelem) ? lastelem._id : ApiTables.LIST_START
|
|
|
|
|
}
|
|
|
|
|
objproj.modified = false
|
|
|
|
|
|
|
|
|
|
Mutations.mutations.createNewItem({ objproj, atfirst, categorySel: objproj.category }) // 1) Create record in Memory
|
|
|
|
|
|
|
|
|
|
const id = await globalroutines(context, 'write', nametable, objproj) // 2) Insert into the IndexedDb
|
|
|
|
|
|
|
|
|
|
let field = ''
|
|
|
|
|
if (atfirst) { // update also the last elem
|
|
|
|
|
if (!!elemtochange) {
|
|
|
|
|
elemtochange.id_prev = id
|
|
|
|
|
console.log('elemtochange', elemtochange)
|
|
|
|
|
field = 'id_prev'
|
|
|
|
|
|
|
|
|
|
// Modify the other record
|
|
|
|
|
await modify(context, { myitem: elemtochange, field })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3) send to the Server
|
2019-04-02 00:18:01 +02:00
|
|
|
await ApiTables.Sync_SaveItem(nametable, 'POST', objproj)
|
|
|
|
|
|
|
|
|
|
return id
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-07 21:24:10 +02:00
|
|
|
async function modify(context, { myitem, field }) {
|
2019-04-05 23:59:52 +02:00
|
|
|
return await ApiTables.table_ModifyRecord(nametable, myitem, listFieldsToChange, field)
|
2019-03-22 20:51:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function swapElems(context, itemdragend: IDrag) {
|
2019-04-06 21:02:33 +02:00
|
|
|
console.log('PROJECT swapElems', itemdragend, stateglob.projects)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-22 01:43:53 +02:00
|
|
|
const myarr = Getters.getters.projs_dacompletare(itemdragend.id_proj, itemdragend.mieiproj)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
2019-04-05 23:59:52 +02:00
|
|
|
tools.swapGeneralElem(nametable, myarr, itemdragend, listFieldsToChange)
|
2019-03-22 20:51:42 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const actions = {
|
2019-03-28 12:58:34 +01:00
|
|
|
dbLoad: b.dispatch(dbLoad),
|
2019-03-22 20:51:42 +01:00
|
|
|
swapElems: b.dispatch(swapElems),
|
|
|
|
|
deleteItem: b.dispatch(deleteItem),
|
2019-03-28 12:58:34 +01:00
|
|
|
dbInsert: b.dispatch(dbInsert),
|
2019-03-22 20:51:42 +01:00
|
|
|
modify: b.dispatch(modify)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Module
|
|
|
|
|
const ProjectsModule = {
|
|
|
|
|
get state() {
|
|
|
|
|
return stateGetter()
|
|
|
|
|
},
|
|
|
|
|
getters: Getters.getters,
|
|
|
|
|
mutations: Mutations.mutations,
|
|
|
|
|
actions: Actions.actions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ProjectsModule
|