Page 1 of 1

PostPosted: Tue Oct 31, 2006 12:57 pm
by Aoirthoir
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.

PostPosted: Wed Nov 01, 2006 11:34 am
by shannah
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.

PostPosted: Wed Nov 01, 2006 10:28 pm
by Aoirthoir
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.

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

PostPosted: Tue Dec 29, 2009 6:30 pm
by kevinwen
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

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

PostPosted: Wed Dec 30, 2009 11:04 am
by shannah
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

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

PostPosted: Mon Jan 04, 2010 12:29 pm
by kevinwen
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

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

PostPosted: Mon Jan 04, 2010 1:10 pm
by kevinwen
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?

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

PostPosted: Mon Jan 04, 2010 3:46 pm
by shannah
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.