Fixed Move to grandparent/sibling

Moving a subtask to its grandparent, or making a task a sub-task of one
of its siblings, didn't work as expected. While the icons were being
updated correctly, the task didn't appear in the right location. That
was because, while the cached structure was being updated, the task
itself wasn't.
This commit is contained in:
Emmanuel BENOîT 2016-01-02 10:47:36 +01:00
parent 143af5a498
commit a9035d5be6
2 changed files with 66 additions and 0 deletions

View file

@ -139,3 +139,32 @@ REVOKE EXECUTE
CREATE TRIGGER tasks_item_au
AFTER UPDATE OF item_id ON tasks
FOR EACH ROW EXECUTE PROCEDURE tasks_item_au( );
/*
* After an update on some task's logical container, set the task's parent ID.
*/
DROP FUNCTION IF EXISTS tasks_item_au( ) CASCADE;
CREATE FUNCTION tasks_ltc_au( )
RETURNS TRIGGER
LANGUAGE PLPGSQL
SECURITY DEFINER
AS $tasks_ltc_au$
BEGIN
UPDATE tasks
SET task_id_parent = (
SELECT task_id
FROM logical_task_containers
WHERE ltc_id = NEW.ltc_id )
WHERE task_id = NEW.task_id;
RETURN NEW;
END;
$tasks_ltc_au$;
REVOKE EXECUTE
ON FUNCTION tasks_ltc_au( )
FROM PUBLIC;
CREATE TRIGGER tasks_ltc_au
AFTER UPDATE OF ltc_id ON tasks
FOR EACH ROW EXECUTE PROCEDURE tasks_ltc_au( );

View file

@ -0,0 +1,37 @@
--
-- Upgrade the database from commit ID bca6b99068cbf1dd4148d6bd5cb60e926162cfe1
--
-- Run this from the top-level directory
--
\i database/config.sql
\c :db_name
BEGIN;
DROP FUNCTION IF EXISTS tasks_item_au( ) CASCADE;
CREATE FUNCTION tasks_ltc_au( )
RETURNS TRIGGER
LANGUAGE PLPGSQL
SECURITY DEFINER
AS $tasks_ltc_au$
BEGIN
UPDATE tasks
SET task_id_parent = (
SELECT task_id
FROM logical_task_containers
WHERE ltc_id = NEW.ltc_id )
WHERE task_id = NEW.task_id;
RETURN NEW;
END;
$tasks_ltc_au$;
REVOKE EXECUTE
ON FUNCTION tasks_ltc_au( )
FROM PUBLIC;
CREATE TRIGGER tasks_ltc_au
AFTER UPDATE OF ltc_id ON tasks
FOR EACH ROW EXECUTE PROCEDURE tasks_ltc_au( );
COMMIT;