Browse Source

Update 2016-08-14.21.24

Add Sortable Project Features
Add sortable Feature Tasks
Filter Unfinished features list only to 'on progress' and 'done' project status
Export project features to Excel (xlsx)
Add Option CRUD with vuejs ajax (single page application)
Add Laravel Excel and Laravel Dompdf
Remove top-nav
Refactor ManageProjectsTest class
pull/1/head
Nafies Luthfi 9 years ago
parent
commit
d2a73a49dc
  1. 6
      app/Entities/BaseRepository.php
  2. 2
      app/Entities/Projects/Feature.php
  3. 16
      app/Entities/Projects/FeaturesRepository.php
  4. 2
      app/Entities/Projects/Project.php
  5. 15
      app/Entities/Projects/ProjectsRepository.php
  6. 6
      app/Entities/Projects/TasksRepository.php
  7. 10
      app/Http/Controllers/Projects/FeaturesController.php
  8. 26
      app/Http/Controllers/Projects/ProjectsController.php
  9. 3
      app/Http/routes.php
  10. 61
      app/Http/routes/options-vue.php
  11. 3
      app/Http/routes/projects.php
  12. 2
      app/Services/FormField.php
  13. 4
      composer.json
  14. 404
      composer.lock
  15. 4
      config/app.php
  16. 691
      config/excel.php
  17. 4
      database/factories/ModelFactory.php
  18. 32
      public/assets/js/sb-admin-2.js
  19. 1
      resources/lang/id/project.php
  20. 2
      resources/views/features/partials/feature-show.blade.php
  21. 32
      resources/views/features/partials/feature-tasks-operation.blade.php
  22. 27
      resources/views/features/partials/feature-tasks.blade.php
  23. 1
      resources/views/layouts/app.blade.php
  24. 12
      resources/views/layouts/guest.blade.php
  25. 8
      resources/views/layouts/partials/sidebar.blade.php
  26. 172
      resources/views/options/index-vue-div.blade.php
  27. 170
      resources/views/options/index-vue.blade.php
  28. 71
      resources/views/projects/features-export.blade.php
  29. 41
      resources/views/projects/features.blade.php
  30. 3
      resources/views/projects/partials/nav-tabs.blade.php
  31. 4
      tests/ManageProjectsTest.php

6
app/Entities/BaseRepository.php

@ -2,6 +2,7 @@
namespace App\Entities;
use App\Entities\Projects\Feature;
use App\Entities\Projects\Project;
use App\Entities\Users\User;
@ -24,4 +25,9 @@ abstract class BaseRepository extends EloquentRepository {
{
return Project::orderBy('name')->lists('name','id');
}
public function requireFeatureById($featureId)
{
return Feature::findOrFail($featureId);
}
}

2
app/Entities/Projects/Feature.php

@ -27,7 +27,7 @@ class Feature extends Model {
public function tasks()
{
return $this->hasMany(Task::class)->orderBy('progress');
return $this->hasMany(Task::class)->orderBy('progress')->orderBy('position');
}
}

16
app/Entities/Projects/FeaturesRepository.php

@ -23,6 +23,9 @@ class FeaturesRepository extends BaseRepository
return $this->model->whereHas('tasks', function($query) {
return $query->where('progress','<',100);
})
->whereHas('project', function($query) {
return $query->whereIn('status_id', [2,3]);
})
->with(['tasks','project','worker'])
->get();
}
@ -84,4 +87,17 @@ class FeaturesRepository extends BaseRepository
$feature->update($featureData);
return $feature;
}
public function tasksReorder($sortedData)
{
$taskOrder = explode(',', $sortedData);
foreach ($taskOrder as $order => $taskId) {
$task = $this->requireTaskById($taskId);
$task->position = $order + 1;
$task->save();
}
return $taskOrder;
}
}

2
app/Entities/Projects/Project.php

@ -18,7 +18,7 @@ class Project extends Model {
public function features()
{
return $this->hasMany(Feature::class);
return $this->hasMany(Feature::class)->orderBy('position');
}
public function payments()

15
app/Entities/Projects/ProjectsRepository.php

@ -95,7 +95,7 @@ class ProjectsRepository extends BaseRepository
public function getProjectFeatures($projectId)
{
return Feature::whereProjectId($projectId)->with('worker','tasks')->get();
return Feature::whereProjectId($projectId)->orderBy('position')->with('worker','tasks')->get();
}
public function updateStatus($statusId, $projectId)
@ -103,8 +103,19 @@ class ProjectsRepository extends BaseRepository
$project = $this->requireById($projectId);
$project->status_id = $statusId;
$project->save();
// die('hit');
return $project;
}
public function featuresReorder($sortedData)
{
$featureOrder = explode(',', $sortedData);
foreach ($featureOrder as $order => $featureId) {
$feature = $this->requireFeatureById($featureId);
$feature->position = $order + 1;
$feature->save();
}
return $featureOrder;
}
}

6
app/Entities/Projects/TasksRepository.php

@ -3,7 +3,6 @@
namespace App\Entities\Projects;
use App\Entities\BaseRepository;
use App\Entities\Projects\Feature;
/**
* Tasks Repository Class
@ -17,11 +16,6 @@ class TasksRepository extends BaseRepository
parent::__construct($model);
}
public function requireFeatureById($featureId)
{
return Feature::findOrFail($featureId);
}
public function createTask($taskData, $featureId)
{
$taskData['feature_id'] = $featureId;

10
app/Http/Controllers/Projects/FeaturesController.php

@ -111,4 +111,14 @@ class FeaturesController extends Controller {
return redirect()->route('projects.features', $projectId);
}
public function tasksReorder(Request $req, $featureId)
{
if ($req->ajax()) {
$data = $this->repo->tasksReorder($req->get('postData'));
return 'oke';
}
return null;
}
}

26
app/Http/Controllers/Projects/ProjectsController.php

@ -91,6 +91,22 @@ class ProjectsController extends Controller {
return view('projects.features', compact('project','features'));
}
public function featuresExport($projectId)
{
$project = $this->repo->requireById($projectId);
$features = $this->repo->getProjectFeatures($projectId);
// return view('projects.features-export', compact('project','features'));
\Excel::create(str_slug(trans('project.features') . '-' . $project->name), function($excel) use ($project, $features) {
$excel->sheet('testng', function($sheet) use ($project, $features) {
$sheet->loadView('projects.features-export',compact('project','features'));
});
})->download('xlsx');
}
public function payments($projectId)
{
$project = $this->repo->requireById($projectId);
@ -105,4 +121,14 @@ class ProjectsController extends Controller {
return redirect()->route('projects.show', $projectId);
}
public function featuresReorder(Request $req, $projectId)
{
if ($req->ajax()) {
$data = $this->repo->featuresReorder($req->get('postData'));
return 'oke';
}
return null;
}
}

3
app/Http/routes.php

@ -9,4 +9,5 @@ require __DIR__ . '/routes/backup.php';
require __DIR__ . '/routes/projects.php';
require __DIR__ . '/routes/payments.php';
require __DIR__ . '/routes/subscriptions.php';
require __DIR__ . '/routes/reports.php';
require __DIR__ . '/routes/reports.php';
require __DIR__ . '/routes/options-vue.php';

61
app/Http/routes/options-vue.php

@ -0,0 +1,61 @@
<?php
/**
* Vue js Trial
*/
/** Index Page */
Route::get('options-vue', function() {
return view('options.index-vue');
});
Route::group(['prefix'=>'api/options'], function() {
Route::match(['GET','POST'], '/', function() {
if (Request::isMethod('GET'))
return App\Entities\Options\Option::all();
else {
return App\Entities\Options\Option::create(Request::only('key','value'));
}
});
Route::match(['GET','PATCH','DELETE'], '/{id}', function($id) {
if (Request::isMethod('GET'))
return App\Entities\Options\Option::findOrFail($id);
else if (Request::isMethod('PATCH')) {
App\Entities\Options\Option::findOrFail($id)->update(Request::only('key','value'));
return Response::json(Request::all());
} else {
return App\Entities\Options\Option::destroy($id);
}
});
});
// /** Fetch all options (API) */
// Route::get('api/options', function() {
// return App\Entities\Options\Option::all();
// });
// /** Create new options (API) */
// use App\Http\Requests\Options\CreateRequest;
// Route::post('api/options', function(CreateRequest $req) {
// return App\Entities\Options\Option::create($req->only('key','value'));
// });
// /** get one option (API) */
// Route::get('api/options/{id}', function($id) {
// return App\Entities\Options\Option::findOrFail($id);
// });
// /** update one option (API) */
// use Illuminate\Http\Request;
// Route::patch('api/options/{id}', function(Request $req, $id) {
// return App\Entities\Options\Option::findOrFail($id)->update($req->only('key','value'));
// });
// /** delete one option (API) */
// Route::delete('api/options/{id}', function($id) {
// App\Entities\Options\Option::destroy($id);
// return 'ok';
// });
/** end of Vue js Trial */

3
app/Http/routes/projects.php

@ -6,7 +6,9 @@ Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'],
*/
Route::get('projects/{id}/delete', ['as'=>'projects.delete', 'uses'=>'ProjectsController@delete']);
Route::get('projects/{id}/features', ['as'=>'projects.features', 'uses'=>'ProjectsController@features']);
Route::get('projects/{id}/features-export', ['as'=>'projects.features-export', 'uses'=>'ProjectsController@featuresExport']);
Route::get('projects/{id}/payments', ['as'=>'projects.payments', 'uses'=>'ProjectsController@payments']);
Route::post('projects/{id}/features-reorder', ['as'=>'projects.features-reorder', 'uses'=>'ProjectsController@featuresReorder']);
Route::patch('projects/{id}/status-update', ['as'=>'projects.status-update', 'uses'=>'ProjectsController@statusUpdate']);
Route::resource('projects','ProjectsController');
@ -16,6 +18,7 @@ Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'],
Route::get('projects/{id}/features/create', ['as'=>'features.create', 'uses'=>'FeaturesController@create']);
Route::get('projects/{id}/features/add-from-other-project', ['as'=>'features.add-from-other-project', 'uses'=>'FeaturesController@addFromOtherProject']);
Route::post('features/{id}/tasks-reorder', ['as'=>'features.tasks-reorder', 'uses'=>'FeaturesController@tasksReorder']);
Route::post('projects/{id}/features', ['as'=>'features.store', 'uses'=>'FeaturesController@store']);
Route::post('projects/{id}/features/store-from-other-project', ['as'=>'features.store-from-other-project', 'uses'=>'FeaturesController@storeFromOtherProject']);
Route::get('features/{id}/delete', ['as'=>'features.delete', 'uses'=>'FeaturesController@delete']);

2
app/Services/FormField.php

@ -67,7 +67,7 @@ class FormField
$hasError = $this->errorBag->has($name) ? 'has-error' : '';
$htmlForm = '<div class="form-group ' . $hasError . '">';
$rows = isset($options['rows']) ? $options['rows'] : 5;
$rows = isset($options['rows']) ? $options['rows'] : 3;
$value = isset($options['value']) ? $options['value'] : null;
$fieldParams = ['class'=>'form-control','rows' => $rows];

4
composer.json

@ -11,7 +11,9 @@
"laracasts/flash": "~1.3",
"laracasts/presenter": "^0.2.1",
"barryvdh/laravel-debugbar": "^2.0",
"backup-manager/laravel": "^1.0"
"backup-manager/laravel": "^1.0",
"maatwebsite/excel": "~2.1.0",
"barryvdh/laravel-dompdf": "^0.6.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

404
composer.lock

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "2fd93827839a83f6c46976e8a385211d",
"content-hash": "b3621e04a66796e567dde2e91b0878b4",
"hash": "6bdf9803e50e6cdbf8ae6733adee4b03",
"content-hash": "dff508a3fbbb8c01be9e0bd1e1352235",
"packages": [
{
"name": "backup-manager/backup-manager",
@ -184,6 +184,54 @@
"time": "2016-05-11 13:54:43"
},
{
"name": "barryvdh/laravel-dompdf",
"version": "v0.6.1",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-dompdf.git",
"reference": "b606788108833f7765801dca35455fb23ce9f869"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/b606788108833f7765801dca35455fb23ce9f869",
"reference": "b606788108833f7765801dca35455fb23ce9f869",
"shasum": ""
},
"require": {
"dompdf/dompdf": "0.6.*",
"illuminate/support": "5.0.x|5.1.x|5.2.x",
"php": ">=5.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.6-dev"
}
},
"autoload": {
"psr-4": {
"Barryvdh\\DomPDF\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "A DOMPDF Wrapper for Laravel",
"keywords": [
"dompdf",
"laravel",
"pdf"
],
"time": "2015-12-21 19:51:22"
},
{
"name": "classpreloader/classpreloader",
"version": "3.0.0",
"source": {
@ -338,6 +386,47 @@
"time": "2015-11-06 14:35:42"
},
{
"name": "dompdf/dompdf",
"version": "v0.6.2",
"source": {
"type": "git",
"url": "https://github.com/dompdf/dompdf.git",
"reference": "cc06008f75262510ee135b8cbb14e333a309f651"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/cc06008f75262510ee135b8cbb14e333a309f651",
"reference": "cc06008f75262510ee135b8cbb14e333a309f651",
"shasum": ""
},
"require": {
"phenx/php-font-lib": "0.2.*"
},
"type": "library",
"autoload": {
"classmap": [
"include/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
},
{
"name": "Brian Sweeney",
"email": "eclecticgeek@gmail.com"
}
],
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
"homepage": "https://github.com/dompdf/dompdf",
"time": "2015-12-07 04:07:13"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
"source": {
@ -838,6 +927,73 @@
"time": "2016-06-03 19:11:39"
},
{
"name": "maatwebsite/excel",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "c6ab521e8a5f2a4acc83cb575c4a09733a5e17c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/c6ab521e8a5f2a4acc83cb575c4a09733a5e17c9",
"reference": "c6ab521e8a5f2a4acc83cb575c4a09733a5e17c9",
"shasum": ""
},
"require": {
"illuminate/cache": "5.0.*|5.1.*|5.2.*",
"illuminate/config": "5.0.*|5.1.*|5.2.*",
"illuminate/filesystem": "5.0.*|5.1.*|5.2.*",
"illuminate/support": "5.0.*|5.1.*|5.2.*",
"nesbot/carbon": "~1.0",
"php": ">=5.5",
"phpoffice/phpexcel": "1.8.*",
"tijsverkoyen/css-to-inline-styles": "~1.5"
},
"require-dev": {
"mockery/mockery": "~0.9",
"orchestra/testbench": "3.1.*",
"phpseclib/phpseclib": "~1.0",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"illuminate/http": "5.0.*|5.1.*|5.2.*",
"illuminate/queue": "5.0.*|5.1.*|5.2.*",
"illuminate/routing": "5.0.*|5.1.*|5.2.*",
"illuminate/view": "5.0.*|5.1.*|5.2.*"
},
"type": "library",
"autoload": {
"classmap": [
"src/Maatwebsite/Excel"
],
"psr-0": {
"Maatwebsite\\Excel\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Maatwebsite.nl",
"email": "patrick@maatwebsite.nl"
}
],
"description": "An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel",
"keywords": [
"PHPExcel",
"batch",
"csv",
"excel",
"export",
"import",
"laravel"
],
"time": "2016-07-09 09:40:10"
},
{
"name": "maximebf/debugbar",
"version": "v1.11.1",
"source": {
@ -1167,6 +1323,97 @@
"time": "2016-03-18 20:34:03"
},
{
"name": "phenx/php-font-lib",
"version": "0.2.2",
"source": {
"type": "git",
"url": "https://github.com/PhenX/php-font-lib.git",
"reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PhenX/php-font-lib/zipball/c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82",
"reference": "c30c7fc00a6b0d863e9bb4c5d5dd015298b2dc82",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"classes/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Fabien Ménager",
"email": "fabien.menager@gmail.com"
}
],
"description": "A library to read, parse, export and make subsets of different types of font files.",
"homepage": "https://github.com/PhenX/php-font-lib",
"time": "2014-02-01 15:22:28"
},
{
"name": "phpoffice/phpexcel",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PHPExcel.git",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"shasum": ""
},
"require": {
"ext-xml": "*",
"ext-xmlwriter": "*",
"php": ">=5.2.0"
},
"type": "library",
"autoload": {
"psr-0": {
"PHPExcel": "Classes/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "http://blog.maartenballiauw.be"
},
{
"name": "Mark Baker"
},
{
"name": "Franck Lefevre",
"homepage": "http://blog.rootslabs.net"
},
{
"name": "Erik Tilt"
}
],
"description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "http://phpexcel.codeplex.com",
"keywords": [
"OpenXML",
"excel",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"time": "2015-05-01 07:00:55"
},
{
"name": "psr/log",
"version": "1.0.0",
"source": {
@ -1390,6 +1637,59 @@
"time": "2016-06-06 15:08:35"
},
{
"name": "symfony/css-selector",
"version": "v3.0.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "e8a66c51bf65f188c02f8120c0748b2291d3a2d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/e8a66c51bf65f188c02f8120c0748b2291d3a2d0",
"reference": "e8a66c51bf65f188c02f8120c0748b2291d3a2d0",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\CssSelector\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jean-François Simon",
"email": "jeanfrancois.simon@sensiolabs.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2016-06-06 11:33:26"
},
{
"name": "symfony/debug",
"version": "v3.0.7",
"source": {
@ -2109,6 +2409,53 @@
"time": "2016-05-24 10:03:10"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
"version": "1.5.5",
"source": {
"type": "git",
"url": "https://github.com/tijsverkoyen/CssToInlineStyles.git",
"reference": "9753fc340726e327e4d48b7c0604f85475ae0bc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/9753fc340726e327e4d48b7c0604f85475ae0bc3",
"reference": "9753fc340726e327e4d48b7c0604f85475ae0bc3",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/css-selector": "~2.1|~3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5.x-dev"
}
},
"autoload": {
"psr-4": {
"TijsVerkoyen\\CssToInlineStyles\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "Tijs Verkoyen",
"email": "css_to_inline_styles@verkoyen.eu",
"role": "Developer"
}
],
"description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.",
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
"time": "2015-12-08 16:14:14"
},
{
"name": "vlucas/phpdotenv",
"version": "v2.3.0",
"source": {
@ -3324,59 +3671,6 @@
"time": "2015-06-21 13:59:46"
},
{
"name": "symfony/css-selector",
"version": "v3.0.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "e8a66c51bf65f188c02f8120c0748b2291d3a2d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/e8a66c51bf65f188c02f8120c0748b2291d3a2d0",
"reference": "e8a66c51bf65f188c02f8120c0748b2291d3a2d0",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\CssSelector\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jean-François Simon",
"email": "jeanfrancois.simon@sensiolabs.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2016-06-06 11:33:26"
},
{
"name": "symfony/dom-crawler",
"version": "v3.0.7",
"source": {

4
config/app.php

@ -158,10 +158,11 @@ return [
App\Providers\OptionServiceProvider::class,
App\Providers\RouteServiceProvider::class,
BackupManager\Laravel\Laravel5ServiceProvider::class,
// Barryvdh\Debugbar\ServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
Laracasts\Flash\FlashServiceProvider::class,
BackupManager\Laravel\Laravel5ServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
],
@ -211,6 +212,7 @@ return [
'Carbon' => Carbon\Carbon::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'Form' => Collective\Html\FormFacade::class,
'FormField' => App\Services\Facades\FormField::class,
'Html' => Collective\Html\HtmlFacade::class,

691
config/excel.php

@ -0,0 +1,691 @@
<?php
return array(
'cache' => array(
/*
|--------------------------------------------------------------------------
| Enable/Disable cell caching
|--------------------------------------------------------------------------
*/
'enable' => true,
/*
|--------------------------------------------------------------------------
| Caching driver
|--------------------------------------------------------------------------
|
| Set the caching driver
|
| Available methods:
| memory|gzip|serialized|igbinary|discISAM|apc|memcache|temp|wincache|sqlite|sqlite3
|
*/
'driver' => 'memory',
/*
|--------------------------------------------------------------------------
| Cache settings
|--------------------------------------------------------------------------
*/
'settings' => array(
'memoryCacheSize' => '32MB',
'cacheTime' => 600
),
/*
|--------------------------------------------------------------------------
| Memcache settings
|--------------------------------------------------------------------------
*/
'memcache' => array(
'host' => 'localhost',
'port' => 11211,
),
/*
|--------------------------------------------------------------------------
| Cache dir (for discISAM)
|--------------------------------------------------------------------------
*/
'dir' => storage_path('cache')
),
'properties' => array(
'creator' => 'Nafies Luthfi',
'lastModifiedBy' => 'Nafies Luthfi',
'title' => 'Spreadsheet',
'description' => 'Default spreadsheet export',
'subject' => 'Spreadsheet export',
'keywords' => 'maatwebsite, excel, export',
'category' => 'Excel',
'manager' => 'Nafies Luthfi',
'company' => 'JasaWebsiteBanjarmasin.com',
),
/*
|--------------------------------------------------------------------------
| Sheets settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Default page setup
|--------------------------------------------------------------------------
*/
'pageSetup' => array(
'orientation' => 'portrait',
'paperSize' => '9',
'scale' => '100',
'fitToPage' => false,
'fitToHeight' => true,
'fitToWidth' => true,
'columnsToRepeatAtLeft' => array('', ''),
'rowsToRepeatAtTop' => array(0, 0),
'horizontalCentered' => false,
'verticalCentered' => false,
'printArea' => null,
'firstPageNumber' => null,
),
),
/*
|--------------------------------------------------------------------------
| Creator
|--------------------------------------------------------------------------
|
| The default creator of a new Excel file
|
*/
'creator' => 'Maatwebsite',
'csv' => array(
/*
|--------------------------------------------------------------------------
| Delimiter
|--------------------------------------------------------------------------
|
| The default delimiter which will be used to read out a CSV file
|
*/
'delimiter' => ',',
/*
|--------------------------------------------------------------------------
| Enclosure
|--------------------------------------------------------------------------
*/
'enclosure' => '"',
/*
|--------------------------------------------------------------------------
| Line endings
|--------------------------------------------------------------------------
*/
'line_ending' => "\r\n",
/*
|--------------------------------------------------------------------------
| setUseBom
|--------------------------------------------------------------------------
*/
'use_bom' => false
),
'export' => array(
/*
|--------------------------------------------------------------------------
| Autosize columns
|--------------------------------------------------------------------------
|
| Disable/enable column autosize or set the autosizing for
| an array of columns ( array('A', 'B') )
|
*/
'autosize' => true,
/*
|--------------------------------------------------------------------------
| Autosize method
|--------------------------------------------------------------------------
|
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX
| The default is based on an estimate, which does its calculation based
| on the number of characters in the cell value (applying any calculation
| and format mask, and allowing for wordwrap and rotation) and with an
| "arbitrary" adjustment based on the font (Arial, Calibri or Verdana,
| defaulting to Calibri if any other font is used) and a proportional
| adjustment for the font size.
|
| --> PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT
| The second method is more accurate, based on actual style formatting as
| well (bold, italic, etc), and is calculated by generating a gd2 imagettf
| bounding box and using its dimensions to determine the size; but this
| method is significantly slower, and its accuracy is still dependent on
| having the appropriate fonts installed.
|
*/
'autosize-method' => PHPExcel_Shared_Font::AUTOSIZE_METHOD_APPROX,
/*
|--------------------------------------------------------------------------
| Auto generate table heading
|--------------------------------------------------------------------------
|
| If set to true, the array indices (or model attribute names)
| will automatically be used as first row (table heading)
|
*/
'generate_heading_by_indices' => true,
/*
|--------------------------------------------------------------------------
| Auto set alignment on merged cells
|--------------------------------------------------------------------------
*/
'merged_cell_alignment' => 'left',
/*
|--------------------------------------------------------------------------
| Pre-calculate formulas during export
|--------------------------------------------------------------------------
*/
'calculate' => false,
/*
|--------------------------------------------------------------------------
| Include Charts during export
|--------------------------------------------------------------------------
*/
'includeCharts' => false,
/*
|--------------------------------------------------------------------------
| Default sheet settings
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Default page margin
|--------------------------------------------------------------------------
|
| 1) When set to false, default margins will be used
| 2) It's possible to enter a single margin which will
| be used for all margins.
| 3) Alternatively you can pass an array with 4 margins
| Default order: array(top, right, bottom, left)
|
*/
'page_margin' => false,
/*
|--------------------------------------------------------------------------
| Value in source array that stands for blank cell
|--------------------------------------------------------------------------
*/
'nullValue' => null,
/*
|--------------------------------------------------------------------------
| Insert array starting from this cell address as the top left coordinate
|--------------------------------------------------------------------------
*/
'startCell' => 'A1',
/*
|--------------------------------------------------------------------------
| Apply strict comparison when testing for null values in the array
|--------------------------------------------------------------------------
*/
'strictNullComparison' => false
),
/*
|--------------------------------------------------------------------------
| Store settings
|--------------------------------------------------------------------------
*/
'store' => array(
/*
|--------------------------------------------------------------------------
| Path
|--------------------------------------------------------------------------
|
| The path we want to save excel file to
|
*/
'path' => storage_path('exports'),
/*
|--------------------------------------------------------------------------
| Return info
|--------------------------------------------------------------------------
|
| Whether we want to return information about the stored file or not
|
*/
'returnInfo' => false
),
/*
|--------------------------------------------------------------------------
| PDF Settings
|--------------------------------------------------------------------------
*/
'pdf' => array(
/*
|--------------------------------------------------------------------------
| PDF Drivers
|--------------------------------------------------------------------------
| Supported: DomPDF, tcPDF, mPDF
*/
'driver' => 'DomPDF',
/*
|--------------------------------------------------------------------------
| PDF Driver settings
|--------------------------------------------------------------------------
*/
'drivers' => array(
/*
|--------------------------------------------------------------------------
| DomPDF settings
|--------------------------------------------------------------------------
*/
'DomPDF' => array(
'path' => base_path('vendor/dompdf/dompdf/')
),
/*
|--------------------------------------------------------------------------
| tcPDF settings
|--------------------------------------------------------------------------
*/
'tcPDF' => array(
'path' => base_path('vendor/tecnick.com/tcpdf/')
),
/*
|--------------------------------------------------------------------------
| mPDF settings
|--------------------------------------------------------------------------
*/
'mPDF' => array(
'path' => base_path('vendor/mpdf/mpdf/')
),
)
)
),
'filters' => array(
/*
|--------------------------------------------------------------------------
| Register read filters
|--------------------------------------------------------------------------
*/
'registered' => array(
'chunk' => 'Maatwebsite\Excel\Filters\ChunkReadFilter'
),
/*
|--------------------------------------------------------------------------
| Enable certain filters for every file read
|--------------------------------------------------------------------------
*/
'enabled' => array()
),
'import' => array(
/*
|--------------------------------------------------------------------------
| Has heading
|--------------------------------------------------------------------------
|
| The sheet has a heading (first) row which we can use as attribute names
|
| Options: true|false|slugged|slugged_with_count|ascii|numeric|hashed|trans|original
|
*/
'heading' => 'slugged',
/*
|--------------------------------------------------------------------------
| First Row with data or heading of data
|--------------------------------------------------------------------------
|
| If the heading row is not the first row, or the data doesn't start
| on the first row, here you can change the start row.
|
*/
'startRow' => 1,
/*
|--------------------------------------------------------------------------
| Cell name word separator
|--------------------------------------------------------------------------
|
| The default separator which is used for the cell names
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
*/
'separator' => '_',
/*
|--------------------------------------------------------------------------
| Include Charts during import
|--------------------------------------------------------------------------
*/
'includeCharts' => false,
/*
|--------------------------------------------------------------------------
| Sheet heading conversion
|--------------------------------------------------------------------------
|
| Convert headings to ASCII
| Note: only applies to 'heading' settings 'true' && 'slugged'
|
*/
'to_ascii' => true,
/*
|--------------------------------------------------------------------------
| Import encoding
|--------------------------------------------------------------------------
*/
'encoding' => array(
'input' => 'UTF-8',
'output' => 'UTF-8'
),
/*
|--------------------------------------------------------------------------
| Calculate
|--------------------------------------------------------------------------
|
| By default cells with formulas will be calculated.
|
*/
'calculate' => true,
/*
|--------------------------------------------------------------------------
| Ignore empty cells
|--------------------------------------------------------------------------
|
| By default empty cells are not ignored
|
*/
'ignoreEmpty' => false,
/*
|--------------------------------------------------------------------------
| Force sheet collection
|--------------------------------------------------------------------------
|
| For a sheet collection even when there is only 1 sheets.
| When set to false and only 1 sheet found, the parsed file will return
| a row collection instead of a sheet collection.
| When set to true, it will return a sheet collection instead.
|
*/
'force_sheets_collection' => false,
/*
|--------------------------------------------------------------------------
| Date format
|--------------------------------------------------------------------------
|
| The format dates will be parsed to
|
*/
'dates' => array(
/*
|--------------------------------------------------------------------------
| Enable/disable date formatting
|--------------------------------------------------------------------------
*/
'enabled' => true,
/*
|--------------------------------------------------------------------------
| Default date format
|--------------------------------------------------------------------------
|
| If set to false, a carbon object will return
|
*/
'format' => false,
/*
|--------------------------------------------------------------------------
| Date columns
|--------------------------------------------------------------------------
*/
'columns' => array()
),
/*
|--------------------------------------------------------------------------
| Import sheets by config
|--------------------------------------------------------------------------
*/
'sheets' => array(
/*
|--------------------------------------------------------------------------
| Example sheet
|--------------------------------------------------------------------------
|
| Example sheet "test" will grab the firstname at cell A2
|
*/
'test' => array(
'firstname' => 'A2'
)
)
),
'views' => array(
/*
|--------------------------------------------------------------------------
| Styles
|--------------------------------------------------------------------------
|
| The default styles which will be used when parsing a view
|
*/
'styles' => array(
/*
|--------------------------------------------------------------------------
| Table headings
|--------------------------------------------------------------------------
*/
'th' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Strong tags
|--------------------------------------------------------------------------
*/
'strong' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Bold tags
|--------------------------------------------------------------------------
*/
'b' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Italic tags
|--------------------------------------------------------------------------
*/
'i' => array(
'font' => array(
'italic' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Heading 1
|--------------------------------------------------------------------------
*/
'h1' => array(
'font' => array(
'bold' => true,
'size' => 24,
)
),
/*
|--------------------------------------------------------------------------
| Heading 2
|--------------------------------------------------------------------------
*/
'h2' => array(
'font' => array(
'bold' => true,
'size' => 18,
)
),
/*
|--------------------------------------------------------------------------
| Heading 2
|--------------------------------------------------------------------------
*/
'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5,
)
),
/*
|--------------------------------------------------------------------------
| Heading 4
|--------------------------------------------------------------------------
*/
'h4' => array(
'font' => array(
'bold' => true,
'size' => 12,
)
),
/*
|--------------------------------------------------------------------------
| Heading 5
|--------------------------------------------------------------------------
*/
'h5' => array(
'font' => array(
'bold' => true,
'size' => 10,
)
),
/*
|--------------------------------------------------------------------------
| Heading 6
|--------------------------------------------------------------------------
*/
'h6' => array(
'font' => array(
'bold' => true,
'size' => 7.5,
)
),
/*
|--------------------------------------------------------------------------
| Hyperlinks
|--------------------------------------------------------------------------
*/
'a' => array(
'font' => array(
'underline' => true,
'color' => array('argb' => 'FF0000FF'),
)
),
/*
|--------------------------------------------------------------------------
| Horizontal rules
|--------------------------------------------------------------------------
*/
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => 'thin',
'color' => array('FF000000')
),
)
)
)
)
);

4
database/factories/ModelFactory.php

@ -96,6 +96,7 @@ $factory->define(Feature::class, function (Faker\Generator $faker) {
'description' => $faker->paragraph,
'worker_id' => factory(User::class)->create()->id,
'type_id' => rand(1,2),
'position' => rand(1,10),
];
});
@ -106,6 +107,7 @@ $factory->define(Task::class, function (Faker\Generator $faker) {
'name' => $faker->sentence(3),
'description' => $faker->paragraph,
'progress' => rand(40,100),
'route_name' => implode('.', $faker->words(3))
'route_name' => implode('.', $faker->words(3)),
'position' => rand(1,10),
];
});

32
public/assets/js/sb-admin-2.js

@ -8,21 +8,21 @@ $(function() {
//collapses the sidebar on window resize.
// Sets the min-height of #page-wrapper to window size
$(function() {
// $(window).bind("load resize", function() {
// topOffset = 50;
// width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
// if (width < 768) {
// $('div.navbar-collapse').addClass('collapse')
// topOffset = 100; // 2-row-menu
// } else {
// $('div.navbar-collapse').removeClass('collapse')
// }
$(window).bind("load resize", function() {
topOffset = 50;
width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
if (width < 768) {
$('div.navbar-collapse').addClass('collapse')
topOffset = 100; // 2-row-menu
} else {
$('div.navbar-collapse').removeClass('collapse')
}
// height = (this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height;
// height = height - topOffset;
// if (height < 1) height = 1;
// if (height > topOffset) {
// $("#page-wrapper").css("min-height", (height) + "px");
// }
// })
// height = (this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height;
// height = height - topOffset;
// if (height < 1) height = 1;
// if (height > topOffset) {
// $("#page-wrapper").css("min-height", (height) + "px");
// }
})
});

1
resources/lang/id/project.php

@ -24,6 +24,7 @@ return [
'cash_out_total' => 'Total Pengeluaran',
'customer' => 'Customer',
'features' => 'Daftar Fitur',
'features_export' => 'Export Fitur ke Excel',
'worker' => 'Pekerja',
'status' => 'Status Project',
'payments' => 'Pembayaran',

2
resources/views/features/partials/feature-show.blade.php

@ -2,7 +2,7 @@
<div class="panel-heading"><h3 class="panel-title">{{ trans('feature.show') }}</h3></div>
<table class="table table-condensed">
<tbody>
<tr><th>{{ trans('feature.name') }}</th><td>{{ $feature->name }}</td></tr>
<tr><th class="col-md-3">{{ trans('feature.name') }}</th><td class="col-md-9">{{ $feature->name }}</td></tr>
<tr><th>{{ trans('feature.price') }}</th><td>{{ formatRp($feature->price) }}</td></tr>
<tr><th>{{ trans('feature.tasks_count') }}</th><td>{{ $feature->tasks->count() }}</td></tr>
<tr><th>{{ trans('feature.progress') }}</th><td>{{ formatDecimal($feature->tasks->avg('progress')) }}%</td></tr>

32
resources/views/features/partials/feature-tasks-operation.blade.php

@ -8,7 +8,7 @@
<div class="col-sm-5">{!! FormField::text('route_name') !!}</div>
<div class="col-sm-2">{!! FormField::text('progress', ['addon' => ['after' => '%'],'value' => 0]) !!}</div>
</div>
{!! FormField::text('description') !!}
{!! FormField::textarea('description') !!}
{!! Form::submit(trans('task.create'), ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
</div>
@ -20,12 +20,18 @@
<div class="panel-heading"><h3 class="panel-title">{{ trans('task.edit') }}</h3></div>
<div class="panel-body">
<div class="row">
<div class="col-sm-5">{!! FormField::text('name') !!}</div>
<div class="col-sm-5">{!! FormField::text('route_name') !!}</div>
<div class="col-sm-2">{!! FormField::text('progress', ['addon' => ['after' => '%']]) !!}</div>
<div class="col-sm-6">{!! FormField::text('name') !!}</div>
<div class="col-sm-6">{!! FormField::text('route_name') !!}</div>
</div>
{!! FormField::textarea('description') !!}
{!! Form::hidden('feature_id', $editableTask->feature_id) !!}
<div class="row">
<div class="col-md-6">
{!! FormField::text('progress', ['addon' => ['after' => '%']]) !!}
</div>
<div class="col-md-6">
{!! FormField::select('feature_id', $feature->project->features->lists('name','id'), ['label' => 'Pindahkan ke Fitur lain']) !!}
</div>
</div>
{!! Form::submit(trans('task.update'), ['class' => 'btn btn-warning']) !!}
{!! link_to_route('features.show', trans('app.cancel'), [$feature->id], ['class' => 'btn btn-default']) !!}
{!! Form::close() !!}
@ -36,18 +42,22 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('task.delete') }}</h3></div>
<div class="panel-body">
<div>{{ $editableTask->name }}</div>
<div class="small text-info">{!! $editableTask->description !!}</div>
</div>
<div class="panel-footer">
{{ trans('app.delete_confirm') }}
{!! link_to_route('features.show', trans('app.cancel'), [$feature->id], ['class' => 'btn btn-default']) !!}
<div class="pull-right">
{!! FormField::delete([
'route'=>['tasks.destroy',$editableTask->id]],
trans('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'route'=>['tasks.destroy',$editableTask->id]],
trans('app.delete_confirm_button'),
['class'=>'btn btn-danger'],
[
'task_id' => $editableTask->id,
'feature_id' => $editableTask->feature_id,
]) !!}
]) !!}
</div>
</div>
</div>
</div>
@endif

27
resources/views/features/partials/feature-tasks.blade.php

@ -8,13 +8,13 @@
<th class="text-center">{{ trans('task.progress') }}</th>
<th>{{ trans('app.action') }}</th>
</thead>
<tbody>
<tbody id="sort-tasks">
@forelse($feature->tasks as $key => $task)
<tr>
<tr id="{{ $task->id }}">
<td>{{ 1 + $key }}</td>
<td>
<div>{{ $task->name }}</div>
<div class="small text-info">{{ $task->description }}</div>
<div class="small text-info">{!! nl2br($task->description) !!}</div>
</td>
<td>{{ $task->route_name }}</td>
<td class="text-center">{{ $task->progress }} %</td>
@ -43,4 +43,23 @@
</tr>
</tfoot>
</table>
</div>
</div>
@section('ext_js')
{!! Html::script(url('assets/js/plugins/jquery-ui.min.js')) !!}
@endsection
@section('script')
<script>
(function() {
$('#sort-tasks').sortable({
update: function (event, ui) {
var data = $(this).sortable('toArray').toString();
// console.log(data);
$.post("{{ route('features.tasks-reorder', $feature->id) }}", {postData: data});
}
});
})();
</script>
@endsection

1
resources/views/layouts/app.blade.php

@ -19,7 +19,6 @@
@include('layouts.partials.sidebar')
<div id="page-wrapper">
{{-- @include('layouts.partials.top-nav') --}}
@include('flash::message')
<div class="container-fluid">
@yield('content')

12
resources/views/layouts/guest.blade.php

@ -9,11 +9,12 @@
<meta name="author" content="">
<title>@yield('title', Option::get('app_name', 'Aplikasi Laravel'))</title>
{!! Html::style('assets/css/bootstrap.min.css') !!}
{!! Html::style('assets/css/bootstrap-theme.min.css') !!}
{!! Html::style('assets/css/font-awesome.min.css') !!}
{!! Html::style('assets/css/sb-admin-2.css') !!}
{{-- {!! Html::style('assets/css/bootstrap.min.css') !!} --}}
{{-- {!! Html::style('assets/css/bootstrap-theme.min.css') !!} --}}
{{-- {!! Html::style('assets/css/font-awesome.min.css') !!} --}}
{{-- {!! Html::style('assets/css/sb-admin-2.css') !!} --}}
{!! Html::style('assets/css/app.css') !!}
@yield('ext_css')
</head>
<body>
<div class="container">
@ -25,11 +26,14 @@
{!! Html::script(url('assets/js/jquery.js')) !!}
{!! Html::script(url('assets/js/bootstrap.min.js')) !!}
@yield('ext_js')
<script type="text/javascript">
(function() {
$("div.alert.notifier").delay(10000).fadeOut();
})();
</script>
@yield('script')
</body>
</html>

8
resources/views/layouts/partials/sidebar.blade.php

@ -1,3 +1,11 @@
<nav class="navbar navbar-default hidden-md" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
Menu
</button>
</div>
</nav>
<div class="navbar-default sidebar hidden-print" role="navigation">
<div class="sidebar-nav navbar-collapse">
<a class="navbar-brand text-center" title="Home | {{ Option::get('app_tagline', 'Laravel app description') }}" href="{{ route('home') }}">

172
resources/views/options/index-vue-div.blade.php

@ -0,0 +1,172 @@
@extends('layouts.guest')
@section('content')
<h1 class="page-header">Options</h1>
<div id="vue-el">
<div class="row">
<div class="col-md-8">
<!-- <div class="alert alert-success" transition="success" v-if="add_success">Add new option success.</div>
<div class="alert alert-success" transition="success" v-if="update_success">Update option success.</div> -->
<div class="row">
<div class="col-md-1">ID</div>
<div class="col-md-4">Key</div>
<div class="col-md-5">Value</div>
<div class="col-md-2">Option</div>
</div>
<div class="row" v-for="option in options">
<options-row :option="option" :options="options"></options-row>
</div>
<div class="row">
<options-new :newOption="newOption" :options="options"></options-new>
</div>
</div>
</div>
</div>
<template id="option-row-template">
<div v-show="!inEditMode">
<div class="col-md-1">@{{ option.id }}</div>
<div class="col-md-4">@{{ option.key }}</div>
<div class="col-md-5">@{{ option.value }}</div>
<div class="col-md-2">
<button class="btn btn-info btn-xs" v-on:click="editForm">Edit</button>
</div>
</div>
<div v-show="inEditMode">
<div class="col-md-1">@{{ option.id }}</div>
<div class="col-md-4">
<input v-model="option.key" v-on:keyup.esc="cancelEditMode" type="text" class="form-control" />
</div>
<div class="col-md-5">
<input v-model="option.value" v-on:keyup.esc="cancelEditMode" type="text" class="form-control" />
</div>
<div class="col-md-2">
<button class="btn btn-info btn-xs" v-on:click="update(option)">update</button>
<button class="btn btn-danger btn-xs" v-on:click="deleteOpt(option)">x</button>
</div>
</div>
</template>
<template id="option-new-template">
<form action="#" method="post" v-on:submit.prevent="addNewOption">
<div class="col-md-1">&nbsp;</div>
<div class="col-md-4">
<input type="text" id="key" name="key" class="form-control" v-model="newOption.key" placeholder="Add new Option key">
</div>
<div class="col-md-5">
<textarea id="value" name="value" class="form-control" v-model="newOption.value" placeholder="Add new Option value"></textarea>
</div>
<div class="col-md-2">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</template>
@endsection
@section('ext_js')
{!! Html::script(url('assets/js/plugins/vue.min.js')) !!}
{!! Html::script(url('assets/js/plugins/vue-resource.min.js')) !!}
@endsection
@section('script')
<script>
Vue.component('options-row', {
data: function() {
return {
inEditMode: false
}
},
props: ['option','options'],
template: '#option-row-template',
methods: {
editForm: function() {
this.inEditMode = true;
},
update: function(option) {
this.$http.patch('api/options/' + option.id, option);
this.inEditMode = false;
},
cancelEditMode: function() {
this.inEditMode = false;
},
deleteOpt: function(option) {
var confirmBox = confirm('Delete this option?');
if (confirmBox) {
this.$http.delete('api/options/' + option.id);
// console.log (this.options);
this.options.$remove(option);
// this.options.splice(id, 1);
// console.log (this.options);
// this.fetchOptions();
}
this.inEditMode = false;
}
}
});
Vue.component('options-new', {
data: function() {
return {
newOption: {
key: '',
value: ''
}
}
},
props: ['options'],
template: '#option-new-template',
methods: {
addNewOption: function() {
// New Option Input
var option = this.newOption;
// Clear form
this.newOption = { key: '', value: '' }
// Send post request
this.$http.post('api/options', option, function(data) {
this.options.push(data);
});
}
}
});
var vm = new Vue({
http: {
headers: {
'X-CSRF-Token': "{{ csrf_token() }}"
}
},
el: "#vue-el",
methods: {
fetchOptions: function() {
this.$http.get('api/options', function(data) {
this.$set('options', data);
});
}
},
ready: function() {
this.fetchOptions();
}
});
</script>
@endsection
@section('style')
<style>
.success-transition {
transition: all .5s ease-in-out;
}
.success-enter, .success-leave {
opacity: 0;
}
</style>
@endsection

170
resources/views/options/index-vue.blade.php

@ -0,0 +1,170 @@
@extends('layouts.guest')
@section('content')
<h1 class="page-header">Options</h1>
<div id="vue-el">
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-1">ID</div>
<div class="col-md-4">Key</div>
<div class="col-md-5">Value</div>
<div class="col-md-2">Option</div>
</div>
<div class="row" v-for="option in options">
<options-row :option="option" :options="options"></options-row>
</div>
<div class="row">
<options-new :newOption="newOption" :options="options"></options-new>
</div>
</div>
</div>
</div>
<template id="option-row-template">
<div v-show="!inEditMode">
<div class="col-md-1">@{{ option.id }}</div>
<div class="col-md-4">@{{ option.key }}</div>
<div class="col-md-5">@{{ option.value }}</div>
<div class="col-md-2">
<button class="btn btn-info btn-xs" v-on:click="editForm">Edit</button>
</div>
</div>
<div v-show="inEditMode">
<div class="col-md-1">@{{ option.id }}</div>
<div class="col-md-4">
<input v-model="option.key" v-on:keyup.esc="cancelEditMode" type="text" class="form-control" />
</div>
<div class="col-md-5">
<input v-model="option.value" v-on:keyup.esc="cancelEditMode" type="text" class="form-control" />
</div>
<div class="col-md-2">
<button class="btn btn-info btn-xs" v-on:click="update(option)">update</button>
<button class="btn btn-danger btn-xs" v-on:click="deleteOpt(option)">x</button>
</div>
</div>
</template>
<template id="option-new-template">
<form action="#" method="post" v-on:submit.prevent="addNewOption">
<div class="col-md-1">&nbsp;</div>
<div class="col-md-4">
<input type="text" id="key" name="key" class="form-control" v-model="newOption.key" placeholder="Add new Option key">
</div>
<div class="col-md-5">
<textarea id="value" name="value" class="form-control" v-model="newOption.value" placeholder="Add new Option value"></textarea>
</div>
<div class="col-md-2">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</template>
@endsection
@section('ext_js')
{!! Html::script(url('assets/js/plugins/vue.min.js')) !!}
{!! Html::script(url('assets/js/plugins/vue-resource.min.js')) !!}
@endsection
@section('script')
<script>
Vue.component('options-row', {
data: function() {
return {
inEditMode: false
}
},
props: ['option','options'],
template: '#option-row-template',
methods: {
editForm: function() {
this.inEditMode = true;
},
update: function(option) {
this.$http.patch('api/options/' + option.id, option);
this.inEditMode = false;
},
cancelEditMode: function() {
this.inEditMode = false;
},
deleteOpt: function(option) {
var confirmBox = confirm('Delete this option?');
if (confirmBox) {
this.$http.delete('api/options/' + option.id);
// console.log (this.options);
this.options.$remove(option);
// this.options.splice(id, 1);
// console.log (this.options);
// this.fetchOptions();
}
this.inEditMode = false;
}
}
});
Vue.component('options-new', {
data: function() {
return {
newOption: {
key: '',
value: ''
}
}
},
props: ['options'],
template: '#option-new-template',
methods: {
addNewOption: function() {
// New Option Input
var option = this.newOption;
// Clear form
this.newOption = { key: '', value: '' }
// Send post request
this.$http.post('api/options', option, function(data) {
this.options.push(data);
});
}
}
});
var vm = new Vue({
http: {
headers: {
'X-CSRF-Token': "{{ csrf_token() }}"
}
},
el: "#vue-el",
methods: {
fetchOptions: function() {
this.$http.get('api/options', function(data) {
this.$set('options', data);
});
}
},
ready: function() {
this.fetchOptions();
}
});
</script>
@endsection
@section('style')
<style>
.success-transition {
transition: all .5s ease-in-out;
}
.success-enter, .success-leave {
opacity: 0;
}
</style>
@endsection

71
resources/views/projects/features-export.blade.php

@ -0,0 +1,71 @@
<?php
// $filename = str_slug(trans('project.features') . '-' . $project->name) . '.xls';
// header("Content-Disposition: attachment; filename=\"$filename\"");
// header("Content-Type: application/vnd.ms-excel");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
{{-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --}}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{ $project->name }}</title>
<style>
th, td {
padding: 5px;
}
</style>
</head>
<body>
<table border="1" class="table table-condensed table-striped">
<thead>
<tr>
<td colspan="4" style="text-align:center">
<h1>{{ trans('project.features') }} {{ $project->name }}</h1>
</td>
</tr>
<tr>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th>
{{-- <th class="text-center">{{ trans('feature.progress') }}</th> --}}
<th class="text-right">{{ trans('feature.price') }}</th>
<th>{{ trans('app.notes') }}</th>
</tr>
</thead>
<tbody id="sort-features">
@forelse($features as $key => $feature)
<tr>
<td rowspan="{{ $feature->tasks->count() + 1 }}">{{ 1 + $key }}</td>
<td>
{{ $feature->name }}
</td>
{{-- <td class="text-center">{{ formatDecimal($feature->progress = $feature->tasks->avg('progress')) }} %</td> --}}
<td rowspan="{{ $feature->tasks->count() + 1 }}" class="text-right">{{ $feature->price }}</td>
<td style="wrap-text: true;">{!! nl2br($feature->description) !!}</td>
</tr>
@if ($feature->tasks->count())
@foreach($feature->tasks as $task)
<tr>
<td></td>
<td>{{ $task->name }}</td>
<td></td>
<td style="wrap-text: true;">{!! nl2br($task->description) !!}</td>
</tr>
@endforeach
@endif
@empty
<tr><td colspan="7">{{ trans('feature.empty') }}</td></tr>
@endforelse
</tbody>
<tfoot>
<tr>
<th class="text-right" colspan="2">Total</th>
{{-- <th class="text-center">{{ formatDecimal($features->avg('progress')) }} %</th> --}}
<th class="text-right">{{ $features->sum('price') }}</th>
<th></th>
</tr>
</tfoot>
</table>
</body>
</html>

41
resources/views/projects/features.blade.php

@ -16,7 +16,7 @@
@include('projects.partials.nav-tabs')
<div class="panel panel-default">
<table class="table table-condensed">
<table id="features-table" class="table table-condensed table-striped">
<thead>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th>
@ -26,17 +26,18 @@
<th>{{ trans('feature.worker') }}</th>
<th>{{ trans('app.action') }}</th>
</thead>
<tbody>
<tbody id="sort-features">
@forelse($features as $key => $feature)
<tr>
<td>{{ 1 + $key }}</td>
@php($no = 1 + $key)
<tr id="{{ $feature->id }}">
<td>{{ $no }}</td>
<td>
{{ $feature->name }}
@if ($feature->tasks->isEmpty() == false)
<ul>
@foreach($feature->tasks as $task)
<li style="cursor:pointer" title="{{ $task->progress }} %">
<i class="fa fa-battery-{{ ceil(4 * $task->progress/100) }}"></i>
<li title="{{ $task->progress }} %">
{{-- <i class="fa fa-battery-{{ ceil(4 * $task->progress/100) }}"></i> --}}
{{ $task->name }}
</li>
@endforeach
@ -68,4 +69,32 @@
</tfoot>
</table>
</div>
@endsection
{{--
@section('ext_css')
{!! Html::style(url('assets/css/plugins/dataTables.bootstrap.css')) !!}
@endsection
--}}
@section('ext_js')
{{-- {!! Html::script(url('assets/js/plugins/dataTables/jquery.dataTables.js')) !!}
{!! Html::script(url('assets/js/plugins/dataTables/dataTables.bootstrap.js')) !!}
--}} {!! Html::script(url('assets/js/plugins/jquery-ui.min.js')) !!}
@endsection
@section('script')
<script>
(function() {
// $('#features-table').dataTable({
// "paging": false,
// "info": false
// });
$('#sort-features').sortable({
update: function (event, ui) {
var data = $(this).sortable('toArray').toString();
$.post("{{ route('projects.features-reorder', $project->id) }}", {postData: data});
}
});
})();
</script>
@endsection

3
resources/views/projects/partials/nav-tabs.blade.php

@ -1,3 +1,6 @@
@if (Request::segment(3) == 'features')
{!! link_to_route('projects.features-export', trans('project.features_export'), [$project->id], ['class' => 'btn btn-success pull-right']) !!}
@endif
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="{{ Request::segment(3) == null ? 'active' : '' }}">

4
tests/ManageProjectsTest.php

@ -71,7 +71,7 @@ class ManageProjectsTest extends TestCase
/** @test */
public function admin_can_delete_a_project()
{
$this->adminUserSigningIn();
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create(['owner_id' => $user->id]);
$feature = factory(Feature::class)->create(['project_id' => $project->id]);
@ -165,7 +165,7 @@ class ManageProjectsTest extends TestCase
/** @test */
public function admin_can_update_project_status_on_project_detail_page()
{
$this->adminUserSigningIn();
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create(['owner_id' => $user->id, 'status_id' => 1]);
$this->visit(route('projects.show', $project->id));

Loading…
Cancel
Save