var args = arguments[0] || {};
Alloy.Collections.visitors.fetch();
function doTransform(model) {
    "use strict";
    var transform = {};
    if (model) {
        transform = model.toJSON();
    }
    console.log(transform);
    transform.canEdit = true;
    transform.selectionStyle = OS_IOS ? Ti.UI.iPhone.ListViewCellSelectionStyle.NONE : null;
    return transform;
}

function updateUi() {
    "use strict";
    console.log("updateUi");
    Alloy.Collections.visitors.fetch();
    updateListViewUi();
}

function deleteItem(e) {
    "use strict";
    var section,
        item,
        model,
        length;
    e = e || {};
    length = $.lv.sections[e.sectionIndex].items.length;
    section = $.lv.sections[e.sectionIndex];
    item = section.getItemAt(e.itemIndex);
    console.log(item);
    if (item && item.uuid && item.uuid.text) {
        console.log(JSON.stringify(item.uuid.text));
        model = Alloy.Collections.visitors.getByUuid(item.uuid.text);
        if (model) {
            console.log(JSON.stringify(model));
            Alloy.Collections.visitors.remove(model);
            model.destroy();
            updateUi();
        } else {
            console.error("cannot delete model");
        }
    } else {
        console.error("no item");
    }
}

function filterFunction(collection) {
    return collection.getCurrentItems();
}

function updateItem(e) {
    console.log("**update");
    console.log(JSON.stringify(e));
}

$.lv.addEventListener("editaction", function(e) {
    "use strict";
    switch(e.action) {
    case "DELETE":
        deleteItem(e);
        break;
    case "DEPART":
        updateItem(e);
        break;
    default:
        console.log("editactions: " + JSON.stringify(e));
        break;
    }
});

@@ -22,16 +22,54 @@
 0%5D %7C%7C %7B%7D
+,%0A    moment = require(%22alloy/moment%22)
 ;%0AAlloy.
@@ -1425,68 +1425,710 @@
     
-console.log(%22**update%22);%0A    console.log(JSON.stringify(e));
+%22use strict%22;%0A    var section,%0A        item,%0A        model,%0A        length;%0A    e = e %7C%7C %7B%7D;%0A    length = $.lv.sections%5Be.sectionIndex%5D.items.length;%0A    section = $.lv.sections%5Be.sectionIndex%5D;%0A    item = section.getItemAt(e.itemIndex);%0A    if (item && item.uuid && item.uuid.text) %7B%0A        console.log(JSON.stringify(item.uuid.text));%0A        model = Alloy.Collections.visitors.getByUuid(item.uuid.text);%0A        if (model) %7B%0A            console.log(JSON.stringify(model));%0A            model.set(%7B%0A                departureTime : moment().format(%22HH:mm%22)%0A            %7D);%0A            model.save();%0A        %7D else %7B%0A            console.error(%22cannot delete model%22);%0A        %7D%0A        updateUi();%0A    %7D
 %0A%7D%0A%0A

update item