Skip to content

Commit

Permalink
Zenhub #960 Add "Shared With" column to Past Goals list
Browse files Browse the repository at this point in the history
  • Loading branch information
jizhaogit committed Jul 11, 2023
1 parent 1e5f351 commit b211d76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
16 changes: 7 additions & 9 deletions app/Http/Controllers/GoalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function index(GoalsDataTable $goalDataTable, Request $request)
]);

$query = $query->leftjoin('goal_tags', 'goal_tags.goal_id', '=', 'goals.id')
->join('users as owner_users', 'goals.user_id', 'owner_users.id')
->leftjoin('tags', 'tags.id', '=', 'goal_tags.tag_id')
->leftjoin('goal_types', 'goal_types.id', '=', 'goals.goal_type_id')
->leftJoin('goals_shared_with', 'goals_shared_with.goal_id', 'goals.id')
Expand All @@ -133,21 +134,18 @@ public function index(GoalsDataTable $goalDataTable, Request $request)
return view('goal.index', compact('goals', 'type', 'goaltypes','goal_types_modal','user', 'tags', 'type_desc_str'));
} else {
$query = $query->where('status', '<>', 'active')
->select('goals.*', DB::raw('group_concat(distinct tags.name separator ", ") as tagnames')
->select('goals.*'
,'owner_users.id as owner_id'
,'owner_users.name as owner_name'
, DB::raw('group_concat(distinct tags.name separator ", ") as tagnames')
,DB::raw('group_concat(distinct goals_shared_with.user_id separator ",") as shared_user_id')
,DB::raw('group_concat(distinct shared_users.name separator ",") as shared_user_name')
,'goal_types.name as typename')
->where(function($query) use($authId) {
$query->where('goals.user_id',$authId)
->orWhere('goals_shared_with.user_id',$authId);
});
/*
$q = $query->toSql();
$b = $query->getBindings();
print_r($q);
print_r($b);
exit;
*/

//$query = $query->where('status', '<>', 'active')->select('goals.*', DB::raw('group_concat(distinct tags.name separator ", ") as tagnames'), 'goal_types.name as typename');
}

Expand Down Expand Up @@ -237,7 +235,7 @@ public function index(GoalsDataTable $goalDataTable, Request $request)

$from = 'goal';

return view('goal.index', compact('goals', 'type', 'goaltypes', 'goal_types_modal', 'tagsList', 'sortby', 'sortorder', 'createdBy', 'user', 'employees', 'tags', 'type_desc_str', 'statusList','from'));
return view('goal.index', compact('goals', 'type', 'goaltypes', 'goal_types_modal', 'tagsList', 'sortby', 'sortorder', 'createdBy', 'user', 'employees', 'tags', 'type_desc_str', 'statusList','from', 'authId'));
}

/**
Expand Down
19 changes: 12 additions & 7 deletions resources/views/goal/partials/past-target-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@
<td >{{ $goal->target_date_human }}</td>
<td>
<select multiple class="form-control share-with-users" name="share_with_users[]" disabled>
<?php if($goal->shared_user_id != '' && $goal->shared_user_name != ''){
$share_user_id_arr = explode(',', $goal->shared_user_id);
$share_user_name_arr = explode(',', $goal->shared_user_name);
for ($i=0; $i<count($share_user_id_arr); $i++){
echo "<option value='".$share_user_id_arr[$i]."' selected>".$share_user_name_arr[$i]."</option>";
}
}?>
<?php if ($goal->owner_id == $authId) { ?>
<?php if($goal->shared_user_id != '' && $goal->shared_user_name != ''){
$share_user_id_arr = explode(',', $goal->shared_user_id);
$share_user_name_arr = explode(',', $goal->shared_user_name);
for ($i=0; $i<count($share_user_id_arr); $i++){
echo "<option value='".$share_user_id_arr[$i]."' selected>".$share_user_name_arr[$i]."</option>";
}
}?>
<?php } else {?>
<?php echo "<option value='".$goal->owner_id."' selected>".$goal->owner_name."</option>"; ?>
<?php } ?>


</select>
</td>
Expand Down

0 comments on commit b211d76

Please sign in to comment.