1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Adjustments to task projects

This commit is contained in:
Hillel Coren 2016-12-15 14:17:10 +02:00
parent bef3b85614
commit d1f496023b
7 changed files with 20 additions and 12 deletions

View File

@ -79,7 +79,7 @@ class ProjectController extends BaseController
public function store(CreateProjectRequest $request)
{
$project = $this->projectRepo->save($request->input());
$project = $this->projectService->save($request->input());
Session::flash('message', trans('texts.created_project'));
@ -88,7 +88,7 @@ class ProjectController extends BaseController
public function update(UpdateProjectRequest $request)
{
$project = $this->projectRepo->save($request->input(), $request->entity());
$project = $this->projectService->save($request->input(), $request->entity());
Session::flash('message', trans('texts.updated_project'));

View File

@ -21,6 +21,7 @@ class CreateProjectRequest extends ProjectRequest
{
return [
'name' => sprintf('required|unique:projects,name,,id,account_id,%s', $this->user()->account_id),
'client_id' => 'required',
];
}
}

View File

@ -20,7 +20,6 @@ class UpdateProjectRequest extends ProjectRequest
public function rules()
{
return [
'name' => 'required',
'name' => sprintf('required|unique:projects,name,%s,id,account_id,%s', $this->entity()->id, $this->user()->account_id),
];
}

View File

@ -22,7 +22,6 @@ class Project extends EntityModel
*/
protected $fillable = [
'name',
'client_id',
];
/**

View File

@ -65,6 +65,7 @@ class ProjectRepository extends BaseRepository
if ( ! $project) {
$project = Project::createNew();
$project['client_id'] = $input['client_id'];
}
$project->fill($input);

View File

@ -45,13 +45,13 @@ class ProjectService extends BaseService
* @param $data
* @return mixed|null
*/
public function save($data)
public function save($data, $project)
{
if (isset($data['client_id']) && $data['client_id']) {
$data['client_id'] = Client::getPrivateId($data['client_id']);
}
return $this->projectRepo->save($data);
return $this->projectRepo->save($data, $project);
}
/**

View File

@ -7,6 +7,7 @@
->method($method)
->rules([
'name' => 'required',
'client_id' => 'required',
]) !!}
@if ($project)
@ -26,11 +27,18 @@
</div>
<div class="panel-body">
{!! Former::text('name') !!}
@if ($project)
{!! Former::plaintext('client_name')
->value($project->client->getDisplayName()) !!}
@else
{!! Former::select('client_id')
->addOption('', '')
->label(trans('texts.client')) !!}
->label(trans('texts.client'))
->addGroupClass('client-select') !!}
@endif
{!! Former::text('name') !!}
</div>
</div>
@ -51,8 +59,6 @@
var clients = {!! $clients !!};
$(function() {
$('#name').focus();
var $clientSelect = $('select#client_id');
for (var i=0; i<clients.length; i++) {
var client = clients[i];
@ -65,7 +71,9 @@
@if ($clientPublicId)
$clientSelect.val({{ $clientPublicId }});
@endif
$clientSelect.combobox();
$clientSelect.combobox().focus();
$('.client-select input.form-control').focus();
});
</script>