Hey,
splitting a task doesn't work as it should. The function doesnt work since being connected to a database. After sync is fired, I have the following information in the header:
{
"type": "sync",
"requestId": 16342112641422,
"revision": 0,
"events": {
"updated": [
{
"duration": 2,
"endDate": "2021-10-15T08:30:00+02:00",
"Id": 180
}
]
}
}
As It says, duration of one task has changed. Which is not true because task should be splited.
State Tracking Manager prints UpdateAction.
Second case:
Sometimes on split I got AddAction in State Tracking Manager and nothing is being synchronised with database.
I have attatched two gif's to show this behaviour, what is more, It's totally random (add action or update action).
Project manager config:
project: new ProjectModel({
transport: {
load: {
url: `${environment.baseDevUrl}schedulercrud/load`,
// url : './assets/data/dataTest.json',
paramName: 'q',
requestConfig: {
fetchOptions: {
credentials: 'omit'
}
}
},
sync: {
url: `${environment.baseDevUrl}schedulercrud/sync`,
// url : './assets/data/dataTest.json',
requestConfig: {
fetchOptions: {
credentials: 'omit',
headers: {
'Content-Type': 'application/json'
},
}
}
}
},
listeners: {
load: (x) => {
this.sessionService.events.next(x.response.events.rows.map(
x => {
x.id = x.Id;
return x;
}
).filter(x => x.planed === false))
}
},
validateResponse: true,
autoLoad: true,
autoSync: true,
stm:{
autoRecord : true,
getTransactionTitle(transaction) {
const lastAction = transaction.queue[transaction.queue.length - 1];
let { type, model } = lastAction;
if (lastAction.modelList && lastAction.modelList.length) {
model = lastAction.modelList[0];
}
let title = 'Transaction ' + this.position;
if (type === 'UpdateAction' && model instanceof EventModel) {
title = 'UpdateAction event ' + model.name;
}
else if (type === 'UpdateAction' && model instanceof ResourceModel) {
title = 'UpdateAction resource ' + model.name;
}
else if (type === 'RemoveAction' && model instanceof EventModel) {
title = 'RemoveAction event ' + model.name;
}
else if (type === 'RemoveAction' && model instanceof ResourceModel) {
title = 'RemoveAction resource ' + model.name;
}
else if (type === 'AddAction' && model instanceof EventModel) {
title = 'AddAction event ' + model.name;
}
else if (type === 'AddAction' && model instanceof DependencyModel) {
title = 'AddAction dependency';
}
return console.log(title);
}
},
resourceStore: {
fields: [
{ name: 'id', dataSource: 'Id' },
{ name: 'name', dataSource: 'name' }
]
},
eventStore: {
fields: [
{ name: 'id', dataSource: 'Id' },
{ name: 'name', dataSource: 'name' },
{ name: 'startDate', dataSource: 'startDate', type: 'date' },
{ name: 'endDate', dataSource: 'endDate', type: 'date' },
{ name: 'cls', dataSource: 'cls' },
{ name: 'draggable', dataSource: 'draggable' },
{ name: 'resizable', dataSource: 'resizable' },
{ name: 'planed', dataSource: 'planed' }
]
},
assignmentStore: {
fields: [
{ name: 'resource', dataSource: 'resourceId' },
{ name: 'event', dataSource: 'event' },
{ name: 'id', dataSource: 'Id' }
]
}
})
}
Event split service:
export class RightClickSplit {
constructor(public sessionService: SessionService) {
}
public getSplitConfig() {
return this.splitEvent;
}
private splitEvent = {
text: 'Split',
icon: 'b-fa b-fa-cut',
onItem: ({ eventRecord }) => {
const popup = new Popup({
header: 'Split options',
autoShow: false,
centered: true,
closable: true,
closeAction: 'destroy',
width: '35em',
minHeight: '25em',
bbar: [
{
text: 'Cancel',
minWidth: 100,
onAction: 'up.close'
},
{
text: 'Split',
minWidth: 300,
cls: 'b-raised b-blue',
onAction: () => this.onSplit(eventRecord, popup)
}
],
items: [
this.CreateNumberField(eventRecord)
]
});
popup.show();
}
}
private CreateNumberField(eventRecord: EventModel) {
let numberFiled = this.CreateNumber(eventRecord)
return numberFiled;
}
private CreateNumber(eventRecord: EventModel): NumberField {
return new NumberField({
min: 0,
max: (eventRecord.durationMS / (1000 * 60 * 60)),
label: 'How many hours to cut?',
style: 'font-size: 1.4rem;',
step: 0.5,
ref: 'splitNumberField',
});
}
private onSplit(eventRecord: EventModel, popup){
let numberValue = popup.widgetMap.splitNumberField.value;
if(numberValue === undefined || numberValue === 0) {
Toast.show('Wrong data');
popup.close();
return;
}
// convert ms to hours
let hours = (eventRecord.durationMS / (1000 * 60 * 60));
// let hours = eventRecord.duration;
let splitData = 1 - (numberValue/(hours))
eventRecord.split(splitData);
Toast.show('Succes');
popup.close();
}
}
I wonder if some "fields" in Project Manager config are missing?