Skip to content

Commit

Permalink
Merge pull request #9 from saber13812002/51-52-set-board-admin-after-…
Browse files Browse the repository at this point in the history
…create-in-nav-menu

51-52-set-board-admin-after-create-in-nav-menu
  • Loading branch information
saber13812002 authored Jul 31, 2020
2 parents 42ecd64 + 91a3e20 commit 3c010cc
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 183 deletions.
17 changes: 13 additions & 4 deletions app/Http/Controllers/BoardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function postBoard(Request $request)
{
$this->validate($request, [
'boardTitle' => 'required|unique:board,boardTitle',
'boardPrivacyType' => 'required',
'boardPrivacyType' => 'required',
]);

return $this->board->createBoard($request, Auth::id());
}

Expand All @@ -60,8 +60,9 @@ public function getBoardDetail(Request $request)
$cardTaskCount = json_decode(json_encode($this->boardCard->cardTotalTask()), True);
$boards = $this->board->getUserBoards(Auth::id());
$recentBoards = $this->board->getUserRecentBoards(Auth::id());
$users = User::all();

return view('user.board', compact('boardDetail', 'lists', 'cards', 'cardTaskCount', 'boards', 'recentBoards'));
return view('user.board', compact('boardDetail', 'lists', 'cards', 'cardTaskCount', 'boards', 'recentBoards', 'users'));
}

/**
Expand All @@ -74,4 +75,12 @@ public function updateBoardFavourite(Request $request)
return $this->board->updateBoardFavourite($request);
}

}
public function setBaordAdmin(Request $request)
{
$this->board->setBaordAdmin($request);

return [
'success' => 'success',
];
}
}
81 changes: 0 additions & 81 deletions app/Http/routes.php

This file was deleted.

24 changes: 17 additions & 7 deletions app/Models/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ class Board extends Model
protected $table = "board";

protected $fillable = [
'user_id', 'boardTitle', 'boardPrivacyType' , 'department_id', 'owner_id',
'user_id', 'boardTitle', 'boardPrivacyType', 'department_id', 'owner_id',
];

public function getUserBoards($user_id)
{
// $group_ids=$this->;
return $this->where(['user_id' => $user_id,])->get();
// $group_ids=$this->;
return $this->where(['user_id' => $user_id,])->get();
}

public function getUserStarredBoards($user_id)
{
return $this->where(['user_id' => $user_id, 'is_starred' => 1])->orderBy('created_at', 'desc')->get();
return $this->where(['user_id' => $user_id, 'is_starred' => 1])->orderBy('created_at', 'desc')->get();
}

public function createBoard($input, $user_id)
{
// get current_user department id
$department_id = Department::getDepartmentIdByUserId($user_id)?:0;
$department_id = Department::getDepartmentIdByUserId($user_id) ?: 0;

return $this->create([
'user_id' => $user_id,
Expand All @@ -46,20 +46,30 @@ public function getBoard($board_id)

public function getUserRecentBoards($user_id)
{
return $this->where(['user_id' => $user_id, ])->orderBy('created_at', 'desc')->take(3)->get();
return $this->where(['user_id' => $user_id,])->orderBy('created_at', 'desc')->take(3)->get();
}

public function updateBoardFavourite($input)
{
return $this->where("id", $input->get("boardId"))->update(["is_starred" => $input->get("isFavourite"),]);
}


/**
* Get the department that owns the board.
*/
public function department()
{
return $this->belongsTo(Department::class);
}

public function setBaordAdmin($input)
{
$boardAdminUserId = $input->get("boardAdminUserId");
$boardId = $input->get("board_id");
$board = Board::where('id', $boardId)->first();
$board->owner_id = $boardAdminUserId;
$board->save();
return true;
}
}
73 changes: 54 additions & 19 deletions public/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,36 @@ $(document).ready(function () {
}
});

// $("#boardAdminUserId").on("change", "", function (e) {
// var optionSelected = $("option:selected", this);
// var valueSelected = this.value;
// console.log(valueSelected);
// });

$(document).on("submit", "#select-user-form", function (event) {

event.preventDefault();
var boardAdminUserId = $("#boardAdminUserId2").val();
var board_id = $("#board_id").val();
var location = window.location;

$.ajax({
url: "set-board-admin",
type: "POST",
dataType: "json",
data: {
boardAdminUserId: boardAdminUserId,
board_id: board_id,
},
success: function (data) {
location.reload();
},
error: function (error) {
location.reload();
},
});
});

$(document).on("click", ".delete-list", function () {
var listId = $(this).data("listid");
that.deleteList(listId, this);
Expand Down Expand Up @@ -1170,31 +1200,31 @@ $(document).ready(function () {
description: description,
},
success: function (data) {
$(".group-con")
.append(
'<li class="list-group-item board-list-items ui-sortable-handle" id="card_' +
data.id +
'" data-cardid="' +
data.id +
'" data-toggle="modal" href="#card-detail">' +
'<div class="row">' +
'<div class="col-lg-12">' +
'<p style="margin-bottom: 0px;" class="pull-left">' +
data.name + " <br /> " +
data.description +
"</p>" +
'<ul class="card-description-intro list-inline pull-right"></ul>' +
"</div>" +
"</div>" +
"</li>"
);
$(".group-con").append(
'<li class="list-group-item board-list-items ui-sortable-handle" id="card_' +
data.id +
'" data-cardid="' +
data.id +
'" data-toggle="modal" href="#card-detail">' +
'<div class="row">' +
'<div class="col-lg-12">' +
'<p style="margin-bottom: 0px;" class="pull-left">' +
data.name +
" <br /> " +
data.description +
"</p>" +
'<ul class="card-description-intro list-inline pull-right"></ul>' +
"</div>" +
"</div>" +
"</li>"
);
// $(that.targetList).find('form').hide();
// $(that.targetList).find('form textarea').val('');
// $(that.targetList).find('a.show-input-field').show();
that.createActivity(
data.id,
"add_group",
"created a group: " + name + "desc: " + description
"created a group: " + name + "desc: " + description
);
},
error: function (error) {
Expand Down Expand Up @@ -1411,4 +1441,9 @@ $(document).ready(function () {
saveListNameBtn: $("#saveListName"),
createBoardLink: $(".board-create-link"),
});


var theButton = document.getElementById("nav-bar-toggle");

theButton.style.display = "block";
});
2 changes: 2 additions & 0 deletions resources/views/layouts/partials/modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
<p><span class="glyphicon glyphicon-briefcase" aria-hidden="true"></span> مدیر بورد</p>
<select name="boardAdminUserId" id="boardAdminUserId" class="form-control" required="required">
<option value="">انتخاب یک مدیر...</option>
@if(isset($users))
@foreach($users as $user)
<option value="{{ $user['id'] }}">{{ $user["name"] }}</option>
@endforeach
@endif
</select>
</div>

Expand Down
Loading

0 comments on commit 3c010cc

Please sign in to comment.