Merge remote-tracking branch 'origin/v3' into v3-master

This commit is contained in:
snipe 2016-06-28 14:52:58 -07:00
commit 38a7bfecf6
3 changed files with 33 additions and 16 deletions

View file

@ -12,6 +12,7 @@ use Str;
use View;
use App\Helpers\Helper;
use Auth;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
@ -90,12 +91,17 @@ class StatuslabelsController extends Controller
*
* @return Redirect
*/
public function postCreate()
public function postCreate(Request $request)
{
// create a new model instance
$statuslabel = new Statuslabel();
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
if (!$request->has('statuslabel_types')) {
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
}
$statustype = Statuslabel::getStatuslabelTypesForDB($request->input('statuslabel_types'));
// Save the Statuslabel data
$statuslabel->name = e(Input::get('name'));
@ -116,11 +122,14 @@ class StatuslabelsController extends Controller
}
public function store()
public function store(Request $request)
{
// create a new status label instance
$statuslabel = new Statuslabel();
if (!$request->has('statuslabel_types')) {
return JsonResponse::create(["error" => trans('validation.statuslabel_type')], 500);
}
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));
$statuslabel->name = e(Input::get('name'));
$statuslabel->user_id = Auth::user()->id;
@ -135,7 +144,7 @@ class StatuslabelsController extends Controller
// Redirect to the new Statuslabel page
return JsonResponse::create($statuslabel);
}
return JsonResponse::create(["error" => "Failed validation: ".print_r($statuslabel->getErrors()->first(), true)], 500);
return JsonResponse::create(["error" => $statuslabel->getErrors()->first()], 500);
}
@ -168,7 +177,7 @@ class StatuslabelsController extends Controller
* @param int $statuslabelId
* @return Redirect
*/
public function postEdit($statuslabelId = null)
public function postEdit(Request $request, $statuslabelId = null)
{
// Check if the Statuslabel exists
if (is_null($statuslabel = Statuslabel::find($statuslabelId))) {
@ -176,6 +185,10 @@ class StatuslabelsController extends Controller
return redirect()->to('admin/settings/statuslabels')->with('error', trans('admin/statuslabels/message.does_not_exist'));
}
if (!$request->has('statuslabel_types')) {
return redirect()->back()->withInput()->withErrors(['statuslabel_types' => trans('validation.statuslabel_type')]);
}
// Update the Statuslabel data
$statustype = Statuslabel::getStatuslabelTypesForDB(Input::get('statuslabel_types'));

View file

@ -16,9 +16,11 @@ class Statuslabel extends Model
protected $rules = array(
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
//'statuslabel_types' => 'required|in:deployable,pending,archived,undeployable',
'notes' => 'string',
'name' => 'required|string|unique:status_labels,name,NULL,deleted_at',
'notes' => 'string',
'deployable' => 'required',
'pending' => 'required',
'archived' => 'required',
);
protected $fillable = ['name'];
@ -47,14 +49,14 @@ class Statuslabel extends Model
public function getStatuslabelType()
{
if ($this->pending == 1) {
if (($this->pending == '1') && ($this->archived == '0') && ($this->deployable == '0')) {
return 'pending';
} elseif ($this->archived == 1) {
} elseif (($this->pending == '0') && ($this->archived == '1') && ($this->deployable == '0')) {
return 'archived';
} elseif ($this->deployable == 1) {
return 'deployable';
} else {
} elseif (($this->pending == '0') && ($this->archived == '0') && ($this->deployable == '0')) {
return 'undeployable';
} else {
return 'deployable';
}
}
@ -74,12 +76,13 @@ class Statuslabel extends Model
$statustype['pending'] = 0;
$statustype['deployable'] = 0;
$statustype['archived'] = 1;
} else {
$statustype['pending'] = 0;
$statustype['deployable'] = 0;
$statustype['archived'] = 0;
}
}
return $statustype;
}

View file

@ -64,6 +64,7 @@ return array(
),
"unique" => "The :attribute has already been taken.",
"url" => "The :attribute format is invalid.",
"statuslabel_type" => "You must select a valid status label type",
/*