Implemented edit and update for entries.
- Added ts_entry:delete/1 to delete an entry from the database. - Implemented ts_api:delete_entry/3. - Added a form to facilitate editing individual entries. - Moved the small show/hide functions directly into the HTML. - Wired up the update timeline form. - Wired up the edit and update entry form.
This commit is contained in:
@ -482,7 +482,22 @@ post_entry(YArg, Username, TimelineId, EntryId) ->
|
||||
_Error -> make_json_500(YArg)
|
||||
end.
|
||||
|
||||
delete_entry(_YArg, _Username, _TimelineId, _EntryId) -> todo.
|
||||
delete_entry(YArg, Username, TimelineId, EntryId) ->
|
||||
|
||||
% find the record to delete
|
||||
case ts_entry:lookup(Username, TimelineId, EntryId) of
|
||||
|
||||
Record ->
|
||||
% try to delete
|
||||
case ts_entry:delete(Record) of
|
||||
ok -> {status, 200};
|
||||
Error ->
|
||||
io:format("Error occurred deleting entry record: ~p", [Error]),
|
||||
make_json_500(YArg)
|
||||
end;
|
||||
|
||||
no_record -> make_json_404(YArg)
|
||||
end.
|
||||
|
||||
% ============================== %
|
||||
% ======== UTIL METHODS ======== %
|
||||
|
@ -1,5 +1,5 @@
|
||||
-module(ts_entry).
|
||||
-export([create_table/1, new/1, update/1, lookup/3, list_asc/3, list_desc/3]).
|
||||
-export([create_table/1, new/1, update/1, delete/1, lookup/3, list_asc/3, list_desc/3]).
|
||||
|
||||
-include("ts_db_records.hrl").
|
||||
-include_lib("stdlib/include/qlc.hrl").
|
||||
@ -35,6 +35,9 @@ lookup(Username, TimelineId, EntryId) ->
|
||||
[Entry] -> Entry
|
||||
end.
|
||||
|
||||
delete(ER = #ts_entry{}) -> mnesia:dirty_delete_object(ER).
|
||||
|
||||
|
||||
list({Username, Timeline}, Start, Length, OrderFun)
|
||||
when is_integer(Start) and is_integer(Length) ->
|
||||
|
||||
|
Reference in New Issue
Block a user