
Ext.namespace("GeoExplorer");

/** api: constructor
 *  A tool to display all previously saved versions of a map, along with date and user.
 */
GeoExplorer.MapSnapshotGrid =  function(mapid) {

/*
var snapReader = new Ext.data.JsonReader({
    // metadata configuration options:
    idProperty: 'id',
    // the fields config option will internally create an Ext.data.Record
    // constructor that provides mapping for reading the record data objects
    fields: [
        // map Record's 'firstname' field to data object's key of same name
        {name: 'user', mapping: 'user'},
        // map Record's 'job' field to data object's 'occupation' key
        {name: 'date', mapping: 'created_dttm'},

        {name: 'link', mapping: 'snapshot'}
    ]
});
*/



var store = new Ext.data.JsonStore({
    url: '/maps/history/' + mapid,
    fields: [{name:'created', type: 'date'}, 'user', 'url', 'map'],
    idProperty: 'url',
    root: '',
    sortInfo: {
        field: 'created',
        direction: 'DESC' // or 'DESC' (case sensitive for local sorting)
    }
});

    var renderDate = function(value, p, record){
        return String.format(
                '<b><a href="/maps/{0}/{1}">{2}</a>',
                record.data.map, record.id, value);
    };

    var renderUser = function(value, p, record){
        return String.format(
                '<b><a href="/profiles/{0}">{1}</a>',
                value, value);
    };

    
var grid = new Ext.grid.GridPanel({
        width:400,
        height:300,
        store: store,
        trackMouseOver:false,

        // grid columns
        columns:[{
            header: "Revision Date",
            dataIndex: 'created',
            width: 200,
            renderer: renderDate,
            sortable: true
        },{
            header: "URL",
            dataIndex: 'url',
            width: 10,
            hidden: true,
            sortable: false
        },{
            header: "User",
            dataIndex: 'user',
            width: 200,
            align: 'right',
            renderer: renderUser,
            sortable: true
        },{
            header: "Map",
            dataIndex: 'map',
            width: 10,
            align: 'right',
            hidden:true,
            sortable: false
        }],

        // customize view config
        viewConfig: {
            forceFit:true
        }
    });




    var historyWindow = new Ext.Window({
            title: 'Map Revision History',
            closeAction: 'destroy',
            items: grid,
            modal: true,
            autoScroll: true
        });


    // trigger the data store load
    store.load();

    historyWindow.show();

}
@@ -192,576 +192,8 @@
  %7B%0A%0A
-/*%0Avar snapReader = new Ext.data.JsonReader(%7B%0A    // metadata configuration options:%0A    idProperty: 'id',%0A    // the fields config option will internally create an Ext.data.Record%0A    // constructor that provides mapping for reading the record data objects%0A    fields: %5B%0A        // map Record's 'firstname' field to data object's key of same name%0A        %7Bname: 'user', mapping: 'user'%7D,%0A        // map Record's 'job' field to data object's 'occupation' key%0A        %7Bname: 'date', mapping: 'created_dttm'%7D,%0A%0A        %7Bname: 'link', mapping: 'snapshot'%7D%0A    %5D%0A%7D);%0A*/%0A%0A%0A
 %0Avar

Remove old unused code