Skip to content

Commit

Permalink
* [Project Boards/UX] On project boards, if a column behavior removes…
Browse files Browse the repository at this point in the history
… a card from the board (e.g. 'Completed'), the card now properly disappears after being dropped into the column. Previously, the card was only removed after a refresh of the board or column.

Fixes #767
  • Loading branch information
jstanden committed Oct 9, 2018
1 parent 2b618d6 commit e7c4928
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
16 changes: 11 additions & 5 deletions features/cerb.project_boards/api/profiles/project_board.php
Expand Up @@ -70,7 +70,10 @@ function savePeekJsonAction() {
return !empty($value);
});

$error = null;

if(empty($id)) { // New

$fields = array(
DAO_ProjectBoard::UPDATED_AT => time(),
DAO_ProjectBoard::NAME => $name,
Expand Down Expand Up @@ -145,7 +148,7 @@ function moveCardAction() {

// [TODO] Validate everything (context/id/privs)

if(false == ($to_column = DAO_ProjectBoardColumn::get($to_column_id)))
if(false == (DAO_ProjectBoardColumn::get($to_column_id)))
return;

DAO_ContextLink::deleteLink(Context_ProjectBoardColumn::ID, $from_column_id, $card_context, $card_id);
Expand Down Expand Up @@ -191,14 +194,17 @@ function refreshCardAction() {
$links = DAO_ContextLink::getContextLinks($context, [$id], Context_ProjectBoardColumn::ID);
@$column = array_shift(array_intersect_key($columns, $links[$id]));

if(isset($column)) {
$card = new DevblocksDictionaryDelegate($dict);
$tpl->assign('card', $card);

if($column) {
$dict['column__context'] = Context_ProjectBoardColumn::ID;
$dict['column_id'] = $column->id;

} else { // Not on this board anymore
$tpl->assign('card_is_removed', true);
}

$card = new DevblocksDictionaryDelegate($dict);
$tpl->assign('card', $card);

$tpl->display('devblocks:cerb.project_boards::boards/board/card.tpl');
}

Expand Down
20 changes: 19 additions & 1 deletion features/cerb.project_boards/templates/boards/board/card.tpl
@@ -1,7 +1,25 @@
{$uniqid = uniqid()}
{$context_ext = Extension_DevblocksContext::get($card->_context)}
<div class="cerb-board-card-type">{$context_ext->manifest->name}</div>
<div>
<div id="{$uniqid}">
<input type="hidden" name="cards[]" value="{$card->_context}:{$card->id}">
<h3><a href="javascript:;" class="cerb-peek-trigger" data-context="{$card->_context}" data-context-id="{$card->id}">{$card->_label}</a></h3>
{$board->renderCard($card)}
</div>

{if $card_is_removed}
<script type="text/javascript">
$(function() {
var $div = $('#{$uniqid}');
var $card = $div.closest('.cerb-board-card');
$card.toggle({
effect:'scale',
duration: 500,
complete: function() {
$card.remove();
}
});
});
{/if}
</script>

0 comments on commit e7c4928

Please sign in to comment.