backend improvements

This commit is contained in:
Arno Kaimbacher 2018-10-10 18:28:51 +02:00
parent 50bcae442e
commit 4ac1c34b6a
16 changed files with 199 additions and 108 deletions

View File

@ -244,7 +244,7 @@ class IndexController extends Controller
$dataset->save();
//store related files
if (null != $data['files']) {
if (isset($data['files'])) {
foreach ($data['files'] as $uploadedFile) {
$file = $uploadedFile['file'];
$label = urldecode($uploadedFile['label']);
@ -299,7 +299,9 @@ class IndexController extends Controller
DB::commit();
} catch (\Exception $e) {
DB::rollback();
Storage::deleteDirectory($datasetFolder);
if (isset($datasetFolder)) {
Storage::deleteDirectory($datasetFolder);
}
return response()->json([
'success' => false,
'error' => [
@ -310,7 +312,9 @@ class IndexController extends Controller
//throw $e;
} catch (\Throwable $e) {
DB::rollback();
Storage::deleteDirectory($datasetFolder);
if (isset($datasetFolder)) {
Storage::deleteDirectory($datasetFolder);
}
return response()->json([
'success' => false,
'error' => [

View File

@ -21,7 +21,8 @@ class LicenseController extends Controller
public function index() : View
{
$licenses = License::get();
$direction = 'asc'; // or desc
$licenses = License::orderBy('sort_order', $direction)->get();
return view('settings.license.license', compact('licenses'));
}

View File

@ -117,7 +117,7 @@ class PersonController extends Controller
}
/**
* activatew author, submitter etc....
* activate author, submitter etc....
*
* @param int $id
* @return \Illuminate\Http\Response

View File

@ -8,8 +8,10 @@ use App\Models\Dataset;
class Collection extends Model
{
public $timestamps = false;
//mass assignable
protected $fillable = [
'name',
'number',
'role_id',
];

View File

@ -27,4 +27,9 @@ class License extends Model
{
return $this->belongsToMany(Dataset::class, 'link_documents_licences', 'licence_id', 'document_id');
}
public function getCheckedAttribute()
{
return "false";
}
}

6
package-lock.json generated
View File

@ -10886,6 +10886,12 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"dev": true
},
"vee-validate": {
"version": "2.1.0-beta.9",
"resolved": "https://registry.npmjs.org/vee-validate/-/vee-validate-2.1.0-beta.9.tgz",
"integrity": "sha512-c5oKINWG1X++aeEoHjLihYFM0ycobfDJMl6/iJhwVtAzRZdr5jH1h5hbajAI3gF+Y7052g49F6EFu7ZY19P1zQ==",
"dev": true
},
"vendors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.2.tgz",

View File

@ -17,6 +17,7 @@
"jquery": "^3.2",
"laravel-mix": "^2.1.14",
"lodash": "^4.17.10",
"vee-validate": "^2.1.0-beta.9",
"vue": "^2.5.7",
"vue-events": "^3.0.0",
"vuetable-2": "^1.7.5"

File diff suppressed because one or more lines are too long

View File

@ -23,9 +23,15 @@ window._ = require('lodash');
// window.Vue = require('vue');
// Vue.prototype.$http = axios;
// import Vue from 'vue';
// Vue.component('example', require('./components/Example.vue'));
//Vue.component('my-autocomplete', require('./components/MyAutocomplete.vue'));
import MyAutocomplete from './components/MyAutocomplete.vue';
import VeeValidate from 'vee-validate';
// import { Validator } from 'vee-validate';
Vue.use(VeeValidate);
const STATUS_INITIAL = 0, STATUS_SAVING = 1, STATUS_SUCCESS = 2, STATUS_FAILED = 3;
const app = new Vue({
@ -38,7 +44,7 @@ const app = new Vue({
// { qty: 5, value: "Something", language: 10, type: "additional", sort_order: 0 },
// { qty: 2, value: "Something else", language: 20, type: "additional", sort_order: 0 },
],
errors: [],
serrors: [],
uploadedFiles: [],
uploadError: null,
currentStatus: null,
@ -66,11 +72,25 @@ const app = new Vue({
language: ''
},
checkedPersons: [],
checkedLicenses: [],
checkedLicenses: [],// [],
files: []
}
}
},
created: function () {
VeeValidate.Validator.extend('Name', {
getMessage: field => '* Enter valid ' + field + '',
validate: value => /^[a-zA-Z]*$/.test(value)
});
// add the required rule
VeeValidate.Validator.extend('oneChecked', {
getMessage: field => 'At least one ' + field + ' needs to be checked.',
validate: (value, [testProp]) => {
const options = this.dataset.checkedLicenses;
return value || options.some((option) => option[testProp]);
}
});
},
mounted() {
this.step = 1;
this.reset();
@ -103,7 +123,7 @@ const app = new Vue({
},
save() {
var _this = this;
this.errors = [];
this.serrors = [];
/*
Initialize the form data
*/
@ -126,7 +146,7 @@ const app = new Vue({
*/
formData.append('type', this.dataset.type);
formData.append('server_state', this.dataset.state);
formData.append('rights', this.dataset.rights);
formData.append('rights', Number(this.dataset.rights));
formData.append('creating_corporation', this.dataset.creating_corporation);
formData.append('project_id', this.dataset.project_id);
formData.append('embargo_date', this.dataset.embargo_date);
@ -171,12 +191,12 @@ const app = new Vue({
var errorsArray = errorObject.response.data.errors;
for (var index in errorsArray) {
console.log(errorsArray[index]);
_this.errors.push(errorsArray[index]);
_this.serrors.push(errorsArray[index]);
}
}
if (errorObject.response.data.error) {
var error = errorObject.response.data.error;
_this.errors.push(error.message);
_this.serrors.push(error.message);
}
_this.currentStatus = STATUS_FAILED;
});
@ -230,8 +250,24 @@ const app = new Vue({
prev() {
this.step--;
},
next() {
this.step++;
next(scope) {
// if(this.validate(scope)) {
// this.step++;
// }
this.$validator.validateAll(scope).then((result) => {
if (result) {
this.step++;
}
});
},
validate: function (scope) {
this.$validator.validateAll(scope);
if (this.errors.any()) {
console.log('The form is invalid');
return false;
}
return true;
},
submit() {
// alert('Submit to blah and show blah and etc.');

View File

@ -4,7 +4,8 @@
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
// window.Vue = require('vue');
import Vue from 'vue';
Vue.prototype.$http = axios;

View File

@ -36,7 +36,7 @@
<ul class="pure-menu-children" role="menu">
<!--<li class="pure-menu-item"><a href="{{ route('settings.book') }}" class="pure-menu-link">BOOK</a></li>-->
<li class="pure-menu-item"><a class="pure-menu-link" href="{{ route('settings.document') }}" >DATASET</a></li>
<li class="pure-menu-item"><a class="pure-menu-link" href="{{ route('settings.collection') }}">COLLECTION</a></li>
<li class="pure-menu-item"><a class="pure-menu-link" href="{{ route('settings.collection.index') }}">COLLECTION</a></li>
<li class="pure-menu-item"><a class="pure-menu-link" href="{{ route('settings.project') }}">PROJECT</a></li>
<!-- <li><a href="{{ route('settings.shelf') }}" class="marvel">SHELF</a></li>-->

View File

@ -1,5 +1,7 @@
@extends('settings.layouts.app')
@section('title', 'Publish')
@section('content')
<div class="header">
<h3 class="header-title">
@ -8,12 +10,14 @@
</div>
<div id="app" class="box-content">
<form action={{ route( 'publish.dataset.store1') }} method="post" class="pure-form" enctype="multipart/form-data">
{{-- <form action={{ route( 'publish.dataset.store1') }} method="post" class="pure-form" enctype="multipart/form-data"> --}}
<main class="steps pure-form" enctype="multipart/form-data">
{{ csrf_field() }}
<div v-if="step === 1">
<form v-if="step === 1" data-vv-scope="step-1">
<h1>Step One</h1>
<fieldset class="left-labels">
<div class="form-group">
<legend>Datensatztyp</legend>
<div class="description hint">
<p>Bitte wählen Sie einen Datensatztyp aus der Liste aus.</p>
@ -22,44 +26,51 @@
<div class="form-item">
<label for="documentType">Datensatztyp<span class="required" title="Dieses Feld muss ausgefüllt werden."> *</span></label>
<div class="select" style="width:300px" title="Bitte wählen Sie einen Datensatztyp aus der Liste aus.">
{!! Form::select('Type', Lang::get('doctypes'), null, ['id' => 'type', 'placeholder' => '-- select type --', 'v-model' =>
'dataset.type']) !!}
{!! Form::select('Type', Lang::get('doctypes'), null, ['id' => 'type', 'placeholder' => '-- select type --',
'v-model' => 'dataset.type', "v-validate" => "'required'"]) !!}
</div>
</div>
</fieldset>
</div>
<fieldset class="left-labels">
<div :class="{'form-group':true, 'has-error':errors.has('rights')}">
<legend>Einräumung eines einfachen Nutzungsrechts</legend>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{{-- <div class="pure-u-1 pure-u-md-1-2 pure-div"> --}}
<p>
I accept
<a target="_blank" href="{{ route("frontend.pages.show", ['page_slug'=>'terms-and-conditions']) }}">
{!! trans('validation.attributes.backend.create-dataset.terms_and_conditions').'*' !!}
</a>
</p>
<small for="rights" class="pure-form-message-inline">Ich habe diese rechtlichen Hinweise gelesen und bin damit einverstanden.
<span class="required" title="Dieses Feld muss ausgefüllt werden.">*</span>
</small> {{-- <input name="rights" value="0" type="hidden"> --}}
<label>
<input class="form-checkbox" name="rights" id="rights" type="checkbox" v-model="dataset.rights" true-value="1" false-value="0">
<p>
I accept
<a target="_blank" href="{{ route("frontend.pages.show", ['page_slug'=>'terms-and-conditions']) }}">
{!! trans('validation.attributes.backend.create-dataset.terms_and_conditions').'*' !!}
</a>
</p>
<input class="form-checkbox" name="rights" id="rights" type="checkbox" v-model="dataset.rights" v-validate="'required'">
<br />
<i v-show="errors.has('step-1.rights')" class="fa fa-warning"></i>
<span v-show="errors.has('step-1.rights')" class="text-danger">@{{ errors.first('step-1.rights') }}</span>
</label>
</div>
</fieldset>
<span class="help-block">You must agree to continue</span>
{{-- </div> --}}
</div>
<br />
<div class="pure-controls">
{{-- <button type="submit" class="pure-button button-small">
<i class="fa fa-arrow-right"></i>
<span>Weiter zum nächsten Schritt</span>
</button> --}}
<button @click.prevent="next()" class="pure-button button-small">
<button @click.prevent="next('step-1')" class="pure-button button-small" :disabled="errors.any()">
<i class="fa fa-arrow-right"></i>
<span>Continue</span>
</button>
</div>
</div>
<div v-if="errors.items.length > 0">
<b>Please correct the following error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in errors.items">@{{ error.msg }}</li>
</ul>
</div>
</form>
<div v-if="step === 2">
<form v-if="step === 2" data-vv-scope="step-2">
<h1>Step Two</h1>
<fieldset id="fieldset-general">
<legend>General</legend>
@ -76,22 +87,22 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('Type', 'Type..') !!}
<div class="select pure-u-23-24">
{!! Form::select('Type', Lang::get('doctypes'), null, ['id' => 'type', 'placeholder' => '-- select type --', 'v-model' =>
'dataset.type']) !!}
{!! Form::select('Type', Lang::get('doctypes'), null, ['id' => 'type', 'placeholder' => '-- select type --',
'v-model' => 'dataset.type', "v-validate" => "'required'"]) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('State', 'State..') !!}
<div class="select pure-u-23-24">
{!! Form::select( 'State', array_except(Config::get('enums.server_states'),['published', 'deleted', 'temporary']), '', ['placeholder'
=> '-- select server state --', 'v-model' => 'dataset.state'] ) !!}
{!! Form::select( 'State', array_except(Config::get('enums.server_states'),['published', 'deleted', 'temporary']), '',
['placeholder' => '-- select server state --', 'v-model' => 'dataset.state', "v-validate" => "'required'"] ) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('CreatingCorporation', 'Creating Corporation') !!} {!! Form::text('CreatingCorporation', null, ['class' =>
'pure-u-23-24', 'v-model' => 'dataset.creating_corporation']) !!}
'pure-u-23-24', 'v-model' => 'dataset.creating_corporation', "v-validate" => "'required'"]) !!}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
@ -125,28 +136,29 @@
<legend>Main Title & Abstract</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleMain', 'Main Title ') !!} {!! Form::text('TitleMain[Value]', null, ['class' => 'pure-u-23-24', 'v-model'
=> 'dataset.title_main.value']) !!}
{!! Form::label('TitleMain', 'Main Title ') !!}
{!! Form::text('TitleMain[Value]', null, ['class' => 'pure-u-23-24', 'v-model'
=> 'dataset.title_main.value', "v-validate" => "'required|min:3'", "data-vv-as" => "Main Title"]) !!}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleLanguage', 'Title Language..') !!}
<div class="select pure-u-23-24">
{!! Form::select('TitleMain[Language]', $languages, null, ['placeholder' => '--no language--', 'v-model' => 'dataset.title_main.language'])
!!}
{!! Form::select('TitleMain[Language]', $languages, null,
['placeholder' => '--no language--', 'v-model' => 'dataset.title_main.language', "v-validate" => "'required'", "data-vv-as" => "Title Language"]) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleAbstract', 'Main Abstract ') !!} {{ Form::textarea('TitleAbstract[Value]', null, ['class' => 'pure-u-23-24',
'size' => '70x6', 'v-model' => 'dataset.abstract_main.value']) }}
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleAbstract', 'Main Abstract ') !!}
{{ Form::textarea('TitleAbstract[Value]', null, ['class' => 'pure-u-23-24',
'size' => '70x6', 'v-model' => 'dataset.abstract_main.value', "v-validate" => "'required|min:3'", "data-vv-as" => "Main Abstract"]) }}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('AbstractLanguage', 'Abstract Language..') !!}
<div class="select pure-u-23-24">
{!! Form::select('TitleAbstract[Language]', $languages, null, ['placeholder' => '--no language--', 'v-model' => 'dataset.abstract_main.language'])
!!}
{!! Form::select('TitleAbstract[Language]', $languages, null,
['placeholder' => '--no language--', 'v-model' => 'dataset.abstract_main.language', "v-validate" => "'required'", "data-vv-as" => "Abstract Language"]) !!}
</div>
</div>
</div>
@ -155,13 +167,19 @@
<legend>Licenses</legend>
<div class="pure-control-group checkboxlist">
@foreach ($licenses as $license)
@foreach ($licenses as $indexKey => $license)
<label for={{ "license". $license->id }} class="pure-checkbox">
<input name="licenses[]" value={{ $license->id }} v-model="dataset.checkedLicenses" type="checkbox" class="form-check-input">
@if ($loop->first)
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" v-validate="'required'" data-vv-as="Licence" >
{{ $license->name_long }}
</label> @endforeach
@else
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" >
{{ $license->name_long }}
@endif
</label>
@endforeach
<br>
<span>Checked licenses: @{{ dataset.checkedLicenses }}</span>
<span>Checked license: @{{ dataset.checkedLicenses }}</span>
</div>
</fieldset>
@ -172,15 +190,20 @@
<span>Back</span>
</button>
<button @click.prevent="next()" class="pure-button button-small">
<button @click.prevent="next('step-2')" class="pure-button button-small" v-bind:disabled="errors.any()">
<i class="fa fa-arrow-right"></i>
<span>Continue</span>
</button>
</div>
<div v-if="errors.items.length > 0">
<b>Please correct the following error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in errors.items">@{{ error.msg }}</li>
</ul>
</div>
</form>
</div>
<div v-if="step === 3">
<form v-if="step === 3" data-vv-scope="step-3">
<h1>Select authors, contributors</h1>
<fieldset id="fieldset-general">
<legend>Authors</legend>
@ -212,6 +235,10 @@
<legend>Contributors</legend>
<small id="contributorHelp" class="pure-form-message-inline">will come soon...</small>
</fieldset>
<fieldset id="fieldset-general">
<legend>Submitters</legend>
<small id="submitterHelp" class="pure-form-message-inline">will come soon...</small>
</fieldset>
<br />
<div class="pure-controls">
<button @click.prevent="prev()" class="pure-button button-small">
@ -219,14 +246,14 @@
<span>Back</span>
</button>
<button @click.prevent="next()" class="pure-button button-small">
<button @click.prevent="next('step-3')" class="pure-button button-small">
<i class="fa fa-arrow-right"></i>
<span>Review Dataset</span>
</button>
</div>
</div>
</form>
<div v-if="step === 4">
<form v-if="step === 4" data-vv-scope="step-4">
<h1>File Upload</h1>
<div class="dropbox">
@ -281,32 +308,41 @@
<span>Create Dataset</span>
</button>
</div>
</form>
<div v-if="errors.length > 0">
<b>Please correct the following error(s):</b>
<div v-if="serrors.length > 0">
<b>Please correct the following server error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in errors">@{{ error }}</li>
<li style="margin-left:5px;" v-for="error in serrors">@{{ error }}</li>
</ul>
</div>
</form>
</main>
{{-- <br/><br/>Debug:@{{ dataset }} --}}
</div>
@stop
@section('styles')
<style type="text/css">
/* main.steps article {
display:block;
} */
.help-block {
display: none;
font-size: 0.8em;
}
.has-error .help-block {
display:block;
}
</style>
@stop
@section('after-scripts') {{--
<script type="text/javascript" src="{{ asset('js/lib.js') }}"></script> --}} {{--
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
@ -314,14 +350,4 @@
<script type="text/javascript" src="{{ resource_path('assets\js\datasetPublish.js') }}"></script> --}}
<script type="text/javascript" src="{{ asset('backend/publish/datasetPublish.js') }}"></script>
@stop

View File

@ -24,9 +24,15 @@
'pure-form pure-form-aligned']) !!}
<fieldset>
<div class="pure-control-group">
{{ Form::label('name', 'collection name') }} {{ Form::text('name', null, ['class' => 'form-control']) }}
{{ Form::label('name', 'collection name') }}
{{ Form::text('name', null, ['class' => 'form-control']) }}
<em>*</em>
</div>
<div class="pure-control-group">
{{ Form::label('number', 'number') }}
{{ Form::text('number', null, ['class' => 'form-control']) }}
<small id="numberHelp" class="pure-form-message-inline">number is optional</small>
</div>
<div class="pure-control-group pure-div">
{!! Form::label('role_id', 'Collection Role..') !!}

View File

@ -49,25 +49,25 @@
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
labels: ["2017", "2018", "2019"],
datasets: [{
label: '# of Votes',
label: 'Number of published datasets',
data: [12, 14, 8, 2, 5, 1],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
'rgba(255, 206, 86, 0.2)'
// 'rgba(75, 192, 192, 0.2)',
// 'rgba(153, 102, 255, 0.2)',
// 'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
'rgba(255, 206, 86, 1)'
// 'rgba(75, 192, 192, 1)',
// 'rgba(153, 102, 255, 1)',
// 'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]

View File

@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" href="{{ asset('/backend/style.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('/backend/pagination.css') }}">
@yield('styles')
</head>
<body>

View File

@ -14,6 +14,7 @@
<thead>
<th>Licence</th>
<th>Sort Order</th>
<th></th>
</thead>
@ -22,6 +23,7 @@
@foreach($licenses as $license)
<tr>
<td>{{ $license->name_long }}</td>
<td>{{ $license->sort_order }}</td>
<td>
<a class="edit" href="{{ route('settings.license.edit', $license->id) }}">