diff --git a/app/Http/Controllers/BoardController.php b/app/Http/Controllers/BoardController.php index 7aeedf5..7990a8c 100644 --- a/app/Http/Controllers/BoardController.php +++ b/app/Http/Controllers/BoardController.php @@ -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()); } @@ -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')); } /** @@ -74,4 +75,12 @@ public function updateBoardFavourite(Request $request) return $this->board->updateBoardFavourite($request); } -} \ No newline at end of file + public function setBaordAdmin(Request $request) + { + $this->board->setBaordAdmin($request); + + return [ + 'success' => 'success', + ]; + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php deleted file mode 100644 index b210944..0000000 --- a/app/Http/routes.php +++ /dev/null @@ -1,81 +0,0 @@ - 'guest', 'uses' => 'UserController@getLogin', 'as' => 'auth.login',]); -Route::get('login', ['middleware' => 'guest', 'uses' => 'UserController@getLogin', 'as' => 'auth.login',]); -Route::post('login', ['middleware' => 'guest', 'uses' => 'UserController@postLogin',]); -//Route::get('password/reset/{token?}', ['middleware' => 'guest', 'uses' => 'UserController@reset',]); -//Route::post('password/reset', ['middleware' => 'guest', 'uses' => 'UserController@resetPassword',]); -Route::get('logout', function () { - Auth::logout(); - return redirect('/'); -}); -Route::get('register', ['middleware' => 'guest', 'uses' => 'UserController@getRegister', 'as' => 'auth.register',]); -Route::post('register', ['middleware' => 'guest', 'uses' => 'UserController@postRegister',]); -Route::get('dashboard', ['middleware' => 'auth', 'uses' => 'UserController@getDashboard', 'as' => 'user.dashboard',]); -Route::get('profile', ['middleware' => 'auth', 'uses' => 'UserController@getProfile', 'as' => 'user.profile',]); -Route::get('activity', ['middleware' => 'auth', 'uses' => 'UserActivityController@getUserActivity', 'as' => 'user.activity',]); - -Route::post('postBoard', ['middleware' => 'auth', 'uses' => 'BoardController@postBoard',]); -Route::post('update-board-favourite', ['middleware' => 'auth', 'uses' => 'BoardController@updateBoardFavourite',]); - -/** - * Board - */ -Route::group( - ['prefix' => 'board'], - function () { - Route::post('/postListName', ['uses' => 'ListController@postListName',]); - Route::post('/delete-list', ['uses' => 'ListController@deleteList',]); - Route::post('/update-list-name', ['uses' => 'ListController@updateListName',]); - - Route::post('/postCard', ['uses' => 'CardController@postCard',]); - Route::post('/changeCardList', ['uses' => 'CardController@changeCardList',]); - Route::post('/deleteCard', ['uses' => 'CardController@deleteCard',]); - Route::post('/getCardDetail', ['uses' => 'CardController@getCardDetail',]); - Route::post('/update-card-data', ['uses' => 'CardController@updateCardData',]); - - Route::post('/save-comment', ['uses' => 'CommentController@saveComment',]); - - Route::post('/save-task', ['uses' => 'TaskController@saveTask',]); - Route::post('/delete-task', ['uses' => 'TaskController@deleteTask',]); - Route::post('/update-task-completed', ['uses' => 'TaskController@updateTaskCompleted',]); - - Route::get('/{id?}', ['middleware' => 'auth', 'uses' => 'BoardController@getBoardDetail', 'as' => 'user.boardDetail',]); - - Route::post('create-user-activity', ['uses' => 'UserActivityController@createUserActivity']); - - - - } -); - -/** - * Password Reset - */ -Route::group( - ['prefix' => 'password'], - function () { - // Password reset link request routes... - Route::get('/email', 'Auth\PasswordController@getEmail'); - Route::post('/email', 'Auth\PasswordController@postEmail'); - - // Password reset routes... - Route::get('/reset/{token}', 'Auth\PasswordController@getReset'); - Route::post('/reset', 'Auth\PasswordController@postReset'); - } -); - -Route::post('create-user-activity', ['uses' => 'UserActivityController@createUserActivity']); \ No newline at end of file diff --git a/app/Models/Board.php b/app/Models/Board.php index 66d2d07..c97b5ac 100644 --- a/app/Models/Board.php +++ b/app/Models/Board.php @@ -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, @@ -46,7 +46,7 @@ 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) @@ -54,7 +54,7 @@ public function updateBoardFavourite($input) return $this->where("id", $input->get("boardId"))->update(["is_starred" => $input->get("isFavourite"),]); } - + /** * Get the department that owns the board. */ @@ -62,4 +62,14 @@ 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; + } } diff --git a/public/js/board.js b/public/js/board.js index 10f1eb4..6aea9e6 100644 --- a/public/js/board.js +++ b/public/js/board.js @@ -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); @@ -1170,31 +1200,31 @@ $(document).ready(function () { description: description, }, success: function (data) { - $(".group-con") - .append( - '
  • ' + - '
    ' + - '
    ' + - '

    ' + - data.name + "
    " + - data.description + - "

    " + - '
      ' + - "
      " + - "
      " + - "
    • " - ); + $(".group-con").append( + '
    • ' + + '
      ' + + '
      ' + + '

      ' + + data.name + + "
      " + + data.description + + "

      " + + '
        ' + + "
        " + + "
        " + + "
      • " + ); // $(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) { @@ -1411,4 +1441,9 @@ $(document).ready(function () { saveListNameBtn: $("#saveListName"), createBoardLink: $(".board-create-link"), }); + + + var theButton = document.getElementById("nav-bar-toggle"); + + theButton.style.display = "block"; }); diff --git a/resources/views/layouts/partials/modal.blade.php b/resources/views/layouts/partials/modal.blade.php index fac0cff..55fd956 100644 --- a/resources/views/layouts/partials/modal.blade.php +++ b/resources/views/layouts/partials/modal.blade.php @@ -24,9 +24,11 @@

        مدیر بورد

        diff --git a/resources/views/layouts/partials/navigation.blade.php b/resources/views/layouts/partials/navigation.blade.php index 358875f..4a4ad5c 100644 --- a/resources/views/layouts/partials/navigation.blade.php +++ b/resources/views/layouts/partials/navigation.blade.php @@ -1,87 +1,117 @@ @if(!Auth::check()) -

        +

        @endif @if (Auth::check()) - + - + + +
      • + ساختن یک بورد جدید +
      • +
        +
      • + {{ trans('board.Home') }} +
      • +
      • + {{ trans('board.Activity') }} +
      • +
      • + {{ trans('board.Profile') }} +
      • +
      • + {{ trans('board.Setting') }} +
      • +
      • + {{ trans('board.Logout') }} +
      • + + @endif
        \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 49f6e92..ebf8cdc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,6 +14,8 @@ */ Route::post('/board/post-group', 'GroupController@postGroup'); +// TODO: MOVE TO AUTH +Route::post('/board/set-board-admin', 'BoardController@setBaordAdmin'); Route::get('/saber', 'saber@index'); Route::get('/', ['middleware' => 'guest', 'uses' => 'UserController@getLogin', 'as' => 'auth.login',]); @@ -33,6 +35,8 @@ Route::get('setting', ['middleware' => 'auth', 'uses' => 'UserActivityController@getUserSetting', 'as' => 'user.setting',]); + +// todo: DUPLICATE ROUTE Route::post('postBoard', ['middleware' => 'auth', 'uses' => 'BoardController@postBoard',]); Route::post('update-board-favourite', ['middleware' => 'auth', 'uses' => 'BoardController@updateBoardFavourite',]); @@ -63,6 +67,7 @@ function () { Route::post('create-user-activity', ['uses' => 'UserActivityController@createUserActivity']); Route::post('/create-board-member', ['uses' => 'BoardMemberController@create',]); + Route::post('postBoard', ['middleware' => 'auth', 'uses' => 'BoardController@postBoard',]); } );