diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index d406a8d28..bcd992545 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -25,7 +25,7 @@ class Install extends Command { const COLOR_GOOD = 'green'; - const COLOR_BAD = 'red'; + const COLOR_BAD = 'red'; const COLOR_INFO = 'blue'; /** @@ -152,7 +152,7 @@ protected function checkEnvironment() $this->checkPhpExtension($this->dbDrivers, '{module} driver for pdo', false, 'Not Found'); // Whether or not one or more valid drivers were found - $validDrivers = $this->getValidDbDrivers(); + $validDrivers = $this->getValidDbDrivers(); $dbDriverStatus = !empty($validDrivers); if (!$dbDriverStatus) { $dbDriverTitle = 'Install one of the following pdo drivers (' @@ -195,8 +195,8 @@ protected function checkEnvironment() protected function checkPhpExtension(array &$modules, $labelFormat, $required = true, $failedLabel = 'No') { foreach ($modules as $module => $status) { - $title = str_replace(['{module}'], [$module], $labelFormat); - $status = extension_loaded($module); + $title = str_replace(['{module}'], [$module], $labelFormat); + $status = extension_loaded($module); $modules[$module] = $status; $this->envRequirementsRow($title, $status, $required, $failedLabel); } @@ -216,8 +216,8 @@ protected function checkPhpExtension(array &$modules, $labelFormat, $required = */ protected function envRequirementsRow($label, $status = false, $required = false, $failedLabel = 'No') { - $statusColor = $status ? static::COLOR_GOOD : ($required ? static::COLOR_BAD : static::COLOR_INFO); - $statusTitle = $status ? 'OK' : $failedLabel; + $statusColor = $status ? static::COLOR_GOOD : ($required ? static::COLOR_BAD : static::COLOR_INFO); + $statusTitle = $status ? 'OK' : $failedLabel; $this->envRequirements[] = $this->formatTableCells([$label, $statusTitle], $statusColor); if ($required) { $this->envStatus = $status; @@ -261,13 +261,13 @@ protected function getValidDbDrivers() protected function isUploadDirectoryPublic() { $pathSegments = explode('/', base_path()); - $count = count($pathSegments); - $indexes = []; + $count = count($pathSegments); + $indexes = []; for ($i = 0; $i < $count; ++$i) { $indexes[] = $i; - $path = implode('/', array_except($pathSegments, $indexes)); - $guessUrl = url($path . '/storage/app/uploads'); - $curl = curl_init($guessUrl); + $path = implode('/', array_except($pathSegments, $indexes)); + $guessUrl = url($path . '/storage/app/uploads'); + $curl = curl_init($guessUrl); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_exec($curl); @@ -329,12 +329,12 @@ protected function stageOne() 'sysName' => 'Email name used by the Tiny Issue for the email address above', 'timezone' => 'The application timezone. Find your timezone from: http://php.net/manual/en/timezones.php)', ]); - $this->data['key'] = md5(str_random(40)); + $this->data['key'] = md5(str_random(40)); $this->data['dbDriver'] = substr($this->data['dbDriver'], 4); // Create .env from .env.example and populate with user data $filesystem = $this->getFilesystem(); - $content = $filesystem->read('.env.example'); + $content = $filesystem->read('.env.example'); if (empty($content)) { throw new \Exception('Unable to read .env.example to create .env file.'); } @@ -348,13 +348,13 @@ protected function stageOne() $filesystem->put('.env', $content); // Update the current database connection - $config = \Config::get('database.connections.' . $this->data['dbDriver']); - $config['driver'] = $this->data['dbDriver']; - $config['host'] = $this->data['dbHost']; + $config = \Config::get('database.connections.' . $this->data['dbDriver']); + $config['driver'] = $this->data['dbDriver']; + $config['host'] = $this->data['dbHost']; $config['database'] = $this->data['dbName']; $config['username'] = $this->data['dbUser']; $config['password'] = $this->data['dbPass']; - $config['prefix'] = $this->data['dbPrefix']; + $config['prefix'] = $this->data['dbPrefix']; \Config::set('database.connections.' . $this->data['dbDriver'], $config); \Config::set('database.default', $this->data['dbDriver']); @@ -394,10 +394,10 @@ protected function askQuestions(array $questions) foreach ($questions as $name => $question) { if (is_array($question)) { - $question[1][0] = $labelFormat($question[1][0], $this->data[$name]); + $question[1][0] = $labelFormat($question[1][0], $this->data[$name]); $this->data[$name] = call_user_func_array([$this, $question[0]], $question[1]); } else { - $question = $labelFormat($question, $this->data[$name]); + $question = $labelFormat($question, $this->data[$name]); $this->data[$name] = $this->ask($question, $this->data[$name]); } } diff --git a/app/Extensions/Html/FormBuilder.php b/app/Extensions/Html/FormBuilder.php index 4b9f28d66..eeb993b30 100644 --- a/app/Extensions/Html/FormBuilder.php +++ b/app/Extensions/Html/FormBuilder.php @@ -42,7 +42,7 @@ public function form(FormInterface $form, array $attrs = []) // Start a form and add rules $formType = $form->openType(); - $former = Former::$formType(); + $former = Former::$formType(); array_walk($attrs, function ($value, $attr) use ($former) { if ($value === null) { $former->$attr(); @@ -87,7 +87,7 @@ public function form(FormInterface $form, array $attrs = []) public function element($name, array $field) { $filterKeys = ['type']; - $attrs = array_diff_key($field, array_flip($filterKeys)); + $attrs = array_diff_key($field, array_flip($filterKeys)); // Create field with name $element = Former::$field['type']($name); @@ -113,7 +113,7 @@ public function element($name, array $field) */ public function actions(FormInterface $form) { - $output = ''; + $output = ''; $buttons = $form->actions(); if (!empty($buttons)) { $actions = Former::actions()->addClass('form-actions'); diff --git a/app/Extensions/Html/Traits/BlueBoxTrait.php b/app/Extensions/Html/Traits/BlueBoxTrait.php index d48358267..5cf3c0220 100644 --- a/app/Extensions/Html/Traits/BlueBoxTrait.php +++ b/app/Extensions/Html/Traits/BlueBoxTrait.php @@ -50,7 +50,7 @@ public function box($content, $style = 'blue-box', $title = null, $moreLink = nu public function startBox($style = 'blue-box', $title = null, array $attrs = []) { $attrs['class'] = isset($attrs['class']) ? $attrs['class'] . ' ' . $style : $style; - $output = '
attributes($attrs) . '>
'; + $output = '
attributes($attrs) . '>
'; if (!empty($title)) { if (is_array($title)) { diff --git a/app/Extensions/Html/Traits/DateTimeTrait.php b/app/Extensions/Html/Traits/DateTimeTrait.php index 7e62219b7..3f786a358 100644 --- a/app/Extensions/Html/Traits/DateTimeTrait.php +++ b/app/Extensions/Html/Traits/DateTimeTrait.php @@ -46,10 +46,10 @@ public function age($timestamp) $timestamp = new \DateTime($timestamp); } - $timestamp = $timestamp->getTimestamp(); + $timestamp = $timestamp->getTimestamp(); $difference = time() - $timestamp; - $periods = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade']; - $lengths = ['60', '60', '24', '7', '4.35', '12', '10']; + $periods = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade']; + $lengths = ['60', '60', '24', '7', '4.35', '12', '10']; for ($j = 0; $difference >= $lengths[$j]; ++$j) { $difference /= $lengths[$j]; } @@ -70,13 +70,13 @@ public function age($timestamp) */ public function duration($seconds) { - $hours = floor($seconds / 3600); + $hours = floor($seconds / 3600); $minutes = ($seconds / 60) % 60; $seconds = $seconds % 60; - $output = ''; + $output = ''; $separatorChar = ', '; - $separator = ''; + $separator = ''; if ($hours > 0) { $output .= $hours . ' ' . trans('tinyissue.short_hours'); $separator = $separatorChar; diff --git a/app/Form/Comment.php b/app/Form/Comment.php index c2c8fad91..13b95826a 100644 --- a/app/Form/Comment.php +++ b/app/Form/Comment.php @@ -39,7 +39,7 @@ class Comment extends FormAbstract public function setup(array $params) { $this->project = $params['project']; - $this->issue = $params['issue']; + $this->issue = $params['issue']; } /** diff --git a/app/Form/GlobalIssue.php b/app/Form/GlobalIssue.php new file mode 100644 index 000000000..7d0e00319 --- /dev/null +++ b/app/Form/GlobalIssue.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Tinyissue\Form; + +use Tinyissue\Model; + +/** + * GlobalIssue is a class to defines fields & rules for adding an issue form + * + * @author Mohamed Alsharaf + */ +class GlobalIssue extends Issue +{ + /** + * List of projects + * + * @var array + */ + protected $projects = []; + + /** + * Returns list of logged in user projects + * + * @return array + */ + protected function getProjects() + { + if (!$this->projects) { + $this->projects = \Auth::user()->projects()->get()->lists('name', 'id'); + } + + return $this->projects; + } + + /** + * @param array $params + * + * @return void + */ + public function setup(array $params) + { + $this->project = new Model\Project(); + } + + /** + * @return array + */ + public function actions() + { + return [ + 'submit' => 'create_issue', + ]; + } + + /** + * @return array + */ + public function fields() + { + $fields = $this->fieldTitle(); + + $fields['project'] = [ + 'type' => 'select', + 'label' => 'project', + 'options' => $this->getProjects()->all(), + ]; + + $fields += $this->fieldBody(); + $fields += $this->fieldTags(); + + // Only on creating new issue + $fields += $this->fieldUpload(); + + return $fields; + } + + /** + * @return array + */ + public function rules() + { + $rules = parent::rules(); + $rules['project'] = 'required|in:' . $this->getProjects()->keys()->implode(','); + + return $rules; + } + + /** + * @return string + */ + public function getRedirectUrl() + { + return 'projects/new-issue'; + } +} diff --git a/app/Form/Issue.php b/app/Form/Issue.php index 0b88b67e3..432396af3 100644 --- a/app/Form/Issue.php +++ b/app/Form/Issue.php @@ -57,14 +57,73 @@ public function fields() { $issueModify = \Auth::user()->permission('issue-modify'); + $fields = $this->fieldTitle(); + $fields += $this->fieldBody(); + $fields += $this->fieldTags(); + + // User with modify issue permission can assign users + if ($issueModify) { + $fields += $this->fieldAssignedTo(); + } + + // Only on creating new issue + if (!$this->isEditing()) { + $fields += $this->fieldUpload(); + } + + // User with modify issue permission can add quote + if ($issueModify) { + $fields += $this->fieldTimeQuote(); + } + + return $fields; + } + + /** + * Returns title field + * + * @return array + */ + protected function fieldTitle() + { + return [ + 'title' => [ + 'type' => 'text', + 'label' => 'title', + ], + ]; + } + + /** + * Returns body field + * + * @return array + */ + protected function fieldBody() + { + return [ + 'body' => [ + 'type' => 'textarea', + 'label' => 'issue', + ], + ]; + } + + /** + * Returns tags field + * + * @return array + */ + protected function fieldTags() + { // Populate tag fields with the submitted tags if ($this->isEditing()) { $selectTags = $this->getModel()->tags()->with('parent')->get()->filter(function (Model\Tag $tag) { return !($tag->name == Model\Tag::STATUS_OPEN || $tag->name == Model\Tag::STATUS_CLOSED); })->map(function (Model\Tag $tag) { return [ - 'value' => $tag->id, - 'label' => ($tag->fullname), + 'value' => $tag->id, + 'label' => ($tag->fullname), 'bgcolor' => $tag->bgcolor, ]; })->toJson(); @@ -72,70 +131,81 @@ public function fields() $selectTags = ''; } - $fields = [ - 'title' => [ - 'type' => 'text', - 'label' => 'title', - ], - 'body' => [ - 'type' => 'textarea', - 'label' => 'issue', - ], + return [ 'tag' => [ - 'type' => 'text', - 'label' => 'tags', - 'multiple' => true, - 'class' => 'tagit', + 'type' => 'text', + 'label' => 'tags', + 'multiple' => true, + 'class' => 'tagit', 'data_tokens' => htmlentities($selectTags, ENT_QUOTES), ], ]; + } - // User with modify issue permission can assign users - if ($issueModify) { - $fields['assigned_to'] = [ - 'type' => 'select', - 'label' => 'assigned_to', + /** + * Returns assigned to field + * + * @return array + */ + protected function fieldAssignedTo() + { + return [ + 'assigned_to' => [ + 'type' => 'select', + 'label' => 'assigned_to', 'options' => [0 => ''] + $this->project->users()->get()->lists('fullname', 'id')->all(), - 'value' => (int) $this->project->default_assignee, - ]; - } + 'value' => (int) $this->project->default_assignee, + ], + ]; + } - // Only on creating new issue - if (!$this->isEditing()) { - $fields += $this->projectUploadFields('upload', $this->project, \Auth::user()); - $fields['upload']['label'] = 'attachments'; - } + /** + * Returns upload field + * + * @return array + */ + protected function fieldUpload() + { + $fields = $this->projectUploadFields('upload', $this->project, \Auth::user()); + $fields['upload']['label'] = 'attachments'; - // User with modify issue permission can add quote - if ($issueModify) { - $fields['time_quote'] = [ - 'type' => 'groupField', - 'label' => 'quote', + return $fields; + } + + /** + * Returns time quote field + * + * @return array + */ + protected function fieldTimeQuote() + { + return [ + 'time_quote' => [ + 'type' => 'groupField', + 'label' => 'quote', 'fields' => [ 'h' => [ - 'type' => 'number', - 'append' => trans('tinyissue.hours'), - 'value' => $this->extractQuoteValue('h'), + 'type' => 'number', + 'append' => trans('tinyissue.hours'), + 'value' => $this->extractQuoteValue('h'), 'addGroupClass' => 'col-sm-12 col-md-12 col-lg-4', ], 'm' => [ - 'type' => 'number', - 'append' => trans('tinyissue.minutes'), - 'value' => $this->extractQuoteValue('m'), + 'type' => 'number', + 'append' => trans('tinyissue.minutes'), + 'value' => $this->extractQuoteValue('m'), 'addGroupClass' => 'col-sm-12 col-md-12 col-lg-4', ], 's' => [ - 'type' => 'number', - 'append' => trans('tinyissue.seconds'), - 'value' => $this->extractQuoteValue('s'), + 'type' => 'number', + 'append' => trans('tinyissue.seconds'), + 'value' => $this->extractQuoteValue('s'), 'addGroupClass' => 'col-sm-12 col-md-12 col-lg-4', ], ], 'addClass' => 'row issue-quote', - ]; - } - - return $fields; + ], + ]; } /** @@ -145,7 +215,7 @@ public function rules() { $rules = [ 'title' => 'required|max:200', - 'body' => 'required', + 'body' => 'required', ]; return $rules; diff --git a/app/Form/Tag.php b/app/Form/Tag.php index b182508a9..b49482460 100644 --- a/app/Form/Tag.php +++ b/app/Form/Tag.php @@ -47,7 +47,7 @@ public function actions() */ public function fields() { - $tag = new Model\Tag(); + $tag = new Model\Tag(); $fields = [ 'name' => [ 'type' => 'text', diff --git a/app/Form/User.php b/app/Form/User.php index 14dc06812..8d3650346 100644 --- a/app/Form/User.php +++ b/app/Form/User.php @@ -66,7 +66,7 @@ public function fields() */ protected function passwordFields() { - $fields = []; + $fields = []; $fields['only_complete_if_changing_password'] = [ 'type' => 'legend', ]; diff --git a/app/Form/UserSetting.php b/app/Form/UserSetting.php index c6b2fabb6..0ed1a1929 100644 --- a/app/Form/UserSetting.php +++ b/app/Form/UserSetting.php @@ -60,7 +60,7 @@ protected function innerFields() */ public function rules() { - $rules = parent::rules(); + $rules = parent::rules(); $rules['password'] = 'confirmed'; $rules['language'] = 'required'; diff --git a/app/Http/Controllers/Project/IssueController.php b/app/Http/Controllers/Project/IssueController.php index 7cb6e0549..93ba1fe06 100644 --- a/app/Http/Controllers/Project/IssueController.php +++ b/app/Http/Controllers/Project/IssueController.php @@ -308,11 +308,11 @@ public function getDisplayAttachment(Project $project, Issue $issue, Attachment $issue->setRelation('project', $project); $attachment->setRelation('issue', $issue); - $path = config('tinyissue.uploads_dir') . '/' . $issue->project_id . '/' . $attachment->upload_token . '/' . $attachment->filename; + $path = config('tinyissue.uploads_dir') . '/' . $issue->project_id . '/' . $attachment->upload_token . '/' . $attachment->filename; $storage = \Storage::disk('local'); - $length = $storage->size($path); - $time = $storage->lastModified($path); - $type = $storage->getDriver()->getMimetype($path); + $length = $storage->size($path); + $time = $storage->lastModified($path); + $type = $storage->getDriver()->getMimetype($path); $response = new Response(); $response->setEtag(md5($time . $path)); diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e235e3497..43c153d81 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -71,10 +71,10 @@ public function getIssues(FilterForm $filterForm, Request $request, Project $pro $issues = $project->listIssues($status, $request->all()); if ($status == Issue::STATUS_OPEN) { $closedIssuesCount = $project->closedIssuesCount()->count(); - $openIssuesCount = $issues->count(); + $openIssuesCount = $issues->count(); } else { $closedIssuesCount = $issues->count(); - $openIssuesCount = $project->openIssuesCount()->count(); + $openIssuesCount = $project->openIssuesCount()->count(); } return view('project.index', [ diff --git a/app/Http/Controllers/ProjectsController.php b/app/Http/Controllers/ProjectsController.php index e627b86f0..f625fd34b 100644 --- a/app/Http/Controllers/ProjectsController.php +++ b/app/Http/Controllers/ProjectsController.php @@ -13,6 +13,7 @@ use Illuminate\Http\Request; use Tinyissue\Form\Project as Form; +use Tinyissue\Form\GlobalIssue as IssueForm; use Tinyissue\Http\Requests\FormRequest; use Tinyissue\Model\Project; @@ -34,21 +35,21 @@ public function getIndex($status = Project::STATUS_OPEN) { $projects = $this->auth->user()->projectsWithCountOpenIssues($status)->get(); if ($status) { - $active = 'active'; - $countActive = $projects->count(); + $active = 'active'; + $countActive = $projects->count(); $countArchived = $this->auth->user()->projectsWithCountOpenIssues(Project::STATUS_ARCHIVED)->count(); } else { - $active = 'archived'; - $countActive = $this->auth->user()->projectsWithCountOpenIssues(Project::STATUS_OPEN)->count(); + $active = 'archived'; + $countActive = $this->auth->user()->projectsWithCountOpenIssues(Project::STATUS_OPEN)->count(); $countArchived = $projects->count(); } return view('projects.index', [ 'content_projects' => $projects, - 'active' => $active, - 'active_count' => $countActive, - 'archived_count' => $countArchived, - 'projects' => $this->auth->user()->projects()->get(), + 'active' => $active, + 'active_count' => $countActive, + 'archived_count' => $countArchived, + 'projects' => $this->auth->user()->projects()->get(), ]); } @@ -62,7 +63,7 @@ public function getIndex($status = Project::STATUS_OPEN) public function getNew(Form $form) { return view('projects.new', [ - 'form' => $form, + 'form' => $form, 'projects' => $this->auth->user()->projects()->get(), ]); } @@ -101,9 +102,9 @@ public function postProgress(Request $request, Project $project) $view = view('partials/progress', ['text' => $progress . '%', 'progress' => $progress])->render(); return [ - 'id' => $project->id, + 'id' => $project->id, 'progress' => [ - 'html' => $view, + 'html' => $view, 'value' => $progress, ], ]; @@ -111,4 +112,46 @@ public function postProgress(Request $request, Project $project) return response()->json(['status' => true, 'progress' => $progress]); } + + /** + * Add new issue form + * + * @param IssueForm $form + * + * @return \Illuminate\View\View + */ + public function getNewIssue(IssueForm $form) + { + return view('projects.new-issue', [ + 'form' => $form, + 'projects' => $this->auth->user()->projects()->get(), + ]); + } + + /** + * To create a new issue + * + * @param Project\Issue $issue + * @param FormRequest\GlobalIssue $request + * + * @return \Illuminate\Http\RedirectResponse + */ + public function postNewIssue(Project\Issue $issue, FormRequest\GlobalIssue $request) + { + $project = Project::find((int) $request->input('project')); + + $issue->setRelation('project', $project); + $issue->setRelation('user', $this->auth->user()); + $issue->createIssue([ + 'title' => $request->input('title'), + 'body' => $request->input('body'), + 'tag' => $request->input('tag'), + 'upload_token' => $request->input('upload_token'), + 'assigned_to' => (int) $project->default_assignee, + 'time_quote' => 0, + ]); + + return redirect($issue->to()) + ->with('notice', trans('tinyissue.issue_has_been_created')); + } } diff --git a/app/Http/Middleware/Permission.php b/app/Http/Middleware/Permission.php index 0964b5e12..e8c3100af 100644 --- a/app/Http/Middleware/Permission.php +++ b/app/Http/Middleware/Permission.php @@ -50,7 +50,7 @@ public function __construct(Guard $auth) public function handle(Request $request, Closure $next) { $permission = $this->getPermission($request); - $user = $this->auth->user(); + $user = $this->auth->user(); // Check if user has the permission // & if the user can access the current context (e.g. is one of the project users) if (!$user->permission($permission) || !$user->permissionInContext($request->route()->parameters())) { diff --git a/app/Http/Middleware/Project.php b/app/Http/Middleware/Project.php index 1d13f8ff2..43db09097 100644 --- a/app/Http/Middleware/Project.php +++ b/app/Http/Middleware/Project.php @@ -47,7 +47,7 @@ public function handle(Request $request, Closure $next) { // Current callback $callback = current($this->callbacks); - $method = 'handle' . $callback . 'Request'; + $method = 'handle' . $callback . 'Request'; if ($callback && !$this->$method($request)) { diff --git a/app/Http/Requests/FormRequest/GlobalIssue.php b/app/Http/Requests/FormRequest/GlobalIssue.php new file mode 100644 index 000000000..c525d4349 --- /dev/null +++ b/app/Http/Requests/FormRequest/GlobalIssue.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Tinyissue\Http\Requests\FormRequest; + +use Tinyissue\Http\Requests\Request; + +/** + * GlobalIssue is a Form Request class for managing add an issue submission (validating, redirect, response, ...) + * + * @author Mohamed Alsharaf + */ +class GlobalIssue extends Request +{ + /** + * @var string + */ + protected $formClassName = 'Tinyissue\Form\GlobalIssue'; +} diff --git a/app/Model/Project.php b/app/Model/Project.php index e23ab5c38..a5982a9a0 100644 --- a/app/Model/Project.php +++ b/app/Model/Project.php @@ -152,8 +152,8 @@ public function getTotalQuote() */ public function getProgress() { - $total = $this->openIssuesCount + $this->closedIssuesCount; - $progress = (float) ($this->closedIssuesCount / $total) * 100; + $total = $this->openIssuesCount + $this->closedIssuesCount; + $progress = (float) ($this->closedIssuesCount / $total) * 100; $progressInt = (int) $progress; if ($progressInt > 0) { $progress = number_format($progress, 2); diff --git a/app/Model/Traits/Project/Issue/Attachment/CrudTrait.php b/app/Model/Traits/Project/Issue/Attachment/CrudTrait.php index d12b40288..ce5707943 100644 --- a/app/Model/Traits/Project/Issue/Attachment/CrudTrait.php +++ b/app/Model/Traits/Project/Issue/Attachment/CrudTrait.php @@ -55,13 +55,13 @@ public function upload(array $input, Project $project, User $user) /* @var $uploadedFile \Symfony\Component\HttpFoundation\File\UploadedFile */ $uploadedFile = $input['upload']; - $file = $uploadedFile->move($path, $uploadedFile->getClientOriginalName()); + $file = $uploadedFile->move($path, $uploadedFile->getClientOriginalName()); - $this->uploaded_by = $user->id; - $this->filename = $file->getFilename(); + $this->uploaded_by = $user->id; + $this->filename = $file->getFilename(); $this->fileextension = $file->getExtension(); - $this->filesize = $file->getSize(); - $this->upload_token = $input['upload_token']; + $this->filesize = $file->getSize(); + $this->upload_token = $input['upload_token']; return $this->save(); } diff --git a/app/Model/Traits/Project/Issue/CrudTagTrait.php b/app/Model/Traits/Project/Issue/CrudTagTrait.php index 86ecffab1..75d001fe8 100644 --- a/app/Model/Traits/Project/Issue/CrudTagTrait.php +++ b/app/Model/Traits/Project/Issue/CrudTagTrait.php @@ -62,14 +62,14 @@ public function changeStatus($status, $userId) $this->closed_at = (new \DateTime())->format('Y-m-d H:i:s'); $activityType = Activity::TYPE_CLOSE_ISSUE; - $addTagName = Tag::STATUS_CLOSED; + $addTagName = Tag::STATUS_CLOSED; /** @var \Illuminate\Support\Collection $ids */ $ids = $this->getTagsExceptStatus()->getRelatedIds(); } else { $activityType = Activity::TYPE_REOPEN_ISSUE; - $removeTag = Tag::STATUS_CLOSED; - $addTagName = Tag::STATUS_OPEN; + $removeTag = Tag::STATUS_CLOSED; + $addTagName = Tag::STATUS_OPEN; /** @var \Illuminate\Support\Collection $ids */ $ids = $this->getTagsExcept($removeTag)->getRelatedIds(); diff --git a/app/Model/Traits/Project/Issue/CrudTrait.php b/app/Model/Traits/Project/Issue/CrudTrait.php index 2b8ea5f0e..ee1340012 100644 --- a/app/Model/Traits/Project/Issue/CrudTrait.php +++ b/app/Model/Traits/Project/Issue/CrudTrait.php @@ -57,7 +57,7 @@ trait CrudTrait */ public function changeUpdatedBy($userId) { - $time = new \DateTime(); + $time = new \DateTime(); $this->updated_at = $time->format('Y-m-d H:i:s'); $this->updated_by = $userId; @@ -74,8 +74,8 @@ public function changeUpdatedBy($userId) */ public function reassign($assignTo, $user) { - $assignToId = !$assignTo instanceof User ? $assignTo : $assignTo->id; - $userId = !$user instanceof User ? $user : $user->id; + $assignToId = !$assignTo instanceof User ? $assignTo : $assignTo->id; + $userId = !$user instanceof User ? $user : $user->id; $this->assigned_to = $assignToId; $this->save(); @@ -143,7 +143,7 @@ public function createIssue(array $input) if ($this->user->permission('issue-modify')) { $fill['assigned_to'] = $input['assigned_to']; - $fill['time_quote'] = $input['time_quote']; + $fill['time_quote'] = $input['time_quote']; } $this->fill($fill)->save(); diff --git a/app/Model/Traits/Project/Note/CrudTrait.php b/app/Model/Traits/Project/Note/CrudTrait.php index d92d6d5ce..0be6e3c22 100644 --- a/app/Model/Traits/Project/Note/CrudTrait.php +++ b/app/Model/Traits/Project/Note/CrudTrait.php @@ -41,7 +41,7 @@ trait CrudTrait */ public function createNote(array $input) { - $this->body = $input['note_body']; + $this->body = $input['note_body']; $this->project_id = $this->project->id; $this->created_by = $this->createdBy->id; $this->save(); diff --git a/app/Model/Traits/Project/QueryTrait.php b/app/Model/Traits/Project/QueryTrait.php index 61521c2e2..00e00f80e 100644 --- a/app/Model/Traits/Project/QueryTrait.php +++ b/app/Model/Traits/Project/QueryTrait.php @@ -59,7 +59,7 @@ public function usersNotIn() { if ($this->id > 0) { $userIds = $this->users()->lists('user_id')->all(); - $users = User::where('deleted', '=', User::NOT_DELETED_USERS)->whereNotIn('id', $userIds)->get(); + $users = User::where('deleted', '=', User::NOT_DELETED_USERS)->whereNotIn('id', $userIds)->get(); } else { $users = User::where('deleted', '=', User::NOT_DELETED_USERS)->get(); } @@ -78,7 +78,7 @@ public function usersNotIn() public function listIssues($status = Project\Issue::STATUS_OPEN, array $filter = []) { $sortOrder = array_get($filter, 'sort.sortorder', 'desc'); - $sortBy = array_get($filter, 'sort.sortby', null); + $sortBy = array_get($filter, 'sort.sortby', null); $query = $this->issues() ->with('countComments', 'user', 'updatedBy', 'tags', 'tags.parent') diff --git a/app/Model/Traits/Tag/CrudTrait.php b/app/Model/Traits/Tag/CrudTrait.php index c4709a97a..69d15db16 100644 --- a/app/Model/Traits/Tag/CrudTrait.php +++ b/app/Model/Traits/Tag/CrudTrait.php @@ -56,14 +56,14 @@ public function createTagFromString($tagFullName) public function validOrCreate($name, Tag $parent = null) { $group = $parent === null ? true : false; - $tag = $this->where('name', '=', $name)->first(); + $tag = $this->where('name', '=', $name)->first(); if ($tag && $tag->group != $group) { return false; } if (!$tag) { - $tag = new Tag(); - $tag->name = $name; + $tag = new Tag(); + $tag->name = $name; $tag->group = $group; if (!is_null($parent)) { $tag->parent_id = $parent->id; diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 7439af6a6..5ce71e911 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -60,6 +60,8 @@ public function map(Router $router) // Projects area $router->get('projects/{status?}', 'ProjectsController@getIndex')->where('status', '[0-1]'); + $router->get('projects/new_issue', 'ProjectsController@getNewIssue'); + $router->post('projects/new_issue', 'ProjectsController@postNewIssue'); $router->group(['middleware' => 'permission', 'permission' => 'project-create'], function (Router $router) { $router->get('projects/new', 'ProjectsController@getNew'); $router->post('projects/new', 'ProjectsController@postNew'); diff --git a/app/Services/Exporter.php b/app/Services/Exporter.php index b18226c18..fe99aa530 100644 --- a/app/Services/Exporter.php +++ b/app/Services/Exporter.php @@ -26,8 +26,8 @@ class Exporter extends NewExcelFile { /** Current supported files type */ - const TYPE_CSV = 'csv'; - const TYPE_XLS = 'xls'; + const TYPE_CSV = 'csv'; + const TYPE_XLS = 'xls'; const TYPE_XLSX = 'xlsx'; /** @@ -79,9 +79,9 @@ public function getParams($key = null) public function exportFile($className, $format = self::TYPE_CSV, array $params = []) { $params['route'] = $this->app->request->route()->parameters(); - $this->format = $format; - $this->params = $params; - $this->type = $className; + $this->format = $format; + $this->params = $params; + $this->type = $className; // Update file name $this->setFileName($this->getFilename()); diff --git a/resources/lang/en/tinyissue.php b/resources/lang/en/tinyissue.php index 7737a9a2d..06b37a874 100644 --- a/resources/lang/en/tinyissue.php +++ b/resources/lang/en/tinyissue.php @@ -49,6 +49,7 @@ 'delete' => 'Delete', 'delete_project_confirm' => 'Are you sure you want to delete this project? There is no going back!', 'create_a_new_issue' => 'Create A New Issue', + 'create_a_new_issue_description' => 'Create a new issue for any of your projects.', 'create_a_new_issue_in' => 'Create a new issue in project', 'title' => 'Title', 'issue' => 'Issue', diff --git a/resources/views/index/dashboard.blade.php b/resources/views/index/dashboard.blade.php index 6c173de57..fd44944f6 100644 --- a/resources/views/index/dashboard.blade.php +++ b/resources/views/index/dashboard.blade.php @@ -12,6 +12,10 @@ @lang('tinyissue.dashboard_description') @stop +@section('headingLink') + {!! link_to('projects/new_issue', trans('tinyissue.new_issue')) !!} +@stop + @section('content') @foreach($projects as $project) @if (count($project->activities) > 0) diff --git a/resources/views/projects/new-issue.blade.php b/resources/views/projects/new-issue.blade.php new file mode 100644 index 000000000..2190e8c8f --- /dev/null +++ b/resources/views/projects/new-issue.blade.php @@ -0,0 +1,21 @@ +@extends('layouts.wrapper') + +@section('nav/projects/class') + active +@stop + +@section('scripts') + {!! Html::script(elixir('js/tiny_project_issue.js')) !!} +@stop + +@section('headingTitle') + @lang('tinyissue.create_a_new_issue') +@stop + +@section('headingSubTitle') + @lang('tinyissue.create_a_new_issue_description') +@stop + +@section('content') + {!! Form::form($form, ['action'=>'','secure'=>null]) !!} +@stop