Turn off enable_tab_task_when_empty by default using tags

  • 3 November 2020
  • 0 replies



To turn off ‘enable_tab_task_when_empty’ by default. This can be overridden using the tag ‘task_without_context_allowed’. This functionality will also turn off ‘enable_tab_task_when_empty’ for all tasks used by drag & drop functionality. This code could easily be expanded by users to include or exclude other situations in which they want tasks to always turn off ‘enable_tab_task_when_empty’.



The solution is the following piece of dynamic model code:

/* turn 'enable_tab_task_when_empty' off by default.
when the tag 'task_without_context_allowed' is assigned, 'enable_tab_task_when_empty' can be turned on,
otherwise it wil be overriden.
if a task is used by drag & drop functionality it wil always have 'enable_task_when_empty' turned on
declare @tag_id varchar(100) = 'task_without_context_allowed'

update tt
set tt.enable_tab_task_when_empty = isnull(c.enable_tab_task_when_empty, 0)
from tab_task tt
-- The outer apply wil only have a result when the task should be enabled when empty.
outer apply ( select top 1 1 as enable_tab_task_when_empty
from task_tag tta
where tta.project_id = tt.project_id
and tta.project_vrs_id = tt.project_vrs_id
and tta.task_id = tt.task_id
and tta.tag_id = @tag_id
-- Except the visible buttons (tasks) in drag and drop
and not exists ( select 1
from drag_drop dd
where dd.project_id = tt.project_id
and dd.project_vrs_id = tt.project_vrs_id
and dd.drag_tab_id = tt.tab_id
and dd.drop_task_id = tta.task_id
) c
where tt.project_id = @project_id
and tt.project_vrs_id = @project_vrs_id
and tt.enable_tab_task_when_empty <> isnull(c.enable_tab_task_when_empty, 0)


0 replies

Be the first to reply!