Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-0.10' into 0.10-multiedit
Browse files Browse the repository at this point in the history
Signed-off-by: Vinzenz Rosenkranz <[email protected]>
  • Loading branch information
v1r0x committed Nov 23, 2022
2 parents 07c706c + 4b4c7a9 commit 95fb283
Show file tree
Hide file tree
Showing 75 changed files with 3,857 additions and 2,582 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,49 @@ All notable changes to this project will be documented in this file.
### Changed
- Entity tree sorting is now accessible through ...-menu

## 0.9.6
### Added
- Info modal in references tab to view all information from an literature reference
- Copy BibTeX-Code of literature item to clipboard
- Entity type color dot to entity detail's link list (entity type name is shown on hover)
- Attach files to bibliography entries
- Validation to bibliography add/edit form
- More (optional) bibtex fields (doi, email, url, type)
### Fixed
- Only delete avatar if is set and exists on disk
- Display image in About modal
- Closing modal after user is (successfully) added
- Display errors from server if user can not be added (e.g. due to already existing nickname or email address)
- References list not visible after added a new one if it's the first literature reference added to that attribute
- Newly created entity types only selectable as sub-entity types after reload
- Column ordering in bibliography
- Saving changed type of bibtex entry
- Do not show _Delete Entity_ action in entity's dropdown if user does not have the permission
- Translations for read notifications
### Changed
- Updated Modal Library to Version 4
- Better handling of `"`, `{` and `{{` in BibTeX
- Show translated BibTeX-Type in literature entry add/edit modal's type selection
- Make new modal library useable by plugins

## 0.9.5
### Fixed
- Display option to access analysis tool in _Tools_ (if available)
- height of notification panel if larger than screen
- Missing styling in _Add Entitytype_ component
- Several geodata related bugs
- Node dropdown not closed on outside click

## 0.9.4
### Fixed
- Error on deleting plugin (Plugin not found)
- Allow `geography` as column type in plugin migrations
- Importing values for integer/percentage datatype in data importer

## 0.9.3
### Fixed
- Wrong translated concepts for languages with lang code mismatch

## 0.9.2
### Added
- Support for color schemas (Dark Mode with unrounded corners included)
Expand Down
2 changes: 1 addition & 1 deletion app/AttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static function stringToValue($strValue, $type) {
break;
case 'integer':
case 'percentage':
if(!is_int($trimmedVal)) {
if(!is_int($trimmedVal) && !ctype_digit($trimmedVal)) {
throw new InvalidDataException("Given data is not an integer");
}
$value = intval($trimmedVal);
Expand Down
255 changes: 225 additions & 30 deletions app/Bibliography.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;
Expand All @@ -14,6 +15,11 @@ class Bibliography extends Model implements Searchable
use LogsActivity;

protected $table = 'bibliography';

protected $appends = [
'file_url',
];

/**
* The attributes that are assignable.
*
Expand Down Expand Up @@ -46,7 +52,8 @@ class Bibliography extends Model implements Searchable
'school',
'series',
'citekey',
'user_id'
'user_id',
'file',
];

protected const searchCols = [
Expand Down Expand Up @@ -79,31 +86,181 @@ class Bibliography extends Model implements Searchable
];

const patchRules = [
'author' => 'string',
'editor' => 'string',
'title' => 'string',
'journal' => 'string',
'year' => 'string',
'pages' => 'string',
'volume' => 'string',
'number' => 'string',
'booktitle' => 'string',
'publisher' => 'string',
'address' => 'string',
'misc' => 'string',
'howpublished'=> 'string',
'type' => 'string',
'annote' => 'string',
'chapter' => 'string',
'crossref' => 'string',
'edition' => 'string',
'institution'=> 'string',
'key' => 'string',
'month' => 'string',
'note' => 'string',
'organization'=> 'string',
'school' => 'string',
'series' => 'string'
'author' => 'string',
'editor' => 'string',
'title' => 'string',
'journal' => 'string',
'year' => 'string',
'pages' => 'string',
'volume' => 'string',
'number' => 'string',
'booktitle' => 'string',
'publisher' => 'string',
'address' => 'string',
'misc' => 'string',
'howpublished' => 'string',
'type' => 'string',
'annote' => 'string',
'chapter' => 'string',
'crossref' => 'string',
'edition' => 'string',
'institution' => 'string',
'key' => 'string',
'month' => 'string',
'note' => 'string',
'organization' => 'string',
'school' => 'string',
'series' => 'string',
'doi' => 'string',
'subtype' => 'string',
'file' => 'file',
];

public const bibtexTypes = [
"article" => [
"fields" => [
'author', 'title', 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note', 'doi', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"journal" => true,
"year" => true,
],
],
"book" => [
"fields" => [
'title', 'publisher', 'year', 'author', 'editor', 'volume', 'number', 'address', 'series', 'edition', 'month', 'note', 'email', 'url'
],
"mandatory" => [
"author" => 'editor',
"editor" => 'author',
"title" => true,
"publisher" => true,
"year" => true,
],
],
"incollection" => [
"fields" => [
'author', 'title', 'booktitle', 'publisher', 'year', 'editor', 'volume', 'number', 'series', 'pages', 'address', 'month', 'organization', 'publisher', 'note', 'subtype', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"booktitle" => true,
"publisher" => true,
"year" => true,
],
],
"misc" => [
"fields" => [
'author', 'title', 'howpublished', 'month', 'year', 'note', 'email', 'url'
],
],
"booklet" => [
"fields" => [
'title', 'author', 'howpublished', 'address', 'month', 'year', 'note', 'email', 'url'
],
"mandatory" => [
"title" => true,
],
],
"conference" => [
"fields" => [
'author', 'title', 'booktitle', 'year', 'editor', 'volume', 'number', 'series', 'pages', 'address', 'month', 'organization', 'publisher', 'note', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"booktitle" => true,
"year" => true,
],
],
"inbook" => [
"fields" => [
'title', 'publisher', 'year', 'author', 'editor', 'chapter', 'pages', 'volume', 'number', 'series', 'address', 'edition', 'month', 'note', 'subtype', 'email', 'url'
],
"mandatory" => [
"author" => "editor",
"editor" => "author",
"title" => true,
"chapter" => "pages",
"pages" => "chapter",
"publisher" => true,
"year" => true,
],
],
"inproceedings" => [
"fields" => [
'author', 'title', 'booktitle', 'year', 'editor', 'volume', 'number', 'series', 'pages', 'address', 'month', 'organization', 'publisher', 'note', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"booktitle" => true,
"year" => true,
],
],
"manual" => [
"fields" => [
'title', 'author', 'organization', 'address', 'edition', 'month', 'year', 'note', 'email', 'url'
],
"mandatory" => [
"title" => true,
],
],
"mastersthesis" => [
"fields" => [
'author', 'title', 'school', 'year', 'address', 'month', 'note', 'subtype', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"school" => true,
"year" => true,
],
],
"phdthesis" => [
"fields" => [
'author', 'title', 'school', 'year', 'address', 'month', 'note', 'subtype', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"school" => true,
"year" => true,
],
],
"proceedings" => [
"fields" => [
'title', 'year', 'editor', 'volume', 'number', 'series', 'address', 'month', 'organization', 'publisher', 'note', 'email', 'url'
],
"mandatory" => [
"title" => true,
"year" => true,
],
],
"techreport" => [
"fields" => [
'author', 'title', 'institution', 'year', 'number', 'address', 'month', 'note', 'subtype', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"institution" => true,
"year" => true,
],
],
"unpublished" => [
"fields" => [
'author', 'title', 'note', 'month', 'year', 'email', 'url'
],
"mandatory" => [
"author" => true,
"title" => true,
"note" => true,
],
],
];

public function getActivitylogOptions() : LogOptions
Expand All @@ -127,17 +284,39 @@ public static function getSearchCols(): array {
}

public function fieldsFromRequest($request, $user) {
$fields = $request->toArray();
if(!isset($fields['title'])) {
$fields['title'] = 'No Title';
}
$fields = is_array($request) ? $request : $request->toArray();
foreach($fields as $key => $value){
$this->{$key} = $value;
}

$type = self::bibtexTypes[$this->type];
// Check if all mandatory fields are set
foreach($type['mandatory'] as $man => $manType) {
// if is simple mandatory field, check if present
// otherwise return false
if($manType === true) {
if(!isset($this->{$man}) || empty($this->{$man})) {
return false;
}
} else {
if(
(!isset($this->{$man}) || empty($this->{$man})) ||
(!isset($this->{$manType}) || empty($this->{$manType}))
) {
return false;
}
}
}
// Unset all fields that are not allowed for the current type
$disallowedFields = array_diff(array_keys(self::patchRules), $type['fields'], ['type', 'file']);
foreach($disallowedFields as $toDel) {
$this->{$toDel} = null;
}

$this->citekey = self::computeCitationKey($this->toArray());
$this->user_id = $user->id;
$this->save();
return true;
}

public function referenceCount() {
Expand Down Expand Up @@ -176,11 +355,27 @@ public static function computeCitationKey($fields) {
return $key;
}

public function uploadFile($file) {
if(isset($this->file) && Storage::exists($this->file)) {
Storage::delete($this->file);
}

$filename = $this->id . "_" . $file->getClientOriginalName();
return $file->storeAs(
'bibliography',
$filename
);
}

public function user() {
return $this->belongsTo('App\User');
}

public function entities() {
return $this->belongsToMany('App\Entity', 'references')->withPivot('description', 'attribute_id');
}

public function getFileUrlAttribute() {
return isset($this->file) ? sp_get_public_url($this->file) : null;
}
}
1 change: 1 addition & 0 deletions app/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ public function getAttributeLinksAttribute() {
$entities[] = [
'id' => $entity->id,
'name' => $entity->name,
'entity_type_id' => $entity->entity_type_id,
];
}
return $entities;
Expand Down
Loading

0 comments on commit 95fb283

Please sign in to comment.