add additional descriptions

This commit is contained in:
Arno Kaimbacher 2019-01-24 17:33:04 +01:00
parent 39623ff5a6
commit c648ebd4fc
6 changed files with 69 additions and 3 deletions

View File

@ -63,8 +63,11 @@ class IndexController extends Controller
$relationTypes = array_combine($relationTypes, $relationTypes); $relationTypes = array_combine($relationTypes, $relationTypes);
$titleTypes = ['sub' => 'sub', 'alternative' => 'alternative', 'translated' => 'translated', 'other' => 'other']; $titleTypes = ['sub' => 'sub', 'alternative' => 'alternative', 'translated' => 'translated', 'other' => 'other'];
$descriptionTypes = [ 'methods' => 'methods', 'series_information' => 'series_information', 'technical_info' => 'technical_info', 'other' => 'other'];
//$relationTypes = array('updates' => 'updates', 'updated-by' => 'updated-by', 'other' => 'other'); //$relationTypes = array('updates' => 'updates', 'updated-by' => 'updated-by', 'other' => 'other');
return view('publish.create-step1', compact('licenses', 'languages', 'projects', 'relatedIdentifierTypes', 'relationTypes', 'titleTypes')); return view('publish.create-step1', compact('licenses', 'languages', 'projects', 'relatedIdentifierTypes', 'relationTypes', 'titleTypes', 'descriptionTypes'));
} }
/** /**
@ -367,6 +370,14 @@ class IndexController extends Controller
$dataset->addMainAbstract($abstract); $dataset->addMainAbstract($abstract);
} }
//save additional descriptions
if (isset($data['descriptions'])) {
foreach ($request->get('descriptions') as $key => $description) {
$descriptionReference = new Description($description);
$dataset->abstracts()->save($descriptionReference);
}
}
//save references //save references
if (isset($data['references'])) { if (isset($data['references'])) {
foreach ($request->get('references') as $key => $reference) { foreach ($request->get('references') as $key => $reference) {

View File

@ -11,6 +11,9 @@ class Description extends Model
protected $fillable = [ protected $fillable = [
'value',
'type',
'language'
]; ];
public function dataset() public function dataset()

File diff suppressed because one or more lines are too long

View File

@ -33,6 +33,7 @@ function initialState() {
files: [], files: [],
references: [], references: [],
titles: [], titles: [],
descriptions: [],
checkedContributors: [], checkedContributors: [],
checkedSubmitters: [], checkedSubmitters: [],

View File

@ -214,6 +214,13 @@ const app = new Vue({
formData.append('titles[' + i + '][type]', title.type); formData.append('titles[' + i + '][type]', title.type);
} }
for (var i = 0; i < this.dataset.descriptions.length; i++) {
let description = this.dataset.descriptions[i];
formData.append('descriptions[' + i + '][value]', description.value);
formData.append('descriptions[' + i + '][language]', description.language);
formData.append('descriptions[' + i + '][type]', description.type);
}
/* /*
Make the request to the POST /multiple-files URL Make the request to the POST /multiple-files URL
*/ */
@ -290,11 +297,22 @@ const app = new Vue({
this.dataset.titles.push(newTitle); this.dataset.titles.push(newTitle);
}, },
/* /*
Removes a selected reference Removes a selected title
*/ */
removeTitle(key) { removeTitle(key) {
this.dataset.titles.splice(key, 1); this.dataset.titles.splice(key, 1);
}, },
addDescription() {
let newTitle = { value: '', language: '', type: '' };
//this.dataset.files.push(uploadedFiles[i]);
this.dataset.descriptions.push(newTitle);
},
/*
Removes a selected description
*/
removeDescription(key) {
this.dataset.descriptions.splice(key, 1);
},
filesChange(fieldName, fileList) { filesChange(fieldName, fileList) {
this.fileCount = fileList.length this.fileCount = fileList.length
// this.dataset.files = this.$refs.files.files; // this.dataset.files = this.$refs.files.files;

View File

@ -107,7 +107,40 @@
"v-validate" => "'required'", "data-vv-as" => "Abstract Language", 'data-vv-scope' => 'step-2']) !!} "v-validate" => "'required'", "data-vv-as" => "Abstract Language", 'data-vv-scope' => 'step-2']) !!}
</div> </div>
</div> </div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('AddtionalDescription', 'Add additional descriptions(s) ') !!}
<button class="pure-button button-small" @click.prevent="addDescription()">+</button>
</div>
</div> </div>
<table class="pure-table pure-table-horizontal" v-if="dataset.descriptions.length">
<thead>
<tr>
<th style="width: 20px;">Description</th>
<th>Type</th>
<th>Language</th>
<th style="width: 130px;"></th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in dataset.descriptions">
<td>
<input name="Description[Value]" class="form-control" placeholder="[DESCRIPTION]" v-model="item.value" v-validate="'required'" data-vv-scope="step-1" />
</td>
<td>
{!! Form::select('Description[Type]', $descriptionTypes, null,
['placeholder' => '[descriptionType]', 'v-model' => 'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!}
</td>
<td>
{!! Form::select('Description[Language]', $languages, null,
['placeholder' => '[language]', 'v-model' => 'item.language', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!}
</td>
<td>
<button class="pure-button button-small is-warning" @click.prevent="removeDescription(index)">-</button>
</td>
</tr>
</tbody>
</table>
</fieldset> </fieldset>
<fieldset id="fieldset-creator"> <fieldset id="fieldset-creator">