add coverage attributes

This commit is contained in:
Arno Kaimbacher 2019-03-20 18:40:14 +01:00
parent 9d195c450e
commit 6bfbbea060
8 changed files with 163 additions and 11 deletions

View File

@ -16,7 +16,7 @@ class SitelinkController extends Controller
->where('server_state', 'LIKE', "%" . $serverState . "%");
$select
->select(DB::raw('YEAR(published_date) as published_date'))
->select(DB::raw('YEAR(server_date_published) as published_date'))
->distinct(true);
$this->years = $select->pluck('published_date');

View File

@ -14,7 +14,6 @@ use App\Rules\RdrFiletypes;
use App\Rules\RdrFilesize;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use App\Models\DatasetReference;
@ -22,6 +21,7 @@ use App\Models\Subject;
use App\Models\GeolocationBox;
use App\Models\Page;
use Illuminate\Support\Facades\Auth;
use App\Models\Coverage;
class IndexController extends Controller
{
@ -416,13 +416,21 @@ class IndexController extends Controller
$formGeolocation['xmax'] !== null && $formGeolocation['ymax'] !== null) {
$geolocation = new GeolocationBox($formGeolocation);
$dataset->geolocation()->save($geolocation);
//$geolocation->dataset()->associate($dataset)->save();
}
}
if (isset($data['coverage'])) {
$formCoverage = $request->input('coverage');
$coverage = new Coverage($formCoverage);
$dataset->coverage()->save($coverage);
//$coverage->dataset()->associate($dataset)->save();
}
// Create relation between Dataset and actual User.
$user = Auth::user();
$dataset->user()->associate($user)->save();
// $error = 'Always throw this error';
// throw new \Exception($error);

25
app/Models/Coverage.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use App\Models\Dataset;
use Illuminate\Database\Eloquent\Model;
class Coverage extends Model
{
protected $table = 'coverage';
public $timestamps = true;
protected $fillable = [
'elevation_min',
'elevation_max',
'elevation_absolut',
'depth_min',
'depth_max',
'depth_absolut'
];
public function dataset()
{
return $this->belongsTo(Dataset::class, 'dataset_id', 'id');
}
}

View File

@ -15,6 +15,7 @@ use App\Models\File;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use App\Models\GeolocationBox;
use App\Models\Coverage;
class Dataset extends Model
{
@ -69,7 +70,13 @@ class Dataset extends Model
return $this->hasOne(GeolocationBox::class, 'dataset_id', 'id');
}
/**
* Get the coverage that owns the dataset.
*/
public function coverage()
{
return $this->hasOne(Coverage::class, 'dataset_id', 'id');
}
/**
* Get the project that the dataset belongs to.

File diff suppressed because one or more lines are too long

View File

@ -28,6 +28,14 @@ function initialState() {
xmax: "",
ymax: ""
},
coverage: {
elevation_min: "",
elevation_max: "",
elevation_absolut: "",
depth_min: "",
depth_max: "",
depth_absolut: ""
},
checkedAuthors: [],
checkedLicenses: [], // [],
files: [],

View File

@ -60,7 +60,9 @@ const app = new Vue({
isModalVisible: false,
step: 0,
dataset: dataset
dataset: dataset,
elevation: "no_elevation",
depth: "no_depth",
// dataset: {
// type: '',
// state: '',
@ -129,7 +131,19 @@ const app = new Vue({
},
isFailed() {
return this.currentStatus === STATUS_FAILED;
}
},
isElevationAbsolut() {
return this.elevation === "absolut";
},
isElevationRange() {
return this.elevation === "range";
},
isDepthAbsolut() {
return this.depth === "absolut";
},
isDepthRange() {
return this.depth === "range";
}
},
methods: {
@ -206,6 +220,23 @@ const app = new Vue({
formData.append('geolocation[xmax]', this.dataset.geolocation.xmax);
formData.append('geolocation[ymax]', this.dataset.geolocation.ymax);
if (this.isElevationAbsolut) {
formData.append('coverage[elevation_absolut]', this.dataset.coverage.elevation_absolut);
}
else if (this.isElevationRange) {
formData.append('coverage[elevation_min]', this.dataset.coverage.elevation_min);
formData.append('coverage[elevation_max]', this.dataset.coverage.elevation_max);
}
if (this.isDepthAbsolut) {
formData.append('coverage[depth_absolut]', this.dataset.coverage.depth_absolut);
}
else if (this.isDepthRange) {
formData.append('coverage[depth_min]', this.dataset.coverage.depth_min);
formData.append('coverage[depth_max]', this.dataset.coverage.depth_max);
}
for (var i = 0; i < this.dataset.checkedLicenses.length; i++) {
formData.append('licenses[' + i + ']', this.dataset.checkedLicenses[i]);
}

View File

@ -267,8 +267,8 @@
<div v-if="step === 2 && isInitial" data-vv-scope="step-2">
<h1>Step Two: Recommended Elements</h1>
<fieldset id="fieldset-subject">
<legend>Subject</legend>
<fieldset id="fieldset-project">
<legend>Project</legend>
<div class="pure-g">
{{-- <div class="pure-u-1 pure-u-md-1-2 pure-div">
@ -300,7 +300,7 @@
</div>
</fieldset-dates>
<fieldset id="fieldset-general">
<fieldset id="fieldset-contributors">
<legend>Contributors</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div">
@ -343,7 +343,80 @@
{!! Form::text('ymax', null, ['class' => 'pure-u-23-24', 'v-model' => 'dataset.geolocation.ymax', 'readonly']) !!}
</div>
</div>
</fieldset>
</fieldset>
<fieldset id="fieldset-coverage">
<legend>Coverage</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2">
<div class="pure-u-1 pure-u-md-1">
<label for="option-one" class="pure-radio">
<input id="option-one" type="radio" v-model="elevation" value="absolut">
absolut elevation
</label>
<label for="option-two" class="pure-radio">
<input id="option-two" type="radio" v-model="elevation" value="range">
elevation range
</label>
<label for="option-three" class="pure-radio">
<input id="option-three" type="radio" v-model="elevation" value="no_elevation">
no elevation
</label>
</div>
<div v-show="elevation === 'absolut'" class="pure-u-1 pure-u-md-1">
{!! Form::label('elevation_absolut', 'elevation absolut: ') !!}
{!! Form::text('elevation_absolut', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_absolut', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationAbsolut ? 'required|integer' : '' " ]) !!}
</div>
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
{!! Form::label('elevation_max', 'elevation max: ') !!}
{!! Form::text('elevation_max', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_max', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
</div>
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
{!! Form::label('elevation_min', 'elevation min: ') !!}
{!! Form::text('elevation_min', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_min', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2">
<div class="pure-u-1 pure-u-md-1">
<label for="depth-option-one" class="pure-radio">
<input id="depth-option-one" type="radio" v-model="depth" value="absolut">
absolut depth
</label>
<label for="depth-option-two" class="pure-radio">
<input id="depth-option-two" type="radio" v-model="depth" value="range">
depth range
</label>
<label for="depth-option-three" class="pure-radio">
<input id="depth-option-three" type="radio" v-model="depth" value="no_depth">
no depth
</label>
</div>
<div v-show="depth === 'absolut'" class="pure-u-1 pure-u-md-1">
{!! Form::label('depth_absolut', 'depth absolut: ') !!}
{!! Form::text('depth_absolut', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_absolut', 'data-vv-scope' => 'step-2', "v-validate" => "this.isDepthAbsolut ? 'required|integer' : '' " ]) !!}
</div>
<div v-show="depth === 'range'" class="pure-u-1 pure-u-md-1">
{!! Form::label('depth_max', 'depth max: ') !!}
{!! Form::text('depth_max', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_max', 'data-vv-scope' => 'step-2', "v-validate" => "this.isDepthRange ? 'required|integer' : '' "]) !!}
</div>
<div v-show="depth === 'range'" class="pure-u-1 pure-u-md-1">
{!! Form::label('depth_min', 'depth min: ') !!}
{!! Form::text('depth_min', null,
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_min', 'data-vv-scope' => 'step-2', "v-validate" => "this.isDepthRange ? 'required|integer' : '' "]) !!}
</div>
</div>
</div>
</fieldset>
<fieldset id="fieldset-references">
<legend>Dataset References</legend>