Skip to content

StoreManager does not use the Identity from the item if it is different of "id" #122

@gtux

Description

@gtux

I want to use a Observable Cache of JsonRest and Memory store but with different identity, in my case "idPlanificacion", but the calendar behavior is wrong on create new items, it does not allows me to drag either.

My Code:

var id = 1,
        jsonStore = new JsonRest({target:"/planificaciones", idProperty: "idPlanificacion"}),
        cacher = new Memory({idProperty: "idPlanificacion"}),
        store = new Observable(new Cache(jsonStore, cacher));

var calendar = new Calendar({
        dateInterval: "week",
        columnViewProps: {
            timeSlotDuration: 60,
            minHours: 0,
            maxHours: 24,
            hourSize: 25
        },
        store: store,
        editable: true,
        createOnGridClick: true,
        createItemFunc: createItem,
        templateString: template
    }, "calendar-wrap");

After a few hours I found that it may because the StorageManager does not get the identity in some cases:

StorageManager Line 102

for(i=l-1; i>=0; i--){
    if(this.items[i].id === tempId){
        this.items[i] = newItem;
	break;
    }
}

then again in the line 117

if(this.items && this.items[newIndex] && this.items[newIndex].id !== newItem.id){
    l = this.items.length;
    for(i=l-1; i>=0; i--){
        if(this.items[i].id === newItem.id){
	    this.items.splice(i, 1);
	    break;
	}
    }
    this.items.splice(newIndex, 0, newItem);
}

The identity of items are evaluate directly for "id". And I think this is the bug because when I change the properties of my store, set the idProperty to "id" everything works fine again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions