What is the order of the __history record save?

A place for users and developers of the Xataface to discuss and receive support.

Postby Aoirthoir » Tue Oct 31, 2006 12:57 pm

Mr. Steve,

I've finally got my MySQL stored procedures and triggers working. One of the things I am doing is using a mysql trigger so that I can have 2 timestamp fields. The first is datetimestamp_inserted fieldType timestamp and the second is datetimestamp_updated fieldtype timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP. This works fine. I also have a mysql on insert trigger as follows: set NEW.datetimestamp_inserted = now().

So my question is, when does the history record get written? Is it just a duplicate of the data you save in the original table, or do you save the original table's data then read it back again and save to the history table? (ie..would my timestamps also be saved..?)

Thank you kindly in advance for your time bro.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Wed Nov 01, 2006 11:34 am

history is saved after all of the afterInsert() etc.. triggers have been handled. It just copies the data directly from the database. Hence, it should record your timestamps.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Wed Nov 01, 2006 10:28 pm

Thanks..I have also finally got the triggers working..so I save a history in mysql as well...I will try to get around to posting the steps this coming weekend.

Thanks again for all the hard work Mr. Steve.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Re: What is the order of the __history record save?

Postby kevinwen » Tue Dec 29, 2009 6:30 pm

what if I want to add a field next to comments on frond end? We have a field called status in a table I want to add the status next to comments so the user doesn't have to expand the history record to see what status the record is associated with. I tried to edit dataface/templates/Dataface_RecordHistory.html and put a heading and column for status, just looks like this (line 154-159):

<th><!-- Actions --></th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_ID"}ID{/translate}</th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_DATE"}Date{/translate}</th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_LANGUAGE"}Language{/translate}</th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_USER"}User{/translate}</th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_COMMENTS"}Comments{/translate}</th>
<th>{translate id="templates.Dataface_RecordHistory.LABEL_STATUS"}Status{/translate}</th>

and this (line 174-179):
<td onclick="historyToolClient.expandHistoryRecord('{$logitem.history__id}', this)"><img src="{$ENV.DATAFACE_URL}/images/treeCollapsed.gif" alt="Show details" id="history-{$logitem.history__id}-collapse-image" />&nbsp;{$logitem.history__id}</td>
<td>{$logitem.history__modified}</td>
<td>{$logitem.history__language}</td>
<td>{$logitem.history__user}</td>
<td>{$logitem.history__comments}</td>
<td>{$logitem.status_id}</td>

Unfortunately, it doesn't work. Is there any way we can accomplish that?


-Kevin
kevinwen
 
Posts: 109
Joined: Mon Dec 28, 2009 3:44 pm

Re: What is the order of the __history record save?

Postby shannah » Wed Dec 30, 2009 11:04 am

An easy way to achieve something similar to what you want is by way of the getHistoryComments() delegate method.
E.g.

Code: Select all
function getHistoryComments(&$record){
    return 'Status: '.$record->val('status');
}


This would then display the status in the comments field of the history page (only for future changes though - not past ones as this is set when the history record is created).

In order to actually show the status field as a separate column, you would need to make some changes to HistoryTool::getHistoryLog() to also return the status field in its sql query - which is a little messier than simply adding this in the history comments.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: What is the order of the __history record save?

Postby kevinwen » Mon Jan 04, 2010 12:29 pm

Thank you so much. It helped me a lot. I know this is a great app for retrieving and displaying database records and has a lot of flexibility for developers to customize what they want. The only problem is the way to find documentation telling what I can do by defining delegate methods and how those methods should look. Is there any place we can find a full list of delegate methods? thanks.

-Kevin
kevinwen
 
Posts: 109
Joined: Mon Dec 28, 2009 3:44 pm

Re: What is the order of the __history record save?

Postby kevinwen » Mon Jan 04, 2010 1:10 pm

Hi, Steve

I used the code you posted and put that into the delegate class under the table on which I wanted to customize history, and it doesn't work. Did I miss something to do along with this delegate method?

Also, I did some investigation and found the following issues:
1. I found that the action.ini of xataface uses 'Dataface_Record_History.html' as template for history action, but the template folder doesn't contain this file and has Dataface_RecordHistory.html instead. Is this template used? Or is this template used for the view_history_record_details action instead?
2. I did try adding another column in the $sql in HistoryTool::getHistoryLog() and it works fine. The problem is this modification is made inside the framework and not good for any upgrade in the future. Is there any way I can just do code change on my app instead of the framework?
kevinwen
 
Posts: 109
Joined: Mon Dec 28, 2009 3:44 pm

Re: What is the order of the __history record save?

Postby shannah » Mon Jan 04, 2010 3:46 pm

The only problem is the way to find documentation telling what I can do by defining delegate methods and how those methods should look. Is there any place we can find a full list of delegate methods?


The wiki is the best place to find this type of documentation. Some things are still missing from it, but slowly but surely it is becoming complete.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved